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:
- Shared typed-message ElGamal reduction (
elGamalMsgCPAGameOn,elGamalMsgToDDHDistinguisher,advantage_elGamalMsgCPAGameOn_le_ideal,isPPT_elGamalMsgToDDHDistinguisher,DDH.negligible_elGamalMsgCPAGameOn_ideal). As inEncryption.gameOn, a challenge-pair admissibility predicatevalid : ℕ → List Bool → Msg → Msg → Boolsees the security parameter and the public key, and an inadmissible pair makes the game outputfalsein both experiments. The reduction needsvalidto 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):falseandtrueare embedded as0andg(bitElement,encodeBit), every pair is admissible, andEncryption.Adversarychooses 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, andvalidadmits only encoded group elements, inSet.range (F.encode d). Replacing the Diffie–Hellman mask(α * β) • gwith an independent uniformγ • gmasks any admissible pair perfectly (uniform_smul_generator_add). APrimeOrderGroupFamilyhas no membership test, sovalidis a parameter; the tests instantiate it on Schnorr groups.
- Bit ElGamal (
- 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 functionH : F.Desc × List Bool → List Bool, the sender masks a message wordmwithpad = H (d, encode (β • u))viaCslib.BitString.listXor pad.length [pad, m](the one-time pad specialization of theE'_EGvariant of Remark 11.1). Security reduces toDDHtogether with key-derivation security (SecureKDF, Attack Game 11.3, p. 448, and Definition 11.5, p. 449: indistinguishability ofH (d, encode (γ • g))from a uniformmsgLen n-bit key). The ciphertext length does not depend on the message, andhashedElGamalCPAGameadmits 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 #
Cslib.Crypto.PrimeOrderGroupFamily.elGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecrypt: algebraic ElGamal encryption and decryption.Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalPublicKey,Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal: polynomial-time public-key generation, encryption, and decryption on encoded group elements.Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgCPAGameOn,Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.AdmitsGroupElements: shared typed-message ElGamal IND-CPA experiment with an admissibility predicate, DDH reduction, and the condition that the predicate admits only group elements ([BS23], Exercise 11.5(a), p. 459).Cslib.Crypto.PrimeOrderGroupFamily.bitElement,Cslib.Crypto.PrimeOrderGroupFamily.encodeBit: embedding and polynomial-time encoding of message bits as group elements.Cslib.Crypto.PrimeOrderGroupFamily.elGamalCPAGame,Cslib.Crypto.PrimeOrderGroupFamily.elGamalIdealINDCPA,Cslib.Crypto.PrimeOrderGroupFamily.elGamalToDDHDistinguisher: bit ElGamal ideal-sampling IND-CPA experiment, its security property, and DDH distinguisher.Cslib.Crypto.PrimeOrderGroupFamily.elGamalGroupCPAGameOn,Cslib.Crypto.PrimeOrderGroupFamily.elGamalGroupToDDHDistinguisher: group-element ElGamal IND-CPA experiment and DDH reduction ([BS23], Exercise 11.5(a), p. 459).Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalDecrypt,Cslib.Crypto.PrimeOrderGroupFamily.encodeHashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.decodeHashedElGamal: algebraic and word-level Hashed ElGamal encryption and decryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1).Cslib.Crypto.PrimeOrderGroupFamily.KDFDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.kdfRealGame,Cslib.Crypto.PrimeOrderGroupFamily.kdfIdealGame,Cslib.Crypto.PrimeOrderGroupFamily.KDFInput,Cslib.Crypto.PrimeOrderGroupFamily.encKDFInput,Cslib.Crypto.PrimeOrderGroupFamily.KDFDistinguisher.IsPPT,Cslib.Crypto.PrimeOrderGroupFamily.KDFDistinguisher.IsPPT.comp,Cslib.Crypto.PrimeOrderGroupFamily.SecureKDF: typed key-derivation distinguishers, the key-derivation experiments, their input record and its encoding, their uniform strict PPT predicate and its composition rule, and secure key derivation ([BS23], Section 11.5.2, Attack Game 11.3 and Definition 11.5, pp. 448–449).Cslib.Crypto.PrimeOrderGroupFamily.kdfToDDHDistinguisher: a key-derivation distinguisher run on the keyH (d, encode w)derived from a DDH candidatew; its random DDH game is the real key-derivation game.Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalCPAGame,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalToKDFDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalToDDHDistinguisher: Hashed ElGamal IND-CPA experiment and reductions ([BS23], Section 11.5.2, Theorem 11.5, pp. 449–451).
Main results #
Cslib.Crypto.PrimeOrderGroupFamily.secureKDF_iff_encoded:SecureKDFis the word-level key-derivation assumption.Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecrypt_elGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalPublicKey_eq_encode,Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalEncrypt_encode,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_encode,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_elGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_encodeElGamalEncrypt: ElGamal correctness.Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_encodeElGamalPublicKey,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_encodeElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_decodeElGamal: polynomial-time certificates for honest ElGamal operations.Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalDecrypt_hashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_encodeHashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_decodeHashedElGamal: Hashed ElGamal correctness and polynomial-time certificates.Cslib.Crypto.PrimeOrderGroupFamily.ddhRandomGame_kdfToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.isPPT_kdfToDDHDistinguisher: the random DDH game of the key-derivation reduction is the real key-derivation game, and the reduction is PPT.
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.
Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalMsgCPAGameWith_le_ideal,Cslib.Crypto.PrimeOrderGroupFamily.isPPT_elGamalMsgToDDHDistinguisherWith,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalMsgCPAGameWith_ideal: the reduction for a guard that also sees the group description, shared with the decodable-group game ofCslibFrontier/Crypto/Computational/ElGamal/Decodable.lean.Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalMsgCPAGameOn_le_ideal,Cslib.Crypto.PrimeOrderGroupFamily.isPPT_elGamalMsgToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalMsgCPAGameOn_ideal: shared typed-message reduction to DDH.Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalCPAGame_le_ideal,Cslib.Crypto.PrimeOrderGroupFamily.isPPT_elGamalToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.DDH.elGamalIdealINDCPA: bit messages.Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalGroupCPAGameOn_le_ideal,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalGroupCPAGameOn_ideal: group-element messages.Cslib.Crypto.PrimeOrderGroupFamily.advantage_hashedElGamalCPAGame_le_ideal,Cslib.Crypto.PrimeOrderGroupFamily.isPPT_hashedElGamalToKDFDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_hashedElGamalCPAGame_ideal: Hashed ElGamal with a one-time pad, under DDH andSecureKDF.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 11.5 (pp. 445–446, Remark 11.1), Section 11.5.2 (pp. 448–451, Attack Game 11.3, Definition 11.5, Theorem 11.5), and Exercise 11.5(a) (p. 459).
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.
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)).
encodeElGamalPublicKey computes the group encoding of (a : ZMod (F.order d)) • g.
Word-level ElGamal public-key computation is computable in polynomial time.
encodeElGamalEncrypt evaluates elGamalEncrypt on encoded group elements.
Word-level ElGamal encryption is computable in polynomial time.
decodeElGamal computes encode (elGamalDecrypt d a (v, e)) on encoded group elements.
Encoded ElGamal decryption of an honest encryption recovers the encoded message.
Word-level ElGamal decryption of encodeElGamalEncrypt under encodeElGamalPublicKey recovers
the encoded message.
Encoded ElGamal decryption is computable in polynomial time.
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.
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.
Shared DDH distinguisher associated with elGamalMsgCPAGameWith.
In the real DDH game, elGamalMsgToDDHDistinguisherWith simulates
elGamalMsgCPAGameWith exactly.
When guard admits only group elements on setup, the uniform mask γ • g hides both
challenge messages in ddhRandomGame.
Quantitative DDH bound for elGamalMsgCPAGameWith.
elGamalMsgToDDHDistinguisherWith is uniform strict PPT whenever guard, encodeMsg, and
adversary are efficient.
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.
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.
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.
In the real DDH game, elGamalMsgToDDHDistinguisher simulates elGamalMsgCPAGameOn
exactly.
The admissibility predicate valid admits only group elements under encodeMsg at groups
supported by setup n.
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).
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.
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.
elGamalMsgToDDHDistinguisher is uniform strict PPT whenever valid and encodeMsg are
computable in polynomial time and adversary is uniform strict PPT.
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.
encodeBit computes the group encoding of bitElement.
Every pair of bit messages encodes group elements, so the always-true predicate admits only
group elements under encodeBit.
encodeBit is computable in polynomial time from the group description and the bit.
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.
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).
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.
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 #
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).
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.
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).
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].
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]).
encodeHashedElGamalEncrypt evaluates hashedElGamalEncrypt on encoded group elements.
Word-level Hashed ElGamal encryption is computable in polynomial time whenever H is.
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].
decodeHashedElGamal computes hashedElGamalDecrypt on encoded group elements.
Word-level Hashed ElGamal decryption of an honest encryption recovers m whenever m has the
same length as the derived pad.
Word-level Hashed ElGamal decryption is computable in polynomial time whenever H is.
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.
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)).
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.
- groupParameters : F.Desc
The candidate key word.
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.
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.
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.
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.
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.
In the real DDH game, hashedElGamalToDDHDistinguisher simulates hashedElGamalCPAGame
exactly.
hashedElGamalToKDFDistinguisher is uniform strict PPT whenever adversary is.
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.