Documentation

GaudisCrypt.Logic.ECCallFrame

EasyCrypt's call (: P ==> Q) in a phoare, with a frame #

phoare_call (: P ==> Q) / x₁, …, glob A
hoare_call (: P ==> Q) / x₁, …, glob A

EC's call (: P ==> Q) keeps, past the call, what the callee does not touch (EC's glob): the game's event after the call need only follow from Q for globals that agree with the ones before on that. Here that is a frame (Module.Proc.Frame, Logic/ECCallOneSided.lean): lenses outside the callee (Preimage2.hash past FEL(A, F).main), the glob of declared modules. Upper bounds (phoareStmt_call_le_frame).

In a Hoare triple (hoare_call_wp_frame) the same frame serves EC's rcondt{i} n; first by auto; inline*; auto; conseq (: _ ==> true); auto: the condition after a call that does not write what it reads is hoare_call (: True ==> True) / x; ec_auto.

EC's call (: P ==> Q) in an upper bound, with a frame Fr the callee keeps: the event after the call bounded by the callee's for the globals in the frame of the ones before.

theorem GaudisCrypt.phoareStmt_call_lossless_frame {sig : ProcedureSignature} {A : ProgramState → Prop} {pre : Stmt} {x : Setter sig.ret ProgramState} {M : Module.Proc sig} {a : Getter sig.ParamType ProgramState} {B : ProgramState → Prop} {Fr : VariableAssignment → VariableAssignment → Prop} (hFr : M.Frame Fr) (hll : M.procedure.IsLossless) (h' : phoare[ A CurrentState.state ==> ∀ (v : sig.ret) (gl : VariableAssignment), Fr CurrentState.state.globals gl → B (x.set v (ProgramState.globalL.set gl CurrentState.state)) ] = 1 { stmt pre; }) :
phoare[ A CurrentState.state ==> B CurrentState.state ] = 1 { stmt pre; x <- call M.procedure (§a); }

EC's call H (H : islossless M) in a phoare … = 1, with a frame Fr the callee keeps: the event B after the call holds with probability 1 when, before it, B holds after the call for every result and every globals in the frame of the current ones.

theorem GaudisCrypt.hoareProc_and_frame {sig : ProcedureSignature} {M : Module.Proc sig} {P : sig.ParamType → VariableAssignment → Prop} {Q : sig.ret → VariableAssignment → Prop} {Fr : VariableAssignment → VariableAssignment → Prop} (hFr : M.Frame Fr) (hp : hoareProc P M.procedure Q) (g₀ : VariableAssignment) :
hoareProc (fun (a : sig.ParamType) (g : VariableAssignment) => P a g ∧ g = g₀) M.procedure fun (r : sig.ret) (g' : VariableAssignment) => Q r g' ∧ Fr g₀ g'

A triple about a module's procedure also says what the procedure keeps (a frame Fr of the module), for the globals g₀ it starts from.

theorem GaudisCrypt.hoare_call_wp_frame {sig : ProcedureSignature} (x : Setter sig.ret ProgramState) (M : Module.Proc sig) (args : Getter sig.ParamType ProgramState) {P : sig.ParamType → VariableAssignment → Prop} {Q : sig.ret → VariableAssignment → Prop} {Fr : VariableAssignment → VariableAssignment → Prop} (hFr : M.Frame Fr) (hp : hoareProc P M.procedure Q) (B : ProgramState → Prop) :
hoare[ P (args.get CurrentState.state) CurrentState.state.globals ∧ ∀ (r : sig.ret) (g : VariableAssignment), Fr CurrentState.state.globals g → Q r g → B (x.set r (ProgramState.globalL.set g CurrentState.state)) ==> B CurrentState.state ] { x <- call M.procedure (§args); }

EC's call (: P ==> Q) in a Hoare triple, with EC's frame: the postcondition after the call for every result and every globals that Q allows and that are in the frame Fr of the current ones (what the callee does not write keeps its value).

EC's call (: P ==> Q) in an upper bound, past what the callee does not touch: the frame x₁, …, glob A (see the module docstring). Goals: the callee's judgment (spec), then the code before the call.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    EC's call H (H : islossless M) in a phoare … = 1, past what the callee does not touch: the frame x₁, …, glob A (phoareStmt_call_lossless_frame). Goal: the code before the call, the event for every result and globals in the frame.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      EC's call (: P ==> Q) in a Hoare triple, past what the callee does not touch: the frame x₁, …, glob A (as phoare_call (: P ==> Q) / …). Goals: the callee's triple (spec; the trivial one, True ==> True, is closed), then the code before the call. EC's rcondt{i} n; first by auto; inline*; auto; conseq (: _ ==> true); auto on a call that does not write what the condition reads is hoare_call (: True ==> True) / x; ec_auto.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For