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.

2.3 Squares and roots 103<br />

simply computes the desired root r = x (p+1)/2 mod f (using polynomial-mod<br />

operations). Note finally that the special cases p ≡ 3, 5, 7 (mod 8) can also<br />

be ferreted out of any of these algorithms, as was done in Algorithm 2.3.8, to<br />

improve average performance.<br />

The complexity of Algorithm 2.3.9 is O(ln 3 p) bit operations (assuming<br />

naive arithmetic), which is asymptotically better than the worst case of<br />

Algorithm 2.3.8. However, if one is loath to implement the modified powering<br />

ladder for the F p 2 arithmetic, the asymptotically slower algorithm will usually<br />

serve. Incidentally, there is yet another, equivalent, approach for square<br />

rooting by way of Lucas sequences (see Exercise 2.31).<br />

It is very interesting to note at this juncture that there is no known fast<br />

method of computing square roots of quadratic residues for general composite<br />

moduli. In fact, as we shall see later, doing so is essentially equivalent to<br />

factoring the modulus (see Exercise 6.5).<br />

2.3.3 Finding polynomial roots<br />

Having discussed issues of existence and calculation of square roots, we now<br />

consider the calculation of roots of a polynomial of arbitrary degree over<br />

a finite field. We specify the finite field as Fp, but much of what we say<br />

generalizes to an arbitrary finite field.<br />

Let g ∈ Fp[x] be a polynomial; that is, it is a polynomial with integer<br />

coefficients reduced (mod p). We are looking for the roots of g in Fp, andso<br />

we might begin by replacing g(x) withthegcdofg(x) andx p − x, sinceas<br />

we have seen, the latter polynomial is the product of x − a as a runs over<br />

all elements of Fp. Ifp>deg g, one should first compute x p mod g(x) via<br />

Algorithm 2.1.5. If the gcd has degree not exceeding 2, the prior methods we<br />

have learned settle the matter. If it has degree greater than 2, then we take a<br />

further gcd with (x + a) (p−1)/2 − 1forarandoma ∈ Fp. Any particular b = 0<br />

in Fp is a root of (x + a) (p−1)/2 − 1 with probability 1/2, so that we have a<br />

positive probability of splitting g(x) into two polynomials of smaller degree.<br />

This suggests a recursive algorithm, which is what we describe below.<br />

Algorithm 2.3.10 (Roots of a polynomial over Fp).<br />

Given a nonzero polynomial g ∈ Fp[x], with p an odd prime, this algorithm returns<br />

the set r of the roots (without multiplicity) in Fp of g.Thesetr is assumed global,<br />

augmented as necessary during all recursive calls.<br />

1. [Initial adjustments]<br />

r = {}; // Root list starts empty.<br />

g(x) =gcd(x p − x, g(x)); // Using Algorithm 2.2.1.<br />

if(g(0) == 0) { // Check for 0 root.<br />

r = r ∪{0};<br />

g(x) =g(x)/x;<br />

}<br />

2. [Call recursive procedure and return]

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

Saved successfully!

Ooh no, something went wrong!