We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9
Modular Exponentiation
• Allow us to evaluate ab (c mod d)
• Used in RSA, El Gamal algorithms. • Methods of computing: 1. Factoring. 2. Memory efficient. 3. Successive squaring (Power of 2). 4. General fast exponentiation. 5. Brute Force General Method (Most important) • 233 mod 30 ? 23 mod 30 = -7 or 23 233 mod 30 = (-7)3 mod 30 = (-7)2 x -7 mod 30 = 49 x -7 mod 30 = 49 mod 30 X -7 mod 30 = 19 X -7 mod 30 = -133 mod 30 = -13 mod 30 = 17 mod 30 233 mod 30 = 17 Exercise • Find 31500 mod 30, 242329 mod 243, 117 mod 13. • Find the following: 1. Factoring • Find the factors of the exponent. • If the factors of the exponent e = xyz, then ae = axyz = (((ax)y)z • Example: 14105 mod 5 = (((143)5)7 mod 5, since 105 = 3 x 5 x 7. 143mod 5 = 2744 mod 5 = 4 145mod 5 = 537824 mod 5 = 4 147mod 5 = 105413504 mod 5 = 4 Thus, 14105 mod 5 = 4*4*4 mod 5 = 64 mod 5 = 4 NOTE: But while apply the general method, 14 mod 5 = 4 mod 5 = -1 then (-1)105 mod 5 = -1 mod 5 = 4. 2. Memory Efficient • Simply multiply by the base and reduce each iteration. • Example: 37 mod 5 ? 32 mod 5 = 3 * 3 mod 5 = 4 33 mod 5 = 32 * 3 mod 5 = 4 * 3 = 12 mod 5 = 2 34 mod 5 = 33 * 3 mod 5 = 2 * 3 = 6 mod 5 = 1 35 mod 5 = 34 * 3 mod 5 = 1 * 3 = 3 mod 5 = 3 36 mod 5 = 35 * 3 mod 5 = 3 * 3 = 9 mod 5 = 4 37 mod 5 = 36 * 3 mod 5 = 4 * 3 = 12 mod 5 = 2 Thus, 37 mod 5 = 2 3. Successive squaring • Useful if the exponent is a power of 2. • Example: 3128 mod 7 ? 32 mod 7 = 3 * 3 mod 7 = 9 mod 7 = 2 34 mod 7 = 32 * 32 mod 7 = 2 * 2 mod 7 = 4 mod 7 = 4 38 mod 7 = 34 * 34 mod 7 = 4 * 4 mod 7 = 16 mod 7 = 2 316 mod 7 = 38 * 38 mod 7 = 2 * 2 mod 7 = 4 mod 7 = 4 332 mod 7 = 316 * 316 mod 7 = 4 * 4 mod 7 = 16 mod 7 = 2 364 mod 7 = 332 * 332 mod 7 = 2 * 2 mod 7 = 4 mod 7 = 4 3128 mod 7 = 364 * 364 mod 7 = 4 * 4 mod 7 = 16 mod 7 = 2 Thus, 3128 mod 7 = 2 4. Fast Exponentiation • Find the binary expansion of the exponent. • Write the exponent as the sum of its binary terms. • Express the original exponentiation in terms of this sum. • Compute the factors reduced by the modulus. • Multiply together. (Reducing wherever possible). Fast Exponentiation - Example • 3133 mod 7 ? • Solution: 13310 = 100001012 = 128 + 4 + 1 3133 = 3128 + 4 + 1 = 3128 x 34 x 31 As we know; 3128 mod 7 = 2 34 mod 7 = 4 Then, 3133 mod 7 = 3128 x 34 x 3 = 2 x 4 x 3 = 24 mod 7 = 3 Thus, 3133 mod 7 = 3 5. Brute Force • Native approach, to calculate ab mod d simply calculate ab then reduce mod d. • Example: 33 mod 5 = 27 mod 5 = 2. • As the exponent gets larger, this becomes harder to do. • For example, finding 31024 mod 5 by using this approach is difficult.