rec22 - 6.006 Intro to Algorithms Recitation 22 April 29,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
6.006 Intro to Algorithms Recitation 22 April 29, 2011 Modular Exponentiation Modular exponentiation is the problem of finding an efficient way of computing a b mod n . Mod- ular exponentiation is applicable in many security measures, such as RSA. The naive approach to computing a b mod n would be to calculate a mod n and then multiplying the result by a an additional b - 1 times. This method requires using O ( b ) multiplications to get the intended result. One key observation to make is that we can create shortcuts by squaring results instead of multiplying by a one at a time. For example, if we want to calculate a 1 0 mod n and we’ve already calculated a 5 mod n , instead of multiplying the result by a 5 more times, we can square a 5 to get a 1 0 , getting to our intended result in just one multiplication instead of five. Squaring doubles the exponent while multiplying increases the exponent by 1. Using a combination of squaring and multiplying will result in modular exponentiation using O (log b ) multiplications to get the intended result. To figure out what order of squaring/multiplying we want to execute, it helps to take a look at the binary representation of b . Given a binary representation of b , ( b k ,b k - 1 ,...,b 1 ,b 0 ), we iterate through the digits of b from most significant to least significant. Every time we see a 1 digit, that
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

rec22 - 6.006 Intro to Algorithms Recitation 22 April 29,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online