Hashed ElGamal Encryption #
Hashed ElGamal masks the message with a hash of the Diffie-Hellman shared secret rather than a group element, so it encrypts messages of an arbitrary type (group elements or otherwise) and achieves IND-CPA security under the DDH assumption in the ROM.
Construction #
Given a cyclic group G with generator g:
keyGen: Samplesk ← Exp; output(sk, pk = g^sk)encrypt(pk, m): Sampler ← Exp; output(g^r, m ⊕ H(pk^r))decrypt(sk, (c₁, c₂)): Outputc₂ ⊕ H(c₁^sk)
where H : G → {0,1}^n is a hash function and ⊕ is XOR.
Security #
Under DDH + ROM: IND-CPA_Advantage ≤ DDH_Advantage
The reduction:
- Given DDH challenge (g^a, g^b, z)
- Set pk = g^a, c₁ = g^b
- If z = g^(ab): H(z) masks m correctly (real game)
- If z = g^c: H(z) is fresh random (ideal/OTP game)
References #
- [Abdalla, Bellare & Rogaway, The Oracle Diffie-Hellman Assumptions, 2001]
- [Shoup, A Proposal for an ISO Standard for PKE, 2001]
Hash Function Type #
A hash function from group elements to the plaintext space. In the ROM, this would be modeled as a random oracle.
- hash : G → PT
Instances For
Hashed ElGamal Scheme #
Hashed ElGamal key generation: sample secret key, compute public key.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hashed ElGamal encryption with XOR masking (for Bool plaintext).
encrypt(pk, m) = (g^r, m ⊕ H(pk^r)) for random r.
Here we use Bool as the plaintext type and xor as the masking operation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hashed ElGamal decryption for Bool plaintext.
decrypt(sk, (c₁, c₂)) = c₂ ⊕ H(c₁^sk)
Equations
- CatCryptCore.Examples.HashedElGamal.heg_decrypt_bool H sk (c₁, c₂) = (H (CatCryptCore.Examples.CyclicGroupDDH.CyclicGroup.elemPow c₁ sk) ^^ c₂)
Instances For
Correctness #
Decryption inverts encryption: H(pk^r) ⊕ (H(pk^r) ⊕ m) = m.
Correctness relies on:
- pk^r = g^(sk·r) = (g^r)^sk = c₁^sk
- H is deterministic
- XOR is self-inverse
IND-CPA Security Game #
Real IND-CPA game for Hashed ElGamal: sample (sk, pk), sample r, return (g^r, H(pk^r) ⊕ m).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Ideal game (random mask): replace H(g^(sk·r)) with a random bit. This is the OTP game — perfectly secure.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DDH-based Security Reduction #
DDH distinguisher from a Hashed ElGamal IND-CPA adversary.
Given DDH challenge (g^a, g^b, z):
- pk := g^a, c₁ := g^b
- If z = g^(ab): encrypt = (g^b, H(g^(ab)) ⊕ m) = real game
- If z = g^c: encrypt = (g^b, H(g^c) ⊕ m) with independent H(g^c)
Equations
Instances For
LHS normal form: heg_real.bind A as explicit double-sample.
RHS normal form: DDH_real.bind reduction as explicit double-sample.
Program equality: the real Hashed ElGamal game composed with adversary A equals the DDH real game composed with the DDH reduction.
Hashed ElGamal IND-CPA advantage is bounded by DDH advantage.
The hypothesis h_ideal_indep captures the key property that in the DDH
ideal world (where z = g^c for random c independent of a, b), the
distinguisher's view is independent of the encrypted message m.
This holds when H is modeled as a random oracle: H(g^c) for random c acts as a fresh random mask, making xor(H(g^c), m) independent of m. It also holds for any hash function H such that H ∘ pow maps uniform exponents to uniform bits (e.g., a universal hash function).
The proof follows the standard DDH reduction:
- Real game = DDH_real ∘ reduction (program equality)
- Triangle: |Adv(real m₀, real m₁)| ≤ DDH(red m₀) + |ideal m₀ vs ideal m₁| + DDH(red m₁)
- Middle term = 0 by h_ideal_indep
- Conclusion: ≤ DDH(red m₀) + DDH(red m₁)
Perfect Security with Random Oracle #
When H is a truly random function (perfect hash), the encryption mask is uniformly random regardless of the shared secret, giving perfect IND-CPA security.
OTP core: with a uniform mask, (c₁, mask ⊕ m) has the same distribution as
(c₁, mask) — the message m is masked away. This is the one-time-pad
bijection (boolXorBij m) applied inside the sampled mask, giving perfect
secrecy of the ideal Hashed ElGamal game.
Perfect secrecy of the ideal game: the two ideal games for distinct messages are the same distribution. Only the innermost mask depends on the message, and the OTP bijection removes that dependence.
With a perfect random oracle, Hashed ElGamal has zero IND-CPA advantage:
the two ideal games are the same distribution (heg_ideal_indep), so every
adversary distinguishes them with advantage 0. This is the OTP/perfect-secrecy
endpoint the DDH reduction (heg_indcpa_le_ddh) targets.