Documentation

CslibFrontier.Crypto.Computational.DiffieHellman.Static

Static Diffie–Hellman and chosen-ciphertext key recovery against multiplicative ElGamal #

Fix an additive commutative group G that is a ZMod q-module, as in CslibFrontier/Crypto/Computational/DiffieHellman/Finite.lean; the textbook element v ^ α is α • v and the identity 1 is 0.

In the static Diffie–Hellman (SDH) experiment ([BS23], Section 16.1.4, Attack Game 16.1, p. 688), the challenger draws a uniform secret α : ZMod q and answers each query v : G with α • v (sdhOracle); the adversary wins when it outputs α (sdhExperiment, sdhAdvantage). With one query at g, a discrete-logarithm adversary A plays dlExperiment q g A inside sdhExperiment (dlToSDH, sdhAdvantage_dlToSDH).

Multiplicative ElGamal ([BS23], Exercise 11.5, p. 459) decrypts a ciphertext (v, e) : G × G under secret key α : ZMod q to e - α • v. As observed in [BS23], Section 16.1.4 (p. 688), decrypting (-v, 0) (the additive form of (1 / v, 1)) returns 0 - α • (-v) = α • v (elGamalDecryptOracle_neg_zero). Consequently, answering each SDH query v by asking the ElGamal decryption oracle elGamalDecryptOracle for (-v, 0) turns any static-DH adversary A into a key-recovery oracle adversary sdhToElGamalKeyRecovery A with the exact same experiment distribution and success probability (elGamalKeyRecoveryAdvantage_sdhToElGamalKeyRecovery), preserving any query budget Q (isQueryBounded_sdhToElGamalKeyRecovery) and submitting only ciphertexts with second component 0 (queriesSatisfy_sdhToElGamalKeyRecovery). Conversely, an ElGamal key-recovery adversary B making at most Q decryption queries gives a static-DH adversary elGamalKeyRecoveryToSDH g B making at most Q + 1 SDH queries (one query at g for the public key α • g, plus one per decryption query) with the same advantage (sdhAdvantage_elGamalKeyRecoveryToSDH, isQueryBounded_elGamalKeyRecoveryToSDH).

All definitions and reductions here are stated for one fixed group with per-reduction query bounds (isQueryBounded_dlToSDH, isQueryBounded_sdhToElGamalKeyRecovery, isQueryBounded_elGamalKeyRecoveryToSDH) and query predicates (queriesSatisfy_dlToSDH, queriesSatisfy_sdhToElGamalKeyRecovery), with no PPT efficiency certificate over a group family (such as IsOraclePPT / IsOraclePPTOn), no asymptotic SDH assumption, no one-more Diffie–Hellman reduction, and no Brown–Gallant–Cheon attack ([BS23], Exercise 16.3). The theorems about sdhToElGamalKeyRecovery are therefore fixed-group steps toward the claim of [BS23], Section 16.1.4 (p. 688), that a CCA adversary recovers the secret key if SDH is easy in G, not the cited result: that claim needs the key-recovery adversary to be efficient whenever the SDH adversary is, and no efficiency certificate for the reduction is proved here (#5293).

Differences from the book #

Main definitions #

Main results #

References #

Static Diffie–Hellman (Attack Game 16.1) #

@[reducible, inline]

The oracle interface of the static Diffie–Hellman game ([BS23], Section 16.1.4, Attack Game 16.1, p. 688): each query is a group element v : G and is answered by a group element.

@[reducible, inline]

An adversary for the static Diffie–Hellman game in a group G of exponent modulus q: a randomized oracle program over SDHSpec G that outputs a guess in ZMod q.

def Cslib.Crypto.sdhOracle {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (α : ZMod q) (v : G) :

The static Diffie–Hellman solve oracle ([BS23], Section 16.1.4, Attack Game 16.1, p. 688, and Section 11.6.3, p. 455): on query v : G, return α • v (the textbook v ^ α). This is also the oracle of the book's CDH solve query in Section 11.6.3 (the one-more Diffie–Hellman game is not formalized here).

noncomputable def Cslib.Crypto.sdhExperiment {G : Type} [AddCommGroup G] (q : ℕ) [NeZero q] [Module (ZMod q) G] (A : SDHAdversary G q) :

The static Diffie–Hellman experiment ([BS23], Section 16.1.4, Attack Game 16.1, p. 688): draw a uniform secret α : ZMod q, run A against sdhOracle q α, and accept when the adversary outputs α.

noncomputable def Cslib.Crypto.sdhAdvantage {G : Type} [AddCommGroup G] (q : ℕ) [NeZero q] [Module (ZMod q) G] (A : SDHAdversary G q) :

The static Diffie–Hellman advantage of A: its success probability in sdhExperiment.

def Cslib.Crypto.dlToSDH {G : Type} {q : ℕ} (g : G) (A : G → ProbComp (ZMod q)) :

Turn a discrete-logarithm adversary A into a 1-query static Diffie–Hellman adversary: query the SDH oracle at g to obtain α • g and run A on the reply.

@[simp]
theorem Cslib.Crypto.run_sdhOracle_dlToSDH {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) (A : G → ProbComp (ZMod q)) (α : ZMod q) :
ProbOracleComp.run (dlToSDH g A) (sdhOracle q α) = A (α • g)

Running dlToSDH g A against sdhOracle q α runs A (α • g).

@[simp]
theorem Cslib.Crypto.sdhExperiment_dlToSDH {G : Type} [AddCommGroup G] (q : ℕ) [NeZero q] [Module (ZMod q) G] (g : G) (A : G → ProbComp (ZMod q)) :

In sdhExperiment, dlToSDH g A is the discrete-logarithm experiment dlExperiment q g A.

@[simp]
theorem Cslib.Crypto.sdhAdvantage_dlToSDH {G : Type} [AddCommGroup G] (q : ℕ) [NeZero q] [Module (ZMod q) G] (g : G) (A : G → ProbComp (ZMod q)) :

dlToSDH g A wins the static Diffie–Hellman game with the exact discrete-logarithm advantage of A.

dlToSDH g A makes at most 1 SDH query on every path.

theorem Cslib.Crypto.queriesSatisfy_dlToSDH {G : Type} {q : ℕ} (g : G) (A : G → ProbComp (ZMod q)) :
ProbOracleComp.QueriesSatisfy (fun (x : G) => x = g) (dlToSDH g A)

Every SDH query made by dlToSDH g A is g.

Key-recovery oracle attack on multiplicative ElGamal #

@[reducible, inline]

The decryption oracle interface of multiplicative ElGamal ([BS23], Exercise 11.5, p. 459, and Section 16.1.4, p. 688): a query is a ciphertext pair (v, e) : G × G and is answered by the decrypted group element in G.

@[reducible, inline]

A key-recovery decryption-oracle adversary against multiplicative ElGamal: given the public key u = α • g, it queries the decryption oracle on ciphertexts in G × G and outputs a guess for the secret key α : ZMod q.

def Cslib.Crypto.elGamalDecryptOracle {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (α : ZMod q) (ct : G × G) :

The multiplicative ElGamal decryption oracle under secret key α : ZMod q ([BS23], Exercise 11.5, p. 459): decrypts (v, e) to e - α • v (matching PrimeOrderGroupFamily.elGamalDecrypt).

@[simp]
theorem Cslib.Crypto.elGamalDecryptOracle_neg_zero {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (α : ZMod q) (v : G) :

Key observation of [BS23], Section 16.1.4 (p. 688): querying elGamalDecryptOracle at (-v, 0) (the additive form of (1 / v, 1)) equals sdhOracle q α v.

The key-recovery decryption-oracle experiment for multiplicative ElGamal ([BS23], Section 16.1.4, p. 688): draw a uniform secret key α : ZMod q, pass the public key α • g to B with access to elGamalDecryptOracle q α, and accept when B outputs α.

noncomputable def Cslib.Crypto.elGamalKeyRecoveryAdvantage {G : Type} [AddCommGroup G] (q : ℕ) [NeZero q] [Module (ZMod q) G] (g : G) (B : ElGamalKeyRecoveryAdversary G q) :

The key-recovery advantage of B against multiplicative ElGamal: its success probability in elGamalKeyRecoveryExperiment.

The static-DH to ElGamal key-recovery reduction ([BS23], Section 16.1.4, p. 688): given a static-DH adversary A, build the key-recovery adversary B that runs A and answers each SDH query v : G by querying the ElGamal decryption oracle on (-v, 0) (the additive form of (1 / v, 1)).

@[simp]

Running sdhToElGamalKeyRecovery A against the ElGamal decryption oracle runs A against the SDH oracle.

@[simp]

The key-recovery experiment of sdhToElGamalKeyRecovery A is sdhExperiment q A: a fixed-group step toward [BS23], Section 16.1.4 (p. 688), not the cited result, which also needs the reduction to be efficient (#5293).

@[simp]

sdhToElGamalKeyRecovery A recovers the ElGamal secret key with the exact SDH advantage of A: a fixed-group step toward [BS23], Section 16.1.4 (p. 688), not the cited result. The book's claim needs the key-recovery adversary to be efficient whenever the SDH adversary is; here there is no group family and no IsOraclePPT certificate for the reduction, only the query bound isQueryBounded_sdhToElGamalKeyRecovery (#5293).

Query-bound certificate for sdhToElGamalKeyRecovery: if A makes at most Q SDH queries, then sdhToElGamalKeyRecovery A makes at most Q decryption queries.

Every decryption query submitted by sdhToElGamalKeyRecovery A has second component 0 (the textbook (1 / v, 1)).

The converse reduction: turn an ElGamal key-recovery adversary B into a static-DH adversary by querying g to obtain the public key α • g and answering each decryption query (v, e) with e - α • v via one SDH query at v.

@[simp]

Running elGamalKeyRecoveryToSDH g B against sdhOracle q α runs B (α • g) against elGamalDecryptOracle q α.

@[simp]

elGamalKeyRecoveryToSDH g B wins the static-DH game with the exact key-recovery advantage of B.

Query-bound certificate for elGamalKeyRecoveryToSDH: if B makes at most Q decryption queries on every public key, then elGamalKeyRecoveryToSDH g B makes at most Q + 1 SDH queries.