10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

190 Chapter 4 PRIMALITY PROVING<br />

4.3 The finite field primality test<br />

This section is primarily theoretical and is not intended to supply a practical<br />

primality test. The algorithm described has a favorable complexity estimate,<br />

but there are other, more complicated algorithms that majorize it in practice.<br />

Some of these algorithms are discussed in the next section.<br />

The preceding sections, and in particular Theorem 4.2.10 and Algorithm<br />

4.2.11, show that if we have a completely factored divisor F of n 2 − 1with<br />

F ≥ n 1/3 , then we can efficiently decide, with a rigorous proof, whether n is<br />

prime or composite. As an aside: If F1 =gcd(F, n−1) and F2 =gcd(F, n+1),<br />

then lcm (F1,F2) ≥ 1<br />

1<br />

2F , so that the “F ” of Theorem 4.2.10 is at least 2n1/3 .<br />

In this section we shall discuss a method in [Lenstra 1985] that works if we<br />

have a fully factored divisor F of nI − 1 for some positive integer I and that<br />

is efficient if F ≥ n1/3 and I is not too large.<br />

Before we describe the algorithm, we discuss a subroutine that will be<br />

used. If n>1 is an integer, consider the ring Zn[x] of polynomials in the<br />

variable x with coefficients being integer residues modulo n. An ideal of Zn[x]<br />

is a nonempty subset closed under addition and closed under multiplication<br />

by all elements of Zn[x]. For example, if f,g ∈ Zn[x], the set of all af with<br />

a ∈ Zn[x] is an ideal, and so is the set of all af +bg with a, b ∈ Zn[x]. The first<br />

exampleisofaprincipal ideal (with generator f). The second example may or<br />

may not be principal. For example, say n =15,f(x) =3x +1,g(x) =x2 +4x.<br />

Then the ideal generated by f and g is all of Z15[x], and so is principally<br />

generated by 1. (To see that 1 is in the ideal, note that f 2 − 9g =1.)<br />

Definition 4.3.1. We shall say that f,g ∈ Zn[x] arecoprime if the ideal<br />

they generate is all of Zn[x]; that is, there are a, b ∈ Zn[x] withaf + bg =1.<br />

It is not so hard to prove that every ideal in Zn[x] is principally generated<br />

if and only if n is prime (see Exercise 4.19). The following algorithm, which is<br />

merely a dressed-up version of the Euclid algorithm (Algorithm 2.2.1), either<br />

finds a monic principal generator for the ideal generated by two members<br />

f,g ∈ Zn[x], or gives a nontrivial factorization of n. If the principal ideal<br />

generated by h ∈ Zn[x] is the same ideal as that generated by f and g and if<br />

h is monic, we write h =gcd(f,g). Thus f,g are coprime in Zn[x] ifandonly<br />

if gcd(f,g) =1.<br />

Algorithm 4.3.2 (Finding principal generator). We are given an integer<br />

n>1 and f,g ∈ Zn[x], with g monic. This algorithm produces either a nontrivial<br />

factorization of n, or a monic element h ∈ Zn[x] such that h =gcd(f,g); thatis,<br />

the ideal generated by f and g is equal to the ideal generated by h. We assume<br />

that either f =0or deg f ≤ deg g.<br />

1. [Zero polynomial check]<br />

if(f == 0) return g;<br />

2. [Euclid step]<br />

Set c equal the leading coefficient of f;

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

Saved successfully!

Ooh no, something went wrong!