Documentation

CslibFrontier.Crypto.Primitives.PRF.ToPRG

Pseudorandom generator from a pseudorandom function #

Evaluating a keyed function F : Key → D → R at ℓ distinct domain points x : Fin ℓ ↪ D yields a deterministic generator PRF.toPRG F x : PRG.Generator Key (Fin ℓ → R) sending a key k to fun i => F k (x i) ([BS23], §4.4.4, Theorem 4.8, p. 138).

Given a randomized PRG distinguisher A : (Fin ℓ → R) → ProbComp Bool, PRF.prgReduction x A queries x 0, ..., x (ℓ - 1) through the PRF oracle (PRF.queryPoints x), passes the collected tuple to A, and outputs whatever A outputs. It makes ℓ external queries (PRF.isQueryBounded_prgReduction) and achieves the exact same advantage (PRF.advantage_toPRG_eq): (toPRG F x).advantage (fun y => ProbComp.eval (A y)) = (PRF.advantage F (prgReduction x A) : ℝ). Here A ranges over ProbComp-valued tests rather than arbitrary Cslib.Crypto.PRG.Adversary ((Fin ℓ → R) → PMF Bool) because general PMF values with arbitrary real weights cannot be simulated inside a finitely-branching ProbComp adversary.

This finite-type identity is a step toward Theorem 4.8, not the cited result: in the theorem the reduction is an elementary wrapper around A and the conclusion is that the generator is a secure PRG, while nothing here certifies prgReduction as efficient. In CslibFrontier.Crypto.Computational.PseudorandomFunction.ToPRG, the theorem's security conclusion is Cslib.Crypto.indistinguishable_prgFromPRF. The exact identity Cslib.Crypto.advantage_prgFromPRF_eq explains the reduction: it equates the two advantages for the oracle-PPT word reduction Cslib.Crypto.prgFromPRFReduction, which runs prgReduction. Cslib.Crypto.PseudorandomFunctionOver.toPRG concludes PseudorandomGenerator and so also needs strict stretch, n < ℓ n * outLen n. For example, one output block as wide as the seed gives indistinguishable outputs but no stretch.

Main definitions #

Main results #

Step toward Theorem 4.8 #

References #

def Cslib.Crypto.PRF.toPRG {Key D R : Type} {ℓ : ℕ} (F : Key → D → R) (x : Fin ℓ ↪ D) :
PRG.Generator Key (Fin ℓ → R)

Pseudorandom generator constructed from a keyed function F : Key → D → R by evaluating at ℓ distinct domain elements x 0, ..., x (ℓ - 1) ([BS23], §4.4.4, p. 138).

@[simp]
theorem Cslib.Crypto.PRF.toPRG_apply {Key D R : Type} {ℓ : ℕ} (F : Key → D → R) (x : Fin ℓ ↪ D) (key : Key) (i : Fin ℓ) :
(toPRG F x) key i = F key (x i)
def Cslib.Crypto.PRF.queryPoints {D R : Type} {ℓ : ℕ} (x : Fin ℓ ↪ D) :
ProbOracleComp (fun (x : D) => R) (Fin ℓ → R)

Query the PRF oracle at x 0, ..., x (ℓ - 1) in order and return the reply tuple.

def Cslib.Crypto.PRF.prgReduction {D R : Type} {ℓ : ℕ} (x : Fin ℓ ↪ D) (A : (Fin ℓ → R) → ProbComp Bool) :

Reduction turning a ProbComp-valued PRG distinguisher A on Fin ℓ → R into an ℓ-query PRF adversary that queries x 0, ..., x (ℓ - 1) and forwards the tuple to A.

theorem Cslib.Crypto.PRF.run_queryPoints {D R : Type} {ℓ : ℕ} (x : Fin ℓ ↪ D) (f : D → R) :
((queryPoints x).run fun (d : D) => pure (f d)) = pure fun (i : Fin ℓ) => f (x i)

Evaluating queryPoints x against a deterministic function f : D → R returns f ∘ x.

queryPoints x makes at most ℓ queries on every execution path.

theorem Cslib.Crypto.PRF.isQueryBounded_prgReduction {D R : Type} {ℓ : ℕ} (x : Fin ℓ ↪ D) (A : (Fin ℓ → R) → ProbComp Bool) :

The PRF reduction prgReduction x A makes at most ℓ oracle queries regardless of private coins and oracle replies.

theorem Cslib.Crypto.PRF.eval_realExperiment_prgReduction {Key D R : Type} {ℓ : ℕ} [Fintype Key] [Nonempty Key] (F : Key → D → R) (x : Fin ℓ ↪ D) (A : (Fin ℓ → R) → ProbComp Bool) :
(realExperiment F (prgReduction x A)).eval = (toPRG F x).realExperiment fun (y : Fin ℓ → R) => (A y).eval

Against F, the PRF real experiment of prgReduction x A has the same distribution as the PRG real experiment of toPRG F x on A.

theorem Cslib.Crypto.PRF.eval_idealExperiment_prgReduction {D R : Type} {ℓ : ℕ} [Fintype D] [DecidableEq D] [Fintype R] [Nonempty R] (x : Fin ℓ ↪ D) (A : (Fin ℓ → R) → ProbComp Bool) :

In the ideal PRF experiment, querying x : Fin ℓ ↪ D yields a uniformly random Fin ℓ → R tuple, matching the PRG ideal experiment on A.

theorem Cslib.Crypto.PRF.advantage_toPRG_eq {Key D R : Type} {ℓ : ℕ} [Fintype Key] [Nonempty Key] [Fintype D] [DecidableEq D] [Fintype R] [Nonempty R] (F : Key → D → R) (x : Fin ℓ ↪ D) (A : (Fin ℓ → R) → ProbComp Bool) :
((toPRG F x).advantage fun (y : Fin ℓ → R) => (A y).eval) = ↑(advantage F (prgReduction x A))

Finite-type advantage identity, a step toward [BS23], Theorem 4.8 (p. 138), not the cited result: for any ProbComp-valued distinguisher A on Fin ℓ → R, its PRG distinguishing advantage against toPRG F x equals the PRF distinguishing advantage of the ℓ-query reduction prgReduction x A against F. Nothing here certifies prgReduction as efficient. The theorem's security conclusion, with an oracle-PPT reduction, is Cslib.Crypto.indistinguishable_prgFromPRF; its exact identity is Cslib.Crypto.advantage_prgFromPRF_eq.

theorem Cslib.Crypto.PRF.isExpanding_toPRG {Key D R : Type} {ℓ : ℕ} [Fintype Key] [Fintype R] (F : Key → D → R) (x : Fin ℓ ↪ D) (hcard : Fintype.card Key < Fintype.card R ^ ℓ) :

toPRG F x is length-expanding (|Key| < |Fin ℓ → R|) whenever |Key| < |R| ^ ℓ.