Exemple #1
0
def check_valid_sqrt_composite(x, a, factors):
    n = unfactorize(factors)

    all_roots = list(sqrtmod(a, factors))
    assertGreater(len(all_roots), 0)
    assertEqual(sorted(all_roots), sorted(set(all_roots)))

    for r in all_roots:
        assertEqual(pow(r, 2, n), a)

    if x is not None:
        assertTrue(x in all_roots)
Exemple #2
0
def check_valid_sqrt_composite(x, a, factors):
    n = unfactorize(factors)

    all_roots = list(sqrtmod(a, factors))
    assert all_roots
    assert sorted(all_roots) == sorted(set(all_roots))

    for r in all_roots:
        assert pow(r, 2, n) == a

    if x is not None:
        assert x in all_roots
Exemple #3
0
    def check_valid_sqrt_composite(self, x, a, factors):
        n = unfactorize(factors)

        any_root = sqrtmod(a, factors).next()
        self.assertEqual(pow(any_root, 2, n), a)

        all_roots = list(sqrtmod(a, factors))
        self.assertEqual(sorted(all_roots), sorted(set(all_roots)))

        for r in all_roots:
            self.assertEqual(pow(r, 2, n), a)

        if x is not None:
            self.assertTrue(x in all_roots)
    def check_valid_sqrt_composite(self, x, a, factors):
        n = unfactorize(factors)

        any_root = sqrtmod(a, factors).next()
        self.assertEqual(pow(any_root, 2, n), a)

        all_roots = list(sqrtmod(a, factors))
        self.assertEqual(sorted(all_roots), sorted(set(all_roots)))

        for r in all_roots:
            self.assertEqual(pow(r, 2, n), a)

        if x is not None:
            self.assertTrue(x in all_roots)