Documentation

CslibFrontier.Crypto.Computational.ElGamal

ElGamal and Hashed ElGamal encryption and IND-CPA security under DDH #

Over a PrimeOrderGroupFamily, multiplicative ElGamal encryption ([BS23], Exercise 11.5, p. 459) uses a group description d, a secret exponent α : ZMod (F.order d), and the public key u = α • g. To encrypt a group element m : F.Carrier d with randomness β : ZMod (F.order d), the sender forms the ciphertext (v, e) = (β • g, β • u + m) = (β • g, (α * β) • g + m). Decryption recovers e - α • v = m, and the word-level operations encodeElGamalPublicKey, encodeElGamalEncrypt, and decodeElGamal compute public-key generation, encryption, and decryption in polynomial time from natural-number exponents and encoded group elements using F.generator, F.order, F.smul, and F.add.

We reduce IND-CPA security to DDH for games that draw the key and challenge exponents exactly uniformly at the PMF level (see Limitations). These ideal-sampling results are steps: the security theorems for the strict-PPT scheme are in CslibFrontier/Crypto/Computational/ElGamal/ProbComp.lean. The settings are:

  1. Shared typed-message ElGamal reduction (elGamalMsgCPAGameOn, elGamalMsgToDDHDistinguisher, advantage_elGamalMsgCPAGameOn_le_ideal, isPPT_elGamalMsgToDDHDistinguisher, DDH.negligible_elGamalMsgCPAGameOn_ideal). As in Encryption.gameOn, a challenge-pair admissibility predicate valid : ℕ → List Bool → Msg → Msg → Bool sees the security parameter and the public key, and an inadmissible pair makes the game output false in both experiments. The reduction needs valid to be computable in polynomial time and to admit only messages whose encodings are group elements (AdmitsGroupElements). It is instantiated for:
    • Bit ElGamal (elGamalCPAGame, elGamalIdealINDCPA, DDH.elGamalIdealINDCPA): false and true are embedded as 0 and g (bitElement, encodeBit), every pair is admissible, and Encryption.Adversary chooses two challenge bits.
    • Group-element ElGamal (Encryption.WordAdversary, elGamalGroupCPAGameOn, DDH.negligible_elGamalGroupCPAGameOn_ideal, [BS23], Exercise 11.5(a), p. 459): a two-stage word-message adversary chooses two words, and valid admits only encoded group elements, in Set.range (F.encode d). Replacing the Diffie–Hellman mask (α * β) • g with an independent uniform γ • g masks any admissible pair perfectly (uniform_smul_generator_add). A PrimeOrderGroupFamily has no membership test, so valid is a parameter; the tests instantiate it on Schnorr groups.
  2. Hashed ElGamal (hashedElGamalEncrypt, hashedElGamalDecrypt, hashedElGamalCPAGame, DDH.negligible_hashedElGamalCPAGame_ideal, [BS23], Section 11.5, pp. 445–446, Remark 11.1, and Section 11.5.2, Attack Game 11.3, Definition 11.5, and Theorem 11.5, pp. 448–451): given a deterministic polynomial-time key-derivation hash function H : F.Desc × List Bool → List Bool, the sender masks a message word m with pad = H (d, encode (β • u)) via Cslib.BitString.listXor pad.length [pad, m] (the one-time pad specialization of the E'_EG variant of Remark 11.1). Security reduces to DDH together with key-derivation security (SecureKDF, Attack Game 11.3, p. 448, and Definition 11.5, p. 449: indistinguishability of H (d, encode (γ • g)) from a uniform msgLen n-bit key). The ciphertext length does not depend on the message, and hashedElGamalCPAGame admits every challenge pair, which is stronger than Attack Game 11.1's equal-length rule.

The reductions are typed distinguishers (DDHDistinguisher, KDFDistinguisher): they receive group elements and encode them only where they build the public key and ciphertext words of the IND-CPA adversary, whose games keep their word encodings.

Limitations #

In this module, key generation and challenge encryption in the security games sample exact uniform exponents in ZMod (F.order d) at the PMF level (PMF.uniformOfFintype (ZMod (F.order d))), because an odd prime order F.order d cannot be sampled with exact uniformity by a bounded-time fair-coin ProbComp machine; deterministic public-key computation (encodeElGamalPublicKey), encryption given randomness (encodeElGamalEncrypt, encodeHashedElGamalEncrypt), and decryption (decodeElGamal, decodeHashedElGamal) are certified polynomial time on words. Strict-PPT (IsPPTOn) key generation, KEM encapsulation/decapsulation, and encryption via ProbComp.sampleModNat (connecting to Encryption.KEMINDCPA, Encryption.INDCPAOn, Encryption.WordINDCPA, and Encryption.INDCPA) are provided in CslibFrontier/Crypto/Computational/ElGamal/ProbComp.lean; non-degenerate SecureKDF instantiation (msgLen n > 0) via BitString.LinearHash and the leftover hash lemma is provided in CslibFrontier/Crypto/Computational/ElGamal/KDF.lean.

Main definitions #

Main results #

Ideal-sampling steps #

These results concern the games of this module, which draw exponents exactly uniformly at the PMF level. They are steps toward the native theorems of CslibFrontier/Crypto/Computational/ElGamal/ProbComp.lean (DDH.indcpaOn_elGamalEncryptProb, DDH.indcpa_elGamalBitEncryptProb, DDH.kemINDCPA_hashedElGamalEncapsProb, DDH.wordINDCPA_hybrid_hashedElGamal), not the cited results. They hold for an arbitrary setup law, while the native theorems fix the group description at each security parameter.

References #

Group-element ElGamal encryption and decryption #

Algebraic ElGamal encryption of a group element m : F.Carrier d under public key u : F.Carrier d with randomness β : ZMod (F.order d).

Under a genuine public key u = α • g, the second ciphertext component is (α * β) • g + m.

Algebraic ElGamal decryption of a ciphertext pair (v, e) using secret key α : ZMod (F.order d).

@[simp]

ElGamal decryption correctness: decrypting an encryption under u = α • g with secret key α recovers the message m.

Word-level ElGamal public-key computation: given (d, a), compute encode ((a : ZMod q) • g) as F.smul (d, a, F.encode d (F.generator d)).

@[simp]

encodeElGamalPublicKey computes the group encoding of (a : ZMod (F.order d)) • g.

@[reducible, inline]

Payload (u, m, b) of a 4-tuple encryption input (d, u, m, b).

@[reducible, inline]

Encoded public-key component u of a 4-tuple encryption input (d, u, m, b).

@[reducible, inline]

Message and randomness pair (m, b) of a 4-tuple encryption input (d, u, m, b).

@[reducible, inline]

Message component m of a 4-tuple encryption input (d, u, m, b).

@[reducible, inline]

Randomness component b of a 4-tuple encryption input (d, u, m, b).

@[reducible, inline]

Payload (a, v, c) of a 4-tuple decryption input (d, a, v, c).

@[reducible, inline]

Secret-key exponent a of a 4-tuple decryption input (d, a, v, c).

@[reducible, inline]

Ciphertext components (v, c) of a 4-tuple decryption input (d, a, v, c).

@[reducible, inline]

Encoded ephemeral element v of a 4-tuple decryption input (d, a, v, c).

@[reducible, inline]

Encoded body c of a 4-tuple decryption input (d, a, v, c).

Word-level ElGamal encryption: given (d, encode u, encode m, b), compute (encode (b • g), encode (b • u + m)).

@[simp]

encodeElGamalEncrypt evaluates elGamalEncrypt on encoded group elements.

Decryption on encoded group elements: given (d, a, encode v, encode e), compute encode (e - a • v) as F.add (d, encode e, F.smul (d, F.order d - a % F.order d, encode v)).

decodeElGamal computes encode (elGamalDecrypt d a (v, e)) on encoded group elements.

@[simp]
theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_elGamalEncrypt (F : PrimeOrderGroupFamily) (d : F.Desc) (a : ℕ) (β : ZMod (F.order d)) (m : F.Carrier d) :
F.decodeElGamal (d, a, F.encode d (F.elGamalEncrypt d (↑a • F.generator d) m β).1, F.encode d (F.elGamalEncrypt d (↑a • F.generator d) m β).2) = F.encode d m

Encoded ElGamal decryption of an honest encryption recovers the encoded message.

Shared typed-message ElGamal IND-CPA reduction ([BS23], Exercise 11.5(a)) #

@[reducible, inline]

Encoding of the five-argument challenge guard input (n, d, pk, m₀, m₁), with n in unary (encUnary) and every component except the last framed by encPair. It is used to share the typed-message ElGamal reduction between external valid predicates and decodable-group membership checks.

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgCPAGameWith (F : PrimeOrderGroupFamily) {Msg : Type} (guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (bit : Bool) (n : ℕ) :

Shared IND-CPA experiment for multiplicative ElGamal parameterized by a guard predicate guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool that receives both the group description d and the encoded public key pk.

def Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgToDDHDistinguisherWith (F : PrimeOrderGroupFamily) {Msg : Type} (guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (adversary : Encryption.AdversaryOf Msg) (bit : Bool) :

Shared DDH distinguisher associated with elGamalMsgCPAGameWith.

theorem Cslib.Crypto.PrimeOrderGroupFamily.ddhRealGame_elGamalMsgToDDHDistinguisherWith (F : PrimeOrderGroupFamily) {Msg : Type} (guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (bit : Bool) (n : ℕ) :
F.ddhRealGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary bit) n = F.elGamalMsgCPAGameWith guard encodeMsg setup adversary bit n

In the real DDH game, elGamalMsgToDDHDistinguisherWith simulates elGamalMsgCPAGameWith exactly.

theorem Cslib.Crypto.PrimeOrderGroupFamily.ddhRandomGame_elGamalMsgToDDHDistinguisherWith_false_eq_true (F : PrimeOrderGroupFamily) {Msg : Type} (guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (n : ℕ) (hsound : ∀ d ∈ (setup n).support, ∀ (u : List Bool) (m₀ m₁ : Msg), guard n d ((Turing.MultiTapeTM.encPair F.encDesc Turing.MultiTapeTM.encBits) (d, u)) m₀ m₁ = true → (∃ (x₀ : F.Carrier d), encodeMsg d m₀ = F.encode d x₀) ∧ ∃ (x₁ : F.Carrier d), encodeMsg d m₁ = F.encode d x₁) :
F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary false) n = F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary true) n

When guard admits only group elements on setup, the uniform mask γ • g hides both challenge messages in ddhRandomGame.

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalMsgCPAGameWith_le_ideal (F : PrimeOrderGroupFamily) {Msg : Type} (guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (n : ℕ) (hsound : ∀ d ∈ (setup n).support, ∀ (u : List Bool) (m₀ m₁ : Msg), guard n d ((Turing.MultiTapeTM.encPair F.encDesc Turing.MultiTapeTM.encBits) (d, u)) m₀ m₁ = true → (∃ (x₀ : F.Carrier d), encodeMsg d m₀ = F.encode d x₀) ∧ ∃ (x₁ : F.Carrier d), encodeMsg d m₁ = F.encode d x₁) :
(F.elGamalMsgCPAGameWith guard encodeMsg setup adversary false n).advantage (F.elGamalMsgCPAGameWith guard encodeMsg setup adversary true n) ≤ (F.ddhRealGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary false) n).advantage (F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary false) n) + (F.ddhRealGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary true) n).advantage (F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary true) n)

Quantitative DDH bound for elGamalMsgCPAGameWith.

theorem Cslib.Crypto.PrimeOrderGroupFamily.isPPT_elGamalMsgToDDHDistinguisherWith (F : PrimeOrderGroupFamily) {Msg : Type} {encMsg : Msg ↪ List Bool} {guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool} (hguard : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × F.Desc × List Bool × Msg × Msg) => match x with | (n, d, pk, m₀, m₁) => guard n d pk m₀ m₁) (F.encElGamalMsgGuardInput encMsg) Turing.MultiTapeTM.encBool) {encodeMsg : F.Desc → Msg → List Bool} (hencMsg : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : F.Desc × Msg) => encodeMsg p.1 p.2) (Turing.MultiTapeTM.encPair F.encDesc encMsg) Turing.MultiTapeTM.encBits) {adversary : Encryption.AdversaryOf Msg} (hA : Encryption.AdversaryOf.IsPPT encMsg adversary) (bit : Bool) :
(F.elGamalMsgToDDHDistinguisherWith guard encodeMsg adversary bit).IsPPT

elGamalMsgToDDHDistinguisherWith is uniform strict PPT whenever guard, encodeMsg, and adversary are efficient.

theorem Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalMsgCPAGameWith_ideal {F : PrimeOrderGroupFamily} {setup : ℕ → PMF F.Desc} {Msg : Type} {encMsg : Msg ↪ List Bool} {guard : ℕ → F.Desc → List Bool → Msg → Msg → Bool} {encodeMsg : F.Desc → Msg → List Bool} (hDDH : F.DDH setup) (hguard : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × F.Desc × List Bool × Msg × Msg) => match x with | (n, d, pk, m₀, m₁) => guard n d pk m₀ m₁) (F.encElGamalMsgGuardInput encMsg) Turing.MultiTapeTM.encBool) (hsound : ∀ (n : ℕ), ∀ d ∈ (setup n).support, ∀ (u : List Bool) (m₀ m₁ : Msg), guard n d ((Turing.MultiTapeTM.encPair F.encDesc Turing.MultiTapeTM.encBits) (d, u)) m₀ m₁ = true → (∃ (x₀ : F.Carrier d), encodeMsg d m₀ = F.encode d x₀) ∧ ∃ (x₁ : F.Carrier d), encodeMsg d m₁ = F.encode d x₁) (hencMsg : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : F.Desc × Msg) => encodeMsg p.1 p.2) (Turing.MultiTapeTM.encPair F.encDesc encMsg) Turing.MultiTapeTM.encBits) {adversary : Encryption.AdversaryOf Msg} (hA : Encryption.AdversaryOf.IsPPT encMsg adversary) :
Negligible fun (n : ℕ) => (F.elGamalMsgCPAGameWith guard encodeMsg setup adversary false n).advantage (F.elGamalMsgCPAGameWith guard encodeMsg setup adversary true n)

Ideal-sampling step toward DDH.indcpaOn_elGamalEncryptProb, not the cited result: under DDH for any setup law, when guard is computable in polynomial time and admits only group elements under encodeMsg on the supported groups, every uniform strict PPT adversary has negligible advantage in elGamalMsgCPAGameWith guard encodeMsg, whose key and challenge exponents are drawn exactly uniformly at the PMF level.

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgCPAGameOn (F : PrimeOrderGroupFamily) {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (bit : Bool) (n : ℕ) :

The IND-CPA experiment for multiplicative ElGamal encryption over message type Msg via a word-level message encoder encodeMsg : F.Desc → Msg → List Bool, with challenge-pair admissibility predicate valid ([BS23], Exercise 11.5(a), p. 459, played in Attack Game 11.1, p. 436): draw d ← setup n and a uniform secret key α : ZMod (F.order d), and pass the encoded public key pk = (d, encode (α • g)) to adversary.choose. If valid n pk m₀ m₁ holds, encrypt the selected message m under a fresh uniform exponent β : ZMod (F.order d) via F.add (d, encode ((α * β) • g), encodeMsg d m) and pass the saved state and encoded ciphertext to adversary.guess; otherwise output false, in both experiments, as Encryption.gameOn does.

def Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgToDDHDistinguisher (F : PrimeOrderGroupFamily) {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (adversary : Encryption.AdversaryOf Msg) (bit : Bool) :

The DDH distinguisher constructed from a typed-message ElGamal IND-CPA adversary ([BS23], Exercise 11.5(a), p. 459): given group parameters d and elements u, v, w, pass the encoded public key pk = (d, encode u) to the adversary; if valid n pk m₀ m₁ holds, mask the selected encoded message encodeMsg d m with encode w using F.add, send the ciphertext (encode v, _) and return the adversary's guess, and otherwise return false.

theorem Cslib.Crypto.PrimeOrderGroupFamily.ddhRealGame_elGamalMsgToDDHDistinguisher (F : PrimeOrderGroupFamily) {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (bit : Bool) (n : ℕ) :
F.ddhRealGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary bit) n = F.elGamalMsgCPAGameOn valid encodeMsg setup adversary bit n

In the real DDH game, elGamalMsgToDDHDistinguisher simulates elGamalMsgCPAGameOn exactly.

def Cslib.Crypto.PrimeOrderGroupFamily.AdmitsGroupElementsOn (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) {Msg : Type} (encodeMsg : F.Desc → Msg → List Bool) (valid : ℕ → List Bool → Msg → Msg → Bool) :

The admissibility predicate valid admits only group elements under encodeMsg at groups supported by setup n.

def Cslib.Crypto.PrimeOrderGroupFamily.AdmitsGroupElements (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc → Msg → List Bool) (valid : ℕ → List Bool → Msg → Msg → Bool) :

The admissibility predicate valid admits only group elements under encodeMsg: at every public key (d, u), an admissible pair (m₀, m₁) has both encodeMsg d m₀ and encodeMsg d m₁ in Set.range (F.encode d).

theorem Cslib.Crypto.PrimeOrderGroupFamily.AdmitsGroupElements.on (F : PrimeOrderGroupFamily) {setup : ℕ → PMF F.Desc} {Msg : Type} {encodeMsg : F.Desc → Msg → List Bool} {valid : ℕ → List Bool → Msg → Msg → Bool} (h : F.AdmitsGroupElements encodeMsg valid) :
F.AdmitsGroupElementsOn setup encodeMsg valid
theorem Cslib.Crypto.PrimeOrderGroupFamily.ddhRandomGame_elGamalMsgToDDHDistinguisher_false_eq_true (F : PrimeOrderGroupFamily) {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (n : ℕ) (hsound : F.AdmitsGroupElements encodeMsg valid) :
F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary false) n = F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary true) n

When valid admits only group elements under encodeMsg, the uniform element c • g of the random DDH game perfectly masks both admissible candidate messages, so the experiments for bit = false and bit = true are identical.

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalMsgCPAGameOn_le_ideal (F : PrimeOrderGroupFamily) {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encodeMsg : F.Desc → Msg → List Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.AdversaryOf Msg) (n : ℕ) (hsound : F.AdmitsGroupElements encodeMsg valid) :
(F.elGamalMsgCPAGameOn valid encodeMsg setup adversary false n).advantage (F.elGamalMsgCPAGameOn valid encodeMsg setup adversary true n) ≤ (F.ddhRealGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary false) n).advantage (F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary false) n) + (F.ddhRealGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary true) n).advantage (F.ddhRandomGame setup (F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary true) n)

Ideal-sampling step toward [BS23], Exercise 11.5(a), p. 459, not the cited result: in elGamalMsgCPAGameOn, whose key and challenge exponents are drawn exactly uniformly at the PMF level, when valid admits only group elements under encodeMsg, the IND-CPA distinguishing advantage of adversary is bounded by the sum of the DDH advantages of elGamalMsgToDDHDistinguisher valid encodeMsg adversary false and elGamalMsgToDDHDistinguisher valid encodeMsg adversary true. The cited result for the strict-PPT scheme is DDH.indcpaOn_elGamalEncryptProb.

theorem Cslib.Crypto.PrimeOrderGroupFamily.isPPT_elGamalMsgToDDHDistinguisher (F : PrimeOrderGroupFamily) {Msg : Type} {encMsg : Msg ↪ List Bool} {valid : ℕ → List Bool → Msg → Msg → Bool} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (Encryption.encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) {encodeMsg : F.Desc → Msg → List Bool} (hencMsg : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : F.Desc × Msg) => encodeMsg p.1 p.2) (Turing.MultiTapeTM.encPair F.encDesc encMsg) Turing.MultiTapeTM.encBits) {adversary : Encryption.AdversaryOf Msg} (hA : Encryption.AdversaryOf.IsPPT encMsg adversary) (bit : Bool) :
(F.elGamalMsgToDDHDistinguisher valid encodeMsg adversary bit).IsPPT

elGamalMsgToDDHDistinguisher is uniform strict PPT whenever valid and encodeMsg are computable in polynomial time and adversary is uniform strict PPT.

theorem Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalMsgCPAGameOn_ideal {F : PrimeOrderGroupFamily} {setup : ℕ → PMF F.Desc} {Msg : Type} {encMsg : Msg ↪ List Bool} {valid : ℕ → List Bool → Msg → Msg → Bool} {encodeMsg : F.Desc → Msg → List Bool} (hDDH : F.DDH setup) (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (Encryption.encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hsound : F.AdmitsGroupElementsOn setup encodeMsg valid) (hencMsg : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : F.Desc × Msg) => encodeMsg p.1 p.2) (Turing.MultiTapeTM.encPair F.encDesc encMsg) Turing.MultiTapeTM.encBits) {adversary : Encryption.AdversaryOf Msg} (hA : Encryption.AdversaryOf.IsPPT encMsg adversary) :
Negligible fun (n : ℕ) => (F.elGamalMsgCPAGameOn valid encodeMsg setup adversary false n).advantage (F.elGamalMsgCPAGameOn valid encodeMsg setup adversary true n)

Ideal-sampling step toward DDH.indcpaOn_elGamalEncryptProb, not the cited result: under DDH, when valid admits only group elements under encodeMsg on groups supported by setup, every uniform strict PPT adversary has negligible advantage in elGamalMsgCPAGameOn valid encodeMsg, whose key and challenge exponents are drawn exactly uniformly at the PMF level (after [BS23], Exercise 11.5(a), p. 459). The setup law is arbitrary.

Bit encryption and IND-CPA security under DDH #

Embed a message bit b : Bool into F.Carrier d as 0 (for false) or g (for true).

Distinct message bits map to distinct group elements.

Encode a message bit b : Bool as an encoded element of F.Carrier d using F.smul.

Every pair of bit messages encodes group elements, so the always-true predicate admits only group elements under encodeBit.

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.elGamalCPAGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (adversary : Encryption.Adversary) (bit : Bool) (n : ℕ) :

The IND-CPA experiment for ElGamal bit encryption ([BS23], Exercise 11.5, p. 459): draw d from setup n and a uniform secret key α : ZMod (F.order d), pass the encoded public key (d, encode (α • g)) to adversary.choose, encrypt the selected challenge bit under a fresh uniform exponent β : ZMod (F.order d), and pass the saved state and encoded ciphertext to adversary.guess.

theorem Cslib.Crypto.PrimeOrderGroupFamily.elGamalCPAGame_eq_elGamalMsgCPAGameOn (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (adversary : Encryption.Adversary) (bit : Bool) (n : ℕ) :
F.elGamalCPAGame setup adversary bit n = F.elGamalMsgCPAGameOn (fun (x : ℕ) (x_1 : List Bool) (x_2 x_3 : Bool) => true) F.encodeBit setup adversary bit n

elGamalCPAGame is the unrestricted encodeBit specialization of elGamalMsgCPAGameOn.

IND-CPA security of ElGamal bit encryption with ideal exponent sampling over F for a setup law setup: every uniform strict PPT Encryption.Adversary has negligible distinguishing advantage between challenge bit false and challenge bit true in elGamalCPAGame, which draws the key and challenge exponents exactly uniformly at the PMF level. For a group family d, the strict-PPT scheme's notion is Encryption.INDCPA (F.elGamalKeyGenProb d) (F.elGamalEncryptProb F.encodeBit d).

@[reducible, inline]

The DDH distinguisher constructed from an IND-CPA adversary ([BS23], proof of Exercise 11.5(a), p. 459): given group parameters d and elements u, v, w, pass the encoded public key (d, encode u) to the adversary, mask the encoded challenge bit with encode w using F.add, send the ciphertext (encode v, _) and return the adversary's guess. It is the unrestricted encodeBit instance of elGamalMsgToDDHDistinguisher.

@[simp]
theorem Cslib.Crypto.PrimeOrderGroupFamily.ddhRealGame_elGamalToDDHDistinguisher (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (adversary : Encryption.Adversary) (bit : Bool) (n : ℕ) :
F.ddhRealGame setup (F.elGamalToDDHDistinguisher adversary bit) n = F.elGamalCPAGame setup adversary bit n

In the real DDH game, elGamalToDDHDistinguisher simulates elGamalCPAGame exactly.

In the random DDH game, the uniform element c • g perfectly masks the challenge bit, so the experiments for bit = false and bit = true are identical.

Ideal-sampling step toward [BS23], Exercise 11.5(a), p. 459, not the cited result: in the bit game elGamalCPAGame, whose key and challenge exponents are drawn exactly uniformly at the PMF level, the IND-CPA distinguishing advantage of adversary is bounded by the sum of the DDH advantages of elGamalToDDHDistinguisher adversary false and elGamalToDDHDistinguisher adversary true. The cited result for the strict-PPT bit scheme is DDH.indcpa_elGamalBitEncryptProb.

elGamalToDDHDistinguisher is uniform strict PPT whenever adversary is.

Ideal-sampling step toward DDH.indcpa_elGamalBitEncryptProb, not the cited result: under DDH for any setup law, bit ElGamal satisfies the ideal-sampling notion elGamalIdealINDCPA (after [BS23], Exercise 11.5(a), p. 459).

Group-element ElGamal IND-CPA security under DDH #

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.PrimeOrderGroupFamily.elGamalGroupCPAGameOn (F : PrimeOrderGroupFamily) (valid : ℕ → List Bool → List Bool → List Bool → Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.WordAdversary) (bit : Bool) (n : ℕ) :

The IND-CPA experiment for group-element ElGamal encryption with challenge-pair admissibility predicate valid ([BS23], Exercise 11.5(a), p. 459): specialization of elGamalMsgCPAGameOn to word messages (Encryption.WordAdversary) with identity message encoding. The message space of Exercise 11.5 is the group, so valid is meant to admit only encoded group elements (AdmitsGroupElements (fun _ m => m) valid).

@[reducible, inline]

The DDH distinguisher constructed from a group-element ElGamal IND-CPA adversary ([BS23], Exercise 11.5(a), p. 459): specialization of elGamalMsgToDDHDistinguisher to identity message encoding.

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalGroupCPAGameOn_le_ideal (F : PrimeOrderGroupFamily) (valid : ℕ → List Bool → List Bool → List Bool → Bool) (setup : ℕ → PMF F.Desc) (adversary : Encryption.WordAdversary) (n : ℕ) (hsound : F.AdmitsGroupElements (fun (x : F.Desc) (m : List Bool) => m) valid) :
(F.elGamalGroupCPAGameOn valid setup adversary false n).advantage (F.elGamalGroupCPAGameOn valid setup adversary true n) ≤ (F.ddhRealGame setup (F.elGamalGroupToDDHDistinguisher valid adversary false) n).advantage (F.ddhRandomGame setup (F.elGamalGroupToDDHDistinguisher valid adversary false) n) + (F.ddhRealGame setup (F.elGamalGroupToDDHDistinguisher valid adversary true) n).advantage (F.ddhRandomGame setup (F.elGamalGroupToDDHDistinguisher valid adversary true) n)

Ideal-sampling step toward [BS23], Exercise 11.5(a), p. 459, not the cited result: in elGamalGroupCPAGameOn valid, whose key and challenge exponents are drawn exactly uniformly at the PMF level, when valid admits only encoded group elements, the IND-CPA distinguishing advantage of adversary is bounded by the sum of the DDH advantages of elGamalGroupToDDHDistinguisher valid adversary false and elGamalGroupToDDHDistinguisher valid adversary true. The cited result for the strict-PPT scheme is DDH.indcpaOn_elGamalEncryptProb at the identity message encoding.

Ideal-sampling step toward DDH.indcpaOn_elGamalEncryptProb (at the identity message encoding), not the cited result: under DDH for any setup law, for a polynomial-time admissibility predicate valid that admits only encoded group elements, every uniform strict PPT Encryption.WordAdversary has negligible advantage in elGamalGroupCPAGameOn valid, whose exponents are drawn exactly uniformly at the PMF level (after [BS23], Exercise 11.5(a), p. 459).

Hashed ElGamal encryption and IND-CPA security ([BS23], Section 11.5) #

Algebraic Hashed ElGamal encryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1): given key-derivation hash function H : F.Desc × List Bool → List Bool, public key u : F.Carrier d, message word m : List Bool, and randomness β : ZMod (F.order d), derive pad = H (d, encode (β • u)) and output (β • g, Cslib.BitString.listXor pad.length [pad, m]).

Under a genuine public key u = α • g, Hashed ElGamal masks m with pad = H (d, encode ((α * β) • g)) via Cslib.BitString.listXor pad.length [pad, m].

Algebraic Hashed ElGamal decryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1): given secret key α : ZMod (F.order d) and ciphertext (v, c), derive pad = H (d, encode (α • v)) and recover Cslib.BitString.listXor pad.length [pad, c].

@[simp]

Hashed ElGamal decryption correctness: when the message word m has the same length as the derived pad H (d, encode ((α * β) • g)), decrypting an encryption under u = α • g with secret key α recovers m.

Word-level Hashed ElGamal encryption: given (d, encode u, m, b), derive pad = H (d, encode (b • u)) and compute (encode (b • g), Cslib.BitString.listXor pad.length [pad, m]).

Word-level Hashed ElGamal decryption: given (d, a, encode v, c), derive pad = H (d, encode (a • v)) and compute Cslib.BitString.listXor pad.length [pad, c].

theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeHashedElGamal_hashedElGamalEncrypt (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (a : ℕ) (β : ZMod (F.order d)) {m : List Bool} (hlen : m.length = (H (d, F.encode d ((↑a * β) • F.generator d))).length) :
F.decodeHashedElGamal H (d, a, F.encode d (F.hashedElGamalEncrypt H d (↑a • F.generator d) m β).1, (F.hashedElGamalEncrypt H d (↑a • F.generator d) m β).2) = m

Word-level Hashed ElGamal decryption of an honest encryption recovers m whenever m has the same length as the derived pad.

The IND-CPA experiment for Hashed ElGamal encryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1, and Section 11.5.2, Theorem 11.5, pp. 449–451): draw d ← setup n and a uniform secret key α : ZMod (F.order d), pass the encoded public key (d, encode (α • g)) to adversary.choose, encrypt the selected message word m under a fresh uniform exponent β : ZMod (F.order d) by masking with pad = H (d, encode ((α * β) • g)) via Cslib.BitString.listXor pad.length [pad, m], and pass the saved state and encoded ciphertext to adversary.guess.

@[reducible, inline]

A key-derivation distinguisher over the family ([BS23], Section 11.5.2, Attack Game 11.3, p. 448): given the security parameter, public group parameters d, two elements of F.Carrier d and a candidate key word, it outputs a bit. SecureKDF states its efficiency on encodings.

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.kdfRealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (distinguisher : F.KDFDistinguisher) (n : ℕ) :

The real key-derivation security experiment ([BS23], Section 11.5.2, Attack Game 11.3, Experiment 0, p. 448): draw d ← setup n and independent uniform a, b, c : ZMod (F.order d), and give the distinguisher a • g, b • g and the derived key H (d, encode (c • g)).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.kdfIdealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (msgLen : ℕ → ℕ) (distinguisher : F.KDFDistinguisher) (n : ℕ) :

The ideal key-derivation security experiment ([BS23], Section 11.5.2, Attack Game 11.3, Experiment 1, p. 448): draw d ← setup n, independent uniform a, b : ZMod (F.order d) and an independent uniform msgLen n-bit key key ← Cslib.BitString.uniformList (msgLen n), and give the distinguisher a • g, b • g and key.

The input of a key-derivation distinguisher: a CDH input and a candidate key word, which is H (d, encode (c • g)) in the real experiment and uniform in the ideal one.

theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_mk_polyTime (F : PrimeOrderGroupFamily) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ℕ} {x1 : γ → F.Desc} {x2 x3 : (c : γ) → F.Carrier (x1 c)} {x4 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn Turing.MultiTapeTM.encUnary) (h1 : Turing.MultiTapeTM.ComputableInPolyTime x1 encIn F.encDesc) (h2 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => F.encode (x1 c) (x2 c)) encIn Turing.MultiTapeTM.encBits) (h3 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => F.encode (x1 c) (x3 c)) encIn Turing.MultiTapeTM.encBits) (h4 : Turing.MultiTapeTM.ComputableInPolyTime x4 encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { secParam := x0 x, groupParameters := x1 x, leftPublic := x2 x, rightPublic := x3 x, key := x4 x }) encIn F.encKDFInput

The encoding of a key-derivation input: the fields of its CDH input followed by the key word, each framed except the last. This is the layout of encDDHInput with the key word in place of the encoded candidate shared element.

theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_mk_budget (F : PrimeOrderGroupFamily) {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → F.Desc} {x2 x3 : (c : γ) → F.Carrier (x1 c)} {x4 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn F.encDesc budget) (h2 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => F.encode (x1 c) (x2 c)) encIn Turing.MultiTapeTM.encBits budget) (h3 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => F.encode (x1 c) (x3 c)) encIn Turing.MultiTapeTM.encBits budget) (h4 : Turing.MultiTapeTM.ComputableInSpace x4 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { secParam := x0 x, groupParameters := x1 x, leftPublic := x2 x, rightPublic := x3 x, key := x4 x }) encIn F.encKDFInput budget
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_toCDHInput_budget (F : PrimeOrderGroupFamily) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → F.KDFInput} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ F.encKDFInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).toCDHInput) encIn✝ F.encCDHInput S✝
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_key_budget (F : PrimeOrderGroupFamily) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → F.KDFInput} :
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_rightPublic_budget (F : PrimeOrderGroupFamily) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → F.KDFInput} :
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_leftPublic_budget (F : PrimeOrderGroupFamily) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → F.KDFInput} :
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_groupParameters_budget (F : PrimeOrderGroupFamily) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → F.KDFInput} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ F.encKDFInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).groupParameters) encIn✝ F.encDesc S✝
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_secParam_budget (F : PrimeOrderGroupFamily) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → F.KDFInput} :
theorem Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput_mk_inO (F : PrimeOrderGroupFamily) {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → F.Desc} {T1 S1 : γ → ℕ} {x2 : (c : γ) → F.Carrier (x1 c)} {T2 S2 : γ → ℕ} {x3 : (c : γ) → F.Carrier (x1 c)} {T3 S3 : γ → ℕ} {x4 : γ → List Bool} {T4 S4 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn F.encDesc T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => F.encode (x1 c) (x2 c)) encIn Turing.MultiTapeTM.encBits T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => F.encode (x1 c) (x3 c)) encIn Turing.MultiTapeTM.encBits T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO x4 encIn Turing.MultiTapeTM.encBits T4 S4) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { secParam := x0 x, groupParameters := x1 x, leftPublic := x2 x, rightPublic := x3 x, key := x4 x }) encIn F.encKDFInput (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + T4 x)))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + S4 x)))

A key-derivation distinguisher is uniform strict PPT: one machine reading the encKDFInput encoding of its security parameter, group parameters, two group elements and key word realizes it.

theorem Cslib.Crypto.PrimeOrderGroupFamily.KDFDistinguisher.IsPPT.comp {F : PrimeOrderGroupFamily} {distinguisher : F.KDFDistinguisher} (hD : distinguisher.IsPPT) {α : Type} {enc : α ↪ List Bool} {n : α → ℕ} {d : α → F.Desc} {u v : (a : α) → F.Carrier (d a)} {key : α → List Bool} (hn : Turing.MultiTapeTM.ComputableInPolyTime n enc Turing.MultiTapeTM.encUnary) (hd : Turing.MultiTapeTM.ComputableInPolyTime d enc F.encDesc) (hu : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => F.encode (d a) (u a)) enc Turing.MultiTapeTM.encBits) (hv : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => F.encode (d a) (v a)) enc Turing.MultiTapeTM.encBits) (hkey : Turing.MultiTapeTM.ComputableInPolyTime key enc Turing.MultiTapeTM.encBits) :
Probability.IsPPTOn enc Turing.MultiTapeTM.encBool fun (a : α) => distinguisher (n a) (d a) (u a) (v a) (key a)

A PPT key-derivation distinguisher run on computed inputs is uniform strict PPT.

Secure key derivation for H over F ([BS23], Section 11.5.2, Attack Game 11.3, p. 448, and Definition 11.5, p. 449): every uniform strict PPT key-derivation distinguisher (KDFDistinguisher.IsPPT) has negligible advantage between kdfRealGame and kdfIdealGame. No nondegenerate SecureKDF instance (msgLen n > 0, e.g., via the leftover hash lemma) is constructed in this module.

SecureKDF is the word-level key-derivation assumption. Quantifying over distinguishers that read (1ⁿ, d, encode u, encode v, key) as words, each with one uniform strict PPT machine on its flat layout, gives the same assumption as quantifying over typed distinguishers, as for DDH (ddh_iff_encoded).

Run a key-derivation distinguisher as a DDH distinguisher: derive the candidate key H (d, encode w) from the candidate shared element w.

@[simp]
theorem Cslib.Crypto.PrimeOrderGroupFamily.ddhRandomGame_kdfToDDHDistinguisher (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (distinguisher : F.KDFDistinguisher) (n : ℕ) :
F.ddhRandomGame setup (F.kdfToDDHDistinguisher H distinguisher) n = F.kdfRealGame setup H distinguisher n

In the random DDH game, kdfToDDHDistinguisher H runs the real key-derivation game.

kdfToDDHDistinguisher H is uniform strict PPT whenever H is polynomial time and the key-derivation distinguisher is uniform strict PPT.

The KDF distinguisher constructed from a Hashed ElGamal IND-CPA adversary ([BS23], Section 11.5.2, proof of Theorem 11.5, pp. 449–451): given (d, u, v, pad), pass (d, encode u) as the public key, mask the selected message word with pad via Cslib.BitString.listXor pad.length [pad, m], send the ciphertext (encode v, _) and return the adversary's guess.

@[reducible, inline]

The DDH distinguisher constructed from a Hashed ElGamal IND-CPA adversary ([BS23], Section 11.5.2, proof of Theorem 11.5, pp. 449–451): hashedElGamalToKDFDistinguisher run with the pad H (d, encode w) derived from the candidate shared element w.

@[simp]

In the real DDH game, hashedElGamalToDDHDistinguisher simulates hashedElGamalCPAGame exactly.

In kdfIdealGame, the uniform msgLen n-bit pad masks any challenge message word perfectly via Cslib.BitString.listXor pad.length [pad, m], so hashedElGamalToKDFDistinguisher accepts with the same law for bit = false and bit = true.

Ideal-sampling step toward [BS23], Section 11.5.2, Theorem 11.5, pp. 449–451, not the cited result: in the one-time-pad Hashed ElGamal game hashedElGamalCPAGame, whose key and challenge exponents are drawn exactly uniformly at the PMF level, the IND-CPA distinguishing advantage of adversary is bounded by the sum of the two DDH advantages of hashedElGamalToDDHDistinguisher and the two KDF advantages of hashedElGamalToKDFDistinguisher. The hybrids of the proof are the random DDH game, which is the real KDF game (ddhRandomGame_kdfToDDHDistinguisher), and the ideal KDF game, where the uniform pad hides the challenge bit. The cited result, for the strict-PPT scheme with a one-time semantically secure cipher, is DDH.indcpaOf_hybrid_hashedElGamal (also DDH.indcpaOn_hybrid_hashedElGamal and DDH.wordINDCPA_hybrid_hashedElGamal), which rests on the strict-PPT KEM bound advantage_kemGame_hashedElGamalEncapsProb_le.

Ideal-sampling step, not the cited result: under DDH and SecureKDF for any setup law, when H is computable in polynomial time, every uniform strict PPT Encryption.WordAdversary has negligible advantage in the one-time-pad Hashed ElGamal game hashedElGamalCPAGame, whose exponents are drawn exactly uniformly at the PMF level (after [BS23], Section 11.5.2, Theorem 11.5, pp. 449–451). The strict-PPT scheme's theorems are DDH.kemINDCPA_hashedElGamalEncapsProb and DDH.wordINDCPA_hybrid_hashedElGamal; DDH.negligible_hashedElGamalCPAGame_ideal_linearHashKDF discharges SecureKDF for a seeded linear hash.