Prime Numbers
Prime Numbers Prime Numbers
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
- Page 420 and 421: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 422 and 423: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 424 and 425: 8.4 Diophantine analysis 415 [Tezuk
- Page 426 and 427: 8.4 Diophantine analysis 417 9262 3
- Page 428 and 429: 8.5 Quantum computation 419 We spea
- Page 430 and 431: 8.5 Quantum computation 421 three H
- Page 432 and 433: 8.5 Quantum computation 423 for a n
- Page 434 and 435: 8.6 Curious, anecdotal, and interdi
- Page 436 and 437: 8.6 Curious, anecdotal, and interdi
- Page 438 and 439: 8.6 Curious, anecdotal, and interdi
- Page 440 and 441: 8.7 Exercises 431 universal Golden
- Page 442 and 443: 8.7 Exercises 433 standards insist
- Page 444 and 445: 8.7 Exercises 435 of positive compo
- Page 446 and 447: 8.8 Research problems 437 element o
- Page 448 and 449: 8.8 Research problems 439 the Leveq
- Page 450 and 451: 8.8 Research problems 441 for every
- Page 452 and 453: Chapter 9 FAST ALGORITHMS FOR LARGE
- Page 454 and 455: 9.1 Tour of “grammar-school” me
- Page 456 and 457: 9.2 Enhancements to modular arithme
- Page 458 and 459: 9.2 Enhancements to modular arithme
- Page 460 and 461: 9.2 Enhancements to modular arithme
- Page 462 and 463: 9.2 Enhancements to modular arithme
- Page 464 and 465: 9.2 Enhancements to modular arithme
- Page 466 and 467: 9.3 Exponentiation 457 Algorithm 9.
- Page 468 and 469: 9.3 Exponentiation 459 But there is
- Page 472 and 473: 9.4 Enhancements for gcd and invers
- Page 474 and 475: 9.4 Enhancements for gcd and invers
- Page 476 and 477: 9.4 Enhancements for gcd and invers
- Page 478 and 479: 9.4 Enhancements for gcd and invers
- Page 480 and 481: 9.4 Enhancements for gcd and invers
- Page 482 and 483: 9.5 Large-integer multiplication 47
- Page 484 and 485: 9.5 Large-integer multiplication 47
- Page 486 and 487: 9.5 Large-integer multiplication 47
- Page 488 and 489: 9.5 Large-integer multiplication 47
- Page 490 and 491: 9.5 Large-integer multiplication 48
- Page 492 and 493: 9.5 Large-integer multiplication 48
- Page 494 and 495: 9.5 Large-integer multiplication 48
- Page 496 and 497: 9.5 Large-integer multiplication 48
- Page 498 and 499: 9.5 Large-integer multiplication 48
- Page 500 and 501: 9.5 Large-integer multiplication 49
- Page 502 and 503: 9.5 Large-integer multiplication 49
- Page 504 and 505: 9.5 Large-integer multiplication 49
- Page 506 and 507: 9.5 Large-integer multiplication 49
- Page 508 and 509: 9.5 Large-integer multiplication 49
- Page 510 and 511: 9.5 Large-integer multiplication 50
- Page 512 and 513: 9.5 Large-integer multiplication 50
- Page 514 and 515: 9.5 Large-integer multiplication 50
- Page 516 and 517: 9.5 Large-integer multiplication 50
- Page 518 and 519: 9.6 Polynomial arithmetic 509 can i
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