Documentation

GaudisCrypt.Lib.EC.DiffieHellman

Diffie–Hellman assumptions (EasyCrypt theories/crypto/DiffieHellman.ec) #

The theories DDH and CDH over a cyclic group of prime order (Lib/EC/Group.lean: EC's clone CyclicGroup as G, clone G.PowZMod as GP, clone GP.FDistr as FD at the head of the file). List_CDH and Set_CDH with their reductions are not ported yet.

Decisional Diffie–Hellman #

structure GaudisCrypt.EC.DiffieHellman.DDH.Adversary.Structure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

The record of the fields of a module of type Adversary: the fields guess, one per moduletype field, each of that field's own module type.

Adversary.mk turns such a record into a Adversary, Adversary.structure turns a Adversary back into one.

Instances For
    @[simp]
    theorem GaudisCrypt.EC.DiffieHellman.DDH.Adversary.destruct_mk {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (theModule✝ : Adversary) :
    mk theModule✝.structure = theModule✝

    @[simp]: Adversary.mk (Adversary.structure m) = m — rebuilding a module from its own fields gives that module back.

    noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.Adversary.guess.utilities {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

    What is derivable about the accessor Adversary.guess, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):

    • Adversary.guess.utilities.accessorModule : Adversary →ₘ … — the accessor as a module, a projection being a module morphism;
    • Adversary.guess.utilities.apply_simp — Module.app Adversary.guess.utilities.accessorModule m = Adversary.guess m: applying that module is the accessor;
    • Adversary.guess.utilities.expression_eq — the same at the level of expressions: (Adversary.guess m).expression = (Adversary.guess.utilities.proj m.expression).reduce.
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem GaudisCrypt.EC.DiffieHellman.DDH.Adversary.mk_destruct {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (theRecord✝ : Structure) :
      (mk theRecord✝).structure = theRecord✝

      @[simp]: Adversary.structure (Adversary.mk r) = r — destructing a module built from a record gives that record back.

      def GaudisCrypt.EC.DiffieHellman.DDH.Adversary.typeRep {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

      The ModuleTypeRep underlying Adversary, the module type declared by moduletype Adversary: the right-nested product of its 1 field types, in declaration order.

      Adversary is by definition Module Adversary.typeRep.

      Equations
      Instances For
        def GaudisCrypt.EC.DiffieHellman.DDH.Adversary {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

        The module type declared by moduletype Adversary, with fields guess: the type Module Adversary.typeRep of modules that are a right-nested tuple of the field types.

        Build one from a record of its fields with Adversary.mk, read a single field off one with the accessors Adversary.guess, and get the whole record back with Adversary.structure.

        Equations
        Instances For
          @[implicit_reducible]
          instance GaudisCrypt.EC.DiffieHellman.DDH.instIsModuleAdversary {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

          The IsModule Adversary instance: Adversary is a module type, with representation Adversary.typeRep.

          It is what lets the name Adversary stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Adversary.typeRep would do on its own but Adversary, a plain (non-reducible) def, would not.

          Equations
          noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.Adversary.guess {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

          The field guess of a module of type Adversary: the projection onto component 0 of the right-nested tuple Adversary.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].

          Adversary.guess.mk_simp reads this field back off a module built by Adversary.mk; Adversary.guess.utilities has the accessor as a module, and the lemmas about it.

          Its parameters are named gx, gy, gz, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).

          Equations
          • theModule✝.guess = theModule✝
          Instances For
            @[simp]
            theorem GaudisCrypt.EC.DiffieHellman.DDH.Adversary.guess.mk_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (theRecord✝ : Structure) :
            (mk theRecord✝).guess = theRecord✝.guess

            @[simp]: reading the field guess back off a module built from a record — Adversary.guess (Adversary.mk r) = r.guess.

            It is what carries the right-hand side of an X.apply_simp (which is an Adversary.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.guess.apply_simp.

            noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.Adversary.structure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

            The record of a module's fields: Adversary.structure m is Adversary.Structure.mk applied to Adversary.guess of m.

            Inverse of Adversary.mk (Adversary.mk_destruct, Adversary.destruct_mk).

            Equations
            Instances For
              @[reducible]
              noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.Adversary.mk {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

              Builds a module of type Adversary from the record Adversary.Structure of its fields, as a right-nested Module.pair'. @[reducible].

              Inverse of Adversary.structure (Adversary.mk_destruct, Adversary.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Adversary.guess.mk_simp.

              Equations
              Instances For
                @[simp]
                theorem GaudisCrypt.EC.DiffieHellman.DDH.DDH0.main.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (A : Adversary) :

                @[simp]: applying DDH0.main to the parameters proc main uses (A) is Module.proc (DDH0.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.

                theorem GaudisCrypt.EC.DiffieHellman.DDH.DDH0.main.procedure.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (holeArgs✝ : (HoleSigs.cons (procsig (group, group, group) → Bool) HoleSigs.empty).Instantiation) :
                procedure.instantiate holeArgs✝ = proc () : Bool { var x : exp, y : exp, b : Bool; x <$ CyclicGroup.dt; y <$ CyclicGroup.dt; b <- call (holeArgs✝.lookup HoleIndex.zero) (CyclicGroup.g ^ §x, CyclicGroup.g ^ §y, CyclicGroup.g ^ (§x * §y)); return §b }

                Instantiating the holes of DDH0.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 [DDH0.main.procedure.apply_simp]).

                @[simp]
                theorem GaudisCrypt.EC.DiffieHellman.DDH.DDH0.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (A : Adversary) :
                DDH0(A).main = Module.app main A

                @[simp]: applying DDH0 to a tuple of its single parameter A — the record of its procedures DDH0.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 DDH0.main.apply_simp to fill that procedure's holes.

                noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.DDH0.main {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                proc main of module DDH0 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 DDH0.main.apply_simp, which fills the holes of DDH0.main.procedure with the callees the body called.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.DDH0 {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                  The module declared by module DDH0, 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 DDH0.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma DDH0.apply_simp says.

                  Equations
                  Instances For
                    noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.DDH0.main.procedure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :
                    proctype () → Bool uses ((group, group, group) → Bool)

                    The body of proc main of module DDH0, as a procedure of its own: the one call it makes to a module parameter (A) 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 DDH0.main.procedure.apply_simp) rather than run. Use DDH0.main for this procedure as a module.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.DDH1.main.procedure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :
                      proctype () → Bool uses ((group, group, group) → Bool)

                      The body of proc main of module DDH1, as a procedure of its own: the one call it makes to a module parameter (A) 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 DDH1.main.procedure.apply_simp) rather than run. Use DDH1.main for this procedure as a module.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        theorem GaudisCrypt.EC.DiffieHellman.DDH.DDH1.main.procedure.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (holeArgs✝ : (HoleSigs.cons (procsig (group, group, group) → Bool) HoleSigs.empty).Instantiation) :
                        procedure.instantiate holeArgs✝ = proc () : Bool { var x : exp, y : exp, z : exp, b : Bool; x <$ CyclicGroup.dt; y <$ CyclicGroup.dt; z <$ CyclicGroup.dt; b <- call (holeArgs✝.lookup HoleIndex.zero) (CyclicGroup.g ^ §x, CyclicGroup.g ^ §y, CyclicGroup.g ^ §z); return §b }

                        Instantiating the holes of DDH1.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 [DDH1.main.procedure.apply_simp]).

                        noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.DDH1 {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                        The module declared by module DDH1, 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 DDH1.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma DDH1.apply_simp says.

                        Equations
                        Instances For
                          @[simp]
                          theorem GaudisCrypt.EC.DiffieHellman.DDH.DDH1.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (A : Adversary) :
                          DDH1(A).main = Module.app main A

                          @[simp]: applying DDH1 to a tuple of its single parameter A — the record of its procedures DDH1.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 DDH1.main.apply_simp to fill that procedure's holes.

                          noncomputable def GaudisCrypt.EC.DiffieHellman.DDH.DDH1.main {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                          proc main of module DDH1 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 DDH1.main.apply_simp, which fills the holes of DDH1.main.procedure with the callees the body called.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            @[simp]
                            theorem GaudisCrypt.EC.DiffieHellman.DDH.DDH1.main.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (A : Adversary) :

                            @[simp]: applying DDH1.main to the parameters proc main uses (A) is Module.proc (DDH1.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.

                            Computational Diffie–Hellman #

                            noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.Adversary.solve.utilities {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                            What is derivable about the accessor Adversary.solve, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):

                            • Adversary.solve.utilities.accessorModule : Adversary →ₘ … — the accessor as a module, a projection being a module morphism;
                            • Adversary.solve.utilities.apply_simp — Module.app Adversary.solve.utilities.accessorModule m = Adversary.solve m: applying that module is the accessor;
                            • Adversary.solve.utilities.expression_eq — the same at the level of expressions: (Adversary.solve m).expression = (Adversary.solve.utilities.proj m.expression).reduce.
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.Adversary.structure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                              The record of a module's fields: Adversary.structure m is Adversary.Structure.mk applied to Adversary.solve of m.

                              Inverse of Adversary.mk (Adversary.mk_destruct, Adversary.destruct_mk).

                              Equations
                              Instances For
                                def GaudisCrypt.EC.DiffieHellman.CDH.Adversary.typeRep {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                The ModuleTypeRep underlying Adversary, the module type declared by moduletype Adversary: the right-nested product of its 1 field types, in declaration order.

                                Adversary is by definition Module Adversary.typeRep.

                                Equations
                                Instances For
                                  @[simp]
                                  theorem GaudisCrypt.EC.DiffieHellman.CDH.Adversary.solve.mk_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (theRecord✝ : Structure) :
                                  (mk theRecord✝).solve = theRecord✝.solve

                                  @[simp]: reading the field solve back off a module built from a record — Adversary.solve (Adversary.mk r) = r.solve.

                                  It is what carries the right-hand side of an X.apply_simp (which is an Adversary.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.solve.apply_simp.

                                  structure GaudisCrypt.EC.DiffieHellman.CDH.Adversary.Structure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                  The record of the fields of a module of type Adversary: the fields solve, one per moduletype field, each of that field's own module type.

                                  Adversary.mk turns such a record into a Adversary, Adversary.structure turns a Adversary back into one.

                                  Instances For
                                    @[reducible]
                                    noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.Adversary.mk {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                    Builds a module of type Adversary from the record Adversary.Structure of its fields, as a right-nested Module.pair'. @[reducible].

                                    Inverse of Adversary.structure (Adversary.mk_destruct, Adversary.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Adversary.solve.mk_simp.

                                    Equations
                                    Instances For
                                      @[simp]
                                      theorem GaudisCrypt.EC.DiffieHellman.CDH.Adversary.destruct_mk {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (theModule✝ : Adversary) :
                                      mk theModule✝.structure = theModule✝

                                      @[simp]: Adversary.mk (Adversary.structure m) = m — rebuilding a module from its own fields gives that module back.

                                      def GaudisCrypt.EC.DiffieHellman.CDH.Adversary {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                      The module type declared by moduletype Adversary, with fields solve: the type Module Adversary.typeRep of modules that are a right-nested tuple of the field types.

                                      Build one from a record of its fields with Adversary.mk, read a single field off one with the accessors Adversary.solve, and get the whole record back with Adversary.structure.

                                      Equations
                                      Instances For
                                        @[simp]
                                        theorem GaudisCrypt.EC.DiffieHellman.CDH.Adversary.mk_destruct {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (theRecord✝ : Structure) :
                                        (mk theRecord✝).structure = theRecord✝

                                        @[simp]: Adversary.structure (Adversary.mk r) = r — destructing a module built from a record gives that record back.

                                        @[implicit_reducible]
                                        instance GaudisCrypt.EC.DiffieHellman.CDH.instIsModuleAdversary {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                        The IsModule Adversary instance: Adversary is a module type, with representation Adversary.typeRep.

                                        It is what lets the name Adversary stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Adversary.typeRep would do on its own but Adversary, a plain (non-reducible) def, would not.

                                        Equations
                                        noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.Adversary.solve {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                        The field solve of a module of type Adversary: the projection onto component 0 of the right-nested tuple Adversary.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].

                                        Adversary.solve.mk_simp reads this field back off a module built by Adversary.mk; Adversary.solve.utilities has the accessor as a module, and the lemmas about it.

                                        Its parameters are named gx, gy, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).

                                        Equations
                                        • theModule✝.solve = theModule✝
                                        Instances For
                                          @[simp]
                                          theorem GaudisCrypt.EC.DiffieHellman.CDH.CDH.main.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (A : Adversary) :

                                          @[simp]: applying CDH.main to the parameters proc main uses (A) is Module.proc (CDH.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.

                                          noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.CDH {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                          The module declared by module CDH, 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 CDH.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma CDH.apply_simp says.

                                          Equations
                                          Instances For
                                            noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.CDH.main {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :

                                            proc main of module CDH 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 CDH.main.apply_simp, which fills the holes of CDH.main.procedure with the callees the body called.

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              noncomputable def GaudisCrypt.EC.DiffieHellman.CDH.CDH.main.procedure {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] :
                                              proctype () → Bool uses ((group, group) → group)

                                              The body of proc main of module CDH, as a procedure of its own: the one call it makes to a module parameter (A) 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 CDH.main.procedure.apply_simp) rather than run. Use CDH.main for this procedure as a module.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                theorem GaudisCrypt.EC.DiffieHellman.CDH.CDH.main.procedure.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (holeArgs✝ : (HoleSigs.cons (procsig (group, group) → group) HoleSigs.empty).Instantiation) :
                                                procedure.instantiate holeArgs✝ = proc () : Bool { var x : exp, y : exp, r : group; x <$ CyclicGroup.dt; y <$ CyclicGroup.dt; r <- call (holeArgs✝.lookup HoleIndex.zero) (CyclicGroup.g ^ §x, CyclicGroup.g ^ §y); return decide (§r = CyclicGroup.g ^ (§x * §y)) }

                                                Instantiating the holes of CDH.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 [CDH.main.procedure.apply_simp]).

                                                @[simp]
                                                theorem GaudisCrypt.EC.DiffieHellman.CDH.CDH.apply_simp {group exp : Type} [_gaudiParam0 : CommGroup group] [_gaudiParam1 : Field exp] [_gaudiParam2 : Fintype exp] [_gaudiParam3 : CyclicGroup.Params group exp] (A : Adversary) :
                                                CDH(A).main = Module.app main A

                                                @[simp]: applying CDH to a tuple of its single parameter A — the record of its procedures CDH.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 CDH.main.apply_simp to fill that procedure's holes.