Security Proofs #2: Security Games and ElGamal
Introduction
Suppose you pick two messages and I encrypt one of them. I show you the ciphertext. Can you tell which message I chose?
You already know both possible messages, so asking whether you can recover the message would be a rather weird way to measure security. The question is whether the ciphertext helps you tell the two possibilities apart.
In Part 1, the reduction had a short job. It handed the attacker a Diffie–Hellman transcript and returned whatever shared secret the attacker recovered. Recovering the secret was already the answer to the computational Diffie–Hellman problem.
Here the attacker gives us a guess about which message was encrypted. How do we turn that guess into anything about Diffie–Hellman? The new idea is to run the same experiment with two kinds of ciphertexts. One uses the real Diffie–Hellman value to mask the message. The other uses a random mask, which makes the attacker's guess no better than a coin flip. If the attacker does better with the real ciphertext, that difference gives us a way to tell a real Diffie–Hellman value from a random one.
We will work through that argument for ElGamal, an encryption scheme built from Diffie–Hellman.
Public-Key Encryption
Suppose Alice wants to send Bob a private message. In public-key encryption, Bob generates two keys. He publishes one, called the public key, and keeps the other, called the secret key, to himself. Alice uses the public key to turn her message into a ciphertext. Bob uses his secret key to turn the ciphertext back into the message.
Anyone who has Bob's public key can send him an encrypted message, including someone who has never talked to Bob before. An eavesdropper can have the very same public key and see the ciphertext. What should it mean for Alice's message to stay private in that situation?

The Security Game
A security game is an experiment between an attacker and a challenger. The challenger runs the experiment and keeps track of the secrets. The rules specify what the attacker sees, what it can do, and what counts as winning.
Here is the game for indistinguishability under chosen-plaintext attack, or IND-CPA, for public-key encryption:
- The challenger generates a key pair and gives the public key to the attacker.
- The attacker chooses two valid messages and of the same length and sends them to the challenger.
- The challenger samples a uniform bit and sends back a fresh encryption of .
- The attacker outputs a guess . It wins if .
The attacker gets to choose the messages after seeing the public key. And since it has that key, it can encrypt any other messages itself, before or after it sees the challenge ciphertext.
Even a random guess wins half the time. We will measure the attacker's advantage by how far its win probability is from that baseline:
The probability is over key generation, the choice of , the randomness used to encrypt, and the attacker's own randomness. The scheme is IND-CPA secure if this advantage is negligible for every efficient attacker.
Why does encryption need fresh randomness? Suppose encryption were deterministic. The attacker could choose two distinct messages, encrypt both with the public key, and compare the results with the challenge ciphertext. Correctness requires the two ciphertexts to be different, so the attacker would win every time.
ElGamal Encryption
We use the same setting as in Part 1. Let be a cyclic group of prime order . For this version of ElGamal, messages are elements of .
- Key generation. Bob samples uniformly from and publishes . He keeps secret.
- Encryption. To encrypt , Alice samples a fresh uniform and sends .
- Decryption. Bob computes and divides it out of , recovering .
The last step works because . This is the same equality that gave us correctness for Diffie–Hellman. Here the shared value masks the message, and Alice's fresh exponent gives her a fresh mask for each encryption.

The Assumption
The decisional Diffie–Hellman (DDH) assumption concerns two ways of sampling a tuple:
where are independently uniform in . The last element is either the shared Diffie–Hellman value or an independent uniform group element. We measure a distinguisher's advantage by the absolute difference between its probabilities of outputting on the two distributions. The assumption says this difference is negligible for every efficient distinguisher.
The Reduction
Suppose we have an efficient attacker that plays the IND-CPA game for ElGamal. We build a DDH distinguisher using that attacker.
- Receive a DDH challenge and give the public key .
- Receive the two messages . Sample a uniform bit and give the ciphertext .
- Receive the guess . Output if and otherwise.
Notice that can do all this without knowing the exponents behind and . The challenge gives it the three group elements it needs. What changes between the two cases is what represents.
When is the shared value
Write and . If , the ciphertext is
This is exactly an honest ElGamal encryption of . The exponents have the right distribution, so sees the real IND-CPA game. The probability that outputs is the attacker's win probability in that game.
When is uniform
Now is an independent uniform element of . Fix the public key, , and the two messages the attacker chose. For any , there is exactly one value of for which , namely . Thus is uniform for either value of .
The attacker sees the same distribution of ciphertexts whichever message was selected. Its guess matches with probability exactly , so outputs with probability .
Putting the two cases together
The reduction runs the attacker once and does a small amount of extra work, so it is efficient whenever the attacker is. If the attacker had non-negligible advantage, the reduction would have the same advantage against DDH. Therefore, ElGamal is IND-CPA secure under the DDH assumption.
What Changed Between the Games?
Replacing the mask was a game hop. To justify the hop, we asked what would happen if the attacker's win probability changed by a noticeable amount. The reduction could use that change to distinguish the two DDH distributions, just by checking whether the attacker won. In a longer proof, we might make several hops and bound how much the win probability can change at each step.
Note: AI used for polishing text and finding bugs.
- ← Previous
Book: Vimukta