Documentation

CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle.Computational

Computational random-oracle key derivation via lazy simulation #

Formalizes the computational form of [BS23], Section 8.10.1 (Attack Game 8.3 and its fourth motivating example, computational unpredictability of a secret source, pp. 325–326) and Section 8.10.2 (Theorem 8.10, pp. 331–332) over general encoded finite secret families S : ℕ → Type, side-information families X : ℕ → Type, and digest/key families T : ℕ → Type, together with the specialization to BitString (secLen n) secrets and BitString (outLen n) keys.

Whereas CslibFrontier.Crypto.Computational.KeyDerivation.RandomOracle states eager-table (uniformOfFintype (S → T)) concrete bounds and an information-theoretic (unbounded-guesser) asymptotic transfer for arbitrary finite nonempty S and T, as steps toward Theorem 8.10, this module constructs the elementary lazy-simulation wrappers lazyROToListGuess and lazyROToGuess over associative-list caches (Cslib.Probability.cachedSamplerOracle), proves their uniform strict PPT certificates from a word-oracle distinguisher's IsOraclePPTOn certificate, and derives the asymptotic random-oracle KDF security transfer under the standard computational unpredictability assumption SecretGuessHard.

Differences from the printed book #

  1. General encoded finite families, arbitrary source and side-information maps. At security parameter n, secrets lie in a nonempty finite type S n encoded by encS n : S n ↪ List Bool with canonical partial decoder decS n : List Bool → Option (S n) (decS n w = some s ↔ encS n s = w, polynomial-time isSome domain recognition, and a polynomial-time fallback element defaultS n); digests and keys lie in a nonempty finite type T n encoded by encT n : T n ↪ List Bool; and public side information lies in X n encoded by encX n : X n ↪ List Bool. Neither sample n nor info n is required to be efficiently computable; SecretGuessHard.negligible_roAdvantage requires only that encX n (info n s) has polynomial length in n on (sample n).support.
  2. Word-oracle distinguishers adapted to typed random-oracle games. Distinguishers operate on words (WordRODistinguisher X) and are adapted to RODistinguisher by toRODistinguisher, answering canonical queries encS n q from the typed random oracle S n → T n via encT n and returning [] on malformed queries outside Set.range (encS n).
  3. Fair-coin sampling of digests and query indices. Because strict-PPT Turing machines flip fair coins, non-power-of-two digest spaces T n (such as ZMod q for an odd modulus q) admit no exact dyadic uniform sampler. The lazy simulator draws keys and cache-miss digests from a caller-supplied strict-PPT sampler sampleT n within statistical distance εT n of uniformOfFintype (T n), adding (Q n + 1) * εT n to the concrete bounds (0 when sampleT n is exact uniform, as for BitString (outLen n)), and lazyROToGuess selects a candidate query index via ProbComp.sampleModIndex (width n) (Q n), adding Q n / 2 ^ width n. Both error terms are absorbed in SecretGuessHard.negligible_roAdvantage when sampleT is StatisticallyIndistinguishable from uniform and width = id.

Main definitions #

Main results #

References #

1. Families of guessing adversaries and computational unpredictability #

@[reducible, inline]

A family of singleton-guessing adversaries in Attack Game 8.3 ([BS23], §8.10.1, p. 326) over secret family S and side-information family X.

def Cslib.Crypto.KeyDerivation.GuessFamilyAdversary.IsPPT {X S : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) (encS : (n : ℕ) → S n ↪ List Bool) (A : GuessFamilyAdversary X S) :

A singleton-guessing family adversary is uniform strict PPT when one machine reads (1ⁿ, encX n x) (encSigma encUnary encX) and writes the encoded candidate secret encS n s.

@[reducible, inline]

A family of list-guessing adversaries ([BS23], §8.10.2, p. 331) over secret family S and side-information family X.

def Cslib.Crypto.KeyDerivation.ListGuessFamilyAdversary.IsPPT {X S : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) (encS : (n : ℕ) → S n ↪ List Bool) (B : ListGuessFamilyAdversary X S) :

A list-guessing family adversary is uniform strict PPT when one machine reads (1ⁿ, encX n x) (encSigma encUnary encX) and writes the framed list of encoded candidate secrets.

def Cslib.Crypto.KeyDerivation.SecretGuessHard {X S : ℕ → Type} [(n : ℕ) → DecidableEq (S n)] (encX : (n : ℕ) → X n ↪ List Bool) (encS : (n : ℕ) → S n ↪ List Bool) (sample : (n : ℕ) → PMF (S n)) (info : (n : ℕ) → S n → X n) :

Computational unpredictability of a secret source given public side information ([BS23], Section 8.10.1, Attack Game 8.3 and its fourth example, p. 326): every uniform strict PPT guessing adversary (GuessFamilyAdversary.IsPPT encX encS) wins Attack Game 8.3 with negligible probability.

Relative to the printed source: sample n and info n need not be efficiently computable, and guessers are uniform strict PPT machines reading (1ⁿ, encX n x) and writing encS n s.

2. Word-oracle KDF distinguishers and typed random-oracle adapter #

Input (1ⁿ, x, z) of a WordRODistinguisher: the security parameter n, the public side information x : X n, and the candidate key word z : List Bool.

  • secParam : ℕ

    The security parameter.

  • sideInfo : X self.secParam

    The leaked public side information.

  • key : List Bool

    The candidate key word.

theorem Cslib.Crypto.KeyDerivation.encWordROInput_secParam_polyTime {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → WordROInput X} :
theorem Cslib.Crypto.KeyDerivation.encWordROInput_secParam_budget {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WordROInput X} :
theorem Cslib.Crypto.KeyDerivation.encWordROInput_key_polyTime {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → WordROInput X} :
theorem Cslib.Crypto.KeyDerivation.encWordROInput_mk_polyTime {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ℕ} {x1 : (c : γ) → X (x0 c)} {x2 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn Turing.MultiTapeTM.encUnary) (h1 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (encX (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits) (h2 : Turing.MultiTapeTM.ComputableInPolyTime x2 encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { secParam := x0 x, sideInfo := x1 x, key := x2 x }) encIn (encWordROInput encX)
@[reducible, inline]

The tuple of the fields of encWordROInput.

theorem Cslib.Crypto.KeyDerivation.encWordROInput_sideInfo_polyTime {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → WordROInput X} :
theorem Cslib.Crypto.KeyDerivation.encWordROInput_sideInfo_budget {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WordROInput X} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encWordROInput encX) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (encX (g✝ c).secParam) (g✝ c).sideInfo) encIn✝ Turing.MultiTapeTM.encBits S✝
@[simp]
theorem Cslib.Crypto.KeyDerivation.encWordROInput_mk_budget {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : (c : γ) → X (x0 c)} {x2 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (encX (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { secParam := x0 x, sideInfo := x1 x, key := x2 x }) encIn (encWordROInput encX) budget
theorem Cslib.Crypto.KeyDerivation.encWordROInput_key_budget {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WordROInput X} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encWordROInput encX) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).key) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.KeyDerivation.encWordROInput_mk_inO {X : ℕ → Type} (encX : (n : ℕ) → X n ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : (c : γ) → X (x0 c)} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (encX (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encBits T2 S2) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { secParam := x0 x, sideInfo := x1 x, key := x2 x }) encIn (encWordROInput encX) (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)

Field-tuple encoding of WordROInput X: the unary security parameter 1ⁿ (framed), followed by encX n x (framed), followed by the raw candidate key word z (unframed).

@[reducible, inline]

A family of word-oracle KDF distinguishers in the random-oracle model: given the security parameter n, public side information x : X n, and candidate key word z : List Bool, it queries a single word oracle and outputs a bit.

One uniform strict oracle-PPT machine reads (1ⁿ, x, z) (encWordROInput encX) and interacts with the word oracle.

def Cslib.Crypto.KeyDerivation.toRODistinguisher {X S T : ℕ → Type} (decS : (n : ℕ) → List Bool → Option (S n)) (encT : (n : ℕ) → T n ↪ List Bool) (D : WordRODistinguisher X) (n : ℕ) :
RODistinguisher (X n) (S n) (T n)

Adapt a word-oracle distinguisher to the typed random-oracle KDF game on S n and T n: pass encT n t as the candidate key, answer canonical queries (decS n q = some s) by querying s and encoding the reply with encT n, and answer malformed queries (decS n q = none) with [].

@[reducible, inline]
abbrev Cslib.Crypto.KeyDerivation.toBitStringRODistinguisher {X : ℕ → Type} (secLen outLen : ℕ → ℕ) (D : WordRODistinguisher X) (n : ℕ) :
RODistinguisher (X n) (BitString (secLen n)) (BitString (outLen n))

Specialization of toRODistinguisher to BitString (secLen n) secrets and BitString (outLen n) digests via OracleCodec.bitString.

3. Lazy list-guessing wrapper #

noncomputable def Cslib.Crypto.KeyDerivation.lazyROToListGuess {X S T : ℕ → Type} (decS : (n : ℕ) → List Bool → Option (S n)) (encT : (n : ℕ) → T n ↪ List Bool) (sampleT : (n : ℕ) → ProbComp (T n)) (D : WordRODistinguisher X) :

The elementary lazy-simulation list-guessing wrapper B of Theorem 8.10 ([BS23], §8.10.2, pp. 331–332): draw an independent candidate key t ← sampleT n, run D n x (encT n t) against cachedSamplerOracle (fun w => (decS n w).isSome) (encT n <$> sampleT n) starting from [], and decode the cached valid queries via decS n.

theorem Cslib.Crypto.KeyDerivation.length_le_of_mem_support_lazyROToListGuess {X S T : ℕ → Type} {decS : (n : ℕ) → List Bool → Option (S n)} {encT : (n : ℕ) → T n ↪ List Bool} {sampleT : (n : ℕ) → ProbComp (T n)} {D : WordRODistinguisher X} {n Q : ℕ} {x : X n} (hQ : ∀ t ∈ (sampleT n).eval.support, (D n x ((encT n) t)).IsQueryBounded Q) {l : List (S n)} (hl : l ∈ (lazyROToListGuess decS encT sampleT D n x).eval.support) :

Lazy output-size bound ([BS23], Theorem 8.10, §8.10.2, p. 331): if D n x (encT n t) makes at most Q oracle queries for every supported t of sampleT n, then every list output by lazyROToListGuess decS encT sampleT D n x has length at most Q.

theorem Cslib.Crypto.KeyDerivation.roAdvantage_toRODistinguisher_le_listGuessAdvantage_add {X S T : ℕ → Type} [(n : ℕ) → Fintype (S n)] [(n : ℕ) → DecidableEq (S n)] [(n : ℕ) → Fintype (T n)] [∀ (n : ℕ), Nonempty (T n)] {encS : (n : ℕ) → S n ↪ List Bool} {decS : (n : ℕ) → List Bool → Option (S n)} (hdecS : ∀ (n : ℕ) (w : List Bool) (s : S n), decS n w = some s ↔ (encS n) s = w) (encT : (n : ℕ) → T n ↪ List Bool) (sampleT : (n : ℕ) → ProbComp (T n)) (sample : (n : ℕ) → PMF (S n)) (info : (n : ℕ) → S n → X n) (D : WordRODistinguisher X) (n Q : ℕ) {εT : NNReal} (hcloseT : Probability.CloseTo (Probability.PMF.uniformOfFintype (T n)) (sampleT n).eval ↑εT) (hQ : ∀ s ∈ (sample n).support, ∀ t ∈ (sampleT n).eval.support, (D n (info n s) ((encT n) t)).IsQueryBounded Q) :
roAdvantage (sample n) (info n) (toRODistinguisher decS encT D n) ≤ listGuessAdvantage (sample n) (info n) (lazyROToListGuess decS encT sampleT D n) + ↑(Q + 1) * εT

Lazy list-guessing inequality of Theorem 8.10 with approximate digest sampling ([BS23], §8.10.2, pp. 331–332): when sampleT n is within statistical distance εT of uniformOfFintype (T n) and D n (info n s) (encT n t) makes at most Q oracle queries on supported secrets s and candidate keys t, the random-oracle KDF advantage is at most listGuessAdvantage (sample n) (info n) (lazyROToListGuess decS encT sampleT D n) + (Q + 1) * εT.

theorem Cslib.Crypto.KeyDerivation.roAdvantage_toRODistinguisher_le_listGuessAdvantage {X S T : ℕ → Type} [(n : ℕ) → Fintype (S n)] [(n : ℕ) → DecidableEq (S n)] [(n : ℕ) → Fintype (T n)] [∀ (n : ℕ), Nonempty (T n)] {encS : (n : ℕ) → S n ↪ List Bool} {decS : (n : ℕ) → List Bool → Option (S n)} (hdecS : ∀ (n : ℕ) (w : List Bool) (s : S n), decS n w = some s ↔ (encS n) s = w) (encT : (n : ℕ) → T n ↪ List Bool) (sampleT : (n : ℕ) → ProbComp (T n)) (sample : (n : ℕ) → PMF (S n)) (info : (n : ℕ) → S n → X n) (D : WordRODistinguisher X) (n : ℕ) (hunif : (sampleT n).eval = Probability.PMF.uniformOfFintype (T n)) :
roAdvantage (sample n) (info n) (toRODistinguisher decS encT D n) ≤ listGuessAdvantage (sample n) (info n) (lazyROToListGuess decS encT sampleT D n)

Exact lazy list-guessing inequality of Theorem 8.10 ([BS23], §8.10.2, pp. 331–332): when sampleT n samples uniformOfFintype (T n) exactly, the random-oracle KDF distinguishing advantage of toRODistinguisher decS encT D n is at most the list-guessing advantage of lazyROToListGuess decS encT sampleT D n, with no query-bound hypothesis.

theorem Cslib.Crypto.KeyDerivation.isPPT_lazyROToListGuess {X S T : ℕ → Type} {encX : (n : ℕ) → X n ↪ List Bool} {encS : (n : ℕ) → S n ↪ List Bool} {decS : (n : ℕ) → List Bool → Option (S n)} {encT : (n : ℕ) → T n ↪ List Bool} {sampleT : (n : ℕ) → ProbComp (T n)} (hdecS : ∀ (n : ℕ) (w : List Bool) (s : S n), decS n w = some s ↔ (encS n) s = w) (hisSome : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => (decS p.1 p.2).isSome) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (hsampleT : Probability.IsPPTOn Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits fun (n : ℕ) => ⇑(encT n) <$> sampleT n) {D : WordRODistinguisher X} (hD : WordRODistinguisher.IsPPT encX D) :
ListGuessFamilyAdversary.IsPPT encX encS (lazyROToListGuess decS encT sampleT D)

The lazy list-guessing wrapper is efficient: lazyROToListGuess decS encT sampleT D is uniform strict PPT whenever (n, w) ↦ (decS n w).isSome is computable in polynomial time, n ↦ encT n <$> sampleT n is uniform strict PPT, and D is uniform strict oracle-PPT.

4. Lazy singleton-guessing wrapper and computational Theorem 8.10 #

noncomputable def Cslib.Crypto.KeyDerivation.lazyROToGuess {X S T : ℕ → Type} (width Q : ℕ → ℕ) (defaultS : (n : ℕ) → S n) (decS : (n : ℕ) → List Bool → Option (S n)) (encT : (n : ℕ) → T n ↪ List Bool) (sampleT : (n : ℕ) → ProbComp (T n)) (D : WordRODistinguisher X) :

The elementary lazy-simulation singleton-guessing wrapper B' of Theorem 8.10 ([BS23], §8.10.2, pp. 331–332) with fair-coin modular index sampling: run lazyROToListGuess decS encT sampleT D n x, draw an index from ProbComp.sampleModIndex (width n) (Q n), and return the entry at that position (or defaultS n past the end of the list).

theorem Cslib.Crypto.KeyDerivation.isPPT_lazyROToGuess {X S T : ℕ → Type} {encX : (n : ℕ) → X n ↪ List Bool} {encS : (n : ℕ) → S n ↪ List Bool} {width Q : ℕ → ℕ} {defaultS : (n : ℕ) → S n} {decS : (n : ℕ) → List Bool → Option (S n)} {encT : (n : ℕ) → T n ↪ List Bool} {sampleT : (n : ℕ) → ProbComp (T n)} (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hQ : Turing.MultiTapeTM.ComputableInPolyTime Q Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hdefault : Turing.MultiTapeTM.ComputableInPolyTime (fun (n : ℕ) => (encS n) (defaultS n)) Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) (hdecS : ∀ (n : ℕ) (w : List Bool) (s : S n), decS n w = some s ↔ (encS n) s = w) (hisSome : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => (decS p.1 p.2).isSome) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (hsampleT : Probability.IsPPTOn Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits fun (n : ℕ) => ⇑(encT n) <$> sampleT n) {D : WordRODistinguisher X} (hD : WordRODistinguisher.IsPPT encX D) :
GuessFamilyAdversary.IsPPT encX encS (lazyROToGuess width Q defaultS decS encT sampleT D)

The lazy singleton-guessing wrapper is efficient: lazyROToGuess width Q defaultS decS encT sampleT D is uniform strict PPT whenever width and Q are computable in polynomial time in unary, (n, w) ↦ (decS n w).isSome and n ↦ encS n (defaultS n) are computable in polynomial time, n ↦ encT n <$> sampleT n is uniform strict PPT, and D is uniform strict oracle-PPT.

theorem Cslib.Crypto.KeyDerivation.roAdvantage_toRODistinguisher_le_mul_guessAdvantage_add {X S T : ℕ → Type} [(n : ℕ) → Fintype (S n)] [(n : ℕ) → DecidableEq (S n)] [(n : ℕ) → Fintype (T n)] [∀ (n : ℕ), Nonempty (T n)] {encS : (n : ℕ) → S n ↪ List Bool} {decS : (n : ℕ) → List Bool → Option (S n)} (hdecS : ∀ (n : ℕ) (w : List Bool) (s : S n), decS n w = some s ↔ (encS n) s = w) (width Q : ℕ → ℕ) (defaultS : (n : ℕ) → S n) (encT : (n : ℕ) → T n ↪ List Bool) (sampleT : (n : ℕ) → ProbComp (T n)) (sample : (n : ℕ) → PMF (S n)) (info : (n : ℕ) → S n → X n) (D : WordRODistinguisher X) (n : ℕ) {εT : NNReal} (hcloseT : Probability.CloseTo (Probability.PMF.uniformOfFintype (T n)) (sampleT n).eval ↑εT) (hQ : ∀ s ∈ (sample n).support, ∀ t ∈ (sampleT n).eval.support, (D n (info n s) ((encT n) t)).IsQueryBounded (Q n)) :
roAdvantage (sample n) (info n) (toRODistinguisher decS encT D n) ≤ ↑(Q n) * guessAdvantage (sample n) (info n) (lazyROToGuess width Q defaultS decS encT sampleT D n) + ↑(Q n) / 2 ^ width n + ↑(Q n + 1) * εT

Concrete singleton-guessing inequality of Theorem 8.10 ([BS23], §8.10.2, pp. 331–332), accounting for fair-coin index and digest sampling: when sampleT n is within statistical distance εT of uniformOfFintype (T n) and D n (info n s) (encT n t) makes at most Q n oracle queries on supported secrets s and candidate keys t, the random-oracle KDF distinguishing advantage is at most Q n * guessAdvantage (sample n) (info n) (lazyROToGuess width Q defaultS decS encT sampleT D n) + Q n / 2 ^ width n + (Q n + 1) * εT.

theorem Cslib.Crypto.KeyDerivation.SecretGuessHard.negligible_roAdvantage {X S T : ℕ → Type} [(n : ℕ) → Fintype (S n)] [(n : ℕ) → DecidableEq (S n)] [(n : ℕ) → Fintype (T n)] [∀ (n : ℕ), Nonempty (T n)] {encX : (n : ℕ) → X n ↪ List Bool} {encS : (n : ℕ) → S n ↪ List Bool} {decS : (n : ℕ) → List Bool → Option (S n)} {defaultS : (n : ℕ) → S n} {encT : (n : ℕ) → T n ↪ List Bool} {sampleT : (n : ℕ) → ProbComp (T n)} {sample : (n : ℕ) → PMF (S n)} {info : (n : ℕ) → S n → X n} (hguess : SecretGuessHard encX encS sample info) (hdecS : ∀ (n : ℕ) (w : List Bool) (s : S n), decS n w = some s ↔ (encS n) s = w) (hisSome : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => (decS p.1 p.2).isSome) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (hdefault : Turing.MultiTapeTM.ComputableInPolyTime (fun (n : ℕ) => (encS n) (defaultS n)) Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) (hsampleT : Probability.IsPPTOn Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits fun (n : ℕ) => ⇑(encT n) <$> sampleT n) (hcloseT : StatisticallyIndistinguishable (fun (n : ℕ) => Probability.PMF.uniformOfFintype (T n)) fun (n : ℕ) => (sampleT n).eval) (hinfo : ∃ (c : ℕ) (d : ℕ), ∀ (n : ℕ), ∀ s ∈ (sample n).support, ((encX n) (info n s)).length ≤ c * (n + 1) ^ d) {D : WordRODistinguisher X} (hD : WordRODistinguisher.IsPPT encX D) :
Negligible fun (n : ℕ) => roAdvantage (sample n) (info n) (toRODistinguisher decS encT D n)

Computational Theorem 8.10 ([BS23], §8.10.2, pp. 331–332, with §8.10.1, Attack Game 8.3, p. 326): over encoded finite secret families S and digest/key families T, if the secret source is computationally unpredictable (SecretGuessHard), decS is the canonical partial decoder of encS with polynomial-time domain recognition and a polynomial-time fallback element defaultS, sampleT is a uniform strict-PPT sampler statistically indistinguishable from uniformOfFintype (T n), and encX n (info n s) has polynomial length in n on (sample n).support, then every uniform strict oracle-PPT word distinguisher has negligible random-oracle KDF distinguishing advantage.

5. Specialization to fixed-width bit strings #

theorem Cslib.Crypto.KeyDerivation.SecretGuessHard.negligible_roAdvantage_bitString {X : ℕ → Type} {encX : (n : ℕ) → X n ↪ List Bool} {secLen outLen : ℕ → ℕ} {sample : (n : ℕ) → PMF (BitString (secLen n))} {info : (n : ℕ) → BitString (secLen n) → X n} (hguess : SecretGuessHard encX (fun (n : ℕ) => Turing.MultiTapeTM.encBitString (secLen n)) sample info) (hsec : Turing.MultiTapeTM.ComputableInPolyTime secLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hout : Turing.MultiTapeTM.ComputableInPolyTime outLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hinfo : ∃ (c : ℕ) (d : ℕ), ∀ (n : ℕ), ∀ s ∈ (sample n).support, ((encX n) (info n s)).length ≤ c * (n + 1) ^ d) {D : WordRODistinguisher X} (hD : WordRODistinguisher.IsPPT encX D) :
Negligible fun (n : ℕ) => roAdvantage (sample n) (info n) (toBitStringRODistinguisher secLen outLen D n)

Computational Theorem 8.10 over fixed-width bit strings ([BS23], §8.10.2, pp. 331–332): specialization of SecretGuessHard.negligible_roAdvantage to BitString (secLen n) secrets and BitString (outLen n) keys when secLen and outLen are computable in polynomial time in unary.