Documentation

VCVio.CryptoFoundations.PRF

Pseudorandom Functions (PRFs) #

This file defines pseudorandom functions and their security game.

A PRF adversary gets oracle access to uniform sampling plus a function D → R and tries to distinguish the real function PRF.eval k (for a random key k) from a truly random function (modeled as a lazy random oracle with consistent responses).

Main Definitions #

structure PRFScheme (K D R : Type) :

A pseudorandom function with key space K, domain D, and range R. Key generation is probabilistic; evaluation is deterministic given a key.

Instances For
    @[reducible]

    Oracle interface for PRF distinguishers: unrestricted access to uniform sampling plus oracle access to the candidate function.

    Instances For
      @[reducible, inline]

      A PRF adversary gets oracle access to uniform sampling and a function D → R, and outputs a boolean guess (true = "real PRF", false = "random function").

      Instances For
        def PRFScheme.UniformKey {K D R : Type} [SampleableType K] (prf : PRFScheme K D R) :

        A PRF has uniform key generation when its keygen algorithm is exactly uniform sampling.

        Instances For
          def PRFScheme.prfRealQueryImpl {K D R : Type} (prf : PRFScheme K D R) (k : K) :

          Query implementation for the real PRF experiment. Uniform-sampling queries are handled by the ambient unifSpec; function queries are answered by prf.eval k.

          Instances For

            Query implementation for the ideal PRF experiment. Uniform-sampling queries are handled by the ambient unifSpec; function queries are answered by a lazy random oracle.

            Instances For
              def PRFScheme.prfRealExp {K D R : Type} (prf : PRFScheme K D R) (adversary : PRFAdversary D R) :

              Real PRF experiment: sample a key, let the adversary query prf.eval k.

              Instances For

                Ideal PRF experiment: let the adversary query a lazy random oracle (consistent random function). The oracle caches responses so that the same input always yields the same output.

                Instances For
                  noncomputable def PRFScheme.prfAdvantage {K D R : Type} [DecidableEq D] [SampleableType R] (prf : PRFScheme K D R) (adversary : PRFAdversary D R) :

                  PRF advantage: how well the adversary distinguishes the real PRF from a random function.

                  Instances For

                    Forwarding lemmas for the PRF query implementations #

                    How prfRealQueryImpl/prfIdealQueryImpl act on a computation lifted in from the ambient unifSpec (their identity-handled left summand) and on a function (Sum.inr) query. These are the facts a PRF distinguisher reduction needs when it forwards its own uniform sampling / oracle access through the PRF experiment: the unifSpec side is transparent, and an inr query is exactly the candidate function (real: prf.eval k; ideal: the lazy random oracle).

                    @[simp]
                    theorem PRFScheme.simulateQ_prfRealQueryImpl_liftComp {K D R : Type} (prf : PRFScheme K D R) (k : K) {β : Type} (ob : OracleComp unifSpec β) :

                    The real PRF handler is transparent on a computation lifted in from unifSpec: its unifSpec side is the identity handler and the function oracle is never consulted.

                    @[simp]

                    The ideal (lazy random oracle) PRF handler is transparent on a computation lifted in from unifSpec, threading the cache: the result is just ob lifted into the cache state monad.

                    @[simp]
                    theorem PRFScheme.simulateQ_prfRealQueryImpl_inr {K D R : Type} (prf : PRFScheme K D R) (k : K) (d : D) :

                    A function query (Sum.inr) under the real PRF handler evaluates the PRF.

                    @[simp]

                    A function query (Sum.inr) under the ideal PRF handler is the lazy random oracle at that point.