Documentation

FraudProof.DataStructures.Hash

Hash Definitions #

Here we define what we explicitly define properties about hash funcitons.

Hash Operations as Classes #

We say that elements in α can be hashed to through mhash.

class Hash (α : Type) :
  • mhash : α
Instances

    Additionally, we define another function combining hashes comb

    class HashMagma ( : Type) :
    • comb :
    Instances

      Usually, Hash and Hashmagma would go together.

      Hash Properties #

      Hash function collision resistant and Injective #

      class CollResistant (α : Type) [op : Hash α ] :
      Instances
        class InjectiveHash (α : Type) [h : Hash α ] :
        Instances

          Injective is stronger than Collision resistant

          def injIsCollResis {α : Type} [m : Hash α ] (inj : InjectiveHash α ) :
          Equations
          • =
          Instances For

            Hash combination respects collision resistant (both arguments) and Injective. #

            class SLawFulHash ( : Type) [m : HashMagma ] :
            • neqLeft (a1 a2 b1 b2 : ) : a1 a2m.comb a1 b1 m.comb a2 b2
            • neqRight (a1 a2 b1 b2 : ) : b1 b2m.comb a1 b1 m.comb a2 b2
            Instances
              class InjectiveMagma ( : Type) [m : HashMagma ] :
              • injectL (a1 a2 b1 b2 : ) : m.comb a1 b1 = m.comb a2 b2a1 = a2
              • injectR (a1 a2 b1 b2 : ) : m.comb a1 b1 = m.comb a2 b2b1 = b2
              Instances

                Injective is stronger than Collision resistant #

                def injIsLawful { : Type} {m : HashMagma } (inj : InjectiveMagma ) :
                Equations
                • =
                Instances For
                  class HomomorphicHash (α : Type) [h : Hash α ] [m : HashMagma ] :
                  Instances

                    Decidability through α and CollResistant #

                    This is kinda important, it actually hides when we are using CollResistant hashes

                    def eq_eqhash {α : Type} [eqa : DecidableEq α] [o : Hash α ] [cfree : CollResistant α ] (a b : α) :
                    Equations
                    Instances For