Exact success probability of the DL and CDH self-reductions in a fixed group #
Fix an additive commutative group G that is a ZMod q-module and an element g : G, as in
CslibFrontier/Crypto/Computational/DiffieHellman/Finite.lean; the textbook g^a is a • g.
[BS23], Section 10.5.1, turns an adversary A that finds the discrete logarithm of a
random group element with probability ε into an algorithm B that finds the discrete logarithm
of every element with probability ε (Theorem 10.2), and Exercise 10.6 asks for the same for CDH.
This module writes these algorithms as programs that call A once per attempt, and computes their
exact output probabilities in one fixed group. This layer has no cost model, so it does not state
that B is efficient, which Theorem 10.2 also claims, nor the consequence over a group family,
that worst-case hardness of the discrete logarithm implies average-case hardness. Both are in
CslibFrontier/Crypto/Computational/DiffieHellman/SelfReduction/Family.lean, for word-level
adversaries over a PrimeOrderGroupFamily.
Write ε = dlAdvantage q g A, the success probability of A in the discrete-logarithm experiment
for g. Footnote 1 of the book (p. 411) fixes the group and generator in the same way. The book
draws a uniform input u and asks for Dlog_g(u); the experiment draws a uniform exponent a and
asks for a, which is the same when g generates a group of order q.
dlRerandomize q g A umasksuasu + σ • gfor a uniform exponentσ, runsAon it and subtractsσfrom the answer. Onu = α • git returnsαwith probability exactlyε.dlSelfReduce q g A k umakes at mostksuch attempts and returns the first answerxwithx • g = u, ornone(OracleComp.retry).dlSelfReduce q g A 1is the book'sB(p. 412) withnoneforfail.cdhSelfReduce q g A u vmasks both inputs, asu + ρ • gandv + τ • g, runsA, and removes the three cross terms of((α + ρ) * (β + τ)) • g. Exercise 10.6 gives no construction; this one is ours. It applies the one-sided map of Exercise 10.5,ũ = g^ρ · uwith[ũ, v] = [u, v] · v^ρ, to both inputs. Masking one input does not suffice: the test file has an adversary for which one-sided masking succeeds with probability1or0depending onv.
Exercise 10.5 itself needs no lemma here. Part (a) is uniformOfFintype_bind_smul_add with
uniformOfFintype_bind_smul, and part (b) is the identity
((α + ρ) * β) • g = (α * β) • g + ρ • (β • g), one step of module.
The book takes G cyclic of prime order q, generated by g. The results below need neither
primality nor a generator. The exact equalities for k attempts assume instead that c ↦ c • g is
injective on ZMod q (that g has order q), and every result except soundness concerns an input
of the form α • g; in the book's setting both hold for every input. Testing an answer needs
DecidableEq G. Probabilities are values of ProbComp.eval in ℝ≥0∞, and ε : ℝ≥0 is coerced.
Main definitions #
Cslib.Crypto.dlRerandomize: one masked call of a discrete-logarithm adversary.Cslib.Crypto.dlSelfReduce: at mostkmasked calls, returning the first checked answer.Cslib.Crypto.cdhSelfReduce: one call of a CDH adversary with both inputs masked.
Main results #
Cslib.Crypto.eval_dlRerandomize_smul_apply: one masked call onα • greturnsαwith probabilityε.Cslib.Crypto.smul_eq_of_mem_support_dlSelfReduce:dlSelfReducereturnsnoneor a discrete logarithm of its input, for every input (Theorem 10.2: "outputs fail orDlog_g(u)").Cslib.Crypto.eval_dlSelfReduce_one_smul_some: one attempt onα • greturnsαwith probabilityε(the probability in Theorem 10.2).Cslib.Crypto.eval_dlSelfReduce_smul_none_le:kattempts all fail with probability at most(1 - ε) ^ k. Whenc ↦ c • gis injective,Cslib.Crypto.eval_dlSelfReduce_smul_noneandCslib.Crypto.eval_dlSelfReduce_smul_somegive the exact probabilities(1 - ε) ^ kof failing and1 - (1 - ε) ^ kof returningα.Cslib.Crypto.eval_dlSelfReduce_smul_none_le_exp_mul,Cslib.Crypto.eval_dlSelfReduce_smul_none_le_exp,Cslib.Crypto.one_sub_exp_le_eval_dlSelfReduce_smul_some: the iteration remark after Theorem 10.2. Withn ⌈1 / ε⌉attempts the failure probability is at mostexp (-n), and the probability of returningαis at least1 - exp (-n).Cslib.Crypto.eval_cdhSelfReduce_smul_apply: on(α • g, β • g),cdhSelfReducereturns(α * β) • gwith probability equal to the CDH advantage ofA(Exercise 10.6).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 10.5.1: Theorem 10.2, the remark after it and its proof (pp. 411–412); Exercises 10.5 and 10.6 (pp. 424–425).
The programs #
One masked call of a discrete-logarithm adversary A on u: draw a uniform exponent σ, run
A on u + σ • g (the textbook u · g^σ) and subtract σ from its answer. This is the
algorithm B in the proof of [BS23], Theorem 10.2 (p. 412), without its final test.
At most k masked calls of A on u (dlRerandomize), returning the first answer x with
x • g = u, or none when all k answers fail this test. dlSelfReduce q g A 1 is the algorithm
B in the proof of [BS23], Theorem 10.2 (p. 412), with none for its output fail. The
book tests g^α₁ = u · g^σ and then outputs α₁ - σ; this program tests (α₁ - σ) • g = u,
which is the same test by sub_smul.
One call of a CDH adversary A on (u, v) with both inputs masked: draw uniform exponents ρ
and τ, run A on (u + ρ • g, v + τ • g) and subtract τ • u + ρ • v + (ρ * τ) • g from its
answer. When u = α • g and v = β • g, the correct answer for the masked inputs is
((α + ρ) * (β + τ)) • g, and the subtraction leaves (α * β) • g.
[BS23], Exercise 10.6 (p. 425) asks for such an algorithm without giving one; this
construction is ours. It has no fail output: as the remark after the exercise notes, under DDH
there is no way to recognize a correct answer.
One attempt #
One masked call on α • g returns α with probability exactly the discrete-logarithm advantage
of A, whatever α: substituting a = α + σ, a bijection of ZMod q, turns the event into
A (a • g) = a for uniform a. The substitution is on exponents, not group elements, so no
hypothesis on G, q or g is needed.
Soundness of the discrete-logarithm self-reduction. Every answer some x that
dlSelfReduce can return is a discrete logarithm of its input: x • g = u. This is the claim of
[BS23], Theorem 10.2 (pp. 411–412), that B outputs either fail or Dlog_g(u), here
for every u and k and with no hypothesis on the group.
The probability in [BS23], Theorem 10.2 (pp. 411–412), in a fixed group: on input
α • g, one attempt returns α with probability exactly ε = dlAdvantage q g A. The theorem's
claim that B is efficient is not stated here; the family-level form is
Cslib.Crypto.PrimeOrderGroupFamily.le_toOuterMeasure_dlSelfReduceRetryAdversary_one, and
Cslib.Crypto.PrimeOrderGroupFamily.isPPTOn_dlSelfReduceRetryAdversary certifies its program.
The book takes G cyclic of prime order q with generator g, where every input is α • g for
its discrete logarithm α; this needs neither hypothesis.
Repeated attempts #
k attempts on α • g all fail with probability at most (1 - ε) ^ k, with no hypothesis on
the group. The bound is an equality when c ↦ c • g is injective
(eval_dlSelfReduce_smul_none); otherwise an attempt can also succeed with another discrete
logarithm of α • g.
When c ↦ c • g is injective on ZMod q (that is, g has order q), k attempts on α • g
all fail with probability exactly (1 - ε) ^ k.
When c ↦ c • g is injective, k attempts on α • g return α with probability exactly
1 - (1 - ε) ^ k, the probability in the remark after [BS23], Theorem 10.2 (p. 412).
k attempts on α • g all fail with probability at most exp (-(k ε)), with no hypothesis on
the group or on ε.
The remark after [BS23], Theorem 10.2 (p. 412), failure form: when 0 < ε,
n ⌈1 / ε⌉ attempts on α • g all fail with probability at most exp (-n). The book leaves
0 < ε implicit in the count; here ⌈ε⁻¹⌉₊ = 0 when ε = 0, and the test file shows that the
bound then fails. No hypothesis on the group is needed: when the loop does not fail, it returns a
discrete logarithm of α • g (smul_eq_of_mem_support_dlSelfReduce).
The remark after [BS23], Theorem 10.2 (p. 412): when c ↦ c • g is injective and
0 < ε, n ⌈1 / ε⌉ attempts on α • g return α with probability at least 1 - exp (-n). The
book writes this as 1 - (1 - ε)^(n⌈1/ε⌉) ≥ 1 - exp(-n), whose left side is the exact probability
of eval_dlSelfReduce_smul_some.
Computational Diffie–Hellman #
The success probability asked for in [BS23], Exercise 10.6 (p. 425), in a fixed
group: on every input (α • g, β • g), cdhSelfReduce returns the Diffie–Hellman element
(α * β) • g with probability exactly the CDH advantage of A. The construction is ours, since
the exercise gives none, and its efficiency is not stated here; the family-level form is
Cslib.Crypto.PrimeOrderGroupFamily.advantage_cdhSelfReduceAdversary_le, and
Cslib.Crypto.PrimeOrderGroupFamily.isPPT_cdhSelfReduceAdversary certifies its program. The book
takes G cyclic of prime order q with generator g; this needs neither hypothesis.