Meier Andreas The ElGamal Cryptosystem - Exercises.pdf
Meier Andreas The ElGamal Cryptosystem - Exercises.pdf
Meier Andreas The ElGamal Cryptosystem - Exercises.pdf
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>The</strong> <strong>ElGamal</strong> <strong>Cryptosystem</strong><br />
<strong>Exercises</strong><br />
<strong>Andreas</strong> V. <strong>Meier</strong> <br />
March 30, 2005<br />
This exercises will help you to understand the Elgamal <strong>Cryptosystem</strong> from two sides.<br />
At the beginning, you will create a keypair (yours). Next, you take the sending side and<br />
send yourself a message. This part can also be done with a colleague, where you publish<br />
your public keys to eachother and send an encrypted message back.<br />
In any case, you have received an encrypted message that you can try to decipher. In<br />
the second exercise, you are given a keypair and a message that has been sent to you.<br />
You are now asked to decipher the message.<br />
In the last exercise you will take the role of the eavesdropper, who has intercepted a<br />
message and wants to get to the plaintext.<br />
Please note that, for the sake of simplicity, the messages here consists of only digits<br />
from 1-10, where the 10 is used as 0. (Including the 0 in the message space would make<br />
no sense obviously.)<br />
1 Key Generation<br />
In this exercise you will generate your public/private Elgamal keypair so you can be sent<br />
encrypted messages.<br />
Prime p: <strong>The</strong> target alphabet are the numbers from 0 to 9. Please find the smallest<br />
prime that can be used to encrypt messages from this alphabet (representing the<br />
digit 0 as 10).<br />
Generator k: Although there usually exist multiple possible generators, in this exercise<br />
we want to be able to compute the algorithm manually. Please find the lowest<br />
usable generator for the group defined by your prime p.<br />
Private key a: Please select now a private key a that fullfills 1 < a ≤ p − 2. (You might<br />
want to choose it such that Figure 1 is helpful.)<br />
Public Key (p, g, g a ): You have now your public key triplet.<br />
1
n 1 2 3 4 5 6 7 8 9 11<br />
2 n 2 4 8 16 32 64 128 256 512 2048<br />
2 n mod 11 2 4 8 5 10 9 7 3 6 2<br />
2 Encryption<br />
Figure 1: Exponent table for p = 11<br />
Take the public key you generated above and encrypt your date of birth specified as<br />
MMDDYYYY to yourself. You may also encrypt the message to your neighbour, using<br />
his public key. If he congratulates you next time you celebrate your brithday, everything<br />
went fine.<br />
Random k: Select a random k with 1 ≤ k ≤ p − 2.<br />
Decryption factor γ: Compute γ = g k mod p<br />
Encryption factor φ: Compute φ = (g a ) k mod p<br />
Replace each occurence of 0 in your message with 10. Now for every digit m i in your<br />
message (with i = |m|), compute δ i = m i ∗ φ.<br />
3 Decryption<br />
You receive the following encrypted message, γ = 7 and δ = {3, 6, 6, 2, 3, 5, 7, 5}, which<br />
contains information about a historical date. <strong>The</strong> sender used your public key (p, g, g a ) =<br />
(11, 2, 5) for the encryption. You are curious and decrypt the message with the help of<br />
your private key a = 4.<br />
4 Interception<br />
Now we look at the Elgamal <strong>Cryptosystem</strong> from the eavesdroppers side. You intercepted<br />
an encrypted message, γ = 6 and c = {8, 2, 3, 2, 3, 5, 4, 4}, and you assume it contains<br />
an important date. You acquire the public key (11, 2, 4) of the receiver through public<br />
means. How can you decipher the Message?<br />
5 Solution<br />
4. - Taher Elgamal was born August 18th, 1955. (hint: compute logg g a , it’s easy here.<br />
3. - Linus Torvalds was born December 28th, 1969.<br />
2. - Example: 11301980: m = (1, 1, 3, 0, 1, 9, 8, 0), k = 6: γ = 5, δ = (3, 3, 9, 8, 3, 5, 2, 8)<br />
1. - e.g. a = 3, public key: (11, 2, 8)<br />
2