3. Generating the public keys
1. Pick two prime numbers p and q, eg 3 and
11
2. Calculate their product n, n = 33
3. Calculate intermediate z (p-1)*(q-1), z = 20
4. Pick a prime k such that k is smaller than z
and z is and not divisible by k, k = 7
5. The numbers n and k are the public key, in
our case n=33, k=7
4. Generating the private key
• The private key j is given by the formula
k * j = 1(mod z)
• In our example, k = 7, z = 20
7 * j = 1(mod 20)
• Is satisfied by j = 3
• Our private key is 3
5. Encrypting and Decrypting
• E is the encrypted value
• P is the plaintext value
• Encrypting, say we send P = 14
P ^ k = E(mod n) 14^7 = 105413504
105413504 / 33 = 3194348.606
14 ^ 7 = E(mod 33) = 20 3194348 * 33 = 105413484
105413504 – 105413484 = 20
• E ^ j = P(mod n) 20^3 = 8000
8000 / 33 = 242.42424242
• 20 ^ 3 = P(mod 33) = 14 242 * 33 = 7986
8000 – 7986 = 14
6. Encrypting and Decrypting
• E is the encrypted value
• P is the plaintext value
• Encrypting, say we send P = 14
P ^ k = E(mod n) 14^7 = 105413504
105413504 / 33 = 3194348.606
14 ^ 7 = E(mod 33) = 20 3194348 * 33 = 105413484
105413504 – 105413484 = 20
• E ^ j = P(mod n) 20^3 = 8000
8000 / 33 = 242.42424242
• 20 ^ 3 = P(mod 33) = 14 242 * 33 = 7986
8000 – 7986 = 14