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.

9.7 Exercises 523<br />

9.23. How general can be the initialization of x in Algorithm 9.2.11?<br />

9.24. Write out a (very) simple algorithm that uses Algorithm 9.2.11 to<br />

determine whether a given integer N is a square. Note that there are much<br />

more efficient ways of approaching the problem, for example first ruling out<br />

the square property modulo some small primes [Cohen 2000].<br />

9.25. Implement Algorithm 9.2.13 within a Lucas–Lehmer test, to prove or<br />

disprove primality of various Mersenne numbers 2 q − 1. Note that with the<br />

special form mod reduction, one does not even need general multiplication for<br />

Lucas–Lehmer tests; just squaring will do.<br />

9.26. Prove that Algorithm 9.2.13 works; that is, it terminates with the<br />

correct returned result.<br />

9.27. Work out an algorithm for fast mod operation with respect to moduli<br />

of the form<br />

p =2 a +2 b + ···+1,<br />

where the existing exponents (binary-bit positions) a,b,... are sparse; i.e.,<br />

a small fraction of the bits of p are 1’s. Work out also a generalization in<br />

which minus signs are allowed, e.g., p =2 a ± 2 b ±···±1, with the existing<br />

exponents still being sparse. You may find the relevant papers [Solinas 1999]<br />

and [Johnson et al. 2001] of interest in this regard.<br />

9.28. Some computations, such as the Fermat number transform (FNT)<br />

and other number-theoretical transforms, require multiplication by powers of<br />

two. On the basis of Theorem 9.2.12, work out an algorithm that for modulus<br />

N =2 m +1, quickly evaluates (x2 r )modN for x ∈ [0,N−1] and any (positive<br />

or negative) integer r. What is desired is an algorithm that quickly performs<br />

the carry adjustments to which the theorem refers, rendering all bits of the<br />

desired residue in standard, nonnegative form (unless, of course, one prefers<br />

to stay with a balanced representation or some other paradigm that allows<br />

negative digits).<br />

9.29. Work out the symbolic powering relation of the type (9.16), but for<br />

the scheme of Algorithm 9.3.1.<br />

9.30. Prove that Algorithm 7.2.4 works. It helps to track through small<br />

examples, such as n = 00112, for which m = 10012 (and so we have<br />

intentionally padded n to have four bits). Compare the complexity with that of<br />

a trivial modification, suitable for elliptic curve arithmetic, to the “left-right”<br />

ladder, Algorithm 9.3.1, to determine whether there is any real advantage in<br />

the “add-subtract” paradigm.<br />

9.31. For the binary gcd and extended binary algorithms, show how to<br />

enhance performance by removing some of the operations when, say, y is<br />

prime and we wish to calculate x −1 mod y. The key is to note that after<br />

the [Initialize] step of each algorithm, knowledge that y is odd allows the<br />

removal of some of the internal variables. In this way, end up with an inversion

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

Saved successfully!

Ooh no, something went wrong!