Documentation

GaudisCrypt.Examples.SHA3.Common

SHA-3: common definitions and lemmas (EasyCrypt proof/Common.ec) #

The sponge's rate r and capacity c; blocks and capacities as bit words; the ideal permutation Perm; padding, chunking and the conversions between bits and blocks; the validity predicates.

The mapping conventions are in notes/SHA3/README.md, the declaration-by-declaration status in notes/SHA3/Mapping.md. In this file:

EasyCrypt's abstract constants op r : { int | 2 <= r } as ge2_r and op c : { int | 0 < c } as gt0_c.

Instances

    #

    clone export BitWord as Capacity and clone export BitWord as Block #

    blocks (enum, the clone's FinType enumeration).

    Equations
    Instances For

      Auxiliary lemmas #

      theorem GaudisCrypt.SHA3.Common.dvdz_close [Params] (n : ℤ) :
      r ∣ n → 0 < n ∧ n < 2 * r → n = r
      theorem GaudisCrypt.SHA3.Common.bits2w_inj_eq [Params] (cs ds : List Bool) :
      EC.size cs = r → EC.size ds = r → (mkblock cs = mkblock ds ↔ cs = ds)
      theorem GaudisCrypt.SHA3.Common.last_drop_all_but_last {α : Type} (y : α) (xs : List α) :
      xs = [] ∨ EC.drop (EC.size xs - 1) xs = [EC.last y xs]

      The primitive: clone export PRP as PRPt with type D <- block * capacity, #

      clone export StrongPRP as PRPSec, clone export RP as Perm with op dD <- bdistr \*` cdistr`

      The clone's module variables Perm.m, Perm.mi.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[reducible, inline]

          [module] "RP" as "Perm": the ideal permutation on block * capacity.

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

            Needed blocks computation #

            theorem GaudisCrypt.SHA3.Common.needed_blocks_eq [Params] (n : ℤ) :
            (n + r - 1) / r = n / r + if n % r = 0 then 0 else 1

            Not an EasyCrypt lemma: (n + r - 1) %/ r is n %/ r, plus one unless r divides n.

            theorem GaudisCrypt.SHA3.Common.needed_blocks_correct [Params] (n : ℤ) :
            0 ≤ (n + r - 1) / r * r - n ∧ (n + r - 1) / r * r - n < r
            theorem GaudisCrypt.SHA3.Common.needed_blocks_rel_div_r [Params] (n : ℤ) :
            n / r = (n + r - 1) / r ∨ n / r + 1 = (n + r - 1) / r

            Padding/unpadding #

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem GaudisCrypt.SHA3.Common.size_pad_equiv [Params] (m : ℤ) :
              0 ≤ m → m + num0 m + 2 = (m + 1) / r * r + r
              theorem GaudisCrypt.SHA3.Common.padE [Params] (s : List Bool) (n : ℤ) :
              0 ≤ n ∧ n < r → r ∣ EC.size s + n + 2 → pad s = s ++ [true] ++ EC.nseq n false ++ [true]

              Not an EasyCrypt lemma: a bit list with a true is falses, that true, and the rest.

              Not an EasyCrypt lemma: what unpad accepts is a padding.

              Instances For

                Chunking #

                theorem GaudisCrypt.SHA3.Common.chunk_cons' {α : Type} (r : ℤ) (bs : List α) (h0 : 0 < r) (h : r ≤ EC.size bs) :

                Not an EasyCrypt lemma: at least r bits make a first chunk, then the chunks of the rest.

                theorem GaudisCrypt.SHA3.Common.flattenK [Params] (bs : List (List Bool)) :
                (∀ b ∈ bs, EC.size b = r) → chunk bs.flatten = bs

                Converting between block lists and bits #

                Padding to blocks / unpadding from blocks #

                Extending/stripping #

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem GaudisCrypt.SHA3.Common.findIdx_replicate_append {α : Type} (p : α → Bool) (a : α) (ha : p a = false) (k : ℕ) (l : List α) :

                  Not an EasyCrypt lemma: before the first match, findIdx sees only non-matches.

                  theorem GaudisCrypt.SHA3.Common.extendK [Params] (xs : List block) (n : ℤ) :
                  EC.last b0 xs ≠ b0 → 0 ≤ n → strip (extend xs n) = (xs, n)

                  Validity #

                  Instances For
                    Instances For
                      Instances For