Modular Arithmetic and Primality
Modular Arithmetic and Primality
Modular Arithmetic and Primality
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
For encryption we need to compute x y mod N for values of x,<br />
y, <strong>and</strong> N which are several hundred bits long<br />
38295034738204523523… 4645987345009439845234… mod 5345098234509345823…<br />
Way too big (<strong>and</strong> slow) unless we keep all intermediate<br />
numbers in the modulus range N.<br />
Algorithm to solve x y mod N<br />
How about multiplying by x mod N, y times, each time doing<br />
modular reduction to keep the number less than N<br />
– Multiplication is n 2 , where n (=log(N)) is length of {x, y, N} in bits.<br />
Relatively fast since each intermediate result is less than N thus each<br />
multiplication time is log 2 (N). Much better than the huge number you<br />
would end up with for non-modular exponentiation.<br />
– However, must still do y multiplies where y can be huge. Requires 2 |y|<br />
multiplications, with y being potentially hundreds of bits long<br />
CS 312 - Complexity Examples - <strong>Arithmetic</strong> <strong>and</strong> RSA 20