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:
op r : { int | 2 <= r } as ge2_randop c : { int | 0 < c } as gt0_c(abstract constants with axioms) are the fields of the parameter classParams. Every later file takes[Common.Params].clone export BitWord as Block with op n <- r rename "word" as "block" …is the namespaceBlockof abbreviations atn := r, exported;Capacitylikewise.clone export PRP as PRPt with type D <- block * capacity,clone export StrongPRP as PRPSecandclone export RP as Perm with op dD <- bdistr \*` cdistrare applications of`GaudisCrypt/Lib/EC/PRP.leanatD := block × capacity`.intisℤ,%/,%%,%|are/,%,∣(EasyCrypt's division is Euclidean, as Lean's onℤ), and list operations onintare those ofGaudisCrypt/Lib/EC/List.lean.
op r: the rate.
Instances For
op c: the capacity.
Instances For
clone export BitWord as Capacity and clone export BitWord as Block #
@[reducible, inline]
Instances For
Instances For
Instances For
c0 (zerow).
Instances For
Instances For
@[reducible, inline]
Instances For
Instances For
Instances For
b0 (zerow).
Instances For
Instances For
blocks (enum, the clone's FinType enumeration).
Instances For
Instances For
Instances For
Auxiliary lemmas #
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`
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
[module type] "PRP" as "PRIMITIVE".
Equations
Instances For
Needed blocks computation #
Padding/unpadding #
Equations
Instances For
Equations
Instances For
Equations
Instances For
theorem
GaudisCrypt.SHA3.Common.split_first_true
(l : List Bool)
:
List.idxOf true l < l.length →
l = List.replicate (List.idxOf true l) false ++ true :: List.drop (List.idxOf true l + 1) l
Not an EasyCrypt lemma: a bit list with a true is falses, that true, and the rest.
Chunking #
Equations
Instances For
theorem
GaudisCrypt.SHA3.Common.chunk_padK
[Params]
:
EC.pcancel (chunk ∘ pad) (unpad ∘ List.flatten)
Converting between block lists and bits #
Equations
Instances For
Equations
Instances For
theorem
GaudisCrypt.SHA3.Common.bits2blocks_cat
[Params]
(xs ys : List Bool)
:
r ∣ EC.size xs → r ∣ EC.size ys → bits2blocks (xs ++ ys) = bits2blocks xs ++ bits2blocks ys
theorem
GaudisCrypt.SHA3.Common.bits2blocksK
[Params]
(bs : List Bool)
:
r ∣ EC.size bs → blocks2bits (bits2blocks bs) = bs
Padding to blocks / unpadding from blocks #
Extending/stripping #
Equations
Instances For
Validity #
In Sponge.
Equations
Instances For
@[implicit_reducible]
instance
GaudisCrypt.SHA3.Common.instDecidableValid_toplevel
(bs : List Bool)
:
Decidable (valid_toplevel bs)
Equations
In BlockSponge.
Equations
Instances For
@[implicit_reducible]
instance
GaudisCrypt.SHA3.Common.instDecidableValid_block
[Params]
(xs : List block)
:
Decidable (valid_block xs)
theorem
GaudisCrypt.SHA3.Common.valid_pad2blocks
[Params]
(bs : List Bool)
:
valid_block (pad2blocks bs)
theorem
GaudisCrypt.SHA3.Common.valid_block_ends_not_b0
[Params]
(xs : List block)
:
valid_block xs → EC.last b0 xs ≠ b0
- ValidBlockStruct1 [Params] {xs : List block} (ys : List block) (x : block) (s : List Bool) (n : ℤ) : xs = ys ++ [x] → 0 ≤ n → ofblock x = s ++ [true] ++ EC.nseq n false ++ [true] → valid_block_struct_spec xs
- ValidBlockStruct2 [Params] {xs : List block} (ys : List block) (y z : block) : xs = ys ++ [y, z] → EC.last false (ofblock y) = true → ofblock z = EC.nseq (r - 1) false ++ [true] → valid_block_struct_spec xs
Instances For
In AbsorbSponge.