Documentation

GaudisCrypt.Lib.EC.OW

One-way trapdoor permutations (EasyCrypt theories/crypto/OW.ec) #

The theory's types D, R, pkey, skey are outParams of the class Params; its operators (dkeys, challenge, f, finv) and axioms are the class's fields: a clone is clone import GaudisCrypt.EC.OW as OW_rand with type D <- …, op dkeys <- … proof * by ….

def GaudisCrypt.EC.OW.valid_keys' {pkey skey : Type} (dkeys : SubProbability (pkey × skey)) (ks : pkey × skey) :

EC's pred valid_keys (ks:pkey * skey) = support dkeys ks.

Equations
Instances For
    def GaudisCrypt.EC.OW.valid_pkey' {pkey skey : Type} (dkeys : SubProbability (pkey × skey)) (pk : pkey) :

    EC's pred valid_pkey (pk:pkey) = exists sk, valid_keys (pk,sk).

    Equations
    Instances For
      def GaudisCrypt.EC.OW.f_dom' {D pkey skey : Type} (dkeys : SubProbability (pkey × skey)) (challenge : pkey → SubProbability D) (pk : pkey) (x : D) :

      EC's pred f_dom (pk:pkey) (x:D) = valid_pkey pk => x \in (challenge pk).

      Equations
      Instances For
        def GaudisCrypt.EC.OW.f_rng' {D R pkey skey : Type} (dkeys : SubProbability (pkey × skey)) (challenge : pkey → SubProbability D) (f : pkey → D → R) (pk : pkey) (y : R) :

        EC's pred f_rng (pk:pkey) (y:R) = valid_pkey pk => exists x, f_dom pk x /\ y = f pk x.

        Equations
        Instances For
          class GaudisCrypt.EC.OW.Params (D R pkey skey : outParam Type) :

          EC's abstract declarations of the theory: the domain and range D, R, the keys, the distribution of the keys and of the challenge, the permutation f and its inverse finv, and the axioms dkeys_ll, challenge_ll, challenge_uni, finv_correct, finvof, fofinv.

          Instances
            @[reducible, inline]
            abbrev GaudisCrypt.EC.OW.valid_keys {D R pkey skey : Type} [Params D R pkey skey] (ks : pkey × skey) :

            EC's pred valid_keys.

            Equations
            Instances For
              @[reducible, inline]
              abbrev GaudisCrypt.EC.OW.valid_pkey {D R pkey skey : Type} [Params D R pkey skey] (pk : pkey) :

              EC's pred valid_pkey.

              Equations
              Instances For
                @[reducible, inline]
                abbrev GaudisCrypt.EC.OW.f_dom {D R pkey skey : Type} [Params D R pkey skey] (pk : pkey) (x : D) :

                EC's pred f_dom.

                Equations
                Instances For
                  @[reducible, inline]
                  abbrev GaudisCrypt.EC.OW.f_rng {D R pkey skey : Type} [Params D R pkey skey] (pk : pkey) (y : R) :

                  EC's pred f_rng.

                  Equations
                  Instances For
                    theorem GaudisCrypt.EC.OW.f_pk_inj {D R pkey skey : Type} [Inhabited D] [Inhabited R] [Inhabited pkey] [Inhabited skey] [Params D R pkey skey] (x y : D) (pk : pkey) (sk : skey) :
                    valid_keys (pk, sk) → f_dom pk x → f_dom pk y → f pk x = f pk y → x = y

                    This is often useful to extract plaintexts: EC's lemma f_pk_inj.

                    We can now define the module types and modules that define security

                    noncomputable def GaudisCrypt.EC.OW.Inverter.invert.utilities {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                    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]
                      theorem GaudisCrypt.EC.OW.Inverter.mk_destruct {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] (theRecord✝ : Structure) :
                      (mk theRecord✝).structure = theRecord✝

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

                      def GaudisCrypt.EC.OW.Inverter {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                      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
                        @[reducible]
                        noncomputable def GaudisCrypt.EC.OW.Inverter.mk {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                        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
                        Instances For
                          @[implicit_reducible]
                          instance GaudisCrypt.EC.OW.instIsModuleInverter {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                          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
                          noncomputable def GaudisCrypt.EC.OW.Inverter.invert {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                          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, y, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).

                          Equations
                          Instances For
                            @[simp]
                            theorem GaudisCrypt.EC.OW.Inverter.destruct_mk {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] (theModule✝ : Inverter) :
                            mk theModule✝.structure = theModule✝

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

                            noncomputable def GaudisCrypt.EC.OW.Inverter.structure {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                            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).

                            Equations
                            Instances For
                              structure GaudisCrypt.EC.OW.Inverter.Structure {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                              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
                                def GaudisCrypt.EC.OW.Inverter.typeRep {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                                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
                                  @[simp]
                                  theorem GaudisCrypt.EC.OW.Inverter.invert.mk_simp {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] (theRecord✝ : Structure) :
                                  (mk theRecord✝).invert = theRecord✝.invert

                                  @[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.

                                  @[simp]
                                  theorem GaudisCrypt.EC.OW.OW.main.apply_simp {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] (I : Inverter) :

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

                                  noncomputable def GaudisCrypt.EC.OW.OW {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

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

                                  Equations
                                  Instances For
                                    noncomputable def GaudisCrypt.EC.OW.OW.main {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                                    proc main of module 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 OW.main.apply_simp, which fills the holes of OW.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.OW.OW.apply_simp {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] (I : Inverter) :
                                      OW(I).main = Module.app main I

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

                                      noncomputable def GaudisCrypt.EC.OW.OW.main.procedure {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] :

                                      The body of proc main of module 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 OW.main.procedure.apply_simp) rather than run. Use OW.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.OW.OW.main.procedure.apply_simp {D R pkey skey : Type} [_gaudiParam0 : Inhabited D] [_gaudiParam1 : Inhabited R] [_gaudiParam2 : Inhabited pkey] [_gaudiParam3 : Inhabited skey] [_gaudiParam4 : Params D R pkey skey] [_gaudiParam5 : DecidableEq D] (holeArgs✝ : (HoleSigs.cons (procsig (pkey, R) → D) HoleSigs.empty).Instantiation) :
                                        procedure.instantiate holeArgs✝ = proc () : Bool { var pk : pkey, sk : skey, x : D, x' : D; pk, sk <$ dkeys; x <$ challenge §pk; x' <- call (holeArgs✝.lookup HoleIndex.zero) (§pk, f §pk §x); return decide (§x = §x') }

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