1 / 4

Fast Exponentiation (3/31)

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.

kalona
Télécharger la présentation

Fast Exponentiation (3/31)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fast Exponentiation (3/31) • What is the most efficient way to compute 312574 (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. 312574 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 slowfor 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 31(mod m), 32(mod m), 34(mod m), 38(mod m), 316(mod m), 332(mod m), 364(mod m), 3128(mod m),3256(mod m), 3512(mod m), 31024(mod m), 32048(mod m), 34096(mod m), 38192(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 ak(mod m) quickly: • 1. If 2n m < 2n+1 , then compute a2^0 (mod m), a2^1 (mod m),a2^2(mod m), a2^3 (mod m), ..., a2^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 – 2n, 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

More Related