10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

266 Chapter 6 SUBEXPONENTIAL FACTORING ALGORITHMS<br />

6.1.2 Basic QS: A summary<br />

We have described the basic QS algorithm in the above discussion. We now<br />

give a summary description.<br />

Algorithm 6.1.1 (Basic quadratic sieve). We are given an odd composite<br />

number n that is not a power. This algorithm attempts to give a nontrivial<br />

factorization of n.<br />

1. [Initialization]<br />

B = L(n) 1/2 ; // Or tune B to taste.<br />

Set p1 =2and a1 =1;<br />

Find the odd primes p ≤ B for which <br />

n<br />

p =1, and label them p2,...,pK;<br />

for(2 ≤ i ≤ K) find roots ±ai with a2 i ≡ n (mod pi);<br />

// Find such roots via Algorithm 2.3.8 or 2.3.9.<br />

2. [Sieving]<br />

Sieve the sequence (x 2 −n), x = ⌈ √ n⌉ , ⌈ √ n⌉+1,...for B-smooth values,<br />

until K +1such pairs (x, x 2 − n) are collected in a set S;<br />

// See Sections 3.2.5, 3.2.6, and remarks (2), (3), (4).<br />

3. [Linear algebra]<br />

for((x, x2 − n) ∈ S) {<br />

Establish prime factorization x2 − n = K i=1 pei i ;<br />

v(x2 − n) =(e1,e2,...,eK); // Exponent vector.<br />

}<br />

Form the (K +1)×K matrix with rows being the various vectors v(x2 −n)<br />

reduced mod 2;<br />

Use algorithms of linear algebra to find a nontrivial subset of the rows of<br />

the matrix that sum to the 0-vector (mod 2), sayv(x1)+v(x2)+···+<br />

v(xk) =0;<br />

4. [Factorization]<br />

x = x1x2 ···xk mod n;<br />

y = (x2 1 − n)(x22 − n) ...(x2 k − n) modn;<br />

// Infer this root directly from the known prime factorization of the<br />

perfect square (x2 1 − n)(x2 2 − n) ...(x2 k − n), see remark (6).<br />

d =gcd(x−y, n);<br />

return d;<br />

There are several points that should be made about this algorithm:<br />

(1) In practice, people generally use a somewhat smaller value of B than that<br />

given by the formula in Step [Initialization]. Any value of B of order of<br />

magnitude L(n) 1/2 will lead to the same overall complexity, and there<br />

are various practical issues that mitigate toward a smaller value, such as<br />

the size of the matrix that one deals with in Step [Linear algebra], and<br />

the size of the moduli one sieves with in comparison to cache size on the<br />

machine used in Step [Sieving]. The optimal B-value is more of an art<br />

than a science, and is perhaps best left to experimentation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!