Chapter 8 - Cryptography
Example 8.4 (affine cipher)
Encryption
1
20
20
21
[1, 20, 20, 21, 14, 11, 19, 21, 6, 12, 11, 24]
Decryption
[1, 6, 6, 9, 14, 5, 3, 9, 16, 8, 5, 18]
Example 8.9 (Pohlig - Hellman)
Prime and exponent selection
746380697
1
Encryption
[586932278, 13007814, 458837458]
Decryption exponent computation
[(4,)]
(1, 360994585, -74)
[16151225, 7180116, 80903]
Massey-Omura exchange
Example 8.11 (Massey-Omura exchange)
We encrypt, putting the 'first lock' on:
19155614901
Next we put the second lock on:
6133869575
Next we find the inverse of the first encryption exponent:
(1, -8974971613, 18314390241)
32914471425
We decrypt, removing the first lock:
2121551126
We find the second decryption exponent:
(1, -9309559951, 10407315)
32579883087
We remove the second lock and recover the original plaintext:
123456789
Example 8.15 (RSA algorithm)
We search for some `large' primes using the next_prime command:
1237
4327
We compute n:
5352499
And φ (n):
5346936
We check that our exponent is relatively prime to φ (n):
1
Now we encrypt:
1676086
Next, we find the decrypting exponent:
(1, -1323499, 25)
4023437
Now we decrypt to obtain the original plaintext:
12345
Notes - Computing Powers Mod p
+----+--------------+
| t | 57^t mod 541 |
+====+==============+
| 1 | 57 |
+----+--------------+
| 2 | 3 |
+----+--------------+
| 4 | 9 |
+----+--------------+
| 8 | 81 |
+----+--------------+
| 16 | 69 |
+----+--------------+
| 32 | 433 |
+----+--------------+
| 64 | 303 |
+----+--------------+
496