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

9.3 Exponentiation 457 Algorithm 9.2.14 (Fast mod operation for Proth moduli). Assume modulus N = k · 2 q + c, with bit length B(|c|)

458 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC the exponent, and so on. Let us first summarize the categories of powering ladders: (1) Recursive powering ladder (Algorithm 2.1.5). (2) Left-right and right-left “unrolled” binary ladders. (3) Windowing ladders, to take advantage of certain bit patterns or of alternative base expansions, a simple example of which being what is essentially a ternary method in Algorithm 7.2.7, step [Loop over bits ...], although one can generally do somewhat better [Müller 1997], [De Win et al. 1998], [Crandall 1999b]. (4) Fixed-x ladders, to compute x y for various y but fixed x. (5) Addition chains and Lucas ladders, as in Algorithm 3.6.7, interesting references being such as [Montgomery 1992b], [Müller 1998]. (6) Modern methods based on actual compression of exponent bit-streams, as in [Yacobi 1999]. The current section starts with basic binary ladders (and even for these, various options exist); then we turn to the windowing, alternative-base, and fixed-x ladders. 9.3.1 Basic binary ladders We next give two forms of explicit binary ladders. The first, a “left-right” form (equivalent to Algorithm 2.1.5), is comparable in complexity (except when arguments are constrained in certain ways) to a second, “right-left” form. Algorithm 9.3.1 (Binary ladder exponentiation (left-right form)). This algorithm computes x y . We assume the binary expansion (y0,...,yD−1) of y>0, where yD−1 =1is the high bit. 1. [Initialize] z = x; 2. [Loop over bits of y, starting with next-to-highest] for(D − 2 ≥ j ≥ 0) { z = z 2 ; // For modular arithmetic, do modN here. if(yj == 1) z = zx; // For modular arithmetic, do modN here. } return z; This algorithm constructs the power x y by running through the bits of the exponent y. Indeed, the number of squarings is (D − 1), and the number of operations z = z ∗ x is clearly one less than the number of 1 bits in the exponent y. Note that the operations turn out to be those of Algorithm 2.1.5. A mnemonic for remembering which of the left-right or right-left ladder forms is equivalent to the recursive form is to note that both Algorithms 9.3.1 and 2.1.5 involve multiplications exclusively by the steady multiplier x.

9.3 Exponentiation 457<br />

Algorithm 9.2.14 (Fast mod operation for Proth moduli). Assume modulus<br />

N = k · 2 q + c, with bit length B(|c|)

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

Saved successfully!

Ooh no, something went wrong!