The DL and CDH self-reductions over a prime-order group family #
[BS23], Section 10.5.1, turns an efficient algorithm A that finds the discrete logarithm
of a random element of a fixed group with probability ε into an efficient algorithm B that,
on every input, outputs fail or the discrete logarithm and outputs the latter with probability
ε (Theorem 10.2), and Exercise 10.6 asks for the same for CDH. The fixed-group module
CslibFrontier/Crypto/Computational/DiffieHellman/SelfReduction.lean computes the exact output
probabilities of these algorithms with uniform masks and no cost model. This module states them
as adversaries over a PrimeOrderGroupFamily, proves that they are uniform strict PPT whenever
A is, and derives the family-level consequences.
Here ε is dlAdvantage (F.order d) (F.generator d) (F.discreteLogAdversary A n d), the success
probability of the word-level adversary A read in the group selected by d
(succProbability_discreteLogGame_pure). Footnote 1 of the book (p. 411) fixes the group in the
same way.
dlSelfReduceAdversary Amasks the input word byσ • gwithF.addandF.smul, runsAand subtractsσfrom the answer read as a natural number; its answer is never the empty word.dlSelfReduceRetryAdversary A kmakes at mostk nsuch calls, each followed by the testx • g = u, computed on encodings by comparingF.smul (d, x, encode g)with the input word, and returns the first answer that passes the test, or the empty word. Withk = fun _ => 1it is the algorithmBof the proof of Theorem 10.2 (p. 412), with the empty word forfail.cdhSelfReduceAdversary Amasks both inputs and removes the three cross terms, asCslib.Crypto.cdhSelfReducedoes; the construction is this library's, since Exercise 10.6 gives none.
The reduction reads only words: on every input word its certificates hold, and the loop's test
rejects every word that encodes no group element
(eq_nil_of_mem_support_dlSelfReduceRetryAdversary_of_not_mem_range).
Differences from the book #
- The masks are drawn by
sampleExp, which is within statistical distance1 / 2 ^ nof uniform onZMod q, not uniform. So the family-level success probabilities are bounded below byεless1 / 2 ^ n(one DL mask) or2 / 2 ^ n(two CDH masks), not equal toεas in Theorem 10.2. The equality holds for the fixed-group programs with uniform masks (Cslib.Crypto.eval_dlSelfReduce_one_smul_some). - The book's
failis the empty word. The discrete-logarithm game reads it as the exponent0, so on the instanceα = 0the game counts a failed run as a win. The bounds for the checked loop are therefore stated on the output word, for the event that it is nonempty and reads asα; the bounds on the exponent that the game reads are corollaries. - The answer
x - σis computed on natural numbers asx + (q - σ % q), which the game reads moduloq. - The iteration remark after Theorem 10.2 runs
Bn ⌈1 / ε⌉times. A uniform machine is given a boundinvEps nwith1 / invEps n ≤ εinstead ofε, and runsn * (2 * invEps n)attempts: the factor2pays for the sampling loss.
Main definitions #
Cslib.Crypto.PrimeOrderGroupFamily.encDiscreteLogInput: the input encoding of a word-level discrete-logarithm adversary, as inDiscreteLog.Cslib.Crypto.PrimeOrderGroupFamily.dlSelfReduceAdversary: one masked call of a word-level discrete-logarithm adversary.Cslib.Crypto.PrimeOrderGroupFamily.dlSelfReduceRetryAdversary: at mostk nchecked attempts.Cslib.Crypto.PrimeOrderGroupFamily.cdhSelfReduceAdversary: one call of a CDH adversary with both inputs masked.Cslib.Crypto.PrimeOrderGroupFamily.dlWorstCaseGame,Cslib.Crypto.PrimeOrderGroupFamily.cdhWorstCaseGame: the adversary against fixed instancesα d • g(andβ d • g) in groups drawn by the setup law.
Main results #
- Certificates:
isPPTOn_dlSelfReduceAdversary,isPPTOn_dlSelfReduceRetryAdversary,isPPTOn_dlSelfReduceRetryAdversary_invEpsandisPPT_cdhSelfReduceAdversary, each from the certificate of the input adversary; the two loop certificates also take an attempt countk, or a boundinvEps, computable in polynomial time in unary. eq_nil_or_encode_smul_eq_of_mem_support_dlSelfReduceRetryAdversary: on every input word the loop outputs the empty word or a wordxwithencode (x • g)equal to the input (Theorem 10.2: "BoutputsfailorDlog_g(u)").le_toOuterMeasure_dlSelfReduceRetryAdversary_one: on the encoding of every instanceα • g, one checked attempt returns a nonempty word that reads asαwith probability at leastε - 1 / 2 ^ n(Theorem 10.2, with the sampling loss), andone_sub_pow_le_toOuterMeasure_dlSelfReduceRetryAdversaryfork nattempts. The corresponding bounds on the exponent that the game reads arele_eval_discreteLogAdversary_dlSelfReduceRetryAdversary_oneandone_sub_pow_le_eval_discreteLogAdversary_dlSelfReduceRetryAdversary.dlSelfReduceRetryAdversary_error_le_powandnegligible_dlSelfReduceRetryAdversary_error: the iteration remark. If the adversary wins in the group with probability at least1 / invEps nand1 / 2 ^ n ≤ 1 / (2 * invEps n), the loop withn * (2 * invEps n)attempts errs, that is returns the empty word or a word that does not read asα, with probability at most(1 / 2) ^ non every instance. So it errs with negligible probability wheninvEpsis computable in polynomial time in unary and, for all largen,0 < invEps nand the adversary wins with probability at least1 / invEps n.discreteLogAdversary_dlSelfReduceRetryAdversary_error_le_powandnegligible_discreteLogAdversary_dlSelfReduceRetryAdversary_errorbound the probability that the game reads an exponent other thanα.advantage_dlWorstCaseGame_discreteLogGame_leanddiscreteLog_of_worstCase: the reduction wins the worst-case game within1 / 2 ^ nof the adversary's average-case success, soDiscreteLogholds if every PPT adversary has instances on which it succeeds with negligible probability.advantage_cdhSelfReduceAdversary_le,advantage_cdhWorstCaseGame_cdhGame_leandcdh_of_worstCase: the same for CDH with loss2 / 2 ^ n(Exercise 10.6, with the sampling loss).
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); Exercise 10.6 (p. 425).
The programs #
The input (n, d, w) of a word-level discrete-logarithm adversary: the security parameter in
unary and the group parameters, each framed, then the instance word. It is the input encoding in
DiscreteLog.
One masked call of a word-level discrete-logarithm adversary on the input word x.2: draw
σ with sampleExp, run the adversary on x.2 + σ • g computed with F.add and F.smul, and
subtract σ from its answer as natural numbers, ofBits answer + (q - σ % q), which the game
reads modulo q.
At most k n checked attempts, each a masked call (dlSelfReduceAdversary) followed by the
test x • g = u computed on encodings, returning the first answer that passes its test, or the
empty word when none does. With k = fun _ => 1 this is the algorithm B in the proof of
[BS23], Theorem 10.2 (p. 412), with the empty word for its output fail.
One call of a CDH adversary with both inputs masked: draw ρ and τ with sampleExp, run
the adversary on (u + ρ • g, v + τ • g) and subtract τ • u + ρ • v + (ρ * τ) • g, as
Cslib.Crypto.cdhSelfReduce does with uniform masks. [BS23], Exercise 10.6 (p. 425)
gives no construction; this one is this library's.
The worst-case discrete-logarithm game for the instances α d • g: draw group parameters d
with the setup law and run the word-level adversary on the encoding of α d • g. It wins when its
answer, read as an exponent, is α d. This game is this library's.
The worst-case CDH game for the instance pairs (α d • g, β d • g): draw group parameters d
with the setup law and run the CDH adversary on the pair. It wins when it outputs
(α d * β d) • g. This game is this library's.
Certificates #
The masked call is efficient: if the word-level adversary is uniform strict PPT, so is
dlSelfReduceAdversary.
The checked loop is efficient: if the word-level adversary is uniform strict PPT and the
number of attempts k n is computable in polynomial time in unary, dlSelfReduceRetryAdversary
is uniform strict PPT.
The loop with n * (2 * invEps n) attempts, the count of
negligible_dlSelfReduceRetryAdversary_error, is uniform strict PPT when invEps is computable
in polynomial time in unary.
The CDH self-reduction is efficient: if the CDH adversary is uniform strict PPT, so is
cdhSelfReduceAdversary.
One masked call #
On the encoding of an element u, the word-level masked call is one masked call of the
fixed-group adversary F.discreteLogAdversary adversary n d, with the mask drawn by sampleExp
in place of the uniform mask of Cslib.Crypto.dlRerandomize.
One masked call on every instance: on α • g, the masked call returns α with the
probability with which the adversary wins the discrete-logarithm experiment in the group d, up
to 1 / 2 ^ n, the sampling loss of sampleExp. With a uniform mask the two are equal
(Cslib.Crypto.eval_dlRerandomize_smul_apply).
Worst case against average case, discrete logarithm #
In the group selected by d, the discrete-logarithm game with the constant setup law is the
fixed-group experiment: its success probability is the ε of [BS23], Theorem 10.2, for
the adversary read in d.
The masked call wins the worst-case game on the instances α d • g within 1 / 2 ^ n of the
adversary's success in the average-case game, for every setup law.
The adversary's average-case success is at most the masked call's worst-case success plus
1 / 2 ^ n.
Average-case discrete-logarithm hardness from worst-case hardness: if for every uniform strict
PPT word-level adversary there are instances α d • g on which it wins the worst-case game with
negligible probability, then DiscreteLog holds for the setup law. The instances may depend on
the adversary. The book states this implication only informally (p. 412: "if it is hard in the
worst case, then it must be hard on average"); this formulation and dlWorstCaseGame are this
library's. Cslib.Crypto.PrimeOrderGroupFamily.ddh_of_worstCase is the DDH analogue, with the
same quantifier order.
The checked loop #
Soundness of the loop on every input word: on (d, w) the loop outputs the empty word
(the book's fail) or a word that reads as an exponent x with F.encode d (x • g) = w. This is
the claim of [BS23], Theorem 10.2 (pp. 411–412), that B outputs fail or
Dlog_g(u), for any number of attempts.
On the encoding of an element u, the loop outputs the empty word or a discrete logarithm of
u.
On a word that encodes no element of the group d, the loop outputs the empty word.
The loop on every instance: on the encoding of α • g, k n checked attempts return a
nonempty word that reads as α with probability at least 1 - (1 - (ε - 1 / 2 ^ n)) ^ k n, where
ε is the adversary's success in the group d. The iteration remark after [BS23],
Theorem 10.2 (p. 412) gives 1 - (1 - ε) ^ k without the sampling loss. The event excludes the
empty word, the book's fail, for the reason given at
le_toOuterMeasure_dlSelfReduceRetryAdversary_one.
[BS23], Theorem 10.2, with the sampling loss: on the encoding of every instance
α • g, one checked attempt returns a nonempty word that reads as α with probability at least
ε - 1 / 2 ^ n, where ε is the adversary's success in the group d.
The bound is on the output word, not on the exponent that the discrete-logarithm game reads from
it. The game reads the empty word, the book's fail, as 0, so on the instance α = 0 the
game-level bound le_eval_discreteLogAdversary_dlSelfReduceRetryAdversary_one holds even for a
loop that always fails. Excluding the empty word gives the book's claim that B returns an answer
other than fail, the discrete logarithm, with probability ε, for every u.
The book's equality = ε is Cslib.Crypto.eval_dlSelfReduce_one_smul_some for the fixed-group
program with a uniform mask; here the mask is drawn by sampleExp, and only the lower bound is
stated. The attempt is efficient (isPPTOn_dlSelfReduceRetryAdversary).
The bound of one_sub_pow_le_toOuterMeasure_dlSelfReduceRetryAdversary for the exponent that
the discrete-logarithm game reads from the loop's answer. At α = 0 it holds for every loop, since
the game reads the empty word as 0.
The bound of le_toOuterMeasure_dlSelfReduceRetryAdversary_one for the exponent that the
discrete-logarithm game reads from the loop's answer. At α = 0 it holds for every loop, since
the game reads the empty word as 0.
The iteration remark after [BS23], Theorem 10.2 (p. 412), in a fixed group with
the sampling loss: if the adversary wins the discrete-logarithm game in the group d with
probability at least 1 / invEps n and 1 / 2 ^ n ≤ 1 / (2 * invEps n), then on the encoding of
every instance α • g the loop with n * (2 * invEps n) attempts errs, that is returns the empty
word or a word that does not read as α, with probability at most (1 / 2) ^ n.
The book runs n ⌈1 / ε⌉ attempts and bounds the error by exp (-n). The second hypothesis forces
0 < invEps n.
The bound of dlSelfReduceRetryAdversary_error_le_pow for the exponent that the
discrete-logarithm game reads from the loop's answer: it reads an exponent other than α with
probability at most (1 / 2) ^ n.
Discrete logarithm on every instance with negligible error: if invEps is computable in
polynomial time in unary and, for large n, 0 < invEps n and the adversary wins the
discrete-logarithm game in the group d n with probability at least 1 / invEps n, then on the
encoding of every sequence of instances α n • g in d n the loop with n * (2 * invEps n)
attempts errs, that is returns the empty word or a word that does not read as α n, with
negligible probability.
The loop is uniform strict PPT (isPPTOn_dlSelfReduceRetryAdversary_invEps). This is the
conclusion of the remark after [BS23], Theorem 10.2 (p. 412), "if 1/ε is
poly-bounded, we can efficiently compute the discrete logarithm of any group element with
negligible failure probability", with invEps in place of ⌈1 / ε⌉.
The conclusion of negligible_dlSelfReduceRetryAdversary_error for the exponent that the
discrete-logarithm game reads from the loop's answer: it reads an exponent other than α n with
negligible probability.
Computational Diffie–Hellman #
[BS23], Exercise 10.6, with the sampling loss: on every pair (α • g, β • g),
cdhSelfReduceAdversary returns (α * β) • g with the probability with which the adversary wins
the CDH experiment in the group d, up to 2 / 2 ^ n, the loss of the two sampleExp masks. The
exercise asks for equality; with uniform masks it holds
(Cslib.Crypto.eval_cdhSelfReduce_smul_apply). The reduction is efficient
(isPPT_cdhSelfReduceAdversary).
cdhSelfReduceAdversary wins the worst-case game on the pairs (α d • g, β d • g) within
2 / 2 ^ n of the adversary's success in the average-case CDH game, for every setup law.
The adversary's average-case CDH success is at most the reduction's worst-case success plus
2 / 2 ^ n.
Average-case CDH hardness from worst-case hardness: if for every uniform strict PPT CDH
adversary there are pairs (α d • g, β d • g) on which it wins the worst-case game with negligible
probability, then CDH holds for the setup law. The pairs may depend on the adversary. This
formulation and cdhWorstCaseGame are this library's.
Cslib.Crypto.PrimeOrderGroupFamily.ddh_of_worstCase is the DDH analogue, with the same
quantifier order.