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.

230 Chapter 5 EXPONENTIAL FACTORING ALGORITHMS<br />

There is one further ingredient in the Pollard rho method. We surely<br />

should not be expected to search over all pairs j, k with 0 ≤ j < k and<br />

to compute gcd(F (j) (s) − F (k) (s),n) for each pair. This could easily take<br />

longer than a trial division search for the prime factor p, since if we search<br />

up to B, there are about 1<br />

2B2 pairs j, k. And we do not expect to be<br />

successful until B is of order √ p. So we need another way to search over<br />

pairs other than to examine all of them. This is afforded by a fabulous<br />

expedient, the Floyd cycle-finding method. Let l = k − j, so that for any<br />

m ≥ j, F (m) (s) ≡ F (m+l) (s) ≡ F (m+2l) (s) ≡ ... (mod p). Consider this for<br />

m = l ⌈j/l⌉, the first multiple of l that exceeds j. ThenF (m) (s) ≡ F (2m) (s)<br />

(mod p), and m ≤ k = O( √ p).<br />

So the basic idea of the Pollard rho method is to compute the sequence<br />

gcd(F (i) (s) − F (2i) (s),n)fori =1, 2,..., and this should terminate with a<br />

nontrivial factorization of n in O( √ p) steps, where p is the least prime factor<br />

of n.<br />

Algorithm 5.2.1 (Pollard rho factorization method). We are given a composite<br />

number n. This algorithm attempts to find a nontrivial factor of n.<br />

1. [Choose seeds]<br />

Choose random a ∈ [1,n− 3];<br />

Choose random s ∈ [0,n− 1];<br />

U = V = s;<br />

Define function F (x) =(x 2 + a) modn;<br />

2. [Factor search]<br />

U = F (U);<br />

V = F (V );<br />

V = F (V ); // F (V ) intentionally invoked twice.<br />

g =gcd(U − V,n);<br />

if(g == 1) goto [Factor search];<br />

3. [Bad seed]<br />

if(g == n) goto [Choose seeds];<br />

4. [Success]<br />

return g; // Nontrivial factor found.<br />

A pleasant feature of the Pollard rho method is that very little space is<br />

required: Only the number n that is being factored and the current values of<br />

U, V need be kept in memory.<br />

The main loop, Step [Factor search], involves 3 modular multiplications<br />

(actually squarings) and a gcd computation. In fact, with the cost of one<br />

extra modular multiplication, one may put off the gcd calculation so that it<br />

is performed only rarely. Namely, the numbers U − V may be accumulated<br />

(multiplied all together) modulo n for k iterations, and then the gcd of this<br />

modular product is taken with n. Soifk is 100, say, the amortized cost of<br />

performing a gcd is made negligible, so that one generic loop consists of 3<br />

modular squarings and one modular multiplication.

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

Saved successfully!

Ooh no, something went wrong!