30 const auto sha256_STATE_TAG_DIFF_4 = (in.get(C::sha256_memory_tag_4_) - constants_MEM_TAG_U32);
31 const auto sha256_STATE_TAG_DIFF_5 = (in.get(C::sha256_memory_tag_5_) - constants_MEM_TAG_U32);
32 const auto sha256_STATE_TAG_DIFF_6 = (in.get(C::sha256_memory_tag_6_) - constants_MEM_TAG_U32);
33 const auto sha256_STATE_TAG_DIFF_7 = (in.get(C::sha256_memory_tag_7_) - constants_MEM_TAG_U32);
34 const auto sha256_BATCHED_TAG_CHECK =
FF(1) * sha256_STATE_TAG_DIFF_0 +
FF(8) * sha256_STATE_TAG_DIFF_1 +
35 FF(64) * sha256_STATE_TAG_DIFF_2 +
FF(512) * sha256_STATE_TAG_DIFF_3 +
36 FF(4096) * sha256_STATE_TAG_DIFF_4 +
FF(32768) * sha256_STATE_TAG_DIFF_5 +
37 FF(262144) * sha256_STATE_TAG_DIFF_6 +
FF(2097152) * sha256_STATE_TAG_DIFF_7;
38 const auto sha256_INPUT_TAG_DIFF =
39 in.get(C::sha256_sel_read_input_from_memory) * (in.get(C::sha256_input_tag) - constants_MEM_TAG_U32);
40 const auto sha256_LATCH_ON_ERROR = (
FF(1) - (
FF(1) - in.get(C::sha256_mem_out_of_range_err)) *
41 (
FF(1) - in.get(C::sha256_sel_invalid_state_tag_err)) *
42 (
FF(1) - in.get(C::sha256_sel_invalid_input_row_tag_err)));
46 auto tmp = in.get(C::sha256_sel) * (
FF(1) - in.get(C::sha256_sel));
47 tmp *= scaling_factor;
48 std::get<0>(evals) +=
typename Accumulator::View(tmp);
52 auto tmp = in.get(C::sha256_start) * (
FF(1) - in.get(C::sha256_sel));
53 tmp *= scaling_factor;
54 std::get<1>(evals) +=
typename Accumulator::View(tmp);
58 auto tmp = in.get(C::sha256_latch) * (
FF(1) - in.get(C::sha256_latch));
59 tmp *= scaling_factor;
60 std::get<2>(evals) +=
typename Accumulator::View(tmp);
64 auto tmp = in.get(C::sha256_latch) * (
FF(1) - in.get(C::sha256_sel));
65 tmp *= scaling_factor;
66 std::get<3>(evals) +=
typename Accumulator::View(tmp);
70 auto tmp = in.get(C::sha256_sel_shift) * (in.get(C::sha256_start_shift) - sha256_LATCH_CONDITION);
71 tmp *= scaling_factor;
72 std::get<4>(evals) +=
typename Accumulator::View(tmp);
76 auto tmp = (
FF(1) - sha256_LATCH_CONDITION) * (in.get(C::sha256_sel_shift) - in.get(C::sha256_sel));
77 tmp *= scaling_factor;
78 std::get<5>(evals) +=
typename Accumulator::View(tmp);
82 auto tmp = (
FF(1) - sha256_LATCH_CONDITION) *
83 (in.get(C::sha256_execution_clk_shift) - in.get(C::sha256_execution_clk));
84 tmp *= scaling_factor;
85 std::get<6>(evals) +=
typename Accumulator::View(tmp);
89 auto tmp = (
FF(1) - sha256_LATCH_CONDITION) * (in.get(C::sha256_space_id_shift) - in.get(C::sha256_space_id));
90 tmp *= scaling_factor;
91 std::get<7>(evals) +=
typename Accumulator::View(tmp);
96 (
FF(1) - sha256_LATCH_CONDITION) * (in.get(C::sha256_output_addr_shift) - in.get(C::sha256_output_addr));
97 tmp *= scaling_factor;
98 std::get<8>(evals) +=
typename Accumulator::View(tmp);
102 auto tmp = in.get(C::sha256_start) * (in.get(C::sha256_max_mem_addr) - constants_AVM_HIGHEST_MEM_ADDRESS);
103 tmp *= scaling_factor;
104 std::get<9>(evals) +=
typename Accumulator::View(tmp);
109 (in.get(C::sha256_max_state_addr) - in.get(C::sha256_start) * (in.get(C::sha256_state_addr) +
FF(7)));
110 tmp *= scaling_factor;
116 (in.get(C::sha256_max_input_addr) - in.get(C::sha256_start) * (in.get(C::sha256_input_addr) +
FF(15)));
117 tmp *= scaling_factor;
123 (in.get(C::sha256_max_output_addr) - in.get(C::sha256_start) * (in.get(C::sha256_output_addr) +
FF(7)));
124 tmp *= scaling_factor;
129 auto tmp = (in.get(C::sha256_mem_out_of_range_err) -
130 (
FF(1) - (
FF(1) - in.get(C::sha256_sel_state_out_of_range_err)) *
131 (
FF(1) - in.get(C::sha256_sel_input_out_of_range_err)) *
132 (
FF(1) - in.get(C::sha256_sel_output_out_of_range_err))));
133 tmp *= scaling_factor;
138 auto tmp = (in.get(C::sha256_u32_tag) - in.get(C::sha256_sel) * constants_MEM_TAG_U32);
139 tmp *= scaling_factor;
145 (in.get(C::sha256_sel_mem_state_or_output) - (sha256_STATE_READ_CONDITION + sha256_OUTPUT_WRITE_CONDITION));
146 tmp *= scaling_factor;
151 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
152 (in.get(C::sha256_memory_address_0_) - (sha256_MEM_ADDR +
FF(0)));
153 tmp *= scaling_factor;
158 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
159 (in.get(C::sha256_memory_address_1_) - (sha256_MEM_ADDR +
FF(1)));
160 tmp *= scaling_factor;
165 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
166 (in.get(C::sha256_memory_address_2_) - (sha256_MEM_ADDR +
FF(2)));
167 tmp *= scaling_factor;
172 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
173 (in.get(C::sha256_memory_address_3_) - (sha256_MEM_ADDR +
FF(3)));
174 tmp *= scaling_factor;
179 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
180 (in.get(C::sha256_memory_address_4_) - (sha256_MEM_ADDR +
FF(4)));
181 tmp *= scaling_factor;
186 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
187 (in.get(C::sha256_memory_address_5_) - (sha256_MEM_ADDR +
FF(5)));
188 tmp *= scaling_factor;
193 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
194 (in.get(C::sha256_memory_address_6_) - (sha256_MEM_ADDR +
FF(6)));
195 tmp *= scaling_factor;
200 auto tmp = in.get(C::sha256_sel_mem_state_or_output) *
201 (in.get(C::sha256_memory_address_7_) - (sha256_MEM_ADDR +
FF(7)));
202 tmp *= scaling_factor;
208 in.get(C::sha256_sel_mem_state_or_output) *
209 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_0_) - in.get(C::sha256_init_a)) +
210 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_0_) - in.get(C::sha256_output_a_rhs)));
211 tmp *= scaling_factor;
217 in.get(C::sha256_sel_mem_state_or_output) *
218 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_1_) - in.get(C::sha256_init_b)) +
219 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_1_) - in.get(C::sha256_output_b_rhs)));
220 tmp *= scaling_factor;
226 in.get(C::sha256_sel_mem_state_or_output) *
227 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_2_) - in.get(C::sha256_init_c)) +
228 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_2_) - in.get(C::sha256_output_c_rhs)));
229 tmp *= scaling_factor;
235 in.get(C::sha256_sel_mem_state_or_output) *
236 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_3_) - in.get(C::sha256_init_d)) +
237 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_3_) - in.get(C::sha256_output_d_rhs)));
238 tmp *= scaling_factor;
244 in.get(C::sha256_sel_mem_state_or_output) *
245 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_4_) - in.get(C::sha256_init_e)) +
246 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_4_) - in.get(C::sha256_output_e_rhs)));
247 tmp *= scaling_factor;
253 in.get(C::sha256_sel_mem_state_or_output) *
254 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_5_) - in.get(C::sha256_init_f)) +
255 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_5_) - in.get(C::sha256_output_f_rhs)));
256 tmp *= scaling_factor;
262 in.get(C::sha256_sel_mem_state_or_output) *
263 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_6_) - in.get(C::sha256_init_g)) +
264 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_6_) - in.get(C::sha256_output_g_rhs)));
265 tmp *= scaling_factor;
271 in.get(C::sha256_sel_mem_state_or_output) *
272 (sha256_STATE_READ_CONDITION * (in.get(C::sha256_memory_register_7_) - in.get(C::sha256_init_h)) +
273 sha256_OUTPUT_WRITE_CONDITION * (in.get(C::sha256_memory_register_7_) - in.get(C::sha256_output_h_rhs)));
274 tmp *= scaling_factor;
279 auto tmp = (in.get(C::sha256_rw) - sha256_OUTPUT_WRITE_CONDITION);
280 tmp *= scaling_factor;
285 auto tmp = in.get(C::sha256_sel_invalid_state_tag_err) * (
FF(1) - in.get(C::sha256_sel_invalid_state_tag_err));
286 tmp *= scaling_factor;
292 (sha256_STATE_READ_CONDITION * sha256_BATCHED_TAG_CHECK *
293 ((
FF(1) - in.get(C::sha256_sel_invalid_state_tag_err)) * (
FF(1) - in.get(C::sha256_batch_tag_inv)) +
294 in.get(C::sha256_batch_tag_inv)) -
295 in.get(C::sha256_sel_invalid_state_tag_err));
296 tmp *= scaling_factor;
301 auto tmp = sha256_OUTPUT_WRITE_CONDITION * sha256_BATCHED_TAG_CHECK;
302 tmp *= scaling_factor;
307 auto tmp = in.get(C::sha256_sel_is_input_round) * (
FF(1) - in.get(C::sha256_sel_is_input_round));
308 tmp *= scaling_factor;
313 auto tmp = in.get(C::sha256_start) * (in.get(C::sha256_sel_is_input_round) -
FF(1));
314 tmp *= scaling_factor;
319 auto tmp = (
FF(1) - sha256_LATCH_CONDITION) *
320 (in.get(C::sha256_input_rounds_rem) * ((
FF(1) - in.get(C::sha256_sel_is_input_round)) *
321 (
FF(1) - in.get(C::sha256_input_rounds_rem_inv)) +
322 in.get(C::sha256_input_rounds_rem_inv)) -
323 in.get(C::sha256_sel_is_input_round));
324 tmp *= scaling_factor;
329 auto tmp = (
FF(1) - sha256_LATCH_CONDITION) * (
FF(1) - in.get(C::sha256_sel_is_input_round)) *
330 in.get(C::sha256_sel_is_input_round_shift);
331 tmp *= scaling_factor;
336 auto tmp = in.get(C::sha256_start) * (in.get(C::sha256_input_rounds_rem) -
FF(16));
337 tmp *= scaling_factor;
342 auto tmp = in.get(C::sha256_sel) * (
FF(1) - sha256_LATCH_CONDITION) *
343 (in.get(C::sha256_input_rounds_rem_shift) -
344 (in.get(C::sha256_input_rounds_rem) - in.get(C::sha256_sel_is_input_round)));
345 tmp *= scaling_factor;
350 auto tmp = (in.get(C::sha256_sel_read_input_from_memory) -
351 in.get(C::sha256_sel) * (
FF(1) - in.get(C::sha256_mem_out_of_range_err)) *
352 in.get(C::sha256_sel_is_input_round) * (
FF(1) - in.get(C::sha256_sel_invalid_state_tag_err)));
353 tmp *= scaling_factor;
358 auto tmp = in.get(C::sha256_sel_is_input_round) * (in.get(C::sha256_input) - in.get(C::sha256_w));
359 tmp *= scaling_factor;
364 auto tmp = in.get(C::sha256_sel_invalid_input_tag_err) * (
FF(1) - in.get(C::sha256_sel_invalid_input_tag_err));
365 tmp *= scaling_factor;
371 in.get(C::sha256_sel_invalid_input_row_tag_err) * (
FF(1) - in.get(C::sha256_sel_invalid_input_row_tag_err));
372 tmp *= scaling_factor;
377 auto tmp = (sha256_INPUT_TAG_DIFF * ((
FF(1) - in.get(C::sha256_sel_invalid_input_row_tag_err)) *
378 (
FF(1) - in.get(C::sha256_input_tag_diff_inv)) +
379 in.get(C::sha256_input_tag_diff_inv)) -
380 in.get(C::sha256_sel_invalid_input_row_tag_err));
381 tmp *= scaling_factor;
386 auto tmp = in.get(C::sha256_sel) * sha256_LATCH_ON_ERROR * (in.get(C::sha256_latch) -
FF(1));
387 tmp *= scaling_factor;
392 auto tmp = sha256_LATCH_CONDITION *
393 (in.get(C::sha256_sel_invalid_input_tag_err) - in.get(C::sha256_sel_invalid_input_row_tag_err));
394 tmp *= scaling_factor;
399 auto tmp = (
FF(1) - sha256_LATCH_CONDITION) *
400 (in.get(C::sha256_sel_invalid_input_tag_err) - in.get(C::sha256_sel_invalid_input_tag_err_shift));
401 tmp *= scaling_factor;
406 auto tmp = (in.get(C::sha256_err) - (
FF(1) - (
FF(1) - in.get(C::sha256_mem_out_of_range_err)) *
407 (
FF(1) - in.get(C::sha256_sel_invalid_state_tag_err)) *
408 (
FF(1) - in.get(C::sha256_sel_invalid_input_tag_err))));
409 tmp *= scaling_factor;