for

INTRODUCTION TO CRYPTOGRAPHY

with Coding Theory, 2nd edition

Wade Trappe Wireless Information Network Laboratory and the Electrical and Computer Engineering Department Rutgers University Lawrence C. Washington Department of Mathematics University of Maryland August 26, 2005

Contents

Exercises

Chapter 2 - Exercises Chapter 3 - Exercises Chapter 4 - Exercises Chapter 5 - Exercises Chapter 6 - Exercises Chapter 7 - Exercises Chapter 8 - Exercises Chapter 9 - Exercises Chapter 10 - Exercises Chapter 11 - Exercises Chapter 12 - Exercises Chapter 13 - Exercises Chapter 14 - Exercises Chapter 15 - Exercises Chapter 16 - Exercises Chapter 17 - Exercises Chapter 18 - Exercises -2 1 6 14 17 19 23 25 27 28 29 31 33 34 36 40 44 46

-1 Chapter 19 - Exercises 51

Mathematica problems

Chapter 2 Chapter 3 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 12 Chapter 16 Chapter 18 52 63 66 72 74 75 78 79 81

Maple problems

Chapter 2 Chapter 3 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 12 Chapter 16 Chapter 18 84 98 102 109 112 113 116 118 121

0

MATLAB problems

Chapter 2 Chapter 3 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 12 Chapter 16 Chapter 18 124 147 151 161 164 165 167 169 174

Chapter 2 - Exercises

1. Among the shifts of EVIRE, there are two words: arena and river. Therefore, Anthony cannot determine where to meet Caesar. 2. The inverse of 9 mod 26 is 3. Therefore, the decryption function is x = 3(y − 2) = 3y − 2 (mod 26). Now simply decrypt letter by letter as follows. U = 20 so decrypt U by calculating 3 ∗ 20 − 6 (mod 26) = 2, and so on. The decrypted message is ’cat’. 3. Changing the plaintext to numbers yields 7, 14, 22, 0, 17, 4, 24, 14, 20. Applying 5x + 7 to each yields 5 · 7 + 7 = 42 ≡ 16 (mod 26), 5 · 14 + 7 = 77 ≡ 25, etc. Changing back to letters yields QZNHOBXZD as the ciphertext. 4. Let mx + n be the encryption function. Since h = 7 and N = 13, we have m · 7 + n ≡ 13 (mod 26). Using the second letters yields m · 0 + n ≡ 14. Therefore n = 14. The ﬁrst congruence now yields 7m ≡ −1 (mod 26). This yields m = 11. The encryption function is therefore 11x + 14. 5. Let the decryption function be x = ay + b. The ﬁrst letters tell us that 7 ≡ a · 2 + b (mod 26). The second letters tell us that 0 ≡ a · 17 + b.Subtracting yields 7 ≡ a · (−15) ≡ 11a. Since 11−1 ≡ 19 (mod 26), we have a ≡ 19 · 7 ≡ 3 (mod 26). The ﬁrst congruence now tells us that 7 ≡ 3 · 2 + b, so b = 1. The decryption function is therefore x ≡ 3y + 1. Applying this to CRWWZ yields happy for the plaintext. 6. Let mx+n be one aﬃne function and ax+b be another. Applying the ﬁrst then the second yields the function a(mx + n) + b = (am)x + (an + b), which is an aﬃne function. Therefore, successively encrypting with two aﬃne functions is the same as encrypting with a single aﬃne function. There is therefore no advantage of doing double encryption in this case. (Technical point: Since gcd(a, 26) = 1 and gcd(m, 26) = 1, it follows that gcd(am, 26) = 1, so the aﬃne function we obtained is still of the required form.) 7. For an aﬃne cipher mx + n (mod 27), we must have gcd(27, m) = 1, and we can always take 1 ≤ m ≤ 27. So we must exclude all multiples of 3, which leaves 18 possibilities for m. All 27 values of n are possible, so we have 18 · 27 = 486 keys. When we work mod 29, all values 1 ≤ m ≤ 28 are allowed, so we have 28 · 29 = 812 keys. 8. (a) In order for α to be valid and lead to a decryption algorithm, we need gcd(α, 30) = 1. The possible values for α are 1, 7, 11, 13, 17, 19, 23, 29. (b) We need to ﬁnd two x such that 10x (mod 30) gives the same value. There are many such possible answers, for example x = 1 and x = 4 will work. 1

2 This corresponds to the letters ’b’ and ’e’. 9. If x1 = x2 +(26/d), then αx1 +β = αx2 +β+(α/d)26. Since d = gcd(α, 26) divides α, the number α/26 is an integer. Therefore (α/d)26 is a multiple of 26, which means that αx1 + β ≡ αx2 + β (mod 26). Therefore x1 and x2 encrypt to...