2#include <gmock/gmock.h>
3#include <gtest/gtest.h>
31using ::testing::StrictMock;
35using simulation::EventEmitter;
36using simulation::MockExecutionIdManager;
37using simulation::MockGreaterThan;
38using simulation::Poseidon2;
39using simulation::Poseidon2HashEvent;
40using simulation::Poseidon2PermutationEvent;
41using simulation::Poseidon2PermutationMemoryEvent;
42using tracegen::CalldataTraceBuilder;
43using tracegen::Poseidon2TraceBuilder;
44using tracegen::PrecomputedTraceBuilder;
45using tracegen::TestTraceContainer;
52class CalldataHashingConstrainingTest :
public ::testing::Test {
66class CalldataHashingConstrainingTestTraceHelper :
public CalldataHashingConstrainingTest {
68 TestTraceContainer process_calldata_hashing_trace(std::vector<std::vector<FF>> all_calldata_fields,
69 std::vector<uint32_t> context_ids)
74 TestTraceContainer
trace({
75 { { C::precomputed_first_row, 1 } },
79 for (uint32_t j = 0; j < all_calldata_fields.size(); j++) {
81 auto calldata_fields = all_calldata_fields[j];
85 auto calldata_field_at = [&calldata_fields](
size_t i) ->
FF {
86 return i < calldata_fields.size() ? calldata_fields[i] : 0;
90 .calldata = all_calldata_fields[j],
92 auto padding_amount = (3 - (calldata_fields.size() % 3)) % 3;
93 auto num_rounds = (calldata_fields.size() + padding_amount) / 3;
94 for (uint32_t i = 0; i < calldata_fields.size(); i += 3) {
98 { C::calldata_hashing_sel, 1 },
99 { C::calldata_hashing_start,
index == 0 ? 1 : 0 },
100 { C::calldata_hashing_sel_not_start,
index == 0 ? 0 : 1 },
101 { C::calldata_hashing_context_id,
context_id },
102 { C::calldata_hashing_calldata_size, calldata_fields.size() - 1 },
103 { C::calldata_hashing_input_len, calldata_fields.size() },
104 { C::calldata_hashing_rounds_rem, num_rounds },
105 { C::calldata_hashing_index_0_,
index },
106 { C::calldata_hashing_index_1_,
index + 1 },
107 { C::calldata_hashing_index_2_,
index + 2 },
108 { C::calldata_hashing_input_0_, calldata_field_at(
index) },
109 { C::calldata_hashing_input_1_, calldata_field_at(
index + 1) },
110 { C::calldata_hashing_input_2_, calldata_field_at(
index + 2) },
111 { C::calldata_hashing_output_hash,
hash },
112 { C::calldata_hashing_sel_not_padding_1, (num_rounds == 1) && (padding_amount == 2) ? 0 : 1 },
113 { C::calldata_hashing_sel_not_padding_2, (num_rounds == 1) && (padding_amount > 0) ? 0 : 1 },
114 { C::calldata_hashing_latch, (num_rounds == 1) ? 1 : 0 },
128TEST_F(CalldataHashingConstrainingTest, EmptyRow)
133TEST_F(CalldataHashingConstrainingTest, SingleCalldataHashOneRow)
137 std::vector<FF> calldata_fields = { 1, 2 };
141 auto trace = TestTraceContainer({
142 { { C::precomputed_first_row, 1 } },
144 { C::calldata_hashing_index_1_, 1 },
145 { C::calldata_hashing_index_2_, 2 },
147 { C::calldata_hashing_input_1_, 1 },
148 { C::calldata_hashing_input_2_, 2 },
149 { C::calldata_hashing_input_len, 3 },
150 { C::calldata_hashing_latch, 1 },
151 { C::calldata_hashing_sel_not_padding_1, 1 },
152 { C::calldata_hashing_sel_not_padding_2, 1 },
153 { C::calldata_hashing_sel_not_start, 0 },
154 { C::calldata_hashing_calldata_size, 2 },
155 { C::calldata_hashing_context_id, 1 },
156 { C::calldata_hashing_index_0_, 0 },
157 { C::calldata_hashing_output_hash,
hash },
158 { C::calldata_hashing_rounds_rem, 1 },
159 { C::calldata_hashing_sel, 1 },
160 { C::calldata_hashing_start, 1 },
164 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
167 check_relation<calldata_hashing>(trace);
168 check_all_interactions<CalldataTraceBuilder>(trace);
171TEST_F(CalldataHashingConstrainingTest, SingleCalldataHashOneElt)
175 std::vector<FF> calldata_fields = { 2 };
179 auto trace = TestTraceContainer({
180 { { C::precomputed_first_row, 1 } },
182 { C::calldata_hashing_index_1_, 1 },
183 { C::calldata_hashing_index_2_, 2 },
185 { C::calldata_hashing_input_1_, 2 },
186 { C::calldata_hashing_input_2_, 0 },
187 { C::calldata_hashing_input_len, 2 },
188 { C::calldata_hashing_latch, 1 },
189 { C::calldata_hashing_sel_not_padding_1, 1 },
190 { C::calldata_hashing_sel_not_padding_2, 0 },
191 { C::calldata_hashing_sel_not_start, 0 },
192 { C::calldata_hashing_calldata_size, 1 },
193 { C::calldata_hashing_context_id, 1 },
194 { C::calldata_hashing_index_0_, 0 },
195 { C::calldata_hashing_output_hash,
hash },
196 { C::calldata_hashing_rounds_rem, 1 },
197 { C::calldata_hashing_sel, 1 },
198 { C::calldata_hashing_start, 1 },
202 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
205 check_relation<calldata_hashing>(trace);
206 check_all_interactions<CalldataTraceBuilder>(trace);
209TEST_F(CalldataHashingConstrainingTest, EmptyCalldataHash)
213 std::vector<FF> calldata_fields = {};
217 auto trace = TestTraceContainer({
218 { { C::precomputed_first_row, 1 } },
220 { C::calldata_hashing_index_1_, 1 },
221 { C::calldata_hashing_index_2_, 2 },
223 { C::calldata_hashing_input_1_, 0 },
224 { C::calldata_hashing_input_2_, 0 },
225 { C::calldata_hashing_input_len, 1 },
226 { C::calldata_hashing_latch, 1 },
227 { C::calldata_hashing_sel_not_padding_1, 0 },
228 { C::calldata_hashing_sel_not_padding_2, 0 },
229 { C::calldata_hashing_sel_not_start, 0 },
230 { C::calldata_hashing_calldata_size, 0 },
231 { C::calldata_hashing_context_id, 1 },
232 { C::calldata_hashing_index_0_, 0 },
233 { C::calldata_hashing_output_hash,
hash },
234 { C::calldata_hashing_rounds_rem, 1 },
235 { C::calldata_hashing_sel, 1 },
236 { C::calldata_hashing_start, 1 },
240 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
243 check_relation<calldata_hashing>(trace);
244 check_all_interactions<CalldataTraceBuilder>(trace);
247TEST_F(CalldataHashingConstrainingTestTraceHelper, EmptyCalldataHash)
249 TestTraceContainer
trace = process_calldata_hashing_trace({}, { 1 });
251 check_relation<calldata_hashing>(trace);
252 check_all_interactions<CalldataTraceBuilder>(trace);
255TEST_F(CalldataHashingConstrainingTestTraceHelper, SingleCalldataHash100Fields)
258 FF hash =
FF(
"0x191383c9f8964afd3ea8879a03b7dda65d6724773966d18dcf80e452736fc1f3");
260 std::vector<FF> calldata_fields = {};
261 calldata_fields.reserve(100);
262 for (uint32_t i = 0; i < 100; i++) {
263 calldata_fields.push_back(
FF(i));
266 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
268 check_relation<calldata_hashing>(trace);
269 check_all_interactions<CalldataTraceBuilder>(trace);
270 EXPECT_EQ(
trace.
get(C::calldata_hashing_output_hash, 1),
hash);
273TEST_F(CalldataHashingConstrainingTestTraceHelper, MultipleCalldataHash)
280 TestTraceContainer
trace = process_calldata_hashing_trace(all_calldata_fields, { 1, 2, 3 });
282 check_relation<calldata_hashing>(trace);
283 check_all_interactions<CalldataTraceBuilder>(trace);
284 uint32_t latch_row = 17;
286 EXPECT_EQ(
trace.
get(C::calldata_hashing_latch, latch_row), 1);
287 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_2, latch_row), 1);
290 EXPECT_EQ(
trace.
get(C::calldata_hashing_latch, latch_row), 1);
291 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_2, latch_row), 0);
292 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_1, latch_row), 1);
295 EXPECT_EQ(
trace.
get(C::calldata_hashing_latch, latch_row), 1);
296 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_2, latch_row), 0);
297 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_1, latch_row), 0);
301TEST_F(CalldataHashingConstrainingTest, NegativeLatchNotSel)
303 TestTraceContainer
trace(
304 { { { C::precomputed_first_row, 1 } }, { { C::calldata_hashing_latch, 1 }, { C::calldata_hashing_sel, 1 } } });
307 trace.
set(C::calldata_hashing_sel, 1, 0);
309 "SEL_TOGGLED_AT_LATCH");
313 { C::calldata_latch, 1 },
314 { C::calldata_sel, 1 },
321 "SEL_TOGGLED_AT_LATCH");
324TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInvalidStartAfterLatch)
328 check_relation<calldata_hashing>(trace);
331 trace.
set(Column::calldata_hashing_start, 1, 0);
333 "START_AFTER_LATCH");
334 trace.
set(Column::calldata_hashing_start, 1, 1);
337 trace.
set(Column::calldata_hashing_start, 2, 0);
339 "START_AFTER_LATCH");
342TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInvalidStartIndex)
344 TestTraceContainer
trace = process_calldata_hashing_trace({
random_fields(10) }, { 1 });
345 check_relation<calldata_hashing>(trace);
348 trace.
set(Column::calldata_hashing_index_0_, 1, 5);
350 "START_INDEX_IS_ZERO");
353TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeStartIsSeparator)
355 TestTraceContainer
trace = process_calldata_hashing_trace({
random_fields(10) }, { 1 });
356 check_relation<calldata_hashing>(trace);
359 trace.
set(Column::calldata_hashing_input_0_, 1, 5);
361 "START_IS_SEPARATOR");
364TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInvalidIndexIncrements)
366 TestTraceContainer
trace = process_calldata_hashing_trace({
random_fields(10) }, { 1 });
367 check_relation<calldata_hashing>(trace);
370 trace.
set(Column::calldata_hashing_index_1_, 1, 2);
372 "INDEX_INCREMENTS_1");
373 trace.
set(Column::calldata_hashing_index_1_, 1, 1);
374 trace.
set(Column::calldata_hashing_index_2_, 1, 3);
376 "INDEX_INCREMENTS_2");
377 trace.
set(Column::calldata_hashing_index_2_, 1, 2);
379 trace.
set(Column::calldata_hashing_index_0_, 2, 2);
384TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeConsistency)
387 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
388 check_relation<calldata_hashing>(trace);
391 trace.
set(Column::calldata_hashing_context_id, 2, 2);
394 trace.
set(Column::calldata_hashing_context_id, 2, 1);
396 trace.
set(Column::calldata_hashing_output_hash, 2, 2);
399 trace.
set(Column::calldata_hashing_output_hash, 2,
trace.
get(Column::calldata_hashing_output_hash, 1));
401 trace.
set(Column::calldata_hashing_calldata_size, 2, 2);
404 trace.
set(Column::calldata_hashing_calldata_size, 2, 10);
407 trace.
set(Column::calldata_hashing_input_len, 1, 2);
410 "CALLDATA_HASH_INPUT_LENGTH_FIELDS");
413TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeCalldataInteraction)
416 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
417 check_all_interactions<CalldataTraceBuilder>(trace);
421 trace.
set(Column::calldata_hashing_index_0_, 2, 0);
423 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_0_settings>(trace)),
424 "Failed.*GET_CALLDATA_FIELD_0. Could not find tuple in destination.");
427 trace.
set(Column::calldata_hashing_input_1_, 2, 0);
429 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_1_settings>(trace)),
430 "Failed.*GET_CALLDATA_FIELD_1. Could not find tuple in destination.");
433 trace.
set(Column::calldata_hashing_context_id, 2, 0);
435 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_2_settings>(trace)),
436 "Failed.*GET_CALLDATA_FIELD_2. Could not find tuple in destination.");
439TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePaddingSelectors)
443 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
444 check_relation<calldata_hashing>(trace);
445 check_all_interactions<CalldataTraceBuilder>(trace);
448 trace.
set(Column::calldata_hashing_sel_not_padding_2, 2, 0);
450 trace.
set(Column::calldata_hashing_sel_not_padding_2, 2, 1);
453 trace.
set(Column::calldata_hashing_sel_not_padding_2, 4, 1);
455 "PADDING_CONSISTENCY");
456 trace.
set(Column::calldata_hashing_sel_not_padding_2, 4, 0);
459 trace.
set(Column::calldata_hashing_input_1_, 4, 1);
462 trace.
set(Column::calldata_hashing_input_2_, 4, 1);
467TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePaddingUnder)
472 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
473 check_relation<calldata_hashing>(trace);
474 check_all_interactions<CalldataTraceBuilder>(trace);
478 trace.
set(Column::calldata_hashing_sel_not_padding_1, 4, 1);
481 "CHECK_FINAL_INDEX");
483 for (uint32_t j = 1; j <= 4; j++) {
484 trace.
set(Column::calldata_hashing_calldata_size, j, 10);
485 trace.
set(Column::calldata_hashing_input_len, j, 11);
487 trace.
set(Column::poseidon2_hash_input_len, j, 11);
490 check_relation<calldata_hashing>(trace);
493 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_1_settings>(trace)),
494 "Failed.*GET_CALLDATA_FIELD_1. Could not find tuple in destination.");
497 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_check_final_size_settings>(trace)),
498 "Failed.*CHECK_FINAL_SIZE. Could not find tuple in destination.");
501TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePaddingOver)
506 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
507 check_relation<calldata_hashing>(trace);
508 check_all_interactions<CalldataTraceBuilder>(trace);
512 trace.
set(Column::calldata_hashing_sel_not_padding_2, 3, 0);
517 trace.
set(Column::calldata_hashing_input_2_, 3, 0);
519 for (uint32_t j = 1; j <= 3; j++) {
520 trace.
set(Column::calldata_hashing_calldata_size, j, 7);
521 trace.
set(Column::calldata_hashing_input_len, j, 8);
523 trace.
set(Column::poseidon2_hash_input_len, j, 8);
526 check_relation<calldata_hashing>(trace);
529 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_check_final_size_settings>(trace)),
530 "Failed.*CHECK_FINAL_SIZE. Could not find tuple in destination.");
533TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInputLen)
538 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
539 check_relation<calldata_hashing>(trace);
540 check_all_interactions<CalldataTraceBuilder>(trace);
543 trace.
set(Column::calldata_hashing_input_len, 1, 0);
545 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_poseidon2_hash_settings>(trace)),
546 "Failed.*LOOKUP_CALLDATA_HASHING_POSEIDON2_HASH. Could not find tuple in destination.");
548 trace.
set(Column::calldata_hashing_input_len, 1, 9);
550 trace.
set(Column::calldata_hashing_input_len, 2, 4);
553 "CALLDATA_HASH_INPUT_LENGTH_FIELDS");
555 trace.
set(Column::calldata_hashing_calldata_size, 2, 3);
559 for (uint32_t j = 1; j <= 3; j++) {
560 trace.
set(Column::calldata_hashing_calldata_size, j, 7);
561 trace.
set(Column::calldata_hashing_input_len, j, 8);
563 trace.
set(Column::poseidon2_hash_input_len, j, 8);
566 trace.
set(Column::calldata_hashing_sel_not_padding_2, 3, 0);
567 trace.
set(Column::calldata_hashing_input_2_, 3, 0);
568 check_relation<calldata_hashing>(trace);
571 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_check_final_size_settings>(trace)),
572 "Failed.*CHECK_FINAL_SIZE. Could not find tuple in destination.");
575TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeRounds)
578 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
579 check_relation<calldata_hashing>(trace);
580 check_all_interactions<CalldataTraceBuilder>(trace);
583 trace.
set(Column::calldata_hashing_rounds_rem, 1, 1);
588TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeOutputHash)
595 auto trace = TestTraceContainer({
596 { { C::precomputed_first_row, 1 } },
598 { C::calldata_hashing_index_1_, 1 },
599 { C::calldata_hashing_index_2_, 2 },
601 { C::calldata_hashing_input_1_, calldata_fields[0] },
602 { C::calldata_hashing_input_2_, calldata_fields[1] },
603 { C::calldata_hashing_input_len, 6 },
604 { C::calldata_hashing_latch, 0 },
605 { C::calldata_hashing_sel_not_padding_1, 1 },
606 { C::calldata_hashing_sel_not_padding_2, 1 },
607 { C::calldata_hashing_sel_not_start, 0 },
608 { C::calldata_hashing_calldata_size, 5 },
609 { C::calldata_hashing_context_id, 1 },
610 { C::calldata_hashing_index_0_, 0 },
611 { C::calldata_hashing_rounds_rem, 2 },
612 { C::calldata_hashing_sel, 1 },
613 { C::calldata_hashing_start, 1 },
616 { C::calldata_hashing_index_1_, 4 },
617 { C::calldata_hashing_index_2_, 5 },
618 { C::calldata_hashing_input_0_, calldata_fields[2] },
619 { C::calldata_hashing_input_1_, calldata_fields[3] },
620 { C::calldata_hashing_input_2_, calldata_fields[4] },
621 { C::calldata_hashing_input_len, 6 },
622 { C::calldata_hashing_latch, 1 },
623 { C::calldata_hashing_sel_not_padding_1, 1 },
624 { C::calldata_hashing_sel_not_padding_2, 1 },
625 { C::calldata_hashing_sel_not_start, 1 },
626 { C::calldata_hashing_calldata_size, 5 },
627 { C::calldata_hashing_context_id, 1 },
628 { C::calldata_hashing_index_0_, 3 },
629 { C::calldata_hashing_rounds_rem, 1 },
630 { C::calldata_hashing_sel, 1 },
634 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
636 auto good_hash = poseidon2_int.hash({
645 auto bad_hash = poseidon2_int.hash({
654 trace.
set(Column::calldata_hashing_output_hash, 1, good_hash);
656 trace.
set(Column::calldata_hashing_output_hash, 2, bad_hash);
658 check_all_interactions<CalldataTraceBuilder>(trace);
664TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePoseidonInteraction)
671 auto trace = TestTraceContainer({
672 { { C::precomputed_first_row, 1 } },
674 { C::calldata_hashing_index_1_, 1 },
675 { C::calldata_hashing_index_2_, 2 },
677 { C::calldata_hashing_input_1_, calldata_fields[0] },
678 { C::calldata_hashing_input_2_, calldata_fields[1] },
679 { C::calldata_hashing_input_len, 11 },
680 { C::calldata_hashing_latch, 0 },
681 { C::calldata_hashing_sel_not_padding_1, 1 },
682 { C::calldata_hashing_sel_not_padding_2, 1 },
683 { C::calldata_hashing_sel_not_start, 0 },
684 { C::calldata_hashing_calldata_size, 10 },
685 { C::calldata_hashing_context_id, 1 },
686 { C::calldata_hashing_index_0_, 0 },
687 { C::calldata_hashing_rounds_rem, 4 },
688 { C::calldata_hashing_sel, 1 },
689 { C::calldata_hashing_start, 1 },
692 { C::calldata_hashing_index_1_, 4 },
693 { C::calldata_hashing_index_2_, 5 },
694 { C::calldata_hashing_input_0_, calldata_fields[2] },
695 { C::calldata_hashing_input_1_, calldata_fields[3] },
696 { C::calldata_hashing_input_2_, calldata_fields[4] },
697 { C::calldata_hashing_input_len, 11 },
698 { C::calldata_hashing_latch, 0 },
699 { C::calldata_hashing_sel_not_padding_1, 1 },
700 { C::calldata_hashing_sel_not_padding_2, 1 },
701 { C::calldata_hashing_sel_not_start, 1 },
702 { C::calldata_hashing_calldata_size, 10 },
703 { C::calldata_hashing_context_id, 1 },
704 { C::calldata_hashing_index_0_, 3 },
705 { C::calldata_hashing_rounds_rem, 3 },
706 { C::calldata_hashing_sel, 1 },
709 { C::calldata_hashing_index_1_, 7 },
710 { C::calldata_hashing_index_2_, 8 },
711 { C::calldata_hashing_input_0_, calldata_fields[5] },
712 { C::calldata_hashing_input_1_, calldata_fields[6] },
713 { C::calldata_hashing_input_2_, calldata_fields[7] },
714 { C::calldata_hashing_input_len, 11 },
715 { C::calldata_hashing_latch, 0 },
716 { C::calldata_hashing_sel_not_padding_1, 1 },
717 { C::calldata_hashing_sel_not_padding_2, 1 },
718 { C::calldata_hashing_sel_not_start, 1 },
719 { C::calldata_hashing_calldata_size, 10 },
720 { C::calldata_hashing_context_id, 1 },
721 { C::calldata_hashing_index_0_, 6 },
722 { C::calldata_hashing_rounds_rem, 2 },
723 { C::calldata_hashing_sel, 1 },
726 { C::calldata_hashing_index_1_, 10 },
727 { C::calldata_hashing_index_2_, 11 },
728 { C::calldata_hashing_input_0_, calldata_fields[8] },
729 { C::calldata_hashing_input_1_, calldata_fields[9] },
730 { C::calldata_hashing_input_2_, 0 },
731 { C::calldata_hashing_input_len, 11 },
732 { C::calldata_hashing_latch, 1 },
733 { C::calldata_hashing_sel_not_padding_1, 1 },
734 { C::calldata_hashing_sel_not_padding_2, 0 },
735 { C::calldata_hashing_sel_not_start, 1 },
736 { C::calldata_hashing_calldata_size, 10 },
737 { C::calldata_hashing_context_id, 1 },
738 { C::calldata_hashing_index_0_, 9 },
739 { C::calldata_hashing_rounds_rem, 1 },
740 { C::calldata_hashing_sel, 1 },
744 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
746 auto bad_hash_prepended = poseidon2_int.hash({
762 auto bad_hash_misordered = poseidon2_int.hash({
776 check_relation<poseidon2>(trace);
777 for (uint32_t j = 1; j <= 4; j++) {
778 trace.
set(Column::calldata_hashing_output_hash, j, bad_hash_prepended);
782 check_relation<calldata_hashing>(trace);
784 "Failed.*LOOKUP_CALLDATA_HASHING_POSEIDON2_HASH. .*row 1");
786 for (uint32_t j = 1; j <= 4; j++) {
787 trace.
set(Column::calldata_hashing_output_hash, j, bad_hash_misordered);
790 check_relation<calldata_hashing>(trace);
792 "Failed.*LOOKUP_CALLDATA_HASHING_POSEIDON2_HASH. .*row 2");
795 trace.
set(Column::calldata_hashing_rounds_rem, 2, 2);
796 trace.
set(Column::calldata_hashing_calldata_size, 2, 8);
797 trace.
set(Column::calldata_hashing_input_len, 2, 9);
799 trace.
set(Column::poseidon2_hash_input_len, 3 + 5, 9);
800 trace.
set(Column::calldata_hashing_rounds_rem, 3, 3);
801 trace.
set(Column::calldata_hashing_calldata_size, 3, 12);
802 trace.
set(Column::calldata_hashing_input_len, 3, 13);
804 trace.
set(Column::poseidon2_hash_input_len, 2 + 5, 13);
806 check_relation<poseidon2>(trace);
808 check_all_interactions<CalldataTraceBuilder>(trace);
#define GENERATOR_INDEX__PUBLIC_CALLDATA
StrictMock< MockGreaterThan > mock_gt
EventEmitter< Poseidon2PermutationMemoryEvent > perm_mem_event_emitter
EventEmitter< Poseidon2PermutationEvent > perm_event_emitter
EventEmitter< Poseidon2HashEvent > hash_event_emitter
Poseidon2TraceBuilder poseidon2_builder
StrictMock< MockExecutionIdManager > mock_execution_id_manager
static constexpr size_t SR_PADDING_END
static constexpr size_t SR_PADDING_CONSISTENCY
static constexpr size_t SR_START_AFTER_LATCH
static constexpr size_t SR_START_IS_SEPARATOR
static constexpr size_t SR_ID_CONSISTENCY
static constexpr size_t SR_ROUNDS_DECREMENT
static constexpr size_t SR_CHECK_FINAL_INDEX
static constexpr size_t SR_SIZE_CONSISTENCY
static constexpr size_t SR_PADDED_BY_ZERO_2
static constexpr size_t SR_INDEX_INCREMENTS_2
static constexpr size_t SR_INDEX_INCREMENTS
static constexpr size_t SR_PADDED_BY_ZERO_1
static constexpr size_t SR_SEL_TOGGLED_AT_LATCH
static constexpr size_t SR_CALLDATA_HASH_INPUT_LENGTH_FIELDS
static constexpr size_t SR_HASH_CONSISTENCY
static constexpr size_t SR_INDEX_INCREMENTS_1
static constexpr size_t SR_START_INDEX_IS_ZERO
void process_hash(const simulation::EventEmitterInterface< simulation::Poseidon2HashEvent >::Container &hash_events, TraceContainer &trace)
const FF & get(Column col, uint32_t row) const
void set(Column col, uint32_t row, const FF &value)
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
Implements a parallelized batch insertion indexed tree Accepts template argument of the type of store...
PrecomputedTraceBuilder precomputed_builder
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
void hash(State &state) noexcept
TEST_F(AvmRecursiveTests, GoblinRecursion)
A test of the Goblinized AVM recursive verifier.
void check_relation(const tracegen::TestTraceContainer &trace, Ts... subrelation)
TestTraceContainer empty_trace()
std::vector< FF > random_fields(size_t n)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept