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 461 the benefit is not so readily apparent. But a benefit would be seen in most cases if the exponent 79 were larger, as in many cryptographic applications. There are many detailed considerations not yet discussed, but before we touch upon those let us give a fairly general windowing ladder that contains most of the applicable ideas: Algorithm 9.3.3 (Windowing ladder). This algorithm computes x y . We assume a base-(B = 2 b ) expansion (as in Definition 9.1.1), denoted by (y0,...,yD−1) of y > 0, with high digit yD−1 = 0, so each digit satisfies 0 ≤ yi < B. We also assume that the values {x d : 1 < d < B; d odd} have been precomputed. 1. [Initialize] z =1; 2. [Loop over digits] for(D − 1 ≥ i ≥ 0) { Express yi =2cd, where d isoddorzero; z = z(xd ) 2c; // xd from storage. if(i >0) z = z2b; } return z; To give an example of why only odd powers of x need to be precomputed, let us take the example of y = 262 = 4068. Looking at this base-8 representation, we see that x 262 = x 4 8 8 x 6 , but if x 3 has been precomputed, we can insert that x 3 at the proper juncture, and Algorithm 9.3.3 tells us to exponentiate like so: x 262 = x 48 4 x 3 2 . Thus, the precomputation is relegated to odd powers only. Another way to exemplify the advantage is in base 16 say, for which each of the 4-bit sequences: 1100, 0110, 0011 in any exponent can be handled via the use of x 3 and the proper sequencing of squarings. Now, as to further detail, it is possible to allow the “window”—essentially the base B—to change as we go along. That is, one can look ahead during processing of the exponent y, trying to find special strings for a little extra efficiency. One “sliding-window” method is presented in [Menezes et al. 1997]. It is also possible to use our balanced-base representation, Definition 9.1.2, to advantage. If we constrain the digits of exponent y to be −⌊B/2⌋ ≤yi ≤⌊(B − 1)/2⌋, and precompute odd powers x d where d is restricted within the range of these digit values, then significant advantages accrue, provided that the inverse

462 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC powers are available. In the case of elliptic multiplication, let us say we desire “exponentiation” [k]P ,whereP is a point, k the exponent. We need to precompute, then, only the multiples {[d]P : 1 0. We also assume that the (total of (B − 1)(D − 1)) values {x iBj have been precomputed. 1. [Initialize] z =1; 2. [Loop over digits] for(0 ≤ j

9.3 Exponentiation 461<br />

the benefit is not so readily apparent. But a benefit would be seen in most<br />

cases if the exponent 79 were larger, as in many cryptographic applications.<br />

There are many detailed considerations not yet discussed, but before we<br />

touch upon those let us give a fairly general windowing ladder that contains<br />

most of the applicable ideas:<br />

Algorithm 9.3.3 (Windowing ladder). This algorithm computes x y . We<br />

assume a base-(B = 2 b ) expansion (as in Definition 9.1.1), denoted by<br />

(y0,...,yD−1) of y > 0, with high digit yD−1 = 0, so each digit satisfies<br />

0 ≤ yi < B. We also assume that the values {x d : 1 < d < B; d odd}<br />

have been precomputed.<br />

1. [Initialize]<br />

z =1;<br />

2. [Loop over digits]<br />

for(D − 1 ≥ i ≥ 0) {<br />

Express yi =2cd, where d isoddorzero;<br />

z = z(xd ) 2c;<br />

// xd from storage.<br />

if(i >0) z = z2b; }<br />

return z;<br />

To give an example of why only odd powers of x need to be precomputed, let<br />

us take the example of y = 262 = 4068. Looking at this base-8 representation,<br />

we see that<br />

x 262 =<br />

x 4 8 8<br />

x 6 ,<br />

but if x 3 has been precomputed, we can insert that x 3 at the proper juncture,<br />

and Algorithm 9.3.3 tells us to exponentiate like so:<br />

x 262 =<br />

x 48 4 x 3<br />

2 .<br />

Thus, the precomputation is relegated to odd powers only. Another way to<br />

exemplify the advantage is in base 16 say, for which each of the 4-bit sequences:<br />

1100, 0110, 0011 in any exponent can be handled via the use of x 3 and the<br />

proper sequencing of squarings.<br />

Now, as to further detail, it is possible to allow the “window”—essentially<br />

the base B—to change as we go along. That is, one can look ahead during<br />

processing of the exponent y, trying to find special strings for a little extra<br />

efficiency. One “sliding-window” method is presented in [Menezes et al. 1997].<br />

It is also possible to use our balanced-base representation, Definition 9.1.2, to<br />

advantage. If we constrain the digits of exponent y to be<br />

−⌊B/2⌋ ≤yi ≤⌊(B − 1)/2⌋,<br />

and precompute odd powers x d where d is restricted within the range of these<br />

digit values, then significant advantages accrue, provided that the inverse

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

Saved successfully!

Ooh no, something went wrong!