Modular exponentiation and fast powering - Discrete Math
- In a Diffie-Hellman key exchange with prime and generator , Alice chooses secret and must compute . Using repeated squaring, what intermediate values will Alice compute? Answer: Computing powers of 5 modulo 23 using repeated squaring: . . . . Option B incorrectly shows without reducing modulo 23. Option C has the wrong final value . Option D has incorrect intermediate values and .
- Irene wants to compute efficiently. She discovers that and uses the Chinese Remainder Theorem. If she finds , , and , but then realizes she made an error in one calculation, which of these is most likely incorrect? Answer: because and By Fermat's Little Theorem: For mod 7: , and since , we get , not 1. For mod 11: , and since , we get . For mod 13: , but , so , not 1. The error in choice C is that 12 does not divide 1000 (since ). Choice A has the right reasoning but wrong conclusion. Choice B is actually correct. Choice D is wrong since not all are correct.
- A cryptographic protocol requires computing where and are secret values, is a generator, and is a large prime. Two approaches are suggested: (1) Compute , then raise this result to the power ; (2) Compute directly. Under what condition are these approaches equivalent? Answer: Always equivalent when is prime and is a generator Both approaches are mathematically equivalent when is prime and . Method 1: . Method 2: By Fermat's Little Theorem, , so . Since is a generator of the multiplicative group mod , we have , so FLT applies. The results are identical. Option B is wrong - we need , not . Option C is wrong - the equivalence holds for any values of . Option D is wrong - they're mathematically equivalent regardless of computational differences.
- To compute efficiently, Alice uses repeated squaring. She observes that . Using this observation and the binary representation , what is the value of ? Answer: Since , we have . Given , we compute: , , , . Therefore . Choice A results from incorrectly applying Fermat's Little Theorem. Choice B comes from computational errors in the squaring process. Choice D results from missing the final reduction modulo 7.
- To compute efficiently, a student uses the fact that by Fermat's Little Theorem. However, the student makes an error and computes , concluding that . What is the correct answer and what was the student's error? Answer: Correct answer is ; student should have used The student's error is using instead of . Since , we need . We have , so . Therefore . Now and . So the correct answer is . The key insight is that when using , we reduce the exponent modulo , not modulo .
- For the computation , a student wants to use Fermat's Little Theorem since 101 is prime. They need to reduce the exponent modulo 100. However, is astronomically large. What is the most efficient approach to find ? Answer: Factor , note , and apply CRT with modulo 25 Since and , we can use the Chinese Remainder Theorem. For mod 4: . For mod 25: Since and , we have . Therefore . By CRT, we need and . Solving: where , so , giving , thus . Option A fails because Euler's theorem requires , but .
- In RSA decryption, to compute where and , a student decides to use Euler's theorem to reduce the exponent first. What is the reduced exponent that should be used? Answer: For RSA with where and are distinct primes, we use . Here . By Euler's theorem, if , then . Therefore, . Since , we have . The other options use incorrect values: 272 = 16×17 (wrong formula), 306 = 17×18 (another wrong formula), 324 = 18×18 (wrong formula).
- In RSA encryption with modulus , the public exponent is . To decrypt a message, David needs to compute . Using the extended Euclidean algorithm, he finds that . What is the correct private exponent ? Answer: We have . The equation shows that , so . We can verify: . Choice B (52) comes from incorrectly computing . Choice C (25) results from computational errors in the extended Euclidean algorithm. Choice D (13) represents the misconception that .
- A student computing decides to use the Chinese Remainder Theorem since . They correctly find and . To combine these using CRT, what equation must they solve? Answer: Find such that and When applying the Chinese Remainder Theorem (CRT), you're reconstructing a number from its remainders modulo coprime factors. Since and , you can find by combining the individual congruences. The key insight is that you must preserve each congruence exactly as computed. Since the student found and , the CRT system becomes: find such that and . This is answer choice C. Answer A switches the moduli incorrectly, giving and — this would solve a different problem entirely. Answer B makes the same error, just written in different order. Both A and B represent the common mistake of mixing up which remainder goes with which modulus. Answer D is nonsensical, presenting and . Since every integer is congruent to 0 modulo 1, the first congruence is impossible, and neither congruence relates to our original problem. Study tip: When setting up CRT systems, always match each remainder with its original modulus. Write down the congruences immediately after computing them to avoid mix-ups. The format is always "" for each piece.
- To optimize the computation of (a common RSA public exponent), a programmer notes that . This means the binary representation has exactly two 1-bits. What is the minimum number of modular multiplications required using this insight? Answer: 17 multiplications: 16 to compute plus 1 to multiply by When you encounter modular exponentiation problems, especially with large exponents, think about how the binary representation of the exponent can optimize your computation strategy. The key insight here is that , which has binary representation — exactly two 1-bits. To compute efficiently, you need to break this into . First, compute using repeated squaring: start with , then square it 16 times to get . This requires exactly 16 multiplications. Then multiply this result by to get , requiring 1 additional multiplication. Total: 17 multiplications. Option A misunderstands the optimization entirely — naive repeated multiplication would actually require 65,536 multiplications, not 32. Option B correctly identifies that standard repeated squaring for a general 17-bit number would need 16 squaring operations, but fails to account for the final multiplication step required when the exponent isn't a pure power of 2. Option D makes a conceptual error by claiming you only need 1 multiplication, ignoring that you must first compute before you can multiply it by . The correct answer is C: 17 multiplications total. Study tip: When optimizing modular exponentiation, count every operation carefully. The binary method requires one multiplication per 1-bit in the exponent's binary representation, plus squaring operations to build the necessary powers.