Documentation

CslibFrontier.Crypto.Game.Inversion

Inversion and prediction experiments #

The two experiments behind one-way functions and hard-core predicates, stated for one fixed function and input distribution.

The input distribution is a parameter, so the same experiment serves fixed-length inputs of a word function and the finite Goldreich–Levin analysis, and can serve other input laws such as uniform residues. There is no security parameter, setup or encoding: asymptotic notions such as Cslib.Crypto.OneWay draw their setup and then run these experiments. The experiments are written for any monad. Programs use ProbComp; finite distributional arguments use PMF, and ProbComp.eval_inversionExperiment relates the two.

Main definitions #

Main results #

References #

def Cslib.Crypto.inversionExperiment {m : Type → Type u_1} [Monad m] {α : Type} {β : Type u_2} [BEq β] (sample : m α) (f : α → β) (inverter : β → m α) :

The inversion experiment for f on inputs drawn from sample: the challenger draws x and gives the inverter f x; the inverter wins when it returns any preimage of f x.

def Cslib.Crypto.predictionExperiment {m : Type → Type u_1} [Monad m] {α : Type} {β : Type u_2} (sample : m α) (f : α → β) (h : α → Bool) (predictor : β → m Bool) :

The prediction experiment for the bit h of inputs drawn from sample: the challenger draws x and gives the predictor f x; the predictor wins when it returns h x.

theorem Cslib.Crypto.inversionExperiment_eq_of_injective {m : Type → Type u_1} [Monad m] {α : Type} {β : Type u_2} [BEq α] [LawfulBEq α] [BEq β] [LawfulBEq β] (sample : m α) {f : α → β} (hf : Function.Injective f) (inverter : β → m α) :
inversionExperiment sample f inverter = do let x ← sample let x' ← inverter (f x) pure (x' == x)

For an injective function, accepting any preimage is the same as recovering the sampled input.

theorem Cslib.Crypto.inversionExperiment_eq_bind_map {α : Type} {β : Type u_2} [BEq β] (sample : PMF α) (f : α → β) (inverter : β → PMF α) :
inversionExperiment sample f inverter = sample.bind fun (x : α) => PMF.map (fun (x' : α) => f x' == f x) (inverter (f x))

On distributions, the inversion experiment maps the inverter's output distribution through the success test.

theorem Cslib.Crypto.inversionExperiment_bind {α : Type} {β : Type u_2} [BEq β] {Coins : Type u_3} (sample : PMF α) (f : α → β) (coins : PMF Coins) (inverter : Coins → β → PMF α) :
(inversionExperiment sample f fun (image : β) => coins.bind fun (seed : Coins) => inverter seed image) = coins.bind fun (seed : Coins) => inversionExperiment sample f (inverter seed)

Randomness that the inverter samples independently of its challenge may be sampled before the experiment.

An independent uniform hidden bit is guessed correctly with probability exactly one half, whatever the predictor: with a fixed view o, the experiment's outcome is a fair bit.

@[simp]
theorem Cslib.ProbComp.eval_inversionExperiment {α β : Type} [BEq β] (sample : ProbComp α) (f : α → β) (inverter : β → ProbComp α) :
(Crypto.inversionExperiment sample f inverter).eval = Crypto.inversionExperiment sample.eval f fun (image : β) => (inverter image).eval

Evaluating the inversion experiment of programs gives the inversion experiment of their distributions.

@[simp]
theorem Cslib.ProbComp.eval_predictionExperiment {α β : Type} (sample : ProbComp α) (f : α → β) (h : α → Bool) (predictor : β → ProbComp Bool) :
(Crypto.predictionExperiment sample f h predictor).eval = Crypto.predictionExperiment sample.eval f h fun (image : β) => (predictor image).eval

Evaluating the prediction experiment of programs gives the prediction experiment of their distributions.