04.11.2012 Views

1 Montgomery Modular Multiplication in Hard- ware

1 Montgomery Modular Multiplication in Hard- ware

1 Montgomery Modular Multiplication in Hard- ware

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

FEI KEMT<br />

so a f<strong>in</strong>al operation required to convert the M-residue S back <strong>in</strong>to S is def<strong>in</strong>ed as:<br />

S = SR −1 mod M (1.13)<br />

= 1SR −1 mod M<br />

= MMM(1, S)<br />

The algorithm works for any modulus M provided that gcd(M, R) = 1. This is<br />

always case <strong>in</strong> the RSA s<strong>in</strong>ce M = pq, product of two primes, and therefore odd.<br />

And s<strong>in</strong>ce R is a power of 2, it is always even.<br />

The MMM algorithm for k-bit operands X = (xk−1, . . . , x1, x0), Y , and M is<br />

given as Algorithm 1 – 2 [86].<br />

Algorithm 1 – 2 The <strong>Montgomery</strong> modular multiplication algorithm for k-bit<br />

operands X = (xk−1, . . . , x1, x0), Y , and M<br />

Require: M = (mk−1 . . . m0)b, X = (xk−1 . . . x0)b, Y = (yk−1 . . . y0)b, with 0 ≥<br />

X, Y < M, R = b n with gcd(M, b), and M ′ = −M −1 mod b.<br />

Ensure: S = XY R −1 mod M.<br />

1: S ⇐ 0 , S = (sk−1 . . . s0)b<br />

2: for i = 0 to k − 1 do<br />

3: qi ⇐ (s0 + xiy0)M ′ mod b<br />

4: S ⇐ (S + xiY + qiM)/b<br />

5: end for<br />

6: if S ≥ M then<br />

7: S ⇐ S − M<br />

8: end if<br />

9: return S<br />

Thanks to the reduction dur<strong>in</strong>g a pre-computation step of Algorithm 1 – 2 it is<br />

possible to avoid an expensive operation of the modular division dur<strong>in</strong>g the com-<br />

putations. In case of a s<strong>in</strong>gle multiplication operation the classical algorithm for<br />

modular multiplication would be faster than the MMM. Due to a need of rather<br />

expensive transformation to the <strong>Montgomery</strong> doma<strong>in</strong> (M-residue) and back, it is<br />

more effective to stay <strong>in</strong> that doma<strong>in</strong> as long as possible and transform the operands<br />

back to the ord<strong>in</strong>ary only at the very end of the computations. That requires a long<br />

sequence of the MMMs as it is <strong>in</strong> case of the modular exponentiation (Algorithm 1 –<br />

1).<br />

11

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

Saved successfully!

Ooh no, something went wrong!