Documentation

CslibFrontier.Crypto.Computational.NaorReingold.Security

Computational security of the Naor–Reingold PRF from DDH #

This module completes the efficient lazy-sampling Decisional Diffie–Hellman (DDH) reduction and the universal-hash bit-string pseudorandom-function bridge for the Naor–Reingold PRF over a PrimeOrderGroupFamily ([BS23], Section 10.11, Exercises 10.4, 10.8, 10.11, pp. 424–426, and Section 4.10, Exercise 4.18, p. 172; [NR04], Section 4.1, Construction 4.1, Theorem 4.1, Lemma 4.2, Construction 4.2, Theorem 4.3, and Remark 4.2):

  1. Inverse-order bound from DDH: DDH.negligible_expected_inv_order, imported from CslibFrontier.Crypto.Computational.DiffieHellman.Order, makes the setup-averaged inverse group order negligible; it bounds the hashed-PRF error terms below.
  2. Word-level adaptive group-PRF games and lazy-sampling IsOraclePPT DDH reduction: naorReingoldFrontierOracle memoizes ddhFixedUWordRerandomize only on the k-bit prefixes queried by an OracleDistinguisher and evaluates the remaining suffix via naorReingoldWordSuffix. Choosing k ← sampleDyadicIndex (inLen n) yields the uniform strict PPT DDH distinguisher naorReingoldToDDHDistinguisher, proving both quantitative single- distinguisher bounds and asymptotic security under F.DDH setup alone: for the keys drawn with the fair-coin sampler sampleNaorReingoldExp (DDH.negligible_naorReingoldProbGame), through the ideal-sampling step with exactly uniform keys (DDH.negligible_naorReingoldWordGame_ideal).
  3. Universal-hash bit-string Naor–Reingold PRF (after [NR04], not checked): composing naorReingoldWordEval with linearHashKDF under a public universal-hash seed (F.withSeed and F.seededSetup) maps a uniform group element to an outLen n-bit string that is jointly close to uniform with the public seed, with error bounded by the Leftover Hash Lemma; a multi-query Leftover Hash Lemma bound via PMF.dist_bind_pair_pi_le_sum yields adaptive bit-string PRF security for exponents drawn with the fair-coin sampler (DDH.negligible_naorReingoldHashedProbGame), through the ideal-key-sampling steps with exactly uniform exponents (DDH.negligible_naorReingoldHashedGame_ideal, DDH.negligible_naorReingoldHashedGame_ideal_const).

Main definitions #

Main results #

Ideal-sampling steps #

References #

Word-level Naor–Reingold group-PRF games and prefix hybrids #

Sample a nearly-uniform modular exponent modulo F.order d via F.sampleExp with n + (F.encDesc d).length statistical slack bits so that the statistical error 1 / 2 ^ (n + |encDesc d|) offsets polynomial query counts depending on |encDesc d| (original).

Every value supported by sampleNaorReingoldExp is strictly less than F.order d.

Projected to ZMod (F.order d), sampleNaorReingoldExp n d has law F.sampleModZModLaw (n + (F.encDesc d).length) d.

Deterministic word-level oracle wrapper encoding fn : BitString m → F.Carrier d on valid m-bit queries and returning [] on malformed queries.

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldWordRealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen : ℕ → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Setup-parameterized real Naor–Reingold group-PRF game with exact uniform ZMod (F.order d) exponents ([BS23], Exercise 10.4, p. 424; [NR04], Construction 4.1 & Theorem 4.1).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldProbRealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen : ℕ → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Setup-parameterized executable Naor–Reingold group-PRF real game sampling modular exponents via sampleNaorReingoldExp (original).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldWordIdealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen : ℕ → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Setup-parameterized ideal random group-function game against OracleDistinguisher ([BS23], Exercise 10.4, p. 424; [NR04], Theorem 4.1).

Lazy-sampling frontier oracle and IsOraclePPT DDH distinguisher #

@[reducible, inline]

Association-list cache mapping queried k-bit prefixes to encoded group-element pairs.

Executable rerandomized pair sampler for naorReingoldFrontierOracle: draw two exponents via sampleNaorReingoldExp and apply ddhFixedUWordRerandomize.

Stateful level-k frontier oracle for Naor–Reingold ([BS23], Exercises 10.4(b) & 4.18(b); [NR04], Theorem 4.1): on a valid m-bit query, memoize a freshly rerandomized DDH pair on query.take k, select the query[k] child, and evaluate the remaining suffix with naorReingoldWordSuffix. Malformed queries return [] without modifying the cache.

Single-challenge uniform strict PPT DDH distinguisher constructed from an adaptive PRF distinguisher adv that reads the group parameters directly: sample a hybrid level k ← sampleDyadicIndex (inLen n), draw suffix exponents αs, and run adv n d against naorReingoldFrontierOracle, given the encodings of the three DDH elements, from an empty cache ([BS23], Exercises 10.4(b) & 10.11; [NR04], Theorem 4.1).

naorReingoldDescToDDHDistinguisher for an OracleDistinguisher, which reads the encoded group parameters F.encDesc d.

naorReingoldToDDHDistinguisher is uniform strict PPT whenever inLen is computable in polynomial time in unary and adversary satisfies IsOraclePPT encBool ([BS23], Exercise 10.4(b); [NR04], Theorem 4.1).

Quantitative and asymptotic DDH security of the Naor–Reingold group-PRF #

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_naorReingoldWordGame_le_ideal (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen : ℕ → ℕ) (adversary : OracleDistinguisher) (n : ℕ) (Q : F.Desc → ℕ) {ε : NNReal} (hQ : ∀ d ∈ (setup n).support, ProbOracleComp.IsQueryBounded (adversary n (F.encDesc d)) (Q d)) (hε : ∀ d ∈ (setup n).support, ↑(inLen n + 2 * Q d) / 2 ^ (n + (F.encDesc d).length) ≤ ε) :
(F.naorReingoldWordRealGame setup inLen adversary n).advantage (F.naorReingoldWordIdealGame setup inLen adversary n) ≤ ↑(Probability.dyadicSize (inLen n)) * ((F.ddhRealGame setup (F.naorReingoldToDDHDistinguisher inLen adversary) n).advantage (F.ddhRandomGame setup (F.naorReingoldToDDHDistinguisher inLen adversary) n) + 2 * ε + (∑' (d : F.Desc), (setup n) d * (↑(F.order d))⁻¹).toNNReal)

Ideal-sampling step toward [BS23], Exercise 10.4 (p. 424), not the cited result: in naorReingoldWordRealGame, whose keys are drawn exactly uniformly from ZMod (F.order d), if adversary makes at most Q d queries on d ∈ (setup n).support with modular-sampling slack bounded by ε, then its PRF distinguishing advantage is at most dyadicSize (inLen n) times the single-challenge DDH advantage of naorReingoldToDDHDistinguisher plus 2 * ε plus the setup-averaged inverse group order. With the fair-coin keys of naorReingoldProbRealGame the bound gains the term of advantage_naorReingoldProbRealGame_wordRealGame_le.

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_naorReingoldProbRealGame_wordRealGame_le (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen : ℕ → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :
(F.naorReingoldProbRealGame setup inLen adversary n).advantage (F.naorReingoldWordRealGame setup inLen adversary n) ≤ ↑(inLen n + 1) / 2 ^ n

Modular-sampling distance between naorReingoldProbRealGame and naorReingoldWordRealGame: replacing (inLen n + 1) calls to sampleNaorReingoldExp by exact uniform ZMod (F.order d) exponents changes the output distribution by at most (inLen n + 1) / 2 ^ n.

Ideal-sampling step toward [BS23], Exercise 10.4 (p. 424), not the cited result: if F.DDH setup holds and inLen is computable in polynomial time in unary, no IsOraclePPT adversary can distinguish naorReingoldWordRealGame, whose keys are drawn exactly uniformly from ZMod (F.order d), from naorReingoldWordIdealGame with non-negligible advantage. The theorem for the keys drawn with the fair-coin sampler sampleNaorReingoldExp is DDH.negligible_naorReingoldProbGame, which uses this one.

Asymptotic DDH security of the executable Naor–Reingold group-PRF (naorReingoldProbRealGame) ([BS23], Exercise 10.4; [NR04], Theorem 4.1): if F.DDH setup holds and inLen is computable in polynomial time in unary, no IsOraclePPT adversary can distinguish naorReingoldProbRealGame from naorReingoldWordIdealGame with non-negligible advantage.

Universal-hash bit-string Naor–Reingold PRF #

def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldHashedWordEval (F : PrimeOrderGroupFamily) (outLen : ℕ) (bound : F.Desc → ℕ) (d : F.Desc) (seed : List Bool) (α₀ : ℕ) (αs : List ℕ) (xs : List Bool) :

Word-level universal-hash Naor–Reingold evaluation (paraphrase of [NR04], Section 4.1, Construction 4.2): evaluate naorReingoldWordEval and hash the resulting encoded group element into {0, 1}^{outLen} with linearHashKDF.

@[simp]
theorem Cslib.Crypto.PrimeOrderGroupFamily.length_naorReingoldHashedWordEval (F : PrimeOrderGroupFamily) (outLen : ℕ) (bound : F.Desc → ℕ) (d : F.Desc) (seed : List Bool) (α₀ : ℕ) (αs : List ℕ) (xs : List Bool) :
(F.naorReingoldHashedWordEval outLen bound d seed α₀ αs xs).length = outLen

naorReingoldHashedWordEval always outputs outLen bits.

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldHashedRealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen outLen : ℕ → ℕ) (bound : F.Desc → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Setup-parameterized real universal-hash Naor–Reingold bit-string PRF game with exact uniform ZMod (F.order d) exponents and public hash seed (d, seed) encoded via F.withSeed.encDesc (paraphrase of [NR04], Section 4.1, Construction 4.2, Theorem 4.3, and Remark 4.2).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldHashedProbRealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen outLen : ℕ → ℕ) (bound : F.Desc → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Setup-parameterized executable real universal-hash Naor–Reingold bit-string PRF game sampling exponents via sampleNaorReingoldExp (original).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldHashedIdealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen outLen : ℕ → ℕ) (bound : F.Desc → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Setup-parameterized ideal bit-string random-function game for universal-hash Naor–Reingold: sample (d, seed) ← F.seededSetup setup (F.linearHashSeedLen outLen bound) n, draw an independent uniform random function f : BitString (inLen n) → BitString (outLen n), and pass F.withSeed.encDesc (d, seed) to adversary (paraphrase of [NR04], Section 4.1, Theorem 4.3 and Remark 4.2).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.naorReingoldHashedGroupIdealGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen outLen : ℕ → ℕ) (bound : F.Desc → ℕ) (adversary : OracleDistinguisher) (n : ℕ) :

Intermediate hybrid game for universal-hash Naor–Reingold: sample (d, seed) via seededSetup, draw an independent uniform random group-valued table B : BitString (inLen n) → ZMod (F.order d), and hash each queried group element B x • g with linearHashKDF (paraphrase of [NR04], Section 4.1, Theorem 4.3 and Remark 4.2, using Lemma 4.2).

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_naorReingoldHashedIdeal_le (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (inLen outLen : ℕ → ℕ) (bound : F.Desc → ℕ) (adversary : OracleDistinguisher) (n Q qMin : ℕ) (hq0 : 0 < qMin) (hbound : ∀ d ∈ (setup n).support, ∀ (x : F.Carrier d), (F.encode d x).length ≤ bound d) (hq : ∀ d ∈ (setup n).support, qMin ≤ F.order d) (hQ : ∀ d ∈ (setup n).support, ∀ (seed : BitString (outLen n * (2 * bound d + 1))), ProbOracleComp.IsQueryBounded (adversary n (F.withSeed.encDesc (d, List.ofFn seed))) Q) :
(F.naorReingoldHashedGroupIdealGame setup inLen outLen bound adversary n).advantage (F.naorReingoldHashedIdealGame setup inLen outLen bound adversary n) ≤ ↑Q * (NNReal.sqrt (2 ^ outLen n / ↑qMin) / 2)

Multi-query Leftover Hash Lemma bound for hashed Naor–Reingold (paraphrase of [NR04], Section 4.1, Lemma 4.2; [BS23], Section 8.10.4, Theorem 8.11, p. 334): if adversary makes at most Q queries on (setup n).support and qMin ≤ F.order d, then replacing hashed random group elements by a uniform random function BitString (inLen n) → BitString (outLen n) changes the output distribution by at most Q * (√(2 ^ (outLen n) / qMin) / 2).

theorem Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_naorReingoldHashedGame_ideal {F : PrimeOrderGroupFamily} {setup : ℕ → PMF F.Desc} {inLen outLen : ℕ → ℕ} {bound : F.Desc → ℕ} {descBound qMin : ℕ → ℕ} (hDDH : F.DDH setup) (hinLen : Turing.MultiTapeTM.ComputableInPolyTime inLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (houtLen : Turing.MultiTapeTM.ComputableInPolyTime outLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hbound_poly : Turing.MultiTapeTM.ComputableInPolyTime bound F.encDesc Turing.MultiTapeTM.encUnary) (hdesc_poly : PolynomiallyBounded descBound) (hdesc : ∀ (n : ℕ), ∀ d ∈ (setup n).support, (F.encDesc d).length ≤ descBound n) (hbound : ∀ (n : ℕ), ∀ d ∈ (setup n).support, ∀ (x : F.Carrier d), (F.encode d x).length ≤ bound d) (hq0 : ∀ (n : ℕ), 0 < qMin n) (hq : ∀ (n : ℕ), ∀ d ∈ (setup n).support, qMin n ≤ F.order d) (hneg : Negligible fun (n : ℕ) => 2 ^ outLen n / ↑(qMin n)) {adversary : OracleDistinguisher} (hadversary : Probability.IsOraclePPT Turing.MultiTapeTM.encBool adversary) :
Negligible fun (n : ℕ) => (F.naorReingoldHashedRealGame setup inLen outLen bound adversary n).advantage (F.naorReingoldHashedIdealGame setup inLen outLen bound adversary n)

Ideal-key-sampling step, not the cited result: under F.DDH setup, when group descriptions on (setup n).support have polynomially bounded bit-length, bound bounds encoded group elements, and 2 ^ (outLen n) / qMin n is negligible, no IsOraclePPT adversary can distinguish naorReingoldHashedRealGame, whose exponents are drawn exactly uniformly from ZMod (F.order d), from naorReingoldHashedIdealGame. The theorem for exponents drawn with the fair-coin sampler sampleNaorReingoldExp is DDH.negligible_naorReingoldHashedProbGame, which uses this one. The construction is after [NR04], not checked.

theorem Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_naorReingoldHashedProbGame {F : PrimeOrderGroupFamily} {setup : ℕ → PMF F.Desc} {inLen outLen : ℕ → ℕ} {bound : F.Desc → ℕ} {descBound qMin : ℕ → ℕ} (hDDH : F.DDH setup) (hinLen : Turing.MultiTapeTM.ComputableInPolyTime inLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (houtLen : Turing.MultiTapeTM.ComputableInPolyTime outLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hbound_poly : Turing.MultiTapeTM.ComputableInPolyTime bound F.encDesc Turing.MultiTapeTM.encUnary) (hdesc_poly : PolynomiallyBounded descBound) (hdesc : ∀ (n : ℕ), ∀ d ∈ (setup n).support, (F.encDesc d).length ≤ descBound n) (hbound : ∀ (n : ℕ), ∀ d ∈ (setup n).support, ∀ (x : F.Carrier d), (F.encode d x).length ≤ bound d) (hq0 : ∀ (n : ℕ), 0 < qMin n) (hq : ∀ (n : ℕ), ∀ d ∈ (setup n).support, qMin n ≤ F.order d) (hneg : Negligible fun (n : ℕ) => 2 ^ outLen n / ↑(qMin n)) {adversary : OracleDistinguisher} (hadversary : Probability.IsOraclePPT Turing.MultiTapeTM.encBool adversary) :
Negligible fun (n : ℕ) => (F.naorReingoldHashedProbRealGame setup inLen outLen bound adversary n).advantage (F.naorReingoldHashedIdealGame setup inLen outLen bound adversary n)

Asymptotic DDH security of the executable universal-hash Naor–Reingold bit-string PRF (naorReingoldHashedProbRealGame) (paraphrase of [NR04], Section 4.1, Construction 4.2, Theorem 4.3, and Remark 4.2).

theorem Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_naorReingoldHashedGame_ideal_const {F : PrimeOrderGroupFamily} {setup : ℕ → PMF F.Desc} {inLen : ℕ → ℕ} {bound : F.Desc → ℕ} {descBound : ℕ → ℕ} (c : ℕ) (hDDH : F.DDH setup) (hinLen : Turing.MultiTapeTM.ComputableInPolyTime inLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hbound_poly : Turing.MultiTapeTM.ComputableInPolyTime bound F.encDesc Turing.MultiTapeTM.encUnary) (hdesc_poly : PolynomiallyBounded descBound) (hdesc : ∀ (n : ℕ), ∀ d ∈ (setup n).support, (F.encDesc d).length ≤ descBound n) (hbound : ∀ (n : ℕ), ∀ d ∈ (setup n).support, ∀ (x : F.Carrier d), (F.encode d x).length ≤ bound d) {adversary : OracleDistinguisher} (hadversary : Probability.IsOraclePPT Turing.MultiTapeTM.encBool adversary) :
Negligible fun (n : ℕ) => (F.naorReingoldHashedRealGame setup inLen (fun (x : ℕ) => c) bound adversary n).advantage (F.naorReingoldHashedIdealGame setup inLen (fun (x : ℕ) => c) bound adversary n)

Ideal-key-sampling step with constant output length, not the cited result: for any constant output length c : ℕ (including c = 1), under F.DDH setup, the only hardness assumption, together with the stated polynomial-time length functions and setup-support encoding bounds, no IsOraclePPT adversary can distinguish naorReingoldHashedRealGame, whose exponents are drawn exactly uniformly from ZMod (F.order d), from naorReingoldHashedIdealGame. F.DDH setup supplies the inverse-order decay that the Leftover Hash Lemma needs (DDH.negligible_expected_inv_order), so no qMin hypothesis is needed. The library has no version of this theorem for fair-coin exponents (#5293); DDH.exists_pseudorandomGenerator in CslibFrontier/Crypto/Computational/NaorReingold/PRF.lean uses this one. The construction is after [NR04], not checked.