Samiksha Jaiswal (Editor)

Congruence of squares

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In number theory, a congruence of squares is a congruence commonly used in integer factorization algorithms.

Contents

Derivation

Given a positive integer n, Fermat's factorization method relies on finding numbers x, y satisfying the equality

x 2 y 2 = n

We can then factor n = x2 - y2 = (x + y)(x - y). This algorithm is slow in practice because we need to search many such numbers, and only a few satisfy the strict equation. However, n may also be factored if we can satisfy the weaker congruence of squares condition:

x 2 y 2 ( mod n )  ,  x ± y ( mod n ) .

From here we easily deduce

x 2 y 2 0 ( mod n )  ,  ( x + y ) ( x y ) 0 ( mod n )

This means that n divides the product (x + y) (x - y), but since we also require x ≠ ±y (mod n), n divides neither (x+y) nor (x−y) alone. Thus (x + y) and (xy) each contain proper factors of n. Computing the greatest common divisors of (x + y, n) and of (x - y, n) will give us these factors; this can be done quickly using the Euclidean algorithm.

Congruences of squares are extremely useful in integer factorization algorithms and are extensively used in, for example, the quadratic sieve, general number field sieve, continued fraction factorization, and Dixon's factorization. Conversely, because finding square roots modulo a composite number turns out to be probabilistic polynomial-time equivalent to factoring that number, any integer factorization algorithm can be used efficiently to identify a congruence of squares.

Further generalizations

It is also possible to use factor bases to help find congruences of squares more quickly. Instead of looking for x 2 y 2 ( mod n ) from the outset, we find many x 2 y ( mod n ) where the y have small prime factors, and try to multiply a few of these together to get a square on the right-hand side.

Factorize 35

We take n = 35 and find that

6 2 = 36 1 1 2 ( mod n ) .

We thus factor as

( gcd [ 6 1 , 35 ] ) ( gcd [ 6 + 1 , 35 ] ) = ( 5 ) ( 7 ) = 35.

Factorize 1649

Using n = 1649, as an example of finding a congruence of squares built up from the products of non-squares (see Dixon's factorization method), first we obtain several congruences

41 2 32 : 42 2 115 : 43 2 200 ( mod 1649 ) ,

of these, two have only small primes as factors

32 = 2 5 : 200 = ( 2 3 ) ( 5 2 ) ,

and a combination of these has an even power of each small prime, and is therefore a square

( 32 ) ( 200 ) = ( 2 5 + 3 ) ( 5 2 ) = ( ( 2 4 ) ( 5 ) ) 2 = 80 2

yielding the congruence of squares

( 32 ) ( 200 ) = 80 2 ( 41 2 ) ( 43 2 ) 114 2 ( mod 1649 )

So using the values of 80 and 114 as our x and y gives factors

( gcd [ 114 80 , 1649 ] ) ( gcd [ 114 + 80 , 1649 ] ) = ( 17 ) ( 97 ) = 1649.

References

Congruence of squares Wikipedia


Similar Topics