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.

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

where H denotes the number of 1’s in the exponent y. Since we expect about<br />

“half 1’s” in a random exponent, the average-case complexity is thus<br />

C ∼ (lg y)S +( 1<br />

2 lg y)M.<br />

Note that using (9.4) one can often achieve S ∼ M/2 so reducing the<br />

expression for the average-case complexity of the above ladders to C ∼<br />

(lg y)M. The estimate S ∼ M/2 is not a universal truth. For one thing,<br />

such an estimate assumes that modular arithmetic is not involved, just<br />

straight nonmodular squaring and multiplication. But even in the nonmodular<br />

world, there are issues. For example, with FFT multiplication (for very large<br />

operands, as described later in this chapter), the S/M ratio can be more<br />

like 2/3. With some practical (modular, grammar-school) implementations,<br />

the ratio S/M is about 0.8, as reported in [Cohen et al. 1998]. Whatever<br />

subroutines one uses, it is of course desirable to have fewer arithmetic<br />

operations to perform. As we shall see in the following section, it is possible<br />

to achieve further operation reduction.<br />

9.3.2 Enhancements to ladders<br />

In factorization studies and cryptography it is a rule of thumb that power<br />

ladders are used much of the time. In factorization, the so-called stage<br />

one of many methods involves almost nothing but exponentiation (in the<br />

case of ECM, elliptic multiplication is the analogue to exponentiation).<br />

In cryptography, the generation of public keys from private ones involves<br />

exponentiation, as do digital signatures and so on. It is therefore important<br />

to optimize powering ladders as much as possible, as these ladder operations<br />

dominate the computational effort in the respective technologies.<br />

One interesting method for ladder enhancement is sometimes referred to<br />

as “windowing.” Observe that if we expand not in binary but in base 4, and<br />

we precompute powers x 2 ,x 3 , then every time we encounter two bits of the<br />

exponent y, we can multiply by one of 1 = x 0 ,x 1 ,x 2 ,x 3 andthensquaretwice<br />

to shift the current register to the left by two bits. Consider for example the<br />

task of calculating x 79 , knowing that 79 = 10011112 = 10334. If we express<br />

the exponent y = 79 in base 4, we can do the power as<br />

x 79 =<br />

<br />

x 42<br />

x 3 4<br />

x 3 ,<br />

which takes 6S +2M (recall nomenclature S, M for square and multiply). On<br />

the other hand, the left-right ladder Algorithm 9.3.1 does the power this way:<br />

x 79 =<br />

x 23<br />

<br />

2<br />

2<br />

2<br />

x x x x,<br />

for a total effort of 6S +4M, more than the effort for the base-4 method. We<br />

have not counted the time to precompute x 2 ,x 3 in the latter method, and so

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

Saved successfully!

Ooh no, something went wrong!