### Problem Set #4

#### Due: May 9th, 2008

1. Let's do RSA. For the following, I used python; please do the same.
• Using Fermat's Test, find the smallest 3-pseudoprime larger than 1278450012840012915. Call this number that you found, p.
• Now find the smallest 3-pseudoprime larger than 92830582375291128351. Call this number that you found, q.
• What is n? (Note: make sure you do the above two steps properly or you will get everything else wrong from here on out!)
• What is phi(n)?
• Let e=5. What is d?
• Let M=19571299103581789. What is the ciphertext C?
• Decipher C using d. Do you get M back?

2. Assume RSA. The public key is (411816231521, 5). The encoding method is to take 8 characters of plaintext and convert to an integer M1. Then encrypt under the public key as usual, to obtain C1. Then we take the next 8 characters of plaintext and convert to M2, which we encrypt to C2. And so forth.

The conversion works as follows: we treat a string of 8 alphabetical characters as a vector of 8 coordinates, each of which is between 0 and 25. (A is 0, B is 1, ..., Z is 25). For example, HEYTHERE converts to (7,4,24,19,7,4,17,4). We then convert this to an integer by taking these coordinates as the digits of a base-26 number. So HEYTHERE converts to the integer 7*267 + 4*266 + 24*265 + 19*264 + 7*263 + 4*262 + 17*26 + 4 = 57752296086.

• Show that this conversion process always produces an integer between 0 and n-1 for the n given above in the public key.
• Assuming that the ciphertexts listed below are encrypted using the public key above and the given conversion process, recover the plaintext. Be sure and document your method.
```225803654487   27035345731   318496681005    222309193242   128671002039
```

3. We showed in class that RSA works. That is, that if you have some M relatively prime to n, then Med = M (mod n). Please show that RSA still works if M is any integer between 1 and n-1.

4. (Extra Credit) Fix some RSA modulus n=pq (where p and q are distinct primes) and some encryption exponent e which is relatively prime to phi(n). Show that the number of messages M, 0 <= M <= n-1, such that Me = M (mod n) is equal to (1 + gcd(e-1, p-1))(1 + gcd(e-1, q-1)).