Guessing advantage and key derivation in the random-oracle model #
Formalizes the guessing games of [BS23], Section 8.10.1 (Attack Game 8.3 and its first
and third motivating examples, pp. 325–326, together with the independent uniform-component case
matching Attack Game 11.3 in Section 11.5.2, pp. 448–449) and the list-guessing game and
list-to-singleton reduction of Section 8.10.2, built on top of
Cslib.Crypto.KeyDerivation.realOutput and idealOutput. Its random-oracle bounds are steps
toward Theorem 8.10 (pp. 331–332), not the cited result: the reductions roToListGuess and
roToGuess sample the whole oracle table uniformOfFintype (S → T) eagerly, so they are not the
theorem's elementary wrappers, and the asymptotic transfer assumes guessing hardness against
unbounded guessers. See
CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational for the elementary
lazy-simulation wrappers lazyROToListGuess and lazyROToGuess and computational Theorem 8.10
over general encoded finite secret and digest families.
Relation to CslibFrontier/Probability/Entropy/Guessing.lean #
CslibFrontier.Probability.Entropy.Guessing defines the deterministic maximum a posteriori
estimator Cslib.Probability.PMF.maxPosteriorGuess for a joint distribution joint : PMF (β × α)
whose observation comes first, and proves errorProb_maxPosteriorGuess_le among deterministic
estimators g : β → α when β and α are finite. Here guessAdvantage sample info A measures
the success probability of an arbitrary randomized adversary A : X → ProbComp S trying to guess
s ← sample from info s. Taking joint := sample.map fun s => (info s, s),
guessAdvantage_le_pure_maxPosteriorGuess and
guessAdvantage_le_one_sub_errorProb_maxPosteriorGuess show that maxPosteriorGuess joint also
achieves the maximum guessAdvantage among all randomized adversaries whenever S is finite and
nonempty (with no finiteness assumption on X).
Differences from the printed book #
- General
sample : PMF Sandinfo : S → X. Attack Game 8.3 (p. 326) takes a probability distributionPon a finite setSand a functionIonS.guessOutput,listGuessOutput, and the reductions work for arbitrarySandXwhere finiteness is not needed (for example,guessOutput_apply_trueandlistGuessAdvantage_le_mul_guessAdvantage). - Eager finite random oracle
uniformOfFintype (S → T). FollowingCslibFrontier/Crypto/Primitives/PRF/RandomOracleModel.lean,roRealOutputandroIdealOutputsample the entire oracletable : S → Teagerly for finite nonemptySandT, andRODistinguisher X S T := X → T → ProbOracleComp (fun _ : S => T) BoolusesProbOracleCompwithD.IsOracleQueryBounded Qcounting oracle queries on every execution path. The proof ofroAdvantage_le_listGuessAdvantagerewritesroRealOutputwithPMF.bind_uniformOfFintype_updateand appliesProbOracleComp.IdenticalUntilBadinstead of the book's lazy associative array. - Random-index tie-breaking with
List.getD.listGuessToGuess Q Bhardcodes a uniform index draw belowQ(Fin.val <$> ProbComp.unifFin (Q - 1)) and defaults toClassical.arbitrary Spast the end ofB's list, holding for everyQ : ℕincludingQ = 0(unlikeListCDH.listCDHToCDH, which takes the index sampler as an argument solistCDHToCDHAdversarycan carry an efficiency certificate; the certified wrapper inCslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.ComputationalusesProbComp.sampleModIndex). - Information-theoretic asymptotic bound over query budgets; computational companion.
The book's Theorem 8.10 states that
BandB'are elementary wrappers aroundD. HereroToListGuessandroToGuesssample the whole oracle tableS → Teagerly inProbComp, which is not polynomial time whenSis exponential, so they are not the elementary wrappers of Theorem 8.10. Accordingly,negligible_roAdvantage_of_statisticalGuessHardtakesPolynomiallyBounded Q,(D n).IsOracleQueryBounded (Q n), and a guessing assumption∀ A, Negligible …ranging over all guessers with no efficiency bound, covering information-theoretically unpredictable sources but not computationally unpredictable ones such as the fourth example of §8.10.1 (pp. 325–326). Attack Game 11.3 in §11.5.2 (pp. 448–449) is such a source only when(Fintype.card Y)⁻¹is negligible: the hidden uniform component inYis guessed with probability(Fintype.card Y)⁻¹(guessAdvantage_bind_uniformOfFintype_fst_le), which is1whenYis a singleton. The certified elementary lazy-simulation wrapperslazyROToListGuessandlazyROToGuessover general encoded finite secret and digest families against computational unpredictability (§8.10.1, fourth example, p. 326) are inCslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational.
Main definitions #
Cslib.Crypto.KeyDerivation.GuessAdversary,guessOutput,guessAdvantage: Attack Game 8.3 andGuessadv[A, sample, info].Cslib.Crypto.KeyDerivation.ListGuessAdversary,listGuessOutput,listGuessAdvantage,listGuessToGuess: the list-guessing game,ListGuessadv[B, sample, info], and the list-to-singleton wrapper.Cslib.Crypto.KeyDerivation.RODistinguisher,RODistinguisher.IsOracleQueryBounded,roRealOutput,roIdealOutput,roAdvantage: key derivation in the random-oracle model andDist^{ro}adv[D, sample, info].Cslib.Crypto.KeyDerivation.roToListGuess,roToGuess: the eager-table list-guessing and singleton-guessing wrappers for Theorem 8.10 (not the elementary wrappers; seelazyROToListGuessandlazyROToGuessinRandomOracle.Computational).
Main results #
Cslib.Crypto.KeyDerivation.guessAdvantage_le_pure_maxPosteriorGuess,guessAdvantage_le_one_sub_errorProb_maxPosteriorGuess:maxPosteriorGuessis optimal even over randomizedGuessAdversaryinstances.Cslib.Crypto.KeyDerivation.guessAdvantage_le_card_mul_of_mass_le,guessAdvantage_uniformOfFintype_const,guessAdvantage_bind_uniformOfFintype_fst_le,guessAdvantage_uniformOfFintype_take_le: guessing bounds for the §8.10.1 examples and Attack Game 11.3.Cslib.Crypto.KeyDerivation.listGuessAdvantage_le_mul_guessAdvantage: list-to-singleton guessing reduction.Cslib.Crypto.KeyDerivation.length_le_of_mem_support_roToListGuess,roAdvantage_le_listGuessAdvantage,roAdvantage_le_mul_guessAdvantage,negligible_roAdvantage_of_statisticalGuessHard: the output-size, list-guessing, singleton-guessing, and information-theoretic asymptotic bounds for the eager-table wrappers, steps toward Theorem 8.10 and not the cited result (seelazyROToListGuessandlazyROToGuessinCslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computationalfor the elementary lazy-simulation wrappers over general encoded finite secret and digest families).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 8.10.1 (Attack Game 8.3 and motivating examples, pp. 325–326), Section 8.10.2 (Theorem 8.10, pp. 331–332), Section 11.5.1 (Theorem 11.4, p. 446, for the open CDH application), and Section 11.5.2 (Attack Game 11.3, pp. 448–449).
1. Attack Game 8.3: Guessing advantage and the examples of §8.10.1 #
A guessing adversary in Attack Game 8.3 ([BS23], §8.10.1, p. 326): given the leaked
side information info s : X, it outputs a candidate secret in S.
Attack Game 8.3 ([BS23], §8.10.1, p. 326): the challenger draws s ← sample, sends
info s to A, and A wins when its output equals s.
Guessadv[A, sample, info] ([BS23], Attack Game 8.3, p. 326): the probability that
A guesses s given info s.
The winning probability in guessOutput is
∑' s, sample s * (ProbComp.eval (A (info s))) s.
For any deterministic guessing function g : X → S, its success probability in guessOutput
equals the probability of {z | g z.1 = z.2} under the joint law of (info s, s).
The maximum a posteriori estimator Cslib.Probability.PMF.maxPosteriorGuess of the joint
distribution of (info s, s) maximizes guessAdvantage among all randomized guessing
adversaries.
Every randomized guessing adversary in Attack Game 8.3 has advantage at most one minus the
error probability of Cslib.Probability.PMF.maxPosteriorGuess on (info s, s).
If every secret has probability at most mass and info takes values in a finite type X,
every guessing adversary has advantage at most |X| * mass.
§8.10.1, first example ([BS23], pp. 325–326): when the secret is uniformly
distributed over a nonempty finite dictionary S and info is constant (no side information),
every adversary has guessing advantage (Fintype.card S)⁻¹.
When the secret is a pair (x, y) whose second component is drawn uniformly from Y
independently of the leaked first component x ([BS23], Attack Game 11.3 in §11.5.2,
pp. 448–449), every adversary has guessing advantage at most (Fintype.card Y)⁻¹.
§8.10.1, third example ([BS23], pp. 325–326): when the secret is a uniformly
distributed BitString (k + m) and info leaks the first k bits
(Fin.take k (Nat.le_add_right k m)), every adversary has guessing advantage at most 1 / 2 ^ m
(for k = 64, m = 64, at most 1 / 2 ^ 64).
2. List guessing game and list-to-singleton reduction (§8.10.2, p. 331) #
A list-guessing adversary ([BS23], §8.10.2, p. 331): given info s : X, it outputs a
list of candidate secrets in S.
The list-guessing game ([BS23], §8.10.2, p. 331): the challenger draws s ← sample,
sends info s to B, and B wins when s is a member of its output list.
ListGuessadv[B, sample, info] ([BS23], §8.10.2, p. 331): the probability that the
secret s lies in the list output by B (info s).
Convert a list-guessing adversary into a singleton-guessing adversary ([BS23],
§8.10.2, p. 331): run B x to obtain a list of candidates, draw an index uniformly below Q
(Fin.val <$> ProbComp.unifFin (Q - 1)), and output the entry at that position (or an arbitrary
element of S when the index falls past the end of the list).
List-to-singleton guessing reduction ([BS23], §8.10.2, p. 331): if every list
output by B has length at most Q, then listGuessAdvantage sample info B ≤ Q * guessAdvantage sample info (listGuessToGuess Q B).
3. Key derivation in the random-oracle model and Theorem 8.10 (§8.10.2, pp. 331–332) #
A key-derivation distinguisher in the random-oracle model ([BS23], §8.10.2, p. 331):
given the side information x : X and a candidate key t : T, it runs an adaptive test with
private coins and oracle access to S → T.
D makes at most Q random-oracle queries on every path for every input (x, t), whatever
its private samples and the oracle replies.
Experiment 0 of key derivation in the random-oracle model ([BS23], §8.10.2, p. 331):
sample a random oracle table : S → T, then play KeyDerivation.realOutput with derive = table
and D answering oracle queries from table.
Experiment 1 of key derivation in the random-oracle model ([BS23], §8.10.2, p. 331):
sample a random oracle table : S → T, then play KeyDerivation.idealOutput with a uniform key on
T and D answering oracle queries from table.
Dist^{ro}adv[D, sample, info] ([BS23], §8.10.2, p. 331): the distinguishing
advantage of D between (info s, O(s)) and (info s, t) when O : S → T is a random oracle.
Eager-table (uniformOfFintype (S → T)) list-guessing wrapper B for Theorem 8.10
([BS23], §8.10.2, pp. 331–332): given x = info s, sample a random oracle
table : S → T and an independent key t : T, run D x t against table, and output the list of
points at which D x t queried table. Because it samples the whole oracle table S → T eagerly
in ProbComp, this is not the elementary wrapper of Theorem 8.10; lazyROToListGuess (and
lazyROToGuess) in CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational
are the elementary lazy-simulation wrappers over general encoded finite domains.
Eager-table (uniformOfFintype (S → T)) singleton-guessing wrapper B' for Theorem 8.10
([BS23], §8.10.2, p. 331): run roToListGuess D x and select one of its first Q
queried points uniformly at random. Because roToListGuess D samples the whole oracle table
S → T eagerly in ProbComp, this is not the elementary wrapper of Theorem 8.10; lazyROToGuess
(built on lazyROToListGuess) in
CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational is the elementary
lazy-simulation wrapper over general encoded finite domains.
Eager-table step toward the output-size bound of [BS23], Theorem 8.10
(§8.10.2, p. 331), not the cited result: if D makes at most Q random-oracle queries on every
path, then the eager-table list guesser roToListGuess D outputs a list of length at most Q on
every supported run. For the elementary lazy-simulation wrapper lazyROToListGuess, see
length_le_of_mem_support_lazyROToListGuess in
CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational.
Eager-table step toward the list-guessing inequality of [BS23], Theorem 8.10
(§8.10.2, pp. 331–332), not the cited result: in the random-oracle model, a KDF distinguisher's
advantage is at most the list-guessing advantage of roToListGuess D. The theorem asks for a list
guesser that is an elementary wrapper around D; roToListGuess D samples the whole oracle table
uniformOfFintype (S → T) eagerly in ProbComp, so it is not one. The elementary lazy-simulation
wrapper lazyROToListGuess in
CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational satisfies this
inequality (roAdvantage_toRODistinguisher_le_listGuessAdvantage for exact uniform digest samplers
and roAdvantage_toRODistinguisher_le_listGuessAdvantage_add for approximate ones).
Eager-table step toward the singleton-guessing inequality of [BS23], Theorem 8.10
(§8.10.2, p. 331), not the cited result: if D makes at most Q random-oracle queries on every
path, its KDF distinguishing advantage in the random-oracle model is at most
Q * guessAdvantage sample info (roToGuess Q D). The theorem asks for a guesser that is an
elementary wrapper around D; roToGuess Q D samples the whole oracle table
uniformOfFintype (S → T) eagerly in ProbComp, so it is not one.
roAdvantage_toRODistinguisher_le_mul_guessAdvantage_add in
CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational is the concrete
variant with the elementary lazy-simulation wrapper lazyROToGuess: its fair-coin index and digest
sampling add Q / 2 ^ width + (Q + 1) * εT to the bound, which the asymptotic corollary
SecretGuessHard.negligible_roAdvantage absorbs.
Statistical-guessing step toward the asymptotic reading of [BS23], Theorem 8.10
(§8.10.2, p. 331), not the cited result: if a family of random-oracle KDF distinguishers makes
polynomially many random-oracle queries and every family of guessing adversaries, with no
efficiency bound, has negligible guessing advantage against the source, then the KDF
distinguishing advantage is negligible. Theorem 8.10 needs guessing hardness only against its
elementary wrappers, which also covers computationally unpredictable sources (§8.10.1, fourth
example, pp. 325–326); this premise holds only for information-theoretically unpredictable ones,
such as Attack Game 11.3 in §11.5.2 (pp. 448–449) when its hidden uniform component ranges over a
set Y with (Fintype.card Y)⁻¹ negligible, since that component is guessed with probability
(Fintype.card Y)⁻¹ (guessAdvantage_bind_uniformOfFintype_fst_le), which is 1 when Y is a
singleton. SecretGuessHard.negligible_roAdvantage in
CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational is the computational
form over general encoded finite secret and digest families.