Documentation

GaudisCrypt.Logic.AbstractCall

The abstract call rule (EasyCrypt's call (: inv) for an adversary with oracles) #

An adversary run against two instantiations of its oracles couples with itself as EasyCrypt's abstract call rule says (equivF_abs_spec, src/phl/ecPhlFun.ml):

  equiv[ O₁.o ~ O₂.o : ={arg} ∧ inv ==> ={res} ∧ inv ]   (for every oracle o the adversary may call)
  ──────────────────────────────────────────────────────────────────────────────────────
  equiv[ D(O₁) ~ D(O₂) : ={arg} ∧ ={glob D} ∧ inv ==> ={res} ∧ ={glob D} ∧ inv ]

The invariant inv reads only the oracles' state: a lens L that the adversary is disjoint from (EasyCrypt's D <: T {-O}; EasyCrypt also rejects an inv that mentions glob D). Globals outside glob D and L are unconstrained, as in EasyCrypt.

={glob} is agreement on a region F (globInvF): everything the adversary may touch, and possibly more, but disjoint from L. There are three forms.

The proof is the oracle-agnostic machinery of Lib/RO/ROCouplingEquiv.lean (instantiate_of_fvP_gen), with two ingredients.

The oracle premises carry ={glob} along, as EasyCrypt's do when an oracle can use D. For oracles confined to L, prhlProc_globInvF_of_confined removes it, as EasyCrypt does. glob_set_of_le_compl rewrites ={glob} through a write that the region cannot see.

The invariant and the adversary's own steps #

The abstract call invariant ={glob} ∧ inv. ={glob} is agreement on the region F, and inv reads the oracle region L.

Equations
Instances For
    def GaudisCrypt.globInv {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} {sig : ProcedureSignature} (A : ProcedureWithHoles holes sig) (I : Ω → Ω → Prop) :

    globInvF at the footprint of a procedure with holes: ={glob A} ∧ inv.

    Equations
    Instances For

      An adversary disjoint from the global lens L is disjoint from it as a procedure (L lifted through globalL). This is fvP_proc_le_roLift_compl for an arbitrary lens.

      A write through a lens X outside the region F leaves F's content unchanged.

      theorem GaudisCrypt.glob_set_of_le_compl {holes : HoleSigs} {sig : ProcedureSignature} {A : ProcedureWithHoles holes sig} {β : Type} {X : Lens β VariableAssignment} (h : X.footprint ≤ (FVP.fvP_proc A)ᶜ) (v : β) (g : VariableAssignment) :
      (FVP.glob A).get (X.set v g) = (FVP.glob A).get g

      A write through a lens X that A cannot see leaves glob A unchanged.

      The global steps outside F, lifted to procedure states (fixing the locals).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem GaudisCrypt.lifted_orbit_outside {F : Footprint VariableAssignment} (loc : VariableAssignment) {g₁ g₂ : state} (h : Relation.EqvGen (fun (a b : state) => ∃ (f : Function.End state), diracKer f ∈ Fᶜ.updates ∧ f a = b) g₁ g₂) :
        Relation.EqvGen (fun (a b : ProgramState) => ∃ fp ∈ liftedStepsOutside F, fp a = b) { globals := g₁, locals := loc } { globals := g₂, locals := loc }

        The adversary's own steps preserve the call invariant. Every program confined to what A may touch self-couples from globInvF-related states, for any region F that contains A's footprint and is disjoint from L. It generalizes footprintCompat_PGlob from equal random-oracle tables to any inv on the L-content. It runs the orbit self-coupling (prhl2_self_of_orbit) and re-attaches inv through the coupling's marginals: neither side's run changes its L-content.

        The oracle side #

        The hole coupling from per-oracle specifications: calls of the two instantiations of an oracle couple under liftRel P when the oracle procedures do under P. This generalizes ro_hhole_prhl from the random oracle to any pair of instantiations.

        theorem GaudisCrypt.satisfies_lens_set_of_inFootprint {Ω : Type} (L : Lens Ω VariableAssignment) {γ : Type} {p : ProgramDenotation VariableAssignment γ} (hp : p.inFootprint L.footprint) (σ : VariableAssignment) :
        (p σ).satisfies fun (xs : γ × VariableAssignment) => ∃ (v : Ω), L.set v σ = xs.2

        A run confined to the lens L only rewrites the L-content: every final state is L.set v σ for some v.

        Oracles confined to L keep the F-content of a region F disjoint from L: an L-confined run changes only the L-content.

        theorem GaudisCrypt.prhlProc_globInvF_of_confined {Ω : Type} (L : Lens Ω VariableAssignment) {F : Footprint VariableAssignment} (hFL : F ≤ L.footprintᶜ) {sig' : ProcedureSignature} {I : Ω → Ω → Prop} {o₁ o₂ : Procedure sig'} (h₁ : ∀ (a : sig'.ParamType), (procedureDenotation o₁ a).inFootprint L.footprint) (h₂ : ∀ (a : sig'.ParamType), (procedureDenotation o₂ a).inFootprint L.footprint) (h : prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ I (L.get g₁) (L.get g₂)) o₁ o₂ fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ I (L.get g₁) (L.get g₂)) :
        prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L F I g₁ g₂) o₁ o₂ fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L F I g₁ g₂

        EasyCrypt's oracle premise. For oracles confined to L, the oracle premise of the rule follows from ={arg} ∧ inv ==> ={res} ∧ inv alone: ={glob} survives because the oracles cannot see it.

        theorem GaudisCrypt.prhlProc_globInv_of_confined {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} {sig sig' : ProcedureSignature} {A : ProcedureWithHoles holes sig} (hdisj : FVP.fvP_proc A ≤ L.footprintᶜ) {I : Ω → Ω → Prop} {o₁ o₂ : Procedure sig'} (h₁ : ∀ (a : sig'.ParamType), (procedureDenotation o₁ a).inFootprint L.footprint) (h₂ : ∀ (a : sig'.ParamType), (procedureDenotation o₂ a).inFootprint L.footprint) (h : prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ I (L.get g₁) (L.get g₂)) o₁ o₂ fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ I (L.get g₁) (L.get g₂)) :
        prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInv L A I g₁ g₂) o₁ o₂ fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInv L A I g₁ g₂

        prhlProc_globInvF_of_confined at the footprint of a procedure with holes.

        The rule #

        theorem GaudisCrypt.prhl2_instantiate_globInvF {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} {sig : ProcedureSignature} (inst₁ inst₂ : holes.Instantiation) (A : ProcedureWithHoles holes sig) (args : sig.ParamType) (F : Footprint VariableAssignment) (hAF : FVP.fvP_proc A ≤ F) (hFL : F ≤ L.footprintᶜ) (I : Ω → Ω → Prop) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (horacle : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig') (a : sig'.ParamType), ProgramDenotation.prhl2 (globInvF L F I) (procedureDenotation (inst₁.lookup n) a) (procedureDenotation (inst₂.lookup n) a) (Lib.RO.Instantiate.liftPost (globInvF L F I))) :

        The abstract call rule, on denotations, for any region F that contains A's footprint and is disjoint from the oracle region L.

        theorem GaudisCrypt.prhlProc_abstract_callF {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} {sig : ProcedureSignature} (inst₁ inst₂ : holes.Instantiation) (A : ProcedureWithHoles holes sig) (F : Footprint VariableAssignment) (hAF : FVP.fvP_proc A ≤ F) (hFL : F ≤ L.footprintᶜ) (I : Ω → Ω → Prop) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (horacle : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig'), prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L F I g₁ g₂) (inst₁.lookup n) (inst₂.lookup n) fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L F I g₁ g₂) :
        prhlProc (fun (a₁ : sig.ParamType) (g₁ : VariableAssignment) (a₂ : sig.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L F I g₁ g₂) (A.instantiate inst₁) (A.instantiate inst₂) fun (r₁ : sig.ret) (g₁ : VariableAssignment) (r₂ : sig.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L F I g₁ g₂

        The abstract call rule, as a prhlProc judgment, for any region F that contains A's footprint and is disjoint from the oracle region L.

        theorem GaudisCrypt.prhlProc_abstract_call {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} {sig : ProcedureSignature} (inst₁ inst₂ : holes.Instantiation) (A : ProcedureWithHoles holes sig) (hdisj : FVP.fvP_proc A ≤ L.footprintᶜ) (I : Ω → Ω → Prop) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (horacle : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig'), prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInv L A I g₁ g₂) (inst₁.lookup n) (inst₂.lookup n) fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInv L A I g₁ g₂) :
        prhlProc (fun (a₁ : sig.ParamType) (g₁ : VariableAssignment) (a₂ : sig.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInv L A I g₁ g₂) (A.instantiate inst₁) (A.instantiate inst₂) fun (r₁ : sig.ret) (g₁ : VariableAssignment) (r₂ : sig.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInv L A I g₁ g₂

        The abstract call rule for a procedure with holes (={glob} is FVP.glob A).

        Modules #

        EasyCrypt declares an adversary as a module of a functor type, declare module D <: T. The rule applies to such a module through a representation: a procedure with holes p that D, applied to any oracles O, behaves like when filled with ext O. ext picks the oracle procedures D may call (EasyCrypt's OI.allowed). In EasyCrypt every module is such code by construction; in Gaudí the module language is more general, and the representation is a hypothesis (Module.Representable) until a representation lemma is proven.

        structure GaudisCrypt.Module.RepresentedBy {T : Type 1} [IsModule T] {sig : ProcedureSignature} (D : Arr T (Proc sig)) {holes : HoleSigs} (ext : T → holes.Instantiation) (p : ProcedureWithHoles holes sig) :

        D applied to oracles O behaves like p filled with ext O, and p touches nothing that D does not.

        Instances For
          def GaudisCrypt.Module.Representable {T : Type 1} [IsModule T] {sig : ProcedureSignature} (D : Arr T (Proc sig)) {holes : HoleSigs} (ext : T → holes.Instantiation) :

          D is represented by some procedure with holes, its oracles chosen by ext.

          Equations
          Instances For
            def GaudisCrypt.Module.ECModule {T : Type 1} [IsModule T] {sig : ProcedureSignature} (D : Arr T (Proc sig)) {holes : HoleSigs} (ext : T → holes.Instantiation) :

            D is an EasyCrypt-like module: representable, its oracles chosen by ext (Module.Representable), and with finitely many global variables (Footprint.FinitelySupported, which fresh variables need: Footprint.exists_fresh). The hypothesis a ported EasyCrypt statement puts on an abstract module (declare module D).

            Equations
            Instances For
              theorem GaudisCrypt.Module.ECModule.representable {T : Type 1} [IsModule T] {sig : ProcedureSignature} {D : Arr T (Proc sig)} {holes : HoleSigs} {ext : T → holes.Instantiation} (h : ECModule D ext) :
              theorem GaudisCrypt.Module.ECModule.finitelySupported {T : Type 1} [IsModule T] {sig : ProcedureSignature} {D : Arr T (Proc sig)} {holes : HoleSigs} {ext : T → holes.Instantiation} (h : ECModule D ext) :
              theorem GaudisCrypt.prhlProc_abstract_call_module {Ω : Type} (L : Lens Ω VariableAssignment) {T : Type 1} [IsModule T] {sig : ProcedureSignature} {holes : HoleSigs} (D : Module.Arr T (Module.Proc sig)) (ext : T → holes.Instantiation) (hD : Module.Representable D ext) (hdisj : FVP.fvP D ≤ L.footprintᶜ) (I : Ω → Ω → Prop) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (O₁ O₂ : T) (horacle : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig'), prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L (FVP.fvP D) I g₁ g₂) ((ext O₁).lookup n) ((ext O₂).lookup n) fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L (FVP.fvP D) I g₁ g₂) :
              prhlProc (fun (a₁ : sig.ParamType) (g₁ : VariableAssignment) (a₂ : sig.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L (FVP.fvP D) I g₁ g₂) (Module.app D O₁).procedure (Module.app D O₂).procedure fun (r₁ : sig.ret) (g₁ : VariableAssignment) (r₂ : sig.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L (FVP.fvP D) I g₁ g₂

              The abstract call rule for a module (EasyCrypt's declare module D <: T {-O}, then call (: inv)). ={glob D} is agreement on FVP.fvP D, everything D may touch.

              theorem GaudisCrypt.prhlProc_abstract_call_moduleF {Ω : Type} (L : Lens Ω VariableAssignment) {T : Type 1} [IsModule T] {sig : ProcedureSignature} {holes : HoleSigs} (D : Module.Arr T (Module.Proc sig)) (ext : T → holes.Instantiation) (hD : Module.Representable D ext) (F : Footprint VariableAssignment) (hDF : FVP.fvP D ≤ F) (hFL : F ≤ L.footprintᶜ) (I : Ω → Ω → Prop) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (O₁ O₂ : T) (horacle : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig'), prhlProc (fun (a₁ : sig'.ParamType) (g₁ : VariableAssignment) (a₂ : sig'.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L F I g₁ g₂) ((ext O₁).lookup n) ((ext O₂).lookup n) fun (r₁ : sig'.ret) (g₁ : VariableAssignment) (r₂ : sig'.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L F I g₁ g₂) :
              prhlProc (fun (a₁ : sig.ParamType) (g₁ : VariableAssignment) (a₂ : sig.ParamType) (g₂ : VariableAssignment) => a₁ = a₂ ∧ globInvF L F I g₁ g₂) (Module.app D O₁).procedure (Module.app D O₂).procedure fun (r₁ : sig.ret) (g₁ : VariableAssignment) (r₂ : sig.ret) (g₂ : VariableAssignment) => r₁ = r₂ ∧ globInvF L F I g₁ g₂

              prhlProc_abstract_call_module at a region F containing glob D (instead of FVP.fvP D itself): the invariant ={F} ∧ I is the same across nested abstract calls (a distinguisher whose oracles are a simulator's procedures, F covering both).

              Representability of concrete functor modules #

              fvP only grows when a procedure's holes are filled: a hole node contributes the write of the result and the read of the arguments, and the call that replaces it contributes those and more. So a functor module D whose application reduces to p.instantiate (ext O) (what the module command's apply_simp lemmas state) is represented by p. The footprint half goes through one oracle O₀ with an empty footprint: fvP_proc p ≤ fvP_proc (p.instantiate (ext O₀)) = fvP (D O₀) ≤ fvP D ⊔ fvP O₀ = fvP D.

              theorem GaudisCrypt.Lens.reduceFootprint_bot {a : Type u_1} {b : Type u_2} (lens : Lens a b) :

              Reducing the empty footprint through a lens gives the empty footprint.

              A procedure-typed module is the module of its procedure.

              A module's procedure stays within the module's footprint (FVP.fvP), on every argument: what {-M}-style restrictions on M are about.

              theorem GaudisCrypt.Module.representedBy_of_app_eq {T : Type 1} [IsModule T] {sig : ProcedureSignature} (D : Arr T (Proc sig)) {holes : HoleSigs} (ext : T → holes.Instantiation) (p : ProcedureWithHoles holes sig) (happ : ∀ (O : T), app D O = proc (p.instantiate (ext O))) (O₀ : T) (h₀ : FVP.fvP O₀ = ⊥) :

              A functor module that applies to p.instantiate (ext O) is represented by p, given one oracle module O₀ with an empty footprint (to bound p's footprint by D's).