proofs/crypto/aes/ghash_defs.bend
bend-collections-laws-crypto@1.0.0.0 · 31 lines · 4 definitions
1import Base
2import bend-collections-laws-crypto@1.0.0.0/src/crypto/aes/gcm.bend as I
3import bend-collections-laws-crypto@1.0.0.0/spec/crypto/aes/gcm.bend as G
4import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/aes/gf.bend as GF
5
6
7
8
9
10
11def R(z: I.Block) -> Word(128n):
12 G.block(I.unpack(z))
13
14
15def bit(c: Bool) -> U32:
16 U32{WCon{c, Word.zero(31n)}}
17
18
19
20def F(acc: I.Acc, cs: List<&2, Bool>) -> Word(128n):
21 match acc:
22 case I.Acc{z, v}:
23 GF.sa(128n, G.low(), cs, R(z), R(v))
24
25
26def steps(cs: List<&2, Bool>, acc: I.Acc) -> I.Acc:
27 match cs:
28 case Nil{}:
29 acc
30 case c <> r:
31 steps(r, I.step(bit(c), acc))