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\mathcal{K} denote the key space (all possible keys), M\mathcal{M} the message space, and C\mathcal{C} ciphertext space (encrypted message).

For a resonably secure public key cryptosystem, we would want the following properties

  1. For any key kKk \in \mathcal{K} and message in mMm \in \mathcal{M}, it must be easy to compute the ciphertext ek(m)=e(k,m)e_k(m) = e(k, m) (encryption is fast).
  2. For any key kKk \in \mathcal{K} and ciphertext in cCc \in \mathcal{C}, it must be easy to compute dk(c)=d(k,c)d_k(c) = d(k, c) (decryption is fast).
  3. Given one or more c1,,cnCc_1, \dots, c_n \in \mathcal{C}, all encrypted using the same kKk \in \mathcal{K}, it must be very difficult to compute any of dk(c1),,dk(cn)d_k(c_1), \dots, d_k(c_n) without knowledge of kk.
  4. Given one or many pairs of plaintexts and corresponding ciphertexts (m1,c1),,(mn,cn)(m_1, c_1), \dots, (m_n, c_n) it must be very difficult to compute any ciphertext besides c1,,cnc_1, \dots, c_n without knowing kk (khown plaintext attack resilience).
  5. For any message m1,,mnMm_1, \dots, m_n \in \mathcal{M} chosen by an adversarial eavesdropper, even with knowledge of ciphertexts ek(m1),,ek(mn)e_k(m_1), \dots, e_k(m_n), it is very difficult to decrypt any ciphertext cc that is not in the given list without knowing key kk (chosen plaintext attack resilience).

§ Elgamal Public Key Cryptosystem

Elgamal Cryptosystem

First, Alice and Bob agree on a common (large) prime pp, and an element g(modp)g \pmod{p}. These values are communicated in public.

Alice chooses a private key aa, and makes her public key ApgaA \equiv_p g^a available to Bob.

Encryption: If Bob wants to send a message mm to Alice, he chooses a random value k(modp)k\pmod{p} and computes the two values

c1pgk and c2pmAkc_1 \equiv_p g^k \text{ and } c_2 \equiv_p mA^k

and sends the pair (c1,c2)(c_1, c_2) to Alice.

Decryption: After receiving Bob's message, she uses the Euclidean algorithm to find the modular inverse of c1c_1 modulo pp. Then, she raises c11c_1^{-1} to the power of her private key aa, i.e. c1apgkac_1^{-a} \equiv_p g^{-ka}. Finally, she decodes the message by

mpgkac2.m \equiv_p g^{-ka}c_2.