proof/AES_TraceBridgeProof.bend
qasim-bend-kit@0.1.0.2 · 37 lines · 4 definitions
1import Base
2import qasim-bend-kit@0.1.0.2/libs/AES256GCMCore.bend as Core
3
4
5
6
7def expand_input_matches(+fuel: Nat, +key: List<&2, U32>,
8 +initial_words: List<&2, U32>, +expected: List<&2, U32>,
9 initial_match: {Core.aes_words(key) == initial_words : List<&2, U32>},
10 expanded_match: {Core.aes_expand.go(fuel, 8, 1, initial_words) == expected : List<&2, U32>}) ->
11 {Core.aes_expand.go(fuel, 8, 1, Core.aes_words(key)) == expected : List<&2, U32>}:
12 Equal.trans(List<&2, U32>, Core.aes_expand.go(fuel, 8, 1, Core.aes_words(key)),
13 Core.aes_expand.go(fuel, 8, 1, initial_words), expected,
14 Equal.cong(List<&2, U32>, List<&2, U32>, values => Core.aes_expand.go(fuel, 8, 1, values),
15 Core.aes_words(key), initial_words, initial_match), expanded_match)
16
17def expand_key_matches(+fuel: Nat, +key: List<&2, U32>,
18 +initial_words: List<&2, U32>, +expected: List<&2, U32>,
19 +initial_match: {Core.aes_words(key) == initial_words : List<&2, U32>},
20 +expanded_match: {Core.aes_expand.go(fuel, 8, 1, initial_words) == expected : List<&2, U32>}) ->
21 {Core.aes_expand_key(fuel, key) == expected : List<&2, U32>}:
22 match key:
23 case Nil{}: expand_input_matches(fuel, key, initial_words, expected, initial_match, expanded_match)
24 case head <> tail: expand_input_matches(fuel, key, initial_words, expected, initial_match, expanded_match)
25
26def expansion_alias() ->
27 {Core.aes256_expand == (+key => Core.aes_expand_key(52n, key)) :
28 @+key: List<&2, U32> -> List<&2, U32>}:
29 {==}
30
31def public_expansion_matches(+key: List<&2, U32>, +expected: List<&2, U32>,
32 same: {Core.aes_expand_key(52n, key) == expected : List<&2, U32>}) ->
33 {Core.aes256_expand(key) == expected : List<&2, U32>}:
34 Equal.trans(List<&2, U32>, Core.aes256_expand(key), Core.aes_expand_key(52n, key), expected,
35 Equal.cong((@+input: List<&2, U32> -> List<&2, U32>), List<&2, U32>,
36 function => function(key), Core.aes256_expand,
37 +input => Core.aes_expand_key(52n, input), expansion_alias()), same)