binius_m3/gadgets/hash/keccak/
mod.rs

1// Copyright 2025 Irreducible Inc.
2
3//! SHA3-256 (Keccak) hash function verification gadgets.
4
5mod state;
6mod test_vector;
7mod trace;
8
9pub mod lookedup;
10pub mod stacked;
11pub use state::StateMatrix;
12
13const ROUNDS_PER_PERMUTATION: usize = 24;
14
15/// Rotation offsets, laid out as [x][y].
16const RHO: [[u32; 5]; 5] = [
17	[0, 36, 3, 41, 18],
18	[1, 44, 10, 45, 2],
19	[62, 6, 43, 15, 61],
20	[28, 55, 25, 21, 56],
21	[27, 20, 39, 8, 14],
22];
23
24/// RC\[i\] is a round constant used in the ⍳ step at the ith round.
25const RC: [u64; ROUNDS_PER_PERMUTATION] = [
26	0x0000000000000001,
27	0x0000000000008082,
28	0x800000000000808A,
29	0x8000000080008000,
30	0x000000000000808B,
31	0x0000000080000001,
32	0x8000000080008081,
33	0x8000000000008009,
34	0x000000000000008A,
35	0x0000000000000088,
36	0x0000000080008009,
37	0x000000008000000A,
38	0x000000008000808B,
39	0x800000000000008B,
40	0x8000000000008089,
41	0x8000000000008003,
42	0x8000000000008002,
43	0x8000000000000080,
44	0x000000000000800A,
45	0x800000008000000A,
46	0x8000000080008081,
47	0x8000000000008080,
48	0x0000000080000001,
49	0x8000000080008008,
50];