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.2 Enhancements to modular arithmetic 455 although the techniques we shall describe apply equally well to general moduli 2 q ±1, any q. That is, whether or not the modulus N has additional properties of primality or special structure is of no consequence for the mod algorithm of this section. A relevant result is the following: Theorem 9.2.12 (Special-form modular arithmetic). For N =2 q +c, c an integer, q a positive integer, and for any integer x, x ≡ (x mod 2 q ) − c⌊x/2 q ⌋ (mod N). (9.15) Furthermore, in the Mersenne case c = −1, multiplication by 2 k modulo N is equivalent to left-circular shift by k bits (so if k>, left-shift

456 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC Algorithm 9.2.13 (Fast mod operation for special-form moduli). Assume modulus N =2 q + c, with B(|c|) 0. The method is generally more efficient for smaller |c|. 1. [Perform reduction] while(B(x) >q) { y = x>>q; // Right-shift does ⌊x/2 q ⌋. x = x − (y

456 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC<br />

Algorithm 9.2.13 (Fast mod operation for special-form moduli). Assume<br />

modulus N =2 q + c, with B(|c|) 0. The method is generally more efficient for smaller |c|.<br />

1. [Perform reduction]<br />

while(B(x) >q) {<br />

y = x>>q; // Right-shift does ⌊x/2 q ⌋.<br />

x = x − (y

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

Saved successfully!

Ooh no, something went wrong!