Documentation

CslibFrontier.Crypto.Computational.ElGamal.Homomorphism

Homomorphism of Multiplicative ElGamal and Equivalence of Semantic Security with DDH #

Multiplicative ElGamal ([BS23], Exercise 11.5, printed p. 459) encrypts a group element m : F.Carrier d under public key u = α • g as (v, e) = (β • g, β • u + m) (written additively on F.Carrier d, matching CslibFrontier/Crypto/Computational/ElGamal.lean) and decrypts (v, e) to e - α • v. This module formalizes parts (b) and (c) of Exercise 11.5:

  1. Homomorphic ciphertext combination ([BS23], Exercise 11.5(c), p. 459): Adding two algebraic ciphertexts on F.Carrier d × F.Carrier d adds both their plaintexts and their randomness exponents (elGamalEncrypt_add), and decryption is a homomorphism (elGamalDecrypt_add). On encoded ciphertexts, elGamalAddCiphertext applies F.add to the two framed components in polynomial time (computableInPolyTime_elGamalAddCiphertext). Because every canonical residue below F.order (d n) lies in the support of F.sampleExp n (d n), combining any two ciphertexts in the support of elGamalEncryptProb under an honest public key produces a ciphertext in the support of elGamalEncryptProb for m₁ + m₂ (elGamalAddCiphertext_mem_support_elGamalEncryptProb) that decrypts to encode (m₁ + m₂) (elGamalDecryptDet_elGamalAddCiphertext).

  2. Semantic security implies DDH ([BS23], Exercise 11.5(b), p. 459): Given a word-level DDH distinguisher W and group schedule d : ℕ → F.Desc, the two-stage adversary ddhWordToElGamalAdversary d W samples c ← F.sampleExp n (d n), submits the challenge pair (encode 0, encode (c • g)) with saved state pk, and runs W on (d n, u, v, e). In world false, the unused draw c drops out and (u, v, e) = (α • g, β • g, (α * β) • g) reproduces ddhRealGame (ddhRealGame_eq_elGamalGroupCPAGameOn_false). In world true, e = (α * β) • g + c • g is within statistical distance 1 / 2 ^ n of a uniform group element (ddhRandomGame, advantage_elGamalGroupCPAGameOn_true_ddhRandomGame_le), and within 5 / 2 ^ n in the native Encryption.gameOn experiment (advantage_ddhGame_le_gameOn, adding 2 / 2 ^ n in each world for elGamalKeyGenProb and elGamalEncryptProb). Through ddh_iff_encoded, semantic security therefore implies F.DDH (ddh_of_indcpaOn_elGamalGroupEncryptProb), yielding the two-sided characterization indcpaOn_elGamalGroupEncryptProb_iff_ddh over a DecodablePrimeOrderGroupFamily. Here each public group F.Carrier (d n) carries a constant effective-length function (§2.3.2, Definition 2.9 and Example 2.13(4), pp. 30–31; Attack Game 11.1 and Definition 11.3(2), pp. 436–438), so elGamalGroupValid admits every encoded group-element pair—including (encode 0, encode (c • g)) when serialized wire lengths differ—rather than requiring equal serialized bit lengths. The equivalence is asymptotic; the exact forward 2ε bound of Exercise 11.5(a) remains open. Callers obtain ¬ DDH → ¬ INDCPAOn via mt (mt (F.indcpaOn_elGamalGroupEncryptProb_iff_ddh hd).mp).

Main definitions #

Main results #

References #

Multiplicative homomorphism ([BS23], Exercise 11.5(c)) #

theorem Cslib.Crypto.PrimeOrderGroupFamily.elGamalEncrypt_add (F : PrimeOrderGroupFamily) (d : F.Desc) (u m₁ m₂ : F.Carrier d) (β₁ β₂ : ZMod (F.order d)) :
F.elGamalEncrypt d u m₁ β₁ + F.elGamalEncrypt d u m₂ β₂ = F.elGamalEncrypt d u (m₁ + m₂) (β₁ + β₂)

Algebraic homomorphism of multiplicative ElGamal encryption ([BS23], Exercise 11.5(c), p. 459, written additively): componentwise addition of two ciphertexts under the same public key u yields the encryption of m₁ + m₂ with randomness β₁ + β₂.

theorem Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecrypt_add (F : PrimeOrderGroupFamily) (d : F.Desc) (α : ZMod (F.order d)) (ct₁ ct₂ : F.Carrier d × F.Carrier d) :
F.elGamalDecrypt d α (ct₁ + ct₂) = F.elGamalDecrypt d α ct₁ + F.elGamalDecrypt d α ct₂

Algebraic homomorphism of multiplicative ElGamal decryption ([BS23], Exercise 11.5(c), p. 459, written additively): decrypting the sum of two ciphertexts equals the sum of their decryptions.

Word-level homomorphic ciphertext combination for multiplicative ElGamal ([BS23], Exercise 11.5(c), p. 459): add both framed group-element components of ct₁ and ct₂ using F.add.

Word-level encryption homomorphism ([BS23], Exercise 11.5(c), p. 459): combining two encodeElGamalEncrypt ciphertexts under encode u with exponents b₁, b₂ : ℕ yields the encodeElGamalEncrypt ciphertext for m₁ + m₂ with exponent b₁ + b₂.

theorem Cslib.Crypto.PrimeOrderGroupFamily.elGamalAddCiphertext_mem_support_elGamalEncryptProb (F : PrimeOrderGroupFamily) (d : ℕ → F.Desc) (n : ℕ) {keys : List Bool × List Bool} (hkeys : keys ∈ (F.elGamalKeyGenProb d n).eval.support) {m₁ m₂ : F.Carrier (d n)} {ct₁ ct₂ : List Bool} (hct₁ : ct₁ ∈ (F.elGamalEncryptProb (fun (x : F.Desc) (x_1 : List Bool) => x_1) d n keys.1 (F.encode (d n) m₁)).eval.support) (hct₂ : ct₂ ∈ (F.elGamalEncryptProb (fun (x : F.Desc) (x_1 : List Bool) => x_1) d n keys.1 (F.encode (d n) m₂)).eval.support) :
F.elGamalAddCiphertext (d n) ct₁ ct₂ ∈ (F.elGamalEncryptProb (fun (x : F.Desc) (x_1 : List Bool) => x_1) d n keys.1 (F.encode (d n) (m₁ + m₂))).eval.support

Homomorphic support closure on elGamalEncryptProb ([BS23], Exercise 11.5(c), p. 459): for any honest key pair (pk, sk) in the support of elGamalKeyGenProb d n and any ciphertexts ct₁, ct₂ in the supports of elGamalEncryptProb for encode m₁ and encode m₂, elGamalAddCiphertext (d n) ct₁ ct₂ lies in the support of elGamalEncryptProb for encode (m₁ + m₂).

theorem Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecryptDet_elGamalAddCiphertext (F : PrimeOrderGroupFamily) (d : ℕ → F.Desc) (n : ℕ) {keys : List Bool × List Bool} (hkeys : keys ∈ (F.elGamalKeyGenProb d n).eval.support) {m₁ m₂ : F.Carrier (d n)} {ct₁ ct₂ : List Bool} (hct₁ : ct₁ ∈ (F.elGamalEncryptProb (fun (x : F.Desc) (x_1 : List Bool) => x_1) d n keys.1 (F.encode (d n) m₁)).eval.support) (hct₂ : ct₂ ∈ (F.elGamalEncryptProb (fun (x : F.Desc) (x_1 : List Bool) => x_1) d n keys.1 (F.encode (d n) m₂)).eval.support) :
F.elGamalDecryptDet d n keys.2 (F.elGamalAddCiphertext (d n) ct₁ ct₂) = F.encode (d n) (m₁ + m₂)

Decryption of homomorphically combined elGamalEncryptProb ciphertexts ([BS23], Exercise 11.5(c), p. 459): for any honest key pair (pk, sk) and honest encryptions ct₁, ct₂ of encode m₁, encode m₂, decrypting elGamalAddCiphertext (d n) ct₁ ct₂ recovers encode (m₁ + m₂).

Semantic security implies DDH ([BS23], Exercise 11.5(b)) #

Chosen-plaintext adversary reducing word-level DDH to group-element multiplicative ElGamal ([BS23], Exercise 11.5(b), p. 459): for group schedule d : ℕ → F.Desc and word-level DDH distinguisher W, choose samples c ← F.sampleExp n (d n) and submits (encode 0, encode (c • g)) with saved state pk, and guess runs W on (d n, u, v, e) where u = dropFrame pk, v = unframe ct, and e = dropFrame ct.

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_ddhGame_le_gameOn (F : PrimeOrderGroupFamily) (valid : ℕ → List Bool → List Bool → List Bool → Bool) (d : ℕ → F.Desc) (W : ℕ → F.Desc × List Bool × List Bool × List Bool → ProbComp Bool) (n : ℕ) (hvalid : ∀ (u m₀ m₁ : F.Carrier (d n)), valid n ((Turing.MultiTapeTM.encPair F.encDesc Turing.MultiTapeTM.encBits) (d n, F.encode (d n) u)) (F.encode (d n) m₀) (F.encode (d n) m₁) = true) :
(F.ddhRealGame (fun (m : ℕ) => PMF.pure (d m)) (fun (m : ℕ) (d' : F.Desc) (u v w : F.Carrier d') => W m (d', F.encode d' u, F.encode d' v, F.encode d' w)) n).advantage (F.ddhRandomGame (fun (m : ℕ) => PMF.pure (d m)) (fun (m : ℕ) (d' : F.Desc) (u v w : F.Carrier d') => W m (d', F.encode d' u, F.encode d' v, F.encode d' w)) n) ≤ Game.advantage (Encryption.gameOn valid (F.elGamalKeyGenProb d) (F.elGamalEncryptProb (fun (x : F.Desc) (m : List Bool) => m) d) (F.ddhWordToElGamalAdversary d W) false n).eval (Encryption.gameOn valid (F.elGamalKeyGenProb d) (F.elGamalEncryptProb (fun (x : F.Desc) (m : List Bool) => m) d) (F.ddhWordToElGamalAdversary d W) true n).eval + 5 / 2 ^ n

Quantitative reduction from word-level DDH to native Encryption.gameOn (after [BS23], Exercise 11.5(b), p. 459; this step bounds DDH advantage with 5 / 2 ^ n fair-coin sampling slack rather than stating the asymptotic contrapositive): on a parameterized group family d : ℕ → F.Desc, DDH advantage is at most the native CPA advantage of ddhWordToElGamalAdversary d W plus 5 / 2 ^ n.

theorem Cslib.Crypto.PrimeOrderGroupFamily.ddh_of_indcpaOn_elGamalGroupEncryptProb (F : PrimeOrderGroupFamily) {d : ℕ → F.Desc} {valid : ℕ → List Bool → List Bool → List Bool → Bool} (hd : Turing.MultiTapeTM.ComputableInPolyTime d Turing.MultiTapeTM.encUnary F.encDesc) (hvalid : ∀ (n : ℕ) (u m₀ m₁ : F.Carrier (d n)), valid n ((Turing.MultiTapeTM.encPair F.encDesc Turing.MultiTapeTM.encBits) (d n, F.encode (d n) u)) (F.encode (d n) m₀) (F.encode (d n) m₁) = true) (hcpa : Encryption.INDCPAOn valid Turing.MultiTapeTM.encBits (F.elGamalKeyGenProb d) (F.elGamalEncryptProb (fun (x : F.Desc) (m : List Bool) => m) d)) :
F.DDH fun (n : ℕ) => PMF.pure (d n)

Native INDCPAOn security of group-element multiplicative ElGamal implies DDH ([BS23], Exercise 11.5(b), p. 459): for a polynomial-time group description family d : ℕ → F.Desc and any admissibility predicate valid admitting all pairs of encoded group elements at d n, INDCPAOn valid encBits (F.elGamalKeyGenProb d) (F.elGamalEncryptProb (fun _ m => m) d) implies F.DDH (fun n => PMF.pure (d n)) (without needing a decoder for F.encDesc or DecodablePrimeOrderGroupFamily). Admitting every encoded group-element pair—so the reduction's (encode 0, encode (c • g)) is valid even when serialized wire lengths differ—models Attack Game 11.1 and Definition 11.3(2) (pp. 436–438) under a constant effective-length function on each public group F.Carrier (d n) (§2.3.2, Definition 2.9 and Example 2.13(4), pp. 30–31), as opposed to equality of serialized bit lengths. Callers obtain ¬ DDH → ¬ INDCPAOn via mt.

Native Encryption.INDCPAOn security of group-element multiplicative ElGamal is equivalent to DDH ([BS23], Exercise 11.5(a)–(b), p. 459): for any DecodablePrimeOrderGroupFamily and polynomial-time group description family d : ℕ → F.Desc, (F.elGamalKeyGenProb d, F.elGamalEncryptProb (fun _ m => m) d) satisfies INDCPAOn (F.elGamalGroupValid d) encBits if and only if F.toPrimeOrderGroupFamily.DDH (fun n => PMF.pure (d n)) holds. Here elGamalGroupValid accepts every pair of encoded elements of F.Carrier (d n), modeling Attack Game 11.1 and Definition 11.3(2) (pp. 436–438) under a constant effective-length function on each public group (§2.3.2, Definition 2.9 and Example 2.13(4), pp. 30–31)—so (encode 0, encode (c • g)) is admissible in the reverse reduction even when serialized wire lengths differ—rather than requiring equal serialized bit lengths. This equivalence is asymptotic; the exact concrete forward bound 2ε of Exercise 11.5(a) remains open. When DDH fails in d, multiplicative ElGamal is not semantically secure (mt (F.indcpaOn_elGamalGroupEncryptProb_iff_ddh hd).mp).