Documentation

VCVio.CryptoFoundations.SecExp

Security Experiments #

This file defines simple security experiments that succeed unless they terminate with failure. Each experiment carries bundled subprobabilistic semantics, so the experiment can be interpreted through an internal semantic monad instead of requiring a global HasEvalSPMF instance on the ambient monad.

We also define BoundedAdversary α β as an oracle computation bundled with a query bound.

noncomputable def ProbComp.boolBiasAdvantage (p : ProbComp Bool) :

Bias advantage of a Boolean-valued game: the gap between the probabilities of the two outputs.

This is the canonical single-game formulation for hidden-bit guessing experiments.

Instances For
    noncomputable def ProbComp.boolDistAdvantage (p q : ProbComp Bool) :

    Distinguishing advantage between two Boolean-valued games, measured on the true branch.

    For Boolean outputs this is equivalent to measuring the gap on false; choosing true is just a conventional presentation.

    Instances For
      noncomputable def SPMF.boolBiasAdvantage (p : SPMF Bool) :

      Bias advantage of a Boolean-valued subdistribution: the gap between the probabilities of returning true and false.

      This is the SPMF analogue of ProbComp.boolBiasAdvantage, used for games that have already been observed under bundled subprobabilistic semantics. Any remaining mass corresponds to failure and therefore contributes to neither Boolean branch.

      Instances For

        Triangle inequality for Boolean distinguishing advantage.

        Re-express Boolean bias as twice the absolute deviation of Pr[true] from 1/2.

        theorem ProbComp.boolBiasAdvantage_eq_boolDistAdvantage_uniformBool_branch (real rand : ProbComp Bool) :
        (do let b$ᵗ Bool have __do_jp : BoolProbComp Bool := fun (z : Bool) => pure (b == z) if b = true then do let yreal __do_jp y else do let yrand __do_jp y).boolBiasAdvantage = real.boolDistAdvantage rand

        A hidden-bit guessing game over two Boolean branches has bias exactly equal to the distinguishing advantage between those two branches.

        theorem ProbComp.boolBiasAdvantage_bind_uniformBool_eq_boolDistAdvantage {α : Type} (pref : ProbComp α) (real rand : αProbComp Bool) :
        (do let apref let b$ᵗ Bool have __do_jp : BoolProbComp Bool := fun (z : Bool) => pure (b == z) if b = true then do let yreal a __do_jp y else do let yrand a __do_jp y).boolBiasAdvantage = (do let apref real a).boolDistAdvantage do let apref rand a

        Version of boolBiasAdvantage_eq_boolDistAdvantage_uniformBool_branch with a shared sampled prefix before the real/random branch is chosen.

        noncomputable def ProbComp.guessAdvantage (p : ProbComp Unit) :

        The advantage of a game p, assumed to be a probabilistic computation ending with a guard statement, is the absolute difference between the probability of success and 1/2.

        Instances For
          noncomputable def ProbComp.distAdvantage (p q : ProbComp Unit) :

          The advantage between two games p and q, modeled as probabilistic computations returning Unit, is the absolute difference between their probabilities of success.

          Instances For
            theorem ProbComp.distAdvantage_le_sum_range {n : } (games : ProbComp Unit) :
            (games 0).distAdvantage (games n) iFinset.range n, (games i).distAdvantage (games (i + 1))
            structure BoundedAdversary {ι : Type u} [DecidableEq ι] (spec : OracleSpec ι) (α β : Type u) :

            A security adversary bundling a computation with a bound on the number of queries it makes, where the bound must be shown to satisfy IsQueryBound. We also require an explicit list of all oracles used in the computation, which is necessary in order to make certain reductions computable.

            Instances For
              structure SecExp (m : TypeType w) [Monad m] extends SPMFSemantics m :
              Type (max (u_1 + 1) w)

              Structure to represent a security experiment. The experiment is considered successful unless it terminates with failure.

              A SecExp carries bundled SPMFSemantics directly. This keeps the semantic assumptions attached to the experiment itself: the surface monad can be interpreted through some internal semantic monad, and only then observed as a subdistribution for measuring success and failure probabilities.

              Instances For
                noncomputable def SecExp.advantage {m : TypeType w} [Monad m] (exp : SecExp m) :

                Advantage of a failure-based security experiment: one minus its failure probability.

                Instances For
                  @[simp]
                  theorem SecExp.advantage_eq_zero_iff {m : TypeType w} [Monad m] (exp : SecExp m) :
                  exp.advantage = 0 Pr[⊥ | exp.evalDist exp.main] = 1

                  A failure-based experiment has zero advantage exactly when it fails with probability 1.

                  @[simp]
                  theorem SecExp.advantage_eq_one_iff {m : TypeType w} [Monad m] (exp : SecExp m) :
                  exp.advantage = 1 Pr[⊥ | exp.evalDist exp.main] = 0

                  A failure-based experiment has advantage 1 exactly when it never fails.