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.

4.4 Gauss and Jacobi sums 197<br />

1. [Initialize]<br />

I = −2;<br />

2. [Preparation]<br />

I = I +4;<br />

Find the prime factors of I by trial division, but if I is not squarefree, goto<br />

[Preparation];<br />

Set F equal to the product of the primes q with q − 1|I, but if F 2 ≤ n<br />

goto [Preparation]; // Now I,F are squarefree, and F> √ n.<br />

If n is a prime factor of IF, return “n is prime”;<br />

If gcd(n, IF ) > 1, return “n is composite”;<br />

for(prime q|F ) find the least positive primitive root gq for q;<br />

3. [Probable-prime computation]<br />

for(prime p|I) factor n p−1 − 1=p sp up where p does not divide up;<br />

for(primes p, q with p|I, q|F, p|q − 1) {<br />

Find the first positive integer w(p, q) ≤ sp with<br />

G(p, q) pw(p,q) up ≡ ζ j p (mod n) for some integer j,<br />

but if no such number w(p, q) is found, return “n is composite”;<br />

} // Compute symbolically in the ring Z[ζp,ζq] (see text).<br />

4. [Maximal order search]<br />

for(prime p|I) setw(p) equal to the maximum of w(p, q) over all primes<br />

q|F with p|q − 1, andsetq0(p) equal to the least such prime q with<br />

w(p) =w(p, q);<br />

for(primes p, q with p|I, q|F, p|q − 1) find an integer l(p, q) ∈ [0,p− 1]<br />

with G(p, q) pw(p) up l(p,q)<br />

≡ ζp (mod n);<br />

5. [Coprime check]<br />

for(primes p with p|I) {<br />

H = G(p, q0(p)) pw(p)−1up mod n;<br />

for(0 ≤ j ≤ p − 1) {<br />

if(gcd n, c(H − ζj p) > 1) return “n is composite”;<br />

} // Notation as in Definition 4.4.4.<br />

}<br />

6. [Divisor search]<br />

l(2) = 0;<br />

for(odd prime q|F ) use the Chinese remainder theorem (see Theorem 2.1.6)<br />

to construct an integer l(q) with<br />

l(q) ≡ l(p, q) (modp) for each prime p|q − 1;<br />

Use the Chinese remainder theorem to construct an integer l with<br />

l ≡ g l(q)<br />

q<br />

(mod q) for each prime q|F ;<br />

for(1 ≤ j < I) if l j mod F is a nontrivial factor of n, return “n is<br />

composite”;<br />

return “n is prime”;

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

Saved successfully!

Ooh no, something went wrong!