Documentation

CslibFrontier.Crypto.Game.Experiment

Security experiments as programs #

A security experiment is the challenger's program: it samples, runs the adversary and returns a bit. Experiment is that program, a ProbComp Bool, and mirrors Game := PMF Bool, its output distribution. Scheme algorithms, adversaries and experiments are written as programs, and ProbComp.eval appears only where a probability is taken: in Experiment.succProbability and Experiment.advantage, which are the Game notions of the evaluated programs.

Names follow one convention. A …Experiment is one instance, at fixed parameters (a group, a key space, a security parameter already chosen). A …Game is a family: Game.withSetup draws public parameters from a setup law, which need not be efficiently sampleable, and then runs the fixed experiment. When the setup is itself a program, such as key generation, the experiment binds it: Experiment.advantage_bind_le_of_support and Experiment.succProbability_bind_le_of_support lift a bound that holds at every possible output of the setup program.

Experiment.succProbability and Experiment.advantage are reducible abbreviations, so simp and term-mode applications of the Game lemmas see through them. rw matches syntactically: unfold with simp only [Experiment.advantage] before rewriting with a Game lemma.

distAdvantage real sim D is the advantage of a distinguisher D between two view distributions, as in simulation-based definitions.

Main definitions #

Main results #

References #

@[reducible, inline]

A security experiment: the challenger's program, which returns whether the adversary won (for a search or forgery experiment) or the adversary's guess (for a distinguishing experiment). Its output distribution is the Game ProbComp.eval e.

@[reducible, inline]

The success probability of an experiment: the probability that it returns true.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Experiment.advantage (e₀ e₁ : Experiment) :

The distinguishing advantage between two experiments: the absolute difference of their success probabilities ([BS23], Section 3.1).

As a real number, the success probability of an experiment is Pr[e].

As a real number, the advantage between two experiments is |Pr[e₀] - Pr[e₁]|.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.distAdvantage {V : Type} (real sim : ProbComp V) (D : V → Experiment) :

The advantage of the distinguisher D between the view distributions real and sim: the advantage between running D on a real view and on a simulated one.

theorem Cslib.Crypto.distAdvantage_eq_zero_of_eval_eq {V : Type} {real sim : ProbComp V} (h : real.eval = sim.eval) (D : V → Experiment) :
distAdvantage real sim D = 0

A perfect simulation, one with the same view distribution, gives every distinguisher advantage zero.

noncomputable def Cslib.Crypto.Game.withSetup {P : Type} (setup : PMF P) (exp : P → Experiment) :

The game that draws public parameters p from the setup law setup and runs the experiment exp p. The setup law is a distribution, not a program: it need not be efficiently sampleable.

@[simp]
theorem Cslib.Crypto.Game.withSetup_pure {P : Type} (p : P) (exp : P → Experiment) :

With a point setup law, the game is the evaluated experiment.

theorem Cslib.Crypto.Game.advantage_withSetup_le {P : Type} (setup : PMF P) (exp₀ exp₁ : P → Experiment) {ε : NNReal} (h : ∀ p ∈ setup.support, (exp₀ p).advantage (exp₁ p) ≤ ε) :
(withSetup setup exp₀).advantage (withSetup setup exp₁) ≤ ε

A bound on the advantage between two experiments at every supported parameter bounds the advantage between the games over the same setup law.

theorem Cslib.Crypto.Game.succProbability_withSetup_le {P : Type} (setup : PMF P) (exp : P → Experiment) {ε : NNReal} (h : ∀ p ∈ setup.support, (exp p).succProbability ≤ ε) :

A bound on the success probability of an experiment at every supported parameter bounds the success probability of the game.

theorem Cslib.Crypto.Experiment.eval_bind_eq_withSetup {P : Type} (setup : ProbComp P) (exp : P → Experiment) :
(setup >>= exp).eval = Game.withSetup setup.eval exp

The experiment that runs a setup program and then an experiment on its output is the game over the setup's output distribution.

theorem Cslib.Crypto.Experiment.advantage_bind_le_of_support {P : Type} (setup : ProbComp P) (exp₀ exp₁ : P → Experiment) {ε : NNReal} (h : ∀ p ∈ setup.eval.support, (exp₀ p).advantage (exp₁ p) ≤ ε) :
advantage (setup >>= exp₀) (setup >>= exp₁) ≤ ε

A bound on the advantage at every possible output of a setup program, such as key generation, bounds the advantage between the experiments that run it first.

theorem Cslib.Crypto.Experiment.succProbability_bind_le_of_support {P : Type} (setup : ProbComp P) (exp : P → Experiment) {ε : NNReal} (h : ∀ p ∈ setup.eval.support, (exp p).succProbability ≤ ε) :
succProbability (setup >>= exp) ≤ ε

A bound on the success probability at every possible output of a setup program bounds the success probability of the experiment that runs it first.