quadratic sieve
Algorithm
To factor a number using the quadratic sieve, one seekstwo numbers and which are not congruent modulo with not congruent
to modulo buthave . If two such numbers are found,one can then say that . Then, and must have non-trivial factors in common with .
The quadratic sieve method of factoring depends upon being ableto create a set of numbers whose factorization can be expressedas a product of pre-chosen primes. These factorizations arerecorded as vectors of the exponents. Once enough vectors arecollected to form a set which contains a linear dependence,this linear dependence is exploited to find two squares whichare equivalent
modulo .
To accomplish this, the quadratic sieve method uses a set ofprime numbers called a factor base. Then, it searches fornumbers which can be factored entirely within that factor base.If there are prime numbers in the factor base, then eachnumber which can be factored within the factor base is storedas a -dimensional vector where the -th component
of thevector for gives the exponent of the -th prime from thefactor base in the factorization of . For example, if thefactor base were , thenthe number would be stored as thevector .
Once of these vectors have been collected, there must bea linear dependence among them. The vectors are takenmodulo to form vectors in . The linear dependenceamong them is used to find a combination of the vectors whichsum up to the zero vector
in . Summing these vectorsis equivalent to multiplying the ’s to which they correspond.And, the zero vector in signals a perfect square
.
To factor , chose a factor base such that and for each oddprime in , is a quadratic residue of . Now,start picking near and calculate . Clearly . If can becompletely factored by numbers in , then it is called-smooth. If it is not -smooth, then discard and and move on to a new choice of . If it is -smooth,then store , , and the vector of its exponents forthe primes in . Also, record a copy of the exponent vectorwith each component taken modulo .
Once vectors have been recorded, there must be a lineardependence among them. Using the copies of the exponent vectorsthat were taken modulo , determine which ones can be addedtogether to form the zero vector. Multiply together the that correspond to those chosen vectors—call this . Also,add together the original vectors that correspond to the chosenvectors to form a new vector . Every component ofthis vector will be even. Divide each element of by. Form .
Because each , . If , then find some more -smoothnumbers and try again. If is not congruent to modulo, then and are factors of .
Example
Consider the number The integer nearest itssquare root is . Given the factor base
, the first few -smooth valuesof are:
Using and , one obtains:
Which results in:
From there:
It may not be completely obvious why we required that be a quadratic residue of each in thefactor base . One mightintuitively think that we actually want the tobe quadratic residues of instead. But, that isnot the case.
We are trying to express as:
where
Because we end up squaring , there is no reasonthat the would need to be quadratic residuesof .
So, why do we require that be a quadratic residueof each ? We can rewrite the as:
If we take that expression modulo for any for which the corresponding is non-zero, we areleft with:
Thus, in order for to show up in a usefulsolution, must be a quadratic residue of .We would be wasting time and space to employ otherprimes in our factoring and linear combinations.