Download presentation
Presentation is loading. Please wait.
Published byBenedict Barber Modified over 8 years ago
1
Fast Exponentiation (3/31) What is the most efficient way to compute 3 12574 (mod 32591)? We will need an efficient algorithm in order to do “RSA cryptography”, which is where we are now headed. Well, we could multiply 3 by itself 12574 times and then reduce mod 32591. That’s gonna take a while and also use up a huge amount of storage space. 3 12574 has about 6000 decimal digits. Better, we could at least save a lot of space by reducing mod 32591 every time our partial product goes above 32591. But this is still going to be slow for large exponents. A better idea: “Fast Exp” or “Successive Squaring”
2
Successive Squaring (Fast Exp) Instead of repeatedly multiplying by the base 3 and reducing (mod m) where m = 32591, instead compute 3 1 (mod m), 3 2 (mod m), 3 4 (mod m), 3 8 (mod m), 3 16 (mod m), 3 32 (mod m), 3 64 (mod m), 3 128 (mod m), 3 256 (mod m), 3 512 (mod m), 3 1024 (mod m), 3 2048 (mod m), 3 4096 (mod m), 3 8192 (mod m) by successive squaring. Note, 13 steps, not 12574 steps. But now we can write 12574 as a sum of the some of the exponents above (this is its “binary representation”): 12754 = 8192 + 4096 + 256 + 128 + 64 + 16 + 2. So we finish by multiplying together the values which we need from the first step above (reducing as we go). Done.
3
The Fast Exp Algorithm To compute a k (mod m) quickly: 1. If 2 n m < 2 n+1, then compute a 2^0 (mod m), a 2^1 (mod m), a 2^2 (mod m), a 2^3 (mod m),..., a 2^n (mod m) by successive squaring. Note: n+1 steps. 2. Write k in its binary representation, i.e., as a sum of powers of two. To do this by hand, compute k – 2 n, select the largest power of 2 which is below this, subtract it, etc. 3. For each power of 2 which appears in k’s binary representation, multiply the corresponding value found in step 1 into a total, always reducing by m as you go along. This algorithm is highly suited to computer implementation. In Mathematica it’s called PowerMod.
4
Assignment Hand-in # 4 is due at class time. Read Chapter 16 and do Exercise 16.1
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.