Strict-PPT ElGamal Key Generation, KEM Encapsulation, and Encryption.INDCPAOn Bridges #
This module defines uniform strict-PPT (IsPPTOn) key generation, encapsulation, decapsulation,
and encryption for multiplicative ElGamal and Hashed ElGamal ([BS23], Section 11.5,
pp. 445–446, Remark 11.1, Section 11.5.2, Theorem 11.5, pp. 449–451, Exercise 11.5(a), p. 459, and
Exercise 11.9, pp. 460–461) using ProbComp.sampleModNat, and connects the PMF-level ElGamal games
in CslibFrontier/Crypto/Computational/ElGamal.lean directly to Encryption.KEMINDCPA,
Encryption.INDCPAOf, Encryption.INDCPAOn, and Encryption.INDCPA.
- Paraphrase of [BS23], Section 11.5 (p. 445) and Remark 11.1 (p. 446): key
generation samples $\alpha \leftarrow \mathbb{Z}_q$ and outputs $(pk = \alpha \cdot g, sk = \alpha)$; in the $\mathcal{E}'_{\mathrm{EG}}$ variant of Remark 11.1, encapsulation/encryption
samples $\beta \leftarrow \mathbb{Z}_q$, sets $v = \beta \cdot g$ and $w = \beta \cdot u$,
derives the symmetric key $k = H(w)$, and encrypts $m$ under $k$; decapsulation/decryption
computes $w = \alpha \cdot v$, recovers $k = H(w)$, and decrypts $c$ under $k$. Theorem 11.5
(pp. 449–451) is stated for $\mathcal{E}_{\mathrm{EG}}$, which derives $k = H(v, w)$; Remark 11.1
states that the security results of the chapter hold for $\mathcal{E}'_{\mathrm{EG}}$ as well, so
the theorems here are Theorem 11.5 for $\mathcal{E}'_{\mathrm{EG}}$. The group description is a
deterministic schedule
d : ℕ → F.Descof the security parameter: the system parameterization $P(\lambda)$ of Section 10.5.2 (p. 413) taken deterministic. - Paraphrase of [BS23], Exercise 11.5(a) (p. 459) and Exercise 11.9 (pp. 460–461):
multiplicative ElGamal encrypts a group element $m \in G$ as $(\beta \cdot g, \beta \cdot u + m)$
and is IND-CPA secure under DDH; composing a semantically secure KEM with a one-time
semantically secure symmetric cipher yields a semantically secure public-key encryption scheme.
That the Hashed ElGamal KEM is semantically secure under DDH and
SecureKDFis Games 0–2 of the proof of Theorem 11.5. The KDF output key space is uniformkeyLen n-bit words;nremains the security parameter controlling the modular-sampling error4 / 2 ^ n.
Main definitions #
Cslib.Crypto.PrimeOrderGroupFamily.elGamalKeyGenProb: uniform strict-PPT ElGamal key generation.Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalEncapsProb,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalDecaps: uniform strict-PPT Hashed ElGamal KEM encapsulation and deterministic polynomial-time decapsulation.Cslib.Crypto.PrimeOrderGroupFamily.kemToKDFDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.kemToDDHDistinguisher: typed KDF and DDH reductions from a KEM distinguisher; the DDH reduction derives the key from the candidate shared element and runs the KDF reduction (kdfToDDHDistinguisher).Cslib.Crypto.PrimeOrderGroupFamily.elGamalEncryptProb,Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecryptDet,Cslib.Crypto.PrimeOrderGroupFamily.elGamalProbExplicitCoinPKE: uniform strict-PPT multiplicative ElGamal encryption, deterministic polynomial-time decryption, and the typed fair-coinExplicitCoinPKEthey realize on encoded group elements.
Main results #
Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalDecaps_hashedElGamalEncapsProb,Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecryptDet_elGamalEncryptProb: support-level decapsulation and decryption correctness.Cslib.Crypto.PrimeOrderGroupFamily.advantage_kemGame_hashedElGamalEncapsProb_le,Cslib.Crypto.PrimeOrderGroupFamily.DDH.kemINDCPA_hashedElGamalEncapsProb: quantitative KEM advantage bound andEncryption.KEMINDCPAsecurity of the $\mathcal{E}'_{\mathrm{EG}}$ KEM underDDHandSecureKDF, the key-encapsulation step of Theorem 11.5.Cslib.Crypto.PrimeOrderGroupFamily.DDH.indcpaOf_hybrid_hashedElGamal,Cslib.Crypto.PrimeOrderGroupFamily.DDH.indcpaOn_hybrid_hashedElGamal,Cslib.Crypto.PrimeOrderGroupFamily.DDH.wordINDCPA_hybrid_hashedElGamal: Theorem 11.5 for the $\mathcal{E}'_{\mathrm{EG}}$ variant of Remark 11.1, over a deterministic polynomial-time group schedule, viaEncryption.INDCPAOf,Encryption.INDCPAOn, andEncryption.WordINDCPAfor any one-time semantically secure symmetric cipher (Encryption.DEMOneTimeKeyINDCPAOf/Encryption.DEMOneTimeKeyINDCPAOn/Encryption.DEMOneTimeKeyWordINDCPA).Cslib.Crypto.PrimeOrderGroupFamily.DDH.indcpaOn_elGamalEncryptProb,Cslib.Crypto.PrimeOrderGroupFamily.DDH.indcpa_elGamalBitEncryptProb: multiplicative and bit ElGamal satisfyEncryption.INDCPAOnandEncryption.INDCPAunderDDH.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 10.5.2 (p. 413), Section 11.5 (pp. 445–446, Remark 11.1), Section 11.5.2 (pp. 448–451, Theorem 11.5), Exercise 11.5(a) (p. 459), and Exercise 11.9 (pp. 460–461).
Probabilistic polynomial-time ElGamal key generation for a group description family
d : ℕ → F.Desc ([BS23], Section 11.5, p. 445, and Exercise 11.5, p. 459): sample
a ← sampleExp n (d n) and output
(encPair F.encDesc encBits (d n, encode (a • g)), encNat a).
elGamalKeyGenProb is uniformly strict PPT whenever d is computable in polynomial time.
Probabilistic polynomial-time Hashed ElGamal KEM encapsulation for a group description family
d : ℕ → F.Desc ([BS23], Section 11.5, p. 445, Remark 11.1, p. 446, and Exercise 11.9,
pp. 460–461): sample b ← sampleExp n (d n), unpack u = dropFrame pk, and output
(H (d n, encode (b • u)), encode (b • g)).
hashedElGamalEncapsProb is uniformly strict PPT whenever H and d are computable in
polynomial time.
Deterministic polynomial-time Hashed ElGamal KEM decapsulation ([BS23], Section 11.5,
p. 445, Remark 11.1, p. 446): given secret key sk = encNat a and KEM ciphertext
ctKem = encode (b • g), recover H (d n, encode (a • v)).
hashedElGamalDecaps is computable in polynomial time whenever H and d are.
Hashed ElGamal KEM decapsulation correctness: for any n : ℕ, any (pk, sk) in the
support of elGamalKeyGenProb d n, and any (k, ctKem) in the support of
hashedElGamalEncapsProb H d n pk, hashedElGamalDecaps H d n sk ctKem = k.
KDF distinguisher constructed from a KEMAdversary (Distinguisher) for
(elGamalKeyGenProb d, hashedElGamalEncapsProb H d): given (d, u, v, key), pass the public key
(d, encode u) and the encapsulation (key, encode v) to the KEM distinguisher.
DDH distinguisher constructed from a KEMAdversary (Distinguisher) for
(elGamalKeyGenProb d, hashedElGamalEncapsProb H d): kemToKDFDistinguisher run with the key
H (d, encode w) derived from the candidate shared element w.
kemToKDFDistinguisher is uniform strict PPT whenever distinguisher is.
Quantitative KEM IND-CPA bound for Hashed ElGamal: the KEM distinguishing advantage of
distinguisher against (elGamalKeyGenProb d, hashedElGamalEncapsProb H d) is bounded by the DDH
advantage of kemToDDHDistinguisher H distinguisher plus the KDF advantage of
kemToKDFDistinguisher distinguisher plus 4 / 2 ^ n. The middle hybrid is the random DDH
game, which is the real KDF game (ddhRandomGame_kdfToDDHDistinguisher).
Key-encapsulation step of Theorem 11.5 for the $\mathcal{E}'_{\mathrm{EG}}$ variant of
Remark 11.1 ([BS23], Remark 11.1, p. 446, and Section 11.5.2, Theorem 11.5,
pp. 449–451, with the KEM notion Encryption.KEMINDCPA, which strengthens that of Exercise 11.9,
pp. 460–461, by giving the distinguisher the public key): the KEM
(elGamalKeyGenProb d, hashedElGamalEncapsProb H d), which derives its key from the
Diffie–Hellman element w = b • u alone (H (d n, encode w), not Theorem 11.5's H (v, w)), over
a deterministic group schedule d : ℕ → F.Desc, satisfies Encryption.KEMINDCPA keyLen when
F.DDH (fun n => PMF.pure (d n)) and F.SecureKDF (fun n => PMF.pure (d n)) H keyLen hold and H
is computable in polynomial time. This is Games 0–2 of the proof of Theorem 11.5, which Remark 11.1
carries over to $\mathcal{E}'_{\mathrm{EG}}$; Theorem 11.5 itself, semantic security of the
encryption scheme, is DDH.wordINDCPA_hybrid_hashedElGamal. At parameter n the group
description is d n: the system parameterization $P(\lambda)$ of Section 10.5.2 (p. 413) taken
deterministic.
Theorem 11.5 for the $\mathcal{E}'_{\mathrm{EG}}$ variant of Remark 11.1, via
Encryption.INDCPAOf ([BS23], Remark 11.1, p. 446, and Section 11.5.2, Theorem 11.5,
pp. 449–451): Hashed ElGamal with the key derived from the Diffie–Hellman element w = b • u alone
(hashedElGamalEncapsProb H d, not Theorem 11.5's H (v, w)), over a deterministic
polynomial-time group schedule d : ℕ → F.Desc, coupled with any uniform strict-PPT one-time
semantically secure symmetric cipher encryptSym
(DEMOneTimeKeyINDCPAOf encMsg keyLen encryptSym), satisfies Encryption.INDCPAOf under
F.DDH (fun n => PMF.pure (d n)) and F.SecureKDF (fun n => PMF.pure (d n)) H keyLen.
Remark 11.1 states that the chapter's security results hold for $\mathcal{E}'_{\mathrm{EG}}$ as
well as for $\mathcal{E}_{\mathrm{EG}}$. At parameter n the group description is d n: the
system parameterization $P(\lambda)$ of Section 10.5.2 (p. 413) taken deterministic. Every
challenge pair is admissible, for the cipher as for the scheme; this is the source's notion when
all messages of Msg have one length, and DDH.wordINDCPA_hybrid_hashedElGamal is the
equal-length form for words. The proof combines DDH.kemINDCPA_hashedElGamalEncapsProb with
KEMINDCPA.hybrid_indcpa.
Theorem 11.5 for the $\mathcal{E}'_{\mathrm{EG}}$ variant of Remark 11.1, via
Encryption.INDCPAOn ([BS23], Remark 11.1, p. 446, and Section 11.5.2, Theorem 11.5,
pp. 449–451): for any polynomial-time admissibility predicate valid that ignores the public key,
Hashed ElGamal with the key derived from the Diffie–Hellman element w = b • u alone
(hashedElGamalEncapsProb H d, not Theorem 11.5's H (v, w)), over a deterministic
polynomial-time group schedule d : ℕ → F.Desc, coupled with any uniform strict-PPT one-time
semantically secure symmetric cipher encryptSym
(DEMOneTimeKeyINDCPAOn valid encMsg keyLen encryptSym), satisfies Encryption.INDCPAOn valid
under F.DDH (fun n => PMF.pure (d n)) and F.SecureKDF (fun n => PMF.pure (d n)) H keyLen.
Remark 11.1 states that the chapter's security results hold for $\mathcal{E}'_{\mathrm{EG}}$ as
well as for $\mathcal{E}_{\mathrm{EG}}$. At parameter n the group description is d n: the
system parameterization $P(\lambda)$ of Section 10.5.2 (p. 413) taken deterministic. Attack
Game 11.1's equal-length rule fun _ _ m₀ m₁ => m₀.length == m₁.length gives the source's notion
(DDH.wordINDCPA_hybrid_hashedElGamal). The proof combines
DDH.kemINDCPA_hashedElGamalEncapsProb with KEMINDCPA.hybrid_indcpaOn.
Theorem 11.5 for the $\mathcal{E}'_{\mathrm{EG}}$ variant of Remark 11.1, via
Encryption.WordINDCPA ([BS23], Remark 11.1, p. 446, and Section 11.5.2,
Theorem 11.5, pp. 449–451): Hashed ElGamal with the key derived from the Diffie–Hellman element
w = b • u alone (hashedElGamalEncapsProb H d, not Theorem 11.5's H (v, w)), over a
deterministic polynomial-time group schedule d : ℕ → F.Desc, coupled with any uniform strict-PPT
one-time semantically secure word cipher encryptSym
(DEMOneTimeKeyWordINDCPA keyLen encryptSym), satisfies Encryption.WordINDCPA under
F.DDH (fun n => PMF.pure (d n)) and F.SecureKDF (fun n => PMF.pure (d n)) H keyLen.
Remark 11.1 states that the chapter's security results hold for $\mathcal{E}'_{\mathrm{EG}}$ as
well as for $\mathcal{E}_{\mathrm{EG}}$; here SecureKDF is Attack Game 11.3 for the hash of w
alone. At parameter n the group description is d n: the system parameterization $P(\lambda)$
of Section 10.5.2 (p. 413) taken deterministic. The scheme and the cipher are held to the
equal-length rules of Attack Games 11.1 and 2.1; the proof applies
DDH.indcpaOn_hybrid_hashedElGamal with fun _ _ m₀ m₁ => m₀.length == m₁.length.
Probabilistic polynomial-time multiplicative ElGamal encryption for a group description family
d : ℕ → F.Desc and message encoder encodeMsg : F.Desc → Msg → List Bool
([BS23], Exercise 11.5, p. 459): sample b ← sampleExp n (d n), unpack
u = dropFrame pk, and output
encPair encBits encBits (encodeElGamalEncrypt (d n, u, encodeMsg (d n) m, b)).
elGamalEncryptProb is uniformly strict PPT whenever encodeMsg and d are computable in
polynomial time.
Deterministic polynomial-time multiplicative ElGamal decryption on words: given secret key
sk = encNat a and ciphertext ct = encPair encBits encBits (v, e), compute
decodeElGamal (d n, ofBits sk, unframe ct, dropFrame ct).
elGamalDecryptDet is computable in polynomial time whenever d is.
Multiplicative ElGamal decryption correctness on ProbComp outputs: for any (pk, sk) in
the support of elGamalKeyGenProb d n, any m : F.Carrier (d n), and any ct in the support of
elGamalEncryptProb (fun d x => x) d n pk (F.encode (d n) m),
elGamalDecryptDet d n sk ct = F.encode (d n) m.
The native Encryption.gameOn experiment for
(elGamalKeyGenProb d, elGamalEncryptProb encodeMsg d) is within statistical distance 2 / 2 ^ n
of the ideal exact-uniform PMF game
elGamalMsgCPAGameOn valid encodeMsg (fun n => PMF.pure (d n)).
Multiplicative ElGamal satisfies Encryption.INDCPAOn under DDH when valid admits
only group elements under encodeMsg at d n
(AdmitsGroupElementsOn (fun n => PMF.pure (d n))).
Multiplicative ElGamal satisfies Encryption.INDCPAOn under DDH ([BS23],
Exercise 11.5(a), p. 459): for any polynomial-time group description family d : ℕ → F.Desc,
polynomial-time message encoder encodeMsg, and polynomial-time admissibility predicate valid
admitting only group elements (AdmitsGroupElements encodeMsg valid),
(elGamalKeyGenProb d, elGamalEncryptProb encodeMsg d) satisfies Encryption.INDCPAOn valid encMsg
whenever F.DDH (fun n => PMF.pure (d n)) holds.
Bit ElGamal satisfies Encryption.INDCPA under DDH ([BS23], Exercise 11.5(a),
p. 459): specialization of DDH.indcpaOn_elGamalEncryptProb to encodeBit.
Fair-coin multiplicative ElGamal ([BS23], Section 12.6.2, pp. 499–500) at security
parameter n and group description d: elGamalExplicitCoinPKEWith drawing both the secret key
and the encryption coins from (Nat.cast : ℕ → ZMod (F.order d)) <$> F.sampleExp n d. Correctness
holds by elGamalExplicitCoinPKEWith_correct, and elGamalKeyGenProb, elGamalEncryptProb, and
elGamalDecryptDet realize it on encoded group elements (eval_fst_elGamalKeyGenProb,
eval_elGamalEncryptProb_encode).
The public-key output distribution of elGamalKeyGenProb d n equals the (d n, encode ·)
image of the public key drawn by (elGamalProbExplicitCoinPKE n (d n)).keyGen.
On an encoded public key (d n, encode u) and encoded group element encode x,
elGamalEncryptProb (fun _ w => w) has the same output distribution as encoding both components of
(elGamalProbExplicitCoinPKE n (d n)).encrypt u x.