Elgamal Cryptosystem
17 Dec 2021
Motivation
We've already discussed how to securely exchange keys, but not a cryptosystem; i.e. a system that can be used to encrypt and decrypt messages. The Elgamal cryptosystem is very similar to Diffie-Hellman, but it can be used to encrypt messages.
Cryptosystem Discussion
Let K denote the key space (all possible keys), M the message space, and C ciphertext space (encrypted message).
For a resonably secure public key cryptosystem, we would want the following properties
- For any key k∈K and message in m∈M, it must be easy to compute the ciphertext ek(m)=e(k,m) (encryption is fast).
- For any key k∈K and ciphertext in c∈C, it must be easy to compute dk(c)=d(k,c) (decryption is fast).
- Given one or more c1,…,cn∈C, all encrypted using the same k∈K, it must be very difficult to compute any of dk(c1),…,dk(cn) without knowledge of k.
- Given one or many pairs of plaintexts and corresponding ciphertexts (m1,c1),…,(mn,cn) it must be very difficult to compute any ciphertext besides c1,…,cn without knowing k (khown plaintext attack resilience).
- For any message m1,…,mn∈M chosen by an adversarial eavesdropper, even with knowledge of ciphertexts ek(m1),…,ek(mn), it is very difficult to decrypt any ciphertext c that is not in the given list without knowing key k (chosen plaintext attack resilience).
Elgamal Public Key Cryptosystem
Elgamal Cryptosystem
First, Alice and Bob agree on a common (large) prime p, and an element g(modp). These values are communicated in public.
Alice chooses a private key a, and makes her public key A≡pga available to Bob.
Encryption: If Bob wants to send a message m to Alice, he chooses a random value k(modp) and computes the two values
c1≡pgk and c2≡pmAk
and sends the pair (c1,c2) to Alice.
Decryption: After receiving Bob's message, she uses the Euclidean algorithm to find the modular inverse of c1 modulo p. Then, she raises c1−1 to the power of her private key a, i.e. c1−a≡pg−ka. Finally, she decodes the message by
m≡pg−kac2.