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.

88 Chapter 2 NUMBER-THEORETICAL TOOLS<br />

Indeed, 62 modulo 3, 5, 7, respectively, gives the required residues 2, 2, 6.<br />

Though ancient, the CRT algorithm still finds many applications. Some<br />

of these are discussed in Chapter 8.8 and its exercises. For the moment,<br />

we observe that the CRT affords a certain “parallelism.” A set of separate<br />

machines can perform arithmetic, each machine doing this with respect to<br />

a small modulus mi, whence some final value may be reconstructed. For<br />

example, if each of x, y has fewer than 100 digits, then a set of prime moduli<br />

{mi} whose product is M > 10 200 can be used for multiplication: The i-th<br />

machine would find ((x mod mi) ∗ (y mod mi)) mod mi, and the final value<br />

x ∗ y would be found via the CRT. Likewise, on one computer chip, separate<br />

multipliers can perform the small-modulus arithmetic.<br />

All of this means that the reconstruction problem is paramount; indeed,<br />

the reconstruction of n tends to be the difficult phase of CRT computations.<br />

Note, however, that if the small moduli are fixed over many computations, a<br />

certain amount of one-time precomputation is called for. In Theorem 2.1.6,<br />

one may compute the Mi and the inverses vi just once, expecting many future<br />

computations with different residue sets {ni}. In fact, one may precompute<br />

the products viMi. A computer with r parallel nodes can then reconstruct<br />

niviMi in O(ln r) steps.<br />

There are other ways to organize the CRT data, such as building up one<br />

partial modulus at a time. One such method is the Garner algorithm [Menezes<br />

et al. 1997], which can also be done with preconditioning.<br />

Algorithm 2.1.7 (CRT reconstruction with preconditioning (Garner)).<br />

Using the nomenclature of Theorem 2.1.6, we assume r ≥ 2 fixed, pairwise<br />

coprime moduli m0,...,mr−1 whose product is M, and a set of given residues<br />

{ni (mod mi)}. This algorithm returns the unique n ∈ [0,M− 1] with the given<br />

residues. After the precomputation step, the algorithm may be reentered for future<br />

evaluations of such n (with the {mi} remaining fixed).<br />

1. [Precomputation]<br />

for(1 ≤ i

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

Saved successfully!

Ooh no, something went wrong!