## Homework 7, Due Thursday, 03/31

1. A Shortcut. Fermat's Little Theorem states that if p is prime, then for any integer a not divisible by p,
a p − 1 ≡ 1    (mod p).
Take advantage of Fermat's Little Theorem to compute the value 95282 % 19 by noticing that 918 ≡ 1  (mod 19). Show your work.

2. Chinese Remainder Theorem. Use the Chinese Remainder Theorem to find an integer x such that 0 ≤ x < 1456 and the following congruences hold:
x ≡ 5   (mod 7)
x ≡ 8   (mod 13)
x ≡ 11   (mod 16)
Note that 7 ⋅ 13 ⋅ 16 = 1456 and recall that the notation
ab   (mod n)
means that a % n = b % n, where % is the remainder operator. Show your work. (See notes on the Chinese Remainder Theorem.)

3. RSA Key Generation. Suppose that you picked p = 1307 and q = 1129 for your RSA keys. Then, n = 1475603 and φ(n) = (p - 1)(q - 1) = 1473168. You still need to find e and d such that ed % φ(n) = 1. Use the Extended Euclid Algorithm to help you find an e and a d. Make sure you report e and d as positive values less than φ(n). Show your work using the Extended Euclid Algorithm. (See notes on the Extended Euclid Algorithm.) Note: Do not use a computer program to do this computation.

Additional Note: You need to pick an e such that gcd(e,φ(n)) = 1. The usual recommendation is to pick a prime number. However, you must still check that gcd(e,φ(n)) = 1 when e is prime, because it is possible that e divides φ(n). For example, in this problem picking e = 3 doesn't work because φ(n) = 1473168 is divisible by 3 and so gcd(3,1473168) = 3. There are no inverses of 3 modulo 1473168.

Another Additional Note: You are not allowed to pick e = 1.

4. RSA Encryption and Decryption (extra credit). Use the keys you generated above to encrypt the message M = 101204. The encrypted message is E = Me % n. The decrypted message is D = Ed % n. If this works, D should be 101204.

Show your work and compute the values of E and D. Since Me and Ed are very large numbers, you should use repeated squaring to compute these values. You may use a computer program or a spreadsheet to help you calculate these values, but you must write down all the intermediate steps from repeated squaring and show that E and D can be computed without using any numbers bigger than n2 = 2170223956224.