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 MonadLiftT _ SPMF 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
        noncomputable def SPMF.boolDistAdvantage (p q : SPMF Bool) :

        Distinguishing advantage between two Boolean-valued subdistributions, measured on the true branch. SPMF analogue of ProbComp.boolDistAdvantage.

        Instances For

          Re-express SPMF Boolean bias as twice the absolute deviation of Pr[true] from 1/2, assuming the SPMF is a full distribution (no failure mass).

          theorem SPMF.boolBiasAdvantage_eq_boolDistAdvantage_coin_branch (coin p q : SPMF Bool) (hcoin_true : Pr[= true | coin] = 1 / 2) (hcoin_false : Pr[= false | coin] = 1 / 2) (hp : Pr[= true | p] + Pr[= false | p] = 1) (hq : Pr[= true | q] + Pr[= false | q] = 1) :
          (do let bcoin let zif b = true then p else q pure (b == z)).boolBiasAdvantage = p.boolDistAdvantage q

          Hidden-bit decomposition at the SPMF level: the bias of a coin-flip guessing game equals the distinguishing advantage between the two branches, assuming the coin is fair and both branches have full mass (no failure).

          This is the SPMF analogue of ProbComp.boolBiasAdvantage_eq_boolDistAdvantage_uniformBool_branch. The ProbComp version holds unconditionally because ProbComp distributions always have total mass

          1. For SPMF distributions, the totality hypotheses are required because failure mass breaks the Pr[false] = 1 - Pr[true] identity that the decomposition depends on.

          Triangle inequality for SPMF Boolean distinguishing advantage.

          Triangle inequality for Boolean distinguishing advantage.

          The true-branch probability of one Boolean-valued game is bounded above by the true-branch probability of another game plus their distinguishing advantage.

          This is the ENNReal-level interpretation of the real-valued identity a ≤ b + |a - b|, packaged for SSP game-hopping: converting an advantage p q ≤ ε assumption into a direct probability inequality Pr[true|p] ≤ Pr[true|q] + ENNReal.ofReal ε that plugs into chained calc-style bounds.

          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.