Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
keccakf1600.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
4#include <string_view>
5
10
11namespace bb::avm2 {
12
13template <typename FF_> class keccakf1600Impl {
14 public:
15 using FF = FF_;
16
17 static constexpr std::array<size_t, 130> SUBRELATION_PARTIAL_LENGTHS = {
18 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
20 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
21 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 3, 3
22 };
23
24 template <typename AllEntities> inline static bool skip(const AllEntities& in)
25 {
26 using C = ColumnAndShifts;
27
28 return (in.get(C::keccakf1600_sel)).is_zero();
29 }
30
31 template <typename ContainerOverSubrelations, typename AllEntities>
32 void static accumulate(ContainerOverSubrelations& evals,
33 const AllEntities& in,
34 [[maybe_unused]] const RelationParameters<FF>&,
35 [[maybe_unused]] const FF& scaling_factor);
36};
37
38template <typename FF> class keccakf1600 : public Relation<keccakf1600Impl<FF>> {
39 public:
40 static constexpr const std::string_view NAME = "keccakf1600";
41
42 // Subrelation indices constants, to be used in tests.
43 static constexpr size_t SR_SEL_ON_START_OR_END = 3;
44 static constexpr size_t SR_TRACE_CONTINUITY = 4;
45 static constexpr size_t SR_START_AFTER_LATCH = 5;
46 static constexpr size_t SR_SEL_NO_ERROR = 6;
47 static constexpr size_t SR_END_ON_ERROR = 8;
48 static constexpr size_t SR_KECCAK_ROUND_INCREMENT = 9;
49 static constexpr size_t SR_THETA_XOR_ROW_MSB_0_BOOLEAN = 13;
50 static constexpr size_t SR_THETA_XOR_ROW_ROTL1_0 = 14;
51 static constexpr size_t SR_THETA_XOR_ROW_MSB_1_BOOLEAN = 15;
52 static constexpr size_t SR_THETA_XOR_ROW_ROTL1_1 = 16;
53 static constexpr size_t SR_THETA_XOR_ROW_MSB_2_BOOLEAN = 17;
54 static constexpr size_t SR_THETA_XOR_ROW_ROTL1_2 = 18;
55 static constexpr size_t SR_THETA_XOR_ROW_MSB_3_BOOLEAN = 19;
56 static constexpr size_t SR_THETA_XOR_ROW_ROTL1_3 = 20;
57 static constexpr size_t SR_THETA_XOR_ROW_MSB_4_BOOLEAN = 21;
58 static constexpr size_t SR_THETA_XOR_ROW_ROTL1_4 = 22;
59 static constexpr size_t SR_STATE_RHO_01 = 23;
60 static constexpr size_t SR_STATE_RHO_02 = 24;
61 static constexpr size_t SR_STATE_RHO_03 = 25;
62 static constexpr size_t SR_STATE_RHO_04 = 26;
63 static constexpr size_t SR_STATE_RHO_10 = 27;
64 static constexpr size_t SR_STATE_RHO_11 = 28;
65 static constexpr size_t SR_STATE_RHO_12 = 29;
66 static constexpr size_t SR_STATE_RHO_13 = 30;
67 static constexpr size_t SR_STATE_RHO_14 = 31;
68 static constexpr size_t SR_STATE_RHO_20 = 32;
69 static constexpr size_t SR_STATE_RHO_21 = 33;
70 static constexpr size_t SR_STATE_RHO_22 = 34;
71 static constexpr size_t SR_STATE_RHO_23 = 35;
72 static constexpr size_t SR_STATE_RHO_24 = 36;
73 static constexpr size_t SR_STATE_RHO_30 = 37;
74 static constexpr size_t SR_STATE_RHO_31 = 38;
75 static constexpr size_t SR_STATE_RHO_32 = 39;
76 static constexpr size_t SR_STATE_RHO_33 = 40;
77 static constexpr size_t SR_STATE_RHO_34 = 41;
78 static constexpr size_t SR_STATE_RHO_40 = 42;
79 static constexpr size_t SR_STATE_RHO_41 = 43;
80 static constexpr size_t SR_STATE_RHO_42 = 44;
81 static constexpr size_t SR_STATE_RHO_43 = 45;
82 static constexpr size_t SR_STATE_RHO_44 = 46;
83 static constexpr size_t SR_STATE_PI_NOT_00 = 71;
84 static constexpr size_t SR_STATE_PI_NOT_01 = 72;
85 static constexpr size_t SR_STATE_PI_NOT_02 = 73;
86 static constexpr size_t SR_STATE_PI_NOT_03 = 74;
87 static constexpr size_t SR_STATE_PI_NOT_04 = 75;
88 static constexpr size_t SR_STATE_PI_NOT_10 = 76;
89 static constexpr size_t SR_STATE_PI_NOT_11 = 77;
90 static constexpr size_t SR_STATE_PI_NOT_12 = 78;
91 static constexpr size_t SR_STATE_PI_NOT_13 = 79;
92 static constexpr size_t SR_STATE_PI_NOT_14 = 80;
93 static constexpr size_t SR_STATE_PI_NOT_20 = 81;
94 static constexpr size_t SR_STATE_PI_NOT_21 = 82;
95 static constexpr size_t SR_STATE_PI_NOT_22 = 83;
96 static constexpr size_t SR_STATE_PI_NOT_23 = 84;
97 static constexpr size_t SR_STATE_PI_NOT_24 = 85;
98 static constexpr size_t SR_STATE_PI_NOT_30 = 86;
99 static constexpr size_t SR_STATE_PI_NOT_31 = 87;
100 static constexpr size_t SR_STATE_PI_NOT_32 = 88;
101 static constexpr size_t SR_STATE_PI_NOT_33 = 89;
102 static constexpr size_t SR_STATE_PI_NOT_34 = 90;
103 static constexpr size_t SR_STATE_PI_NOT_40 = 91;
104 static constexpr size_t SR_STATE_PI_NOT_41 = 92;
105 static constexpr size_t SR_STATE_PI_NOT_42 = 93;
106 static constexpr size_t SR_STATE_PI_NOT_43 = 94;
107 static constexpr size_t SR_STATE_PI_NOT_44 = 95;
108 static constexpr size_t SR_NEXT_STATE_IN_00 = 96;
109 static constexpr size_t SR_NEXT_STATE_IN_01 = 97;
110 static constexpr size_t SR_NEXT_STATE_IN_02 = 98;
111 static constexpr size_t SR_NEXT_STATE_IN_03 = 99;
112 static constexpr size_t SR_NEXT_STATE_IN_04 = 100;
113 static constexpr size_t SR_NEXT_STATE_IN_10 = 101;
114 static constexpr size_t SR_NEXT_STATE_IN_11 = 102;
115 static constexpr size_t SR_NEXT_STATE_IN_12 = 103;
116 static constexpr size_t SR_NEXT_STATE_IN_13 = 104;
117 static constexpr size_t SR_NEXT_STATE_IN_14 = 105;
118 static constexpr size_t SR_NEXT_STATE_IN_20 = 106;
119 static constexpr size_t SR_NEXT_STATE_IN_21 = 107;
120 static constexpr size_t SR_NEXT_STATE_IN_22 = 108;
121 static constexpr size_t SR_NEXT_STATE_IN_23 = 109;
122 static constexpr size_t SR_NEXT_STATE_IN_24 = 110;
123 static constexpr size_t SR_NEXT_STATE_IN_30 = 111;
124 static constexpr size_t SR_NEXT_STATE_IN_31 = 112;
125 static constexpr size_t SR_NEXT_STATE_IN_32 = 113;
126 static constexpr size_t SR_NEXT_STATE_IN_33 = 114;
127 static constexpr size_t SR_NEXT_STATE_IN_34 = 115;
128 static constexpr size_t SR_NEXT_STATE_IN_40 = 116;
129 static constexpr size_t SR_NEXT_STATE_IN_41 = 117;
130 static constexpr size_t SR_NEXT_STATE_IN_42 = 118;
131 static constexpr size_t SR_NEXT_STATE_IN_43 = 119;
132 static constexpr size_t SR_NEXT_STATE_IN_44 = 120;
133 static constexpr size_t SR_ERROR = 122;
134 static constexpr size_t SR_DST_ADDR_PROPAGATION = 123;
135 static constexpr size_t SR_CLK_PROPAGATION = 124;
136 static constexpr size_t SR_SPACE_ID_PROPAGATION = 125;
137 static constexpr size_t SR_SEL_NO_ERROR_PROPAGATION = 126;
138 static constexpr size_t SR_SEL_SLICE_READ = 127;
139 static constexpr size_t SR_SEL_SLICE_WRITE = 128;
140 static constexpr size_t SR_ROUND_COUNT_AT_WRITE = 129;
141
142 static std::string get_subrelation_label(size_t index)
143 {
144 switch (index) {
146 return "SEL_ON_START_OR_END";
148 return "TRACE_CONTINUITY";
150 return "START_AFTER_LATCH";
151 case SR_SEL_NO_ERROR:
152 return "SEL_NO_ERROR";
153 case SR_END_ON_ERROR:
154 return "END_ON_ERROR";
156 return "KECCAK_ROUND_INCREMENT";
158 return "THETA_XOR_ROW_MSB_0_BOOLEAN";
160 return "THETA_XOR_ROW_ROTL1_0";
162 return "THETA_XOR_ROW_MSB_1_BOOLEAN";
164 return "THETA_XOR_ROW_ROTL1_1";
166 return "THETA_XOR_ROW_MSB_2_BOOLEAN";
168 return "THETA_XOR_ROW_ROTL1_2";
170 return "THETA_XOR_ROW_MSB_3_BOOLEAN";
172 return "THETA_XOR_ROW_ROTL1_3";
174 return "THETA_XOR_ROW_MSB_4_BOOLEAN";
176 return "THETA_XOR_ROW_ROTL1_4";
177 case SR_STATE_RHO_01:
178 return "STATE_RHO_01";
179 case SR_STATE_RHO_02:
180 return "STATE_RHO_02";
181 case SR_STATE_RHO_03:
182 return "STATE_RHO_03";
183 case SR_STATE_RHO_04:
184 return "STATE_RHO_04";
185 case SR_STATE_RHO_10:
186 return "STATE_RHO_10";
187 case SR_STATE_RHO_11:
188 return "STATE_RHO_11";
189 case SR_STATE_RHO_12:
190 return "STATE_RHO_12";
191 case SR_STATE_RHO_13:
192 return "STATE_RHO_13";
193 case SR_STATE_RHO_14:
194 return "STATE_RHO_14";
195 case SR_STATE_RHO_20:
196 return "STATE_RHO_20";
197 case SR_STATE_RHO_21:
198 return "STATE_RHO_21";
199 case SR_STATE_RHO_22:
200 return "STATE_RHO_22";
201 case SR_STATE_RHO_23:
202 return "STATE_RHO_23";
203 case SR_STATE_RHO_24:
204 return "STATE_RHO_24";
205 case SR_STATE_RHO_30:
206 return "STATE_RHO_30";
207 case SR_STATE_RHO_31:
208 return "STATE_RHO_31";
209 case SR_STATE_RHO_32:
210 return "STATE_RHO_32";
211 case SR_STATE_RHO_33:
212 return "STATE_RHO_33";
213 case SR_STATE_RHO_34:
214 return "STATE_RHO_34";
215 case SR_STATE_RHO_40:
216 return "STATE_RHO_40";
217 case SR_STATE_RHO_41:
218 return "STATE_RHO_41";
219 case SR_STATE_RHO_42:
220 return "STATE_RHO_42";
221 case SR_STATE_RHO_43:
222 return "STATE_RHO_43";
223 case SR_STATE_RHO_44:
224 return "STATE_RHO_44";
226 return "STATE_PI_NOT_00";
228 return "STATE_PI_NOT_01";
230 return "STATE_PI_NOT_02";
232 return "STATE_PI_NOT_03";
234 return "STATE_PI_NOT_04";
236 return "STATE_PI_NOT_10";
238 return "STATE_PI_NOT_11";
240 return "STATE_PI_NOT_12";
242 return "STATE_PI_NOT_13";
244 return "STATE_PI_NOT_14";
246 return "STATE_PI_NOT_20";
248 return "STATE_PI_NOT_21";
250 return "STATE_PI_NOT_22";
252 return "STATE_PI_NOT_23";
254 return "STATE_PI_NOT_24";
256 return "STATE_PI_NOT_30";
258 return "STATE_PI_NOT_31";
260 return "STATE_PI_NOT_32";
262 return "STATE_PI_NOT_33";
264 return "STATE_PI_NOT_34";
266 return "STATE_PI_NOT_40";
268 return "STATE_PI_NOT_41";
270 return "STATE_PI_NOT_42";
272 return "STATE_PI_NOT_43";
274 return "STATE_PI_NOT_44";
276 return "NEXT_STATE_IN_00";
278 return "NEXT_STATE_IN_01";
280 return "NEXT_STATE_IN_02";
282 return "NEXT_STATE_IN_03";
284 return "NEXT_STATE_IN_04";
286 return "NEXT_STATE_IN_10";
288 return "NEXT_STATE_IN_11";
290 return "NEXT_STATE_IN_12";
292 return "NEXT_STATE_IN_13";
294 return "NEXT_STATE_IN_14";
296 return "NEXT_STATE_IN_20";
298 return "NEXT_STATE_IN_21";
300 return "NEXT_STATE_IN_22";
302 return "NEXT_STATE_IN_23";
304 return "NEXT_STATE_IN_24";
306 return "NEXT_STATE_IN_30";
308 return "NEXT_STATE_IN_31";
310 return "NEXT_STATE_IN_32";
312 return "NEXT_STATE_IN_33";
314 return "NEXT_STATE_IN_34";
316 return "NEXT_STATE_IN_40";
318 return "NEXT_STATE_IN_41";
320 return "NEXT_STATE_IN_42";
322 return "NEXT_STATE_IN_43";
324 return "NEXT_STATE_IN_44";
325 case SR_ERROR:
326 return "ERROR";
328 return "DST_ADDR_PROPAGATION";
330 return "CLK_PROPAGATION";
332 return "SPACE_ID_PROPAGATION";
334 return "SEL_NO_ERROR_PROPAGATION";
336 return "SEL_SLICE_READ";
338 return "SEL_SLICE_WRITE";
340 return "ROUND_COUNT_AT_WRITE";
341 }
342 return std::to_string(index);
343 }
344};
345
346} // namespace bb::avm2
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static constexpr size_t SR_STATE_RHO_20
static constexpr size_t SR_THETA_XOR_ROW_ROTL1_0
static constexpr size_t SR_NEXT_STATE_IN_10
static constexpr size_t SR_SEL_NO_ERROR
static constexpr size_t SR_NEXT_STATE_IN_41
static constexpr size_t SR_STATE_RHO_14
static constexpr size_t SR_STATE_PI_NOT_12
static constexpr size_t SR_NEXT_STATE_IN_21
static constexpr size_t SR_STATE_PI_NOT_01
static constexpr size_t SR_STATE_RHO_44
static constexpr size_t SR_THETA_XOR_ROW_ROTL1_2
static constexpr size_t SR_STATE_PI_NOT_00
static constexpr size_t SR_NEXT_STATE_IN_04
static constexpr size_t SR_NEXT_STATE_IN_33
static constexpr size_t SR_STATE_PI_NOT_11
static constexpr size_t SR_STATE_PI_NOT_10
static constexpr size_t SR_KECCAK_ROUND_INCREMENT
static constexpr size_t SR_STATE_RHO_22
static constexpr size_t SR_NEXT_STATE_IN_34
static constexpr size_t SR_THETA_XOR_ROW_MSB_4_BOOLEAN
static constexpr size_t SR_STATE_RHO_11
static constexpr size_t SR_NEXT_STATE_IN_20
static constexpr size_t SR_STATE_RHO_12
static constexpr size_t SR_STATE_PI_NOT_20
static std::string get_subrelation_label(size_t index)
static constexpr size_t SR_STATE_PI_NOT_03
static constexpr size_t SR_THETA_XOR_ROW_MSB_3_BOOLEAN
static constexpr const std::string_view NAME
static constexpr size_t SR_CLK_PROPAGATION
static constexpr size_t SR_STATE_PI_NOT_32
static constexpr size_t SR_STATE_PI_NOT_02
static constexpr size_t SR_NEXT_STATE_IN_23
static constexpr size_t SR_NEXT_STATE_IN_02
static constexpr size_t SR_STATE_PI_NOT_04
static constexpr size_t SR_NEXT_STATE_IN_01
static constexpr size_t SR_SEL_NO_ERROR_PROPAGATION
static constexpr size_t SR_STATE_PI_NOT_23
static constexpr size_t SR_STATE_RHO_24
static constexpr size_t SR_STATE_RHO_21
static constexpr size_t SR_STATE_RHO_04
static constexpr size_t SR_STATE_PI_NOT_22
static constexpr size_t SR_STATE_RHO_13
static constexpr size_t SR_STATE_RHO_02
static constexpr size_t SR_ROUND_COUNT_AT_WRITE
static constexpr size_t SR_THETA_XOR_ROW_ROTL1_4
static constexpr size_t SR_STATE_RHO_43
static constexpr size_t SR_STATE_PI_NOT_43
static constexpr size_t SR_NEXT_STATE_IN_14
static constexpr size_t SR_SEL_SLICE_READ
static constexpr size_t SR_NEXT_STATE_IN_43
static constexpr size_t SR_NEXT_STATE_IN_32
static constexpr size_t SR_STATE_PI_NOT_42
static constexpr size_t SR_SEL_ON_START_OR_END
static constexpr size_t SR_STATE_PI_NOT_14
static constexpr size_t SR_SEL_SLICE_WRITE
static constexpr size_t SR_STATE_PI_NOT_13
static constexpr size_t SR_STATE_RHO_42
static constexpr size_t SR_THETA_XOR_ROW_MSB_1_BOOLEAN
static constexpr size_t SR_STATE_RHO_10
static constexpr size_t SR_THETA_XOR_ROW_ROTL1_3
static constexpr size_t SR_STATE_PI_NOT_21
static constexpr size_t SR_STATE_RHO_32
static constexpr size_t SR_STATE_RHO_33
static constexpr size_t SR_STATE_PI_NOT_41
static constexpr size_t SR_STATE_PI_NOT_30
static constexpr size_t SR_NEXT_STATE_IN_13
static constexpr size_t SR_STATE_RHO_34
static constexpr size_t SR_END_ON_ERROR
static constexpr size_t SR_DST_ADDR_PROPAGATION
static constexpr size_t SR_NEXT_STATE_IN_30
static constexpr size_t SR_STATE_PI_NOT_34
static constexpr size_t SR_STATE_PI_NOT_33
static constexpr size_t SR_NEXT_STATE_IN_00
static constexpr size_t SR_STATE_PI_NOT_31
static constexpr size_t SR_STATE_RHO_31
static constexpr size_t SR_STATE_RHO_41
static constexpr size_t SR_STATE_PI_NOT_40
static constexpr size_t SR_STATE_RHO_01
static constexpr size_t SR_NEXT_STATE_IN_42
static constexpr size_t SR_STATE_PI_NOT_44
static constexpr size_t SR_NEXT_STATE_IN_40
static constexpr size_t SR_THETA_XOR_ROW_ROTL1_1
static constexpr size_t SR_STATE_RHO_23
static constexpr size_t SR_STATE_RHO_40
static constexpr size_t SR_START_AFTER_LATCH
static constexpr size_t SR_ERROR
static constexpr size_t SR_NEXT_STATE_IN_11
static constexpr size_t SR_STATE_RHO_03
static constexpr size_t SR_STATE_PI_NOT_24
static constexpr size_t SR_NEXT_STATE_IN_44
static constexpr size_t SR_NEXT_STATE_IN_24
static constexpr size_t SR_THETA_XOR_ROW_MSB_0_BOOLEAN
static constexpr size_t SR_TRACE_CONTINUITY
static constexpr size_t SR_NEXT_STATE_IN_12
static constexpr size_t SR_NEXT_STATE_IN_03
static constexpr size_t SR_THETA_XOR_ROW_MSB_2_BOOLEAN
static constexpr size_t SR_NEXT_STATE_IN_22
static constexpr size_t SR_STATE_RHO_30
static constexpr size_t SR_NEXT_STATE_IN_31
static constexpr size_t SR_SPACE_ID_PROPAGATION
static constexpr std::array< size_t, 130 > SUBRELATION_PARTIAL_LENGTHS
static bool skip(const AllEntities &in)
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
AvmFlavorSettings::FF FF
Definition field.hpp:10
ColumnAndShifts
Definition columns.hpp:34
std::string to_string(bb::avm2::ValueTag tag)
Container for parameters used by the grand product (permutation, lookup) Honk relations.