Prime Numbers

Prime Numbers Prime Numbers

thales.doa.fmph.uniba.sk
from thales.doa.fmph.uniba.sk More from this publisher
10.12.2012 Views

178 Chapter 4 PRIMALITY PROVING Since n is prime, this must be a trivial factorization of n, thatis, c1 + tF −|u| =0, which implies c4 = t. Butc4 ≥ F ≥ n 3/10 ≥ 214 3/10 > 5 ≥ t, a contradiction. So if (1) fails, n must be composite. It is obvious that if n is prime, then (2) holds. ✷ As with Theorem 4.1.5, if Theorem 4.1.6 is to be used as a primality test, one should use Algorithm 9.2.11 as a subroutine to recognize squares. In addition, one should use Newton’s method or a divide and conquer strategy to search for integral roots of the cubic polynomial in condition (2) of the theorem. We next embody Theorems 4.1.3-4.1.6 in one algorithm. Algorithm 4.1.7 (The n − 1 test). Supposewehaveanintegern ≥ 214 and that (4.2) holds with F ≥ n 3/10 . This probabilistic algorithm attempts to decide whether n is prime (YES) or composite (NO). 1. [Pocklington test] Choose random a ∈ [2,n− 2]; if(a n−1 ≡ 1(modn)) return NO; // n is composite. for(prime q|F ) { g =gcd (a (n−1)/q mod n) − 1,n ; if(1

4.1 The n − 1 test 179 4.1.3 Succinct certificates The goal in primality testing is to quickly find a short proof of primality for prime inputs p. But how do we know that a short proof exists? Any search will necessarily be in vain if p does not have a short primality proof. We now show that every prime p has a short proof of primality, or what V. Pratt has called a “succinct certificate.” In fact, there is always a short proof that is based on the Lucas Theorem 4.1.1. This might appear obvious, for once you have somehow found the complete prime factorization of p − 1 and the primitive root a, the conditions (4.1) may be quickly verified. However, for the proof to be complete, one needs a demonstration that we indeed have the complete factorization of p − 1; that is, that the numbers q appearing in (4.1) really are prime. This suggests an iteration of the method, but then arises the possibility that there may be a proliferation of cases. The heart of the proof is to show in the worst case, not too much proliferation can occur. It is convenient to make a small, and quite practical, modification in the Lucas Theorem 4.1.1. The idea is to treat the prime q = 2 differently from the other primes q dividing p − 1. In fact, we know what a (p−1)/2 should be congruent to (mod p) ifitisnot1,namely−1. And if a (p−1)/2 ≡−1(modp), we do not need to check that a p−1 ≡ 1(modp). Further, if q is an odd prime factor of p − 1, let m = a (p−1)/2q .Ifm q ≡−1(modp) andm 2 ≡ 1(modp), then m ≡−1(modp) (regardless of whether p is prime or composite). Thus, to show that a (p−1)/q ≡ 1(modp) it suffices to show a (p−1)/2q ≡−1(modp). Thus we have the following result. Theorem 4.1.8. Suppose p>1 is an odd integer and a (p−1)/2 ≡−1(modp), a (p−1)/2q ≡−1(modp) for every odd prime q|p − 1. (4.11) Then p is prime. Conversely, if p is an odd prime, then every primitive root a of p satisfies conditions (4.11). We now describe what might be called a “Lucas tree.” It is a rooted tree with odd primes at the vertices, p at the root (level 0), and for each positive level k, aprimer at level k is connected to a prime q at level k − 1ifandonly if r|q − 1.Forexample,hereistheLucastreeforp = 1279: 1279 ✓❙ ✓✓ ❙❙71 3 ✓❙ ✓✓ ❙❙7 5 ✓ level 0 level 1 level 2 ✓✓ 3 level 3

4.1 The n − 1 test 179<br />

4.1.3 Succinct certificates<br />

The goal in primality testing is to quickly find a short proof of primality for<br />

prime inputs p. But how do we know that a short proof exists? Any search<br />

will necessarily be in vain if p does not have a short primality proof. We now<br />

show that every prime p has a short proof of primality, or what V. Pratt has<br />

called a “succinct certificate.”<br />

In fact, there is always a short proof that is based on the Lucas Theorem<br />

4.1.1. This might appear obvious, for once you have somehow found the<br />

complete prime factorization of p − 1 and the primitive root a, the conditions<br />

(4.1) may be quickly verified.<br />

However, for the proof to be complete, one needs a demonstration that we<br />

indeed have the complete factorization of p − 1; that is, that the numbers q<br />

appearing in (4.1) really are prime. This suggests an iteration of the method,<br />

but then arises the possibility that there may be a proliferation of cases. The<br />

heart of the proof is to show in the worst case, not too much proliferation can<br />

occur.<br />

It is convenient to make a small, and quite practical, modification in the<br />

Lucas Theorem 4.1.1. The idea is to treat the prime q = 2 differently from<br />

the other primes q dividing p − 1. In fact, we know what a (p−1)/2 should be<br />

congruent to (mod p) ifitisnot1,namely−1. And if a (p−1)/2 ≡−1(modp),<br />

we do not need to check that a p−1 ≡ 1(modp). Further, if q is an odd prime<br />

factor of p − 1, let m = a (p−1)/2q .Ifm q ≡−1(modp) andm 2 ≡ 1(modp),<br />

then m ≡−1(modp) (regardless of whether p is prime or composite). Thus,<br />

to show that a (p−1)/q ≡ 1(modp) it suffices to show a (p−1)/2q ≡−1(modp).<br />

Thus we have the following result.<br />

Theorem 4.1.8. Suppose p>1 is an odd integer and<br />

a (p−1)/2 ≡−1(modp),<br />

a (p−1)/2q ≡−1(modp) for every odd prime q|p − 1.<br />

(4.11)<br />

Then p is prime. Conversely, if p is an odd prime, then every primitive root<br />

a of p satisfies conditions (4.11).<br />

We now describe what might be called a “Lucas tree.” It is a rooted tree<br />

with odd primes at the vertices, p at the root (level 0), and for each positive<br />

level k, aprimer at level k is connected to a prime q at level k − 1ifandonly<br />

if r|q − 1.Forexample,hereistheLucastreeforp = 1279:<br />

1279<br />

✓❙<br />

✓✓ ❙❙71<br />

3<br />

✓❙<br />

✓✓ ❙❙7<br />

5<br />

✓<br />

level 0<br />

level 1<br />

level 2<br />

✓✓ 3 level 3

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

Saved successfully!

Ooh no, something went wrong!