1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use *;
use crate*;
pub const KECCAK_FIRST_SPARSE_BASE: u64 = 13;
// conveter for the function that unites together xi and i trnasformations of keccak:
// f_log = a ^ (~b & c) ^ d
// the corresponding algebraic encoding is f_alg: 2a + b + 3c + 2d
// | idx | a | b | c | d | a ^ (~b & c) ^ d | 2a + b + 3c + 2d |
// -------------------------------------------------------------
// | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
// | 1 | 0 | 0 | 0 | 1 | 1 | 2 |
// | 2 | 0 | 0 | 1 | 0 | 1 | 3 |
// | 3 | 0 | 0 | 1 | 1 | 0 | 5 |
// | 4 | 0 | 1 | 0 | 0 | 0 | 1 |
// | 5 | 0 | 1 | 0 | 1 | 1 | 3 |
// | 6 | 0 | 1 | 1 | 0 | 0 | 4 |
// | 7 | 0 | 1 | 1 | 1 | 1 | 6 |
// | 8 | 1 | 0 | 0 | 0 | 1 | 2 |
// | 9 | 1 | 0 | 0 | 1 | 0 | 4 |
// | 10 | 1 | 0 | 1 | 0 | 0 | 5 |
// | 11 | 1 | 0 | 1 | 1 | 1 | 7 |
// | 12 | 1 | 1 | 0 | 0 | 1 | 3 |
// | 13 | 1 | 1 | 0 | 1 | 0 | 5 |
// | 14 | 1 | 1 | 1 | 0 | 1 | 6 |
// | 15 | 1 | 1 | 1 | 1 | 0 | 8 |
// -----------------------------------------|------------------|
// this table shows that mapping f_alg -> f_log is indeed well-defined
pub const KECCAK_SECOND_SPARSE_BASE: u64 = 9;