Bellare and Rogaway's encryption scheme is IND-CPA (EasyCrypt examples/br93.ec) #
Bellare and Rogaway, "Random oracles are practical: a paradigm for designing efficient
protocols" (1993): enc pk m = (f pk r, H r +^ m) for a one-way trapdoor permutation f and a
random oracle H. EC's file, declaration by declaration and script line by line, in its two
parts:
abstract theory BR93(lines 1–422; namespaceGaudisCrypt.Examples.BR93): correctness, and the reductionPr[BR93_CPA(A).main : res] - 1/2 ≤ Pr[OW(I(A)).main : res]by three games (the oracle call of the challenge replaced by a sampling, up to the adversary queryingr; the one-time padh +^ mreplaced byh; the inverter);- the instance on bitstrings (lines 425–659; namespace
GaudisCrypt.Examples.BR93Concrete): plaintexts of lengthk, nonces of lengthl, ciphertextsr || p, the textbook'sCPA,BR,Exp_OW, andReductionfor them from the theory's, cloned asInstance.
All of EC's lemmas are proven.
Translation:
abstract theory BR93with its types and operators isclass Params (ptxt rand pkey skey); the theory'sclone import ROM as H,clone import OW as OW_randare clones (Lib/EC/ROM.lean,Lib/EC/OW.lean).module type Adv (ARO : POracle) = { proc a1 … proc a2 … }isabbrev Adv := POracle →ₘ AdvProcs;declare module A <: Adv {…},declare axiom A_a1_ll (O <: POracle {-A}) : islossless O.o => islossless A(O).a1aredeclare moduleand a sectionvariablewith the same binder.- A module's
var xismodule_var M.x : Tbefore the module. x \in LRO.misFMap.dom §LRO.m x;witnessisdefault.- The instance:
op k,op l,type pkey, skey,op dkeys,f,fiand their axioms areclass BR93Concrete.Params (pkey skey); the three clones ofBitWord(ptxt,rand,ctxt) areBitWord.word k,BitWord.word l,BitWord.word n;r || pisr ∥ p; EC'sSelf.IisI, the theory'sInstance.I. module A_CPA (A : Adv) (H : POracle)ismodule A_CPA (A : Adv) using (H : POracle):Aa Lean parameter, so that EC's partial applicationA_CPA(A)is the moduleA_CPA A.
Gap list (what keeps the file from reading as EC's):
- GAP 1:
local module Game1 = BR93_CPA(A) with { … }andGame2 = Game1 with { … }(EC's module update) are written out as full modulesGame1,Game2with the parameterA. - GAP 2:
={glob Log, glob LRO}in an invariant is={glob A, Log.qs, LRO.m}(glob Mof a concrete module is not a variable list here;glob Ais stated, where EC adds it). Inpr_Game0_Game1'sseq,glob LRO, glob LogisLRO.m, Log.qs. - GAP 3: the restriction is
{-LRO, -Log, -Game1, -Game2, -OWr}: EC's{-LRO, -Log}, and the section's local modules, which EC keeps apart fromAby declaring them after it. - GAP 4:
1: by simon the oracle's judgment isequiv_proc; stmt_inline*; equiv_auto; auto_progress(simfinds no equality set for the cloned oracle), andOW_OWr'sby byequiv=> //=; simis the inverter's call by hand. - GAP 5:
call (LRO_o_ll _); auto; apply: dptxt_llfor the logged oracle's losslessness isislossless(applyingLRO_o_lldoes not unify through the clone's accessor). - GAP 6: the pure goals after
auto=> />are closed by hand where EC names the pieces with an intro pattern (rename_i,rintro), and EC'ssmt(@FMap)issmt_close [FMap.mem_set]. - GAP 7:
rewrite (OW_OWr &m (I(A)))needsI(A)'s restriction{-OWr}as an instance, stated by hand (haveI : Module.Declared (Module.app I A) …); EC checks it itself. - GAP 8: three lemmas, and the instance's
Reduction, need more than the default heartbeats. - GAP 9: the section is
declare module A <: Adv {…} with glob Rwith{-R}for{-A}inA_a1_ll,A_a2_ll(notes/SHA3/Exceptions.md, E14), so that the instance can applyReductiontoA_CPA(A):glob A_CPA(A)is known from above only. - GAP 10 (instance): EC clones
ROMa second time, at the types of the clone insideBR93, and the two bridges keepH.Lazy.LRO.m{1} = LRO.m{2}. Two clones of a theory at the same types and operators are one module here and share its variable: the invariant is={glob A, LRO.m}(per-clone variables:notes/SHA3/TacticReview.md, last section). - GAP 11 (instance):
local clone import BR93 as Instanceis made before the section, and the restriction ofAis{-LRO, -I, -Log, -Game1, -Game2, -OWr}: EC's{-LRO, -I}, and the clone's variables, fresh forAin EC because the clone is made afterAis declared. They show in the statement ofReduction. - GAP 12 (instance): EC's
module QROinsideIis the moduleI.QROnext to it; EC's procedure aliasproc a1 = A(H).a1inA_CPAis a procedure with one call (one moreinlinein the first bridge). - GAP 13 (instance):
apply/(Reduction (A_CPA(A)) _ _ &m)states EC's restriction checks ofA_CPA(A)by hand (⟨by fp_finite, by fp_disjoint⟩,Footprint.Restricted.glob_declared A), with the instanceModule.ECGlob (A_CPA A) RfromfvP_A_CPA; the last goal of the second bridge (EC'sby auto) needs the invariant'sLog.qs{1} = I.qs{2}rewritten. [Countable rand]is an assumption EC does not state (the samplings intorand).
The abstract scenario of EC's abstract theory BR93.
- add : ptxt → ptxt → ptxt
- dptxt : SubProbability ptxt
- drand : SubProbability rand
- dkeys : SubProbability (pkey × skey)
- f : pkey → rand → rand
- fi : skey → rand → rand
Instances
@[simp]: applying BR93.dec to the parameters proc dec uses (H) is Module.proc (BR93.dec.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
@[simp]: applying BR93 to a tuple of its single parameter H — the record of its procedures BR93.keygen, BR93.enc, BR93.dec, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with BR93.keygen.apply_simp, BR93.enc.apply_simp, BR93.dec.apply_simp to fill that procedure's holes.
The module declared by module BR93, abstracted over its single parameter H, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures BR93.keygen, BR93.enc, BR93.dec, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma BR93.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: BR93.keygen = Module.proc BR93.keygen.procedure — true by definition, proc keygen using no module parameter and so having no holes to fill.
proc keygen of module BR93 as a module: Module.proc BR93.keygen.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — BR93.keygen.apply_simp says exactly that.
Equations
Instances For
Instantiating the holes of BR93.dec.procedure with a tuple holeArgs of procedures: the body of proc dec as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR93.dec.procedure.apply_simp]).
Instantiating the holes of BR93.enc.procedure with a tuple holeArgs of procedures: the body of proc enc as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR93.enc.procedure.apply_simp]).
proc enc of module BR93 as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma BR93.enc.apply_simp, which fills the holes of BR93.enc.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc dec of module BR93, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR93.dec.procedure.apply_simp) rather than run. Use BR93.dec for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of BR93.keygen.procedure with a tuple holeArgs of procedures: the body of proc keygen as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR93.keygen.procedure.apply_simp]).
proc dec of module BR93 as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma BR93.dec.apply_simp, which fills the holes of BR93.dec.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc enc of module BR93, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR93.enc.procedure.apply_simp) rather than run. Use BR93.enc for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc keygen of module BR93, as a procedure of its own: it calls no module parameter, so it has no holes.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR93.keygen.procedure.apply_simp) rather than run. Use BR93.keygen for this procedure as a module.
Equations
- GaudisCrypt.Examples.BR93.BR93.keygen.procedure = proc () : (pkey × skey) { var kp : pkey × skey; kp <$ GaudisCrypt.Examples.BR93.dkeys; return §kp }
Instances For
@[simp]: applying BR93.enc to the parameters proc enc uses (H) is Module.proc (BR93.enc.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
We can quickly prove it correct as a sanity check.
The body of proc main of module Correctness, as a procedure of its own: it calls no module parameter, so it has no holes.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Correctness.main.procedure.apply_simp) rather than run. Use Correctness.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: Correctness.main = Module.proc Correctness.main.procedure — true by definition, proc main using no module parameter and so having no holes to fill.
Instantiating the holes of Correctness.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Correctness.main.procedure.apply_simp]).
proc main of module Correctness as a module: Module.proc Correctness.main.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Correctness.main.apply_simp says exactly that.
Equations
Instances For
The module declared by module Correctness: the record of its procedures Correctness.main.
The declaration has no parameter list, so no procedure of it can call one either and the module is not a function — it is the plain record itself, and there is no Correctness.apply_simp to apply it with.
Instances For
We use cloning to get definitions for OWTP security
But we can't do it (yet) for IND-CPA because of the random oracle. Instead, we define CPA for BR93 with that particular RO.
@[simp]: AdvProcs.structure (AdvProcs.mk r) = r — destructing a module built from a record gives that record back.
The module type declared by moduletype AdvProcs, with fields a1, a2: the type Module AdvProcs.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with AdvProcs.mk, read a single field off one with the accessors AdvProcs.a1, AdvProcs.a2, and get the whole record back with AdvProcs.structure.
Equations
Instances For
What is derivable about the accessor AdvProcs.a2, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
AdvProcs.a2.utilities.accessorModule : AdvProcs →ₘ …— the accessor as a module, a projection being a module morphism;AdvProcs.a2.utilities.apply_simp—Module.app AdvProcs.a2.utilities.accessorModule m = AdvProcs.a2 m: applying that module is the accessor;AdvProcs.a2.utilities.expression_eq— the same at the level of expressions:(AdvProcs.a2 m).expression = (AdvProcs.a2.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The field a1 of a module of type AdvProcs: the projection onto component 0 of the right-nested tuple AdvProcs.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
AdvProcs.a1.mk_simp reads this field back off a module built by AdvProcs.mk; AdvProcs.a1.utilities has the accessor as a module, and the lemmas about it.
Its parameters are named p, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).
Equations
- theModule✝.a1 = GaudisCrypt.Module.fst' theModule✝
Instances For
The record of a module's fields: AdvProcs.structure m is AdvProcs.Structure.mk applied to AdvProcs.a1, AdvProcs.a2 of m.
Inverse of AdvProcs.mk (AdvProcs.mk_destruct, AdvProcs.destruct_mk).
Instances For
The record of the fields of a module of type AdvProcs: the fields a1, a2, one per moduletype field, each of that field's own module type.
AdvProcs.mk turns such a record into a AdvProcs, AdvProcs.structure turns a AdvProcs back into one.
Instances For
@[simp]: reading the field a1 back off a module built from a record — AdvProcs.a1 (AdvProcs.mk r) = r.a1.
It is what carries the right-hand side of an X.apply_simp (which is an AdvProcs.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.a1.apply_simp.
The ModuleTypeRep underlying AdvProcs, the module type declared by moduletype AdvProcs: the right-nested product of its 2 field types, in declaration order.
AdvProcs is by definition Module AdvProcs.typeRep.
Equations
Instances For
@[simp]: AdvProcs.mk (AdvProcs.structure m) = m — rebuilding a module from its own fields gives that module back.
Builds a module of type AdvProcs from the record AdvProcs.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of AdvProcs.structure (AdvProcs.mk_destruct, AdvProcs.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas AdvProcs.a1.mk_simp, AdvProcs.a2.mk_simp.
Equations
- GaudisCrypt.Examples.BR93.AdvProcs.mk theRecord✝ = GaudisCrypt.Module.pair' theRecord✝.a1 theRecord✝.a2
Instances For
What is derivable about the accessor AdvProcs.a1, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
AdvProcs.a1.utilities.accessorModule : AdvProcs →ₘ …— the accessor as a module, a projection being a module morphism;AdvProcs.a1.utilities.apply_simp—Module.app AdvProcs.a1.utilities.accessorModule m = AdvProcs.a1 m: applying that module is the accessor;AdvProcs.a1.utilities.expression_eq— the same at the level of expressions:(AdvProcs.a1 m).expression = (AdvProcs.a1.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: reading the field a2 back off a module built from a record — AdvProcs.a2 (AdvProcs.mk r) = r.a2.
It is what carries the right-hand side of an X.apply_simp (which is an AdvProcs.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.a2.apply_simp.
The field a2 of a module of type AdvProcs: the projection onto component 1 of the right-nested tuple AdvProcs.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
AdvProcs.a2.mk_simp reads this field back off a module built by AdvProcs.mk; AdvProcs.a2.utilities has the accessor as a module, and the lemmas about it.
Its parameters are named c, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).
Equations
- theModule✝.a2 = GaudisCrypt.Module.snd' theModule✝
Instances For
The IsModule AdvProcs instance: AdvProcs is a module type, with representation AdvProcs.typeRep.
It is what lets the name AdvProcs stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module AdvProcs.typeRep would do on its own but AdvProcs, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.Examples.BR93.instIsModuleAdvProcs = { moduleTypeRep := GaudisCrypt.Examples.BR93.AdvProcs.typeRep, isModule := ⋯ }
EC's module type Adv (ARO : POracle) = { proc a1(p:pkey): (ptxt * ptxt) proc a2(c:ctxt): bool }.
Equations
- GaudisCrypt.Examples.BR93.Adv = GaudisCrypt.Module.Arr GaudisCrypt.Examples.BR93.H.POracle GaudisCrypt.Examples.BR93.AdvProcs
Instances For
We need to log the random oracle queries made to the adversary in order to express the final theorem.
Equations
- GaudisCrypt.Examples.BR93.Log.qs = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.Examples.BR93.Log.qs" (List rand))
Instances For
Instantiating the holes of Log.o.procedure with a tuple holeArgs of procedures: the body of proc o as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Log.o.procedure.apply_simp]).
The body of proc init of module Log, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Log.init.procedure.apply_simp) rather than run. Use Log.init for this procedure as a module.
Equations
- GaudisCrypt.Examples.BR93.Log.init.procedure = proc () uses (H_init : () → Unit) : Unit { GaudisCrypt.Examples.BR93.Log.qs <- []; call H_init (); return () }
Instances For
The body of proc o of module Log, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Log.o.procedure.apply_simp) rather than run. Use Log.o for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Log.init to the parameters proc init uses (H) is Module.proc (Log.init.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
@[simp]: applying Log to a tuple of its single parameter H — the record of its procedures Log.init, Log.o, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with Log.init.apply_simp, Log.o.apply_simp to fill that procedure's holes.
The module declared by module Log, abstracted over its single parameter H, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the module type it was declared with.
Applied to such a tuple it is the record of its procedures Log.init, Log.o, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Log.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Log.o to the parameters proc o uses (H) is Module.proc (Log.o.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc init of module Log as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Log.init.apply_simp, which fills the holes of Log.init.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc o of module Log as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Log.o.apply_simp, which fills the holes of Log.o.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of Log.init.procedure with a tuple holeArgs of procedures: the body of proc init as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Log.init.procedure.apply_simp]).
glob Log: its list Log.qs (read off the code; for the footprint tactics).
Instantiating the holes of BR93_CPA.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR93_CPA.main.procedure.apply_simp]).
The body of proc main of module BR93_CPA, as a procedure of its own: the 2 calls it makes to module parameters (A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR93_CPA.main.procedure.apply_simp) rather than run. Use BR93_CPA.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying BR93_CPA.main to the parameters proc main uses (A) is Module.proc (BR93_CPA.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
The module declared by module BR93_CPA, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures BR93_CPA.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma BR93_CPA.apply_simp says.
Equations
Instances For
proc main of module BR93_CPA as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma BR93_CPA.main.apply_simp, which fills the holes of BR93_CPA.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying BR93_CPA to a tuple of its single parameter A — the record of its procedures BR93_CPA.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with BR93_CPA.main.apply_simp to fill that procedure's holes.
We construct I as follows, using A.a1 and A.a2 as black boxes
Equations
- GaudisCrypt.Examples.BR93.I.x = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.Examples.BR93.I.x" rand)
Instances For
Instantiating the holes of I.invert.procedure with a tuple holeArgs of procedures: the body of proc invert as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [I.invert.procedure.apply_simp]).
@[simp]: applying I to a tuple of its single parameter A — the record of its procedures I.invert, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with I.invert.apply_simp to fill that procedure's holes.
The body of proc invert of module I, as a procedure of its own: the 2 calls it makes to module parameters (A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see I.invert.procedure.apply_simp) rather than run. Use I.invert for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module declared by module I, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the module type it was declared with.
Applied to such a tuple it is the record of its procedures I.invert, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma I.apply_simp says.
Equations
Instances For
proc invert of module I as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma I.invert.apply_simp, which fills the holes of I.invert.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying I.invert to the parameters proc invert uses (A) is Module.proc (I.invert.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
We now prove the result using a sequence of games
Equations
- GaudisCrypt.Examples.BR93.Game1.r = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.Examples.BR93.Game1.r" rand)
Instances For
@[simp]: applying Game1.main to the parameters proc main uses (A) is Module.proc (Game1.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc main of module Game1 as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Game1.main.apply_simp, which fills the holes of Game1.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module declared by module Game1, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures Game1.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Game1.apply_simp says.
Equations
Instances For
@[simp]: applying Game1 to a tuple of its single parameter A — the record of its procedures Game1.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with Game1.main.apply_simp to fill that procedure's holes.
Instantiating the holes of Game1.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Game1.main.procedure.apply_simp]).
The body of proc main of module Game1, as a procedure of its own: the 2 calls it makes to module parameters (A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Game1.main.procedure.apply_simp) rather than run. Use Game1.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- GaudisCrypt.Examples.BR93.Game2.r = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.Examples.BR93.Game2.r" rand)
Instances For
@[simp]: applying Game2.main to the parameters proc main uses (A) is Module.proc (Game2.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
The body of proc main of module Game2, as a procedure of its own: the 2 calls it makes to module parameters (A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Game2.main.procedure.apply_simp) rather than run. Use Game2.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of Game2.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Game2.main.procedure.apply_simp]).
The module declared by module Game2, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures Game2.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Game2.apply_simp says.
Equations
Instances For
proc main of module Game2 as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Game2.main.apply_simp, which fills the holes of Game2.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Game2 to a tuple of its single parameter A — the record of its procedures Game2.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with Game2.main.apply_simp to fill that procedure's holes.
Equations
- GaudisCrypt.Examples.BR93.OWr.x = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.Examples.BR93.OWr.x" rand)
Instances For
@[simp]: applying OWr to a tuple of its single parameter I — the record of its procedures OWr.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with OWr.main.apply_simp to fill that procedure's holes.
proc main of module OWr as a module, abstracted over the module parameters it uses (I, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma OWr.main.apply_simp, which fills the holes of OWr.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of OWr.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [OWr.main.procedure.apply_simp]).
The module declared by module OWr, abstracted over its single parameter I, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures OWr.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma OWr.apply_simp says.
Equations
Instances For
The body of proc main of module OWr, as a procedure of its own: the one call it makes to a module parameter (I) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see OWr.main.procedure.apply_simp) rather than run. Use OWr.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying OWr.main to the parameters proc main uses (I) is Module.proc (OWr.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
The concrete instance (EC lines 425–659) #
We now consider a concrete instance:
The operators and axioms of the second half of EC's file: the lengths k, l, a set
pkey * skey of keypairs with a lossless, full, uniform distribution dkeys, and a family f
of trapdoor permutations over rand with inverse family fi.
- k : ℤ
- l : ℤ
- dkeys : SubProbability (pkey × skey)
- f : pkey → EC.BitWord.word l → EC.BitWord.word l
- fi : skey → EC.BitWord.word l → EC.BitWord.word l
Instances
Equations
Instances For
EC's Plaintext.DWord.dunifin, renamed dptxt.
Instances For
EC's Randomness.DWord.dunifin, renamed drand.
Instances For
Parsing and Formatting
EC's op (||) (r:rand) (p:ptxt) : ctxt = mkctxt ((ofrand r) ++ (ofptxt p)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Random Oracle
A Definition for OWTP Security
The record of the fields of a module of type Inverter: the fields invert, one per moduletype field, each of that field's own module type.
Inverter.mk turns such a record into a Inverter, Inverter.structure turns a Inverter back into one.
Instances For
The record of a module's fields: Inverter.structure m is Inverter.Structure.mk applied to Inverter.invert of m.
Inverse of Inverter.mk (Inverter.mk_destruct, Inverter.destruct_mk).
Instances For
@[simp]: Inverter.structure (Inverter.mk r) = r — destructing a module built from a record gives that record back.
What is derivable about the accessor Inverter.invert, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
Inverter.invert.utilities.accessorModule : Inverter →ₘ …— the accessor as a module, a projection being a module morphism;Inverter.invert.utilities.apply_simp—Module.app Inverter.invert.utilities.accessorModule m = Inverter.invert m: applying that module is the accessor;Inverter.invert.utilities.expression_eq— the same at the level of expressions:(Inverter.invert m).expression = (Inverter.invert.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: reading the field invert back off a module built from a record — Inverter.invert (Inverter.mk r) = r.invert.
It is what carries the right-hand side of an X.apply_simp (which is an Inverter.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.invert.apply_simp.
The IsModule Inverter instance: Inverter is a module type, with representation Inverter.typeRep.
It is what lets the name Inverter stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Inverter.typeRep would do on its own but Inverter, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.Examples.BR93Concrete.instIsModuleInverter = { moduleTypeRep := GaudisCrypt.Examples.BR93Concrete.Inverter.typeRep, isModule := ⋯ }
@[simp]: Inverter.mk (Inverter.structure m) = m — rebuilding a module from its own fields gives that module back.
The field invert of a module of type Inverter: the projection onto component 0 of the right-nested tuple Inverter.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
Inverter.invert.mk_simp reads this field back off a module built by Inverter.mk; Inverter.invert.utilities has the accessor as a module, and the lemmas about it.
Its parameters are named pk, x, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).
Instances For
The ModuleTypeRep underlying Inverter, the module type declared by moduletype Inverter: the right-nested product of its 1 field types, in declaration order.
Inverter is by definition Module Inverter.typeRep.
Equations
Instances For
The module type declared by moduletype Inverter, with fields invert: the type Module Inverter.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with Inverter.mk, read a single field off one with the accessors Inverter.invert, and get the whole record back with Inverter.structure.
Equations
Instances For
Builds a module of type Inverter from the record Inverter.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of Inverter.structure (Inverter.mk_destruct, Inverter.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Inverter.invert.mk_simp.
Equations
- GaudisCrypt.Examples.BR93Concrete.Inverter.mk theRecord✝ = theRecord✝.invert
Instances For
The module declared by module Exp_OW, abstracted over its single parameter I, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures Exp_OW.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Exp_OW.apply_simp says.
Equations
Instances For
Instantiating the holes of Exp_OW.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Exp_OW.main.procedure.apply_simp]).
@[simp]: applying Exp_OW to a tuple of its single parameter I — the record of its procedures Exp_OW.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with Exp_OW.main.apply_simp to fill that procedure's holes.
@[simp]: applying Exp_OW.main to the parameters proc main uses (I) is Module.proc (Exp_OW.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc main of module Exp_OW as a module, abstracted over the module parameters it uses (I, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Exp_OW.main.apply_simp, which fills the holes of Exp_OW.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc main of module Exp_OW, as a procedure of its own: the one call it makes to a module parameter (I) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Exp_OW.main.procedure.apply_simp) rather than run. Use Exp_OW.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A Definition for CPA Security
The record of a module's fields: SchemeProcs.structure m is SchemeProcs.Structure.mk applied to SchemeProcs.keygen, SchemeProcs.enc of m.
Inverse of SchemeProcs.mk (SchemeProcs.mk_destruct, SchemeProcs.destruct_mk).
Instances For
What is derivable about the accessor SchemeProcs.keygen, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
SchemeProcs.keygen.utilities.accessorModule : SchemeProcs →ₘ …— the accessor as a module, a projection being a module morphism;SchemeProcs.keygen.utilities.apply_simp—Module.app SchemeProcs.keygen.utilities.accessorModule m = SchemeProcs.keygen m: applying that module is the accessor;SchemeProcs.keygen.utilities.expression_eq— the same at the level of expressions:(SchemeProcs.keygen m).expression = (SchemeProcs.keygen.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: SchemeProcs.structure (SchemeProcs.mk r) = r — destructing a module built from a record gives that record back.
The IsModule SchemeProcs instance: SchemeProcs is a module type, with representation SchemeProcs.typeRep.
It is what lets the name SchemeProcs stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module SchemeProcs.typeRep would do on its own but SchemeProcs, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.Examples.BR93Concrete.instIsModuleSchemeProcs = { moduleTypeRep := GaudisCrypt.Examples.BR93Concrete.SchemeProcs.typeRep, isModule := ⋯ }
The ModuleTypeRep underlying SchemeProcs, the module type declared by moduletype SchemeProcs: the right-nested product of its 2 field types, in declaration order.
SchemeProcs is by definition Module SchemeProcs.typeRep.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: SchemeProcs.mk (SchemeProcs.structure m) = m — rebuilding a module from its own fields gives that module back.
The field keygen of a module of type SchemeProcs: the projection onto component 0 of the right-nested tuple SchemeProcs.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
SchemeProcs.keygen.mk_simp reads this field back off a module built by SchemeProcs.mk; SchemeProcs.keygen.utilities has the accessor as a module, and the lemmas about it.
It takes no parameters (recorded in @[gaudiProcParamNames]).
Equations
- theModule✝.keygen = GaudisCrypt.Module.fst' theModule✝
Instances For
The record of the fields of a module of type SchemeProcs: the fields keygen, enc, one per moduletype field, each of that field's own module type.
SchemeProcs.mk turns such a record into a SchemeProcs, SchemeProcs.structure turns a SchemeProcs back into one.
Instances For
The module type declared by moduletype SchemeProcs, with fields keygen, enc: the type Module SchemeProcs.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with SchemeProcs.mk, read a single field off one with the accessors SchemeProcs.keygen, SchemeProcs.enc, and get the whole record back with SchemeProcs.structure.
Equations
Instances For
What is derivable about the accessor SchemeProcs.enc, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
SchemeProcs.enc.utilities.accessorModule : SchemeProcs →ₘ …— the accessor as a module, a projection being a module morphism;SchemeProcs.enc.utilities.apply_simp—Module.app SchemeProcs.enc.utilities.accessorModule m = SchemeProcs.enc m: applying that module is the accessor;SchemeProcs.enc.utilities.expression_eq— the same at the level of expressions:(SchemeProcs.enc m).expression = (SchemeProcs.enc.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: reading the field enc back off a module built from a record — SchemeProcs.enc (SchemeProcs.mk r) = r.enc.
It is what carries the right-hand side of an X.apply_simp (which is an SchemeProcs.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.enc.apply_simp.
Builds a module of type SchemeProcs from the record SchemeProcs.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of SchemeProcs.structure (SchemeProcs.mk_destruct, SchemeProcs.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas SchemeProcs.keygen.mk_simp, SchemeProcs.enc.mk_simp.
Equations
- GaudisCrypt.Examples.BR93Concrete.SchemeProcs.mk theRecord✝ = GaudisCrypt.Module.pair' theRecord✝.keygen theRecord✝.enc
Instances For
The field enc of a module of type SchemeProcs: the projection onto component 1 of the right-nested tuple SchemeProcs.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
SchemeProcs.enc.mk_simp reads this field back off a module built by SchemeProcs.mk; SchemeProcs.enc.utilities has the accessor as a module, and the lemmas about it.
Its parameters are named pk, m, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).
Equations
- theModule✝.enc = GaudisCrypt.Module.snd' theModule✝
Instances For
@[simp]: reading the field keygen back off a module built from a record — SchemeProcs.keygen (SchemeProcs.mk r) = r.keygen.
It is what carries the right-hand side of an X.apply_simp (which is an SchemeProcs.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.keygen.apply_simp.
EC's module type Scheme (RO : Oracle) = { proc keygen(): (pkey * skey) proc enc(pk:pkey, m:ptxt): ctxt }.
Equations
- GaudisCrypt.Examples.BR93Concrete.Scheme = GaudisCrypt.Module.Arr GaudisCrypt.Examples.BR93Concrete.H.Oracle GaudisCrypt.Examples.BR93Concrete.SchemeProcs
Instances For
The IsModule AdvProcs instance: AdvProcs is a module type, with representation AdvProcs.typeRep.
It is what lets the name AdvProcs stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module AdvProcs.typeRep would do on its own but AdvProcs, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.Examples.BR93Concrete.instIsModuleAdvProcs = { moduleTypeRep := GaudisCrypt.Examples.BR93Concrete.AdvProcs.typeRep, isModule := ⋯ }
The module type declared by moduletype AdvProcs, with fields a1, a2: the type Module AdvProcs.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with AdvProcs.mk, read a single field off one with the accessors AdvProcs.a1, AdvProcs.a2, and get the whole record back with AdvProcs.structure.
Equations
Instances For
@[simp]: AdvProcs.structure (AdvProcs.mk r) = r — destructing a module built from a record gives that record back.
The field a1 of a module of type AdvProcs: the projection onto component 0 of the right-nested tuple AdvProcs.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
AdvProcs.a1.mk_simp reads this field back off a module built by AdvProcs.mk; AdvProcs.a1.utilities has the accessor as a module, and the lemmas about it.
Its parameters are named p, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).
Equations
- theModule✝.a1 = GaudisCrypt.Module.fst' theModule✝
Instances For
What is derivable about the accessor AdvProcs.a1, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
AdvProcs.a1.utilities.accessorModule : AdvProcs →ₘ …— the accessor as a module, a projection being a module morphism;AdvProcs.a1.utilities.apply_simp—Module.app AdvProcs.a1.utilities.accessorModule m = AdvProcs.a1 m: applying that module is the accessor;AdvProcs.a1.utilities.expression_eq— the same at the level of expressions:(AdvProcs.a1 m).expression = (AdvProcs.a1.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: AdvProcs.mk (AdvProcs.structure m) = m — rebuilding a module from its own fields gives that module back.
The field a2 of a module of type AdvProcs: the projection onto component 1 of the right-nested tuple AdvProcs.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
AdvProcs.a2.mk_simp reads this field back off a module built by AdvProcs.mk; AdvProcs.a2.utilities has the accessor as a module, and the lemmas about it.
Its parameters are named c, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).
Equations
- theModule✝.a2 = GaudisCrypt.Module.snd' theModule✝
Instances For
The record of a module's fields: AdvProcs.structure m is AdvProcs.Structure.mk applied to AdvProcs.a1, AdvProcs.a2 of m.
Inverse of AdvProcs.mk (AdvProcs.mk_destruct, AdvProcs.destruct_mk).
Instances For
The record of the fields of a module of type AdvProcs: the fields a1, a2, one per moduletype field, each of that field's own module type.
AdvProcs.mk turns such a record into a AdvProcs, AdvProcs.structure turns a AdvProcs back into one.
Instances For
The ModuleTypeRep underlying AdvProcs, the module type declared by moduletype AdvProcs: the right-nested product of its 2 field types, in declaration order.
AdvProcs is by definition Module AdvProcs.typeRep.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: reading the field a1 back off a module built from a record — AdvProcs.a1 (AdvProcs.mk r) = r.a1.
It is what carries the right-hand side of an X.apply_simp (which is an AdvProcs.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.a1.apply_simp.
Builds a module of type AdvProcs from the record AdvProcs.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of AdvProcs.structure (AdvProcs.mk_destruct, AdvProcs.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas AdvProcs.a1.mk_simp, AdvProcs.a2.mk_simp.
Equations
- GaudisCrypt.Examples.BR93Concrete.AdvProcs.mk theRecord✝ = GaudisCrypt.Module.pair' theRecord✝.a1 theRecord✝.a2
Instances For
What is derivable about the accessor AdvProcs.a2, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
AdvProcs.a2.utilities.accessorModule : AdvProcs →ₘ …— the accessor as a module, a projection being a module morphism;AdvProcs.a2.utilities.apply_simp—Module.app AdvProcs.a2.utilities.accessorModule m = AdvProcs.a2 m: applying that module is the accessor;AdvProcs.a2.utilities.expression_eq— the same at the level of expressions:(AdvProcs.a2 m).expression = (AdvProcs.a2.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: reading the field a2 back off a module built from a record — AdvProcs.a2 (AdvProcs.mk r) = r.a2.
It is what carries the right-hand side of an X.apply_simp (which is an AdvProcs.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.a2.apply_simp.
EC's module type Adv (ARO : POracle) = { proc a1(p:pkey): (ptxt * ptxt) proc a2(c:ctxt): bool }.
Equations
- GaudisCrypt.Examples.BR93Concrete.Adv = GaudisCrypt.Module.Arr GaudisCrypt.Examples.BR93Concrete.H.POracle GaudisCrypt.Examples.BR93Concrete.AdvProcs
Instances For
@[simp]: applying CPA to a tuple of its 3 parameters O, S, A — the record of its procedures CPA.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with CPA.main.apply_simp to fill that procedure's holes.
proc main of module CPA as a module, abstracted over the module parameters it uses (O, S, A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma CPA.main.apply_simp, which fills the holes of CPA.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module declared by module CPA, abstracted over its 3 parameters O, S, A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures CPA.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma CPA.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of CPA.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [CPA.main.procedure.apply_simp]).
The body of proc main of module CPA, as a procedure of its own: the 5 calls it makes to module parameters (O, S, A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see CPA.main.procedure.apply_simp) rather than run. Use CPA.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying CPA.main to the parameters proc main uses (O, S, A) is Module.proc (CPA.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
And a definition for the concrete Bellare-Rogaway Scheme
The module declared by module BR, abstracted over its single parameter H, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the module type it was declared with.
Applied to such a tuple it is the record of its procedures BR.keygen, BR.enc, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma BR.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of BR.enc.procedure with a tuple holeArgs of procedures: the body of proc enc as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR.enc.procedure.apply_simp]).
The body of proc enc of module BR, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR.enc.procedure.apply_simp) rather than run. Use BR.enc for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc dec of module BR, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR.dec.procedure.apply_simp) rather than run. Use BR.dec for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of BR.keygen.procedure with a tuple holeArgs of procedures: the body of proc keygen as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR.keygen.procedure.apply_simp]).
The body of proc keygen of module BR, as a procedure of its own: it calls no module parameter, so it has no holes.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see BR.keygen.procedure.apply_simp) rather than run. Use BR.keygen for this procedure as a module.
Equations
- GaudisCrypt.Examples.BR93Concrete.BR.keygen.procedure = proc () : (pkey × skey) { var pk : pkey, sk : skey; pk, sk <$ GaudisCrypt.Examples.BR93Concrete.dkeys; return (§pk, §sk) }
Instances For
proc keygen of module BR as a module: Module.proc BR.keygen.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — BR.keygen.apply_simp says exactly that.
Equations
Instances For
proc dec of module BR as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma BR.dec.apply_simp, which fills the holes of BR.dec.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying BR.dec to the parameters proc dec uses (H) is Module.proc (BR.dec.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
@[simp]: applying BR.enc to the parameters proc enc uses (H) is Module.proc (BR.enc.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc enc of module BR as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma BR.enc.apply_simp, which fills the holes of BR.enc.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: BR.keygen = Module.proc BR.keygen.procedure — true by definition, proc keygen using no module parameter and so having no holes to fill.
@[simp]: applying BR to a tuple of its single parameter H — the record of its procedures BR.keygen, BR.enc, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with BR.keygen.apply_simp, BR.enc.apply_simp to fill that procedure's holes.
Instantiating the holes of BR.dec.procedure with a tuple holeArgs of procedures: the body of proc dec as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [BR.dec.procedure.apply_simp]).
And our inverter
Equations
- GaudisCrypt.Examples.BR93Concrete.I.qs = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.Examples.BR93Concrete.I.qs" (List GaudisCrypt.Examples.BR93Concrete.rand))
Instances For
The body of proc o of module I.QRO, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see I.QRO.o.procedure.apply_simp) rather than run. Use I.QRO.o for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module declared by module I.QRO, abstracted over its single parameter H, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the module type it was declared with.
Applied to such a tuple it is the record of its procedures I.QRO.o, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma I.QRO.apply_simp says.
Equations
Instances For
@[simp]: applying I.QRO.o to the parameters proc o uses (H) is Module.proc (I.QRO.o.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
@[simp]: applying I.QRO to a tuple of its single parameter H — the record of its procedures I.QRO.o, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with I.QRO.o.apply_simp to fill that procedure's holes.
Instantiating the holes of I.QRO.o.procedure with a tuple holeArgs of procedures: the body of proc o as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [I.QRO.o.procedure.apply_simp]).
proc o of module I.QRO as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma I.QRO.o.apply_simp, which fills the holes of I.QRO.o.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc invert of module I, as a procedure of its own: the 3 calls it makes to module parameters (A, H) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see I.invert.procedure.apply_simp) rather than run. Use I.invert for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying I to a tuple of its 2 parameters A, H — the record of its procedures I.invert, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with I.invert.apply_simp to fill that procedure's holes.
@[simp]: applying I.invert to the parameters proc invert uses (A, H) is Module.proc (I.invert.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
The module declared by module I, abstracted over its 2 parameters A, H, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures I.invert, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma I.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of I.invert.procedure with a tuple holeArgs of procedures: the body of proc invert as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [I.invert.procedure.apply_simp]).
proc invert of module I as a module, abstracted over the module parameters it uses (A, H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma I.invert.apply_simp, which fills the holes of I.invert.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
We will need to turn a concrete CPA adversary into an abstract one. We do not need to do it for the inverter as the types coincide.
Instantiating the holes of A_CPA.a1.procedure with a tuple holeArgs of procedures: the body of proc a1 as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [A_CPA.a1.procedure.apply_simp]).
@[simp]: applying A_CPA.a2 to the parameters proc a2 uses (H) is Module.proc (A_CPA.a2.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc a2 of module A_CPA as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma A_CPA.a2.apply_simp, which fills the holes of A_CPA.a2.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc a2 of module A_CPA, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see A_CPA.a2.procedure.apply_simp) rather than run. Use A_CPA.a2 for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of A_CPA.a2.procedure with a tuple holeArgs of procedures: the body of proc a2 as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [A_CPA.a2.procedure.apply_simp]).
The module declared by module A_CPA, abstracted over its single parameter H, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the module type it was declared with.
Applied to such a tuple it is the record of its procedures A_CPA.a1, A_CPA.a2, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma A_CPA.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying A_CPA to a tuple of its single parameter H — the record of its procedures A_CPA.a1, A_CPA.a2, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with A_CPA.a1.apply_simp, A_CPA.a2.apply_simp to fill that procedure's holes.
The body of proc a1 of module A_CPA, as a procedure of its own: the one call it makes to a module parameter (H) is its single hole.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see A_CPA.a1.procedure.apply_simp) rather than run. Use A_CPA.a1 for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying A_CPA.a1 to the parameters proc a1 uses (H) is Module.proc (A_CPA.a1.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc a1 of module A_CPA as a module, abstracted over the module parameters it uses (H, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma A_CPA.a1.apply_simp, which fills the holes of A_CPA.a1.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's glob A_CPA(A): glob A (A_CPA has no variables).