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_size =
static_cast<uint32_t
>(all_calldata_fields[j].size()),
93 auto padding_amount = (3 - (calldata_fields.size() % 3)) % 3;
94 auto num_rounds = (calldata_fields.size() + padding_amount) / 3;
95 for (uint32_t i = 0; i < calldata_fields.size(); i += 3) {
99 { C::calldata_hashing_sel, 1 },
100 { C::calldata_hashing_start, index == 0 ? 1 : 0 },
101 { C::calldata_hashing_sel_not_start, index == 0 ? 0 : 1 },
102 { C::calldata_hashing_context_id,
context_id },
103 { C::calldata_hashing_calldata_size, calldata_fields.size() - 1 },
104 { C::calldata_hashing_input_len, calldata_fields.size() },
105 { C::calldata_hashing_rounds_rem, num_rounds },
106 { C::calldata_hashing_index_0_, index },
107 { C::calldata_hashing_index_1_, index + 1 },
108 { C::calldata_hashing_index_2_, index + 2 },
109 { C::calldata_hashing_input_0_, calldata_field_at(index) },
110 { C::calldata_hashing_input_1_, calldata_field_at(index + 1) },
111 { C::calldata_hashing_input_2_, calldata_field_at(index + 2) },
112 { C::calldata_hashing_output_hash,
hash },
113 { C::calldata_hashing_sel_not_padding_1, (num_rounds == 1) && (padding_amount == 2) ? 0 : 1 },
114 { C::calldata_hashing_sel_not_padding_2, (num_rounds == 1) && (padding_amount > 0) ? 0 : 1 },
115 { C::calldata_hashing_latch, (num_rounds == 1) ? 1 : 0 },
129TEST_F(CalldataHashingConstrainingTest, EmptyRow)
134TEST_F(CalldataHashingConstrainingTest, SingleCalldataHashOneRow)
138 std::vector<FF> calldata_fields = { 1, 2 };
142 auto trace = TestTraceContainer({
143 { { C::precomputed_first_row, 1 } },
145 { C::calldata_hashing_index_1_, 1 },
146 { C::calldata_hashing_index_2_, 2 },
148 { C::calldata_hashing_input_1_, 1 },
149 { C::calldata_hashing_input_2_, 2 },
150 { C::calldata_hashing_input_len, 3 },
151 { C::calldata_hashing_latch, 1 },
152 { C::calldata_hashing_sel_not_padding_1, 1 },
153 { C::calldata_hashing_sel_not_padding_2, 1 },
154 { C::calldata_hashing_sel_not_start, 0 },
155 { C::calldata_hashing_calldata_size, 2 },
156 { C::calldata_hashing_context_id, 1 },
157 { C::calldata_hashing_index_0_, 0 },
158 { C::calldata_hashing_output_hash,
hash },
159 { C::calldata_hashing_rounds_rem, 1 },
160 { C::calldata_hashing_sel, 1 },
161 { C::calldata_hashing_start, 1 },
165 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
168 check_relation<calldata_hashing>(
trace);
169 check_all_interactions<CalldataTraceBuilder>(
trace);
172TEST_F(CalldataHashingConstrainingTest, SingleCalldataHashOneElt)
176 std::vector<FF> calldata_fields = { 2 };
180 auto trace = TestTraceContainer({
181 { { C::precomputed_first_row, 1 } },
183 { C::calldata_hashing_index_1_, 1 },
184 { C::calldata_hashing_index_2_, 2 },
186 { C::calldata_hashing_input_1_, 2 },
187 { C::calldata_hashing_input_2_, 0 },
188 { C::calldata_hashing_input_len, 2 },
189 { C::calldata_hashing_latch, 1 },
190 { C::calldata_hashing_sel_not_padding_1, 1 },
191 { C::calldata_hashing_sel_not_padding_2, 0 },
192 { C::calldata_hashing_sel_not_start, 0 },
193 { C::calldata_hashing_calldata_size, 1 },
194 { C::calldata_hashing_context_id, 1 },
195 { C::calldata_hashing_index_0_, 0 },
196 { C::calldata_hashing_output_hash,
hash },
197 { C::calldata_hashing_rounds_rem, 1 },
198 { C::calldata_hashing_sel, 1 },
199 { C::calldata_hashing_start, 1 },
203 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
206 check_relation<calldata_hashing>(
trace);
207 check_all_interactions<CalldataTraceBuilder>(
trace);
210TEST_F(CalldataHashingConstrainingTest, EmptyCalldataHash)
214 std::vector<FF> calldata_fields = {};
218 auto trace = TestTraceContainer({
219 { { C::precomputed_first_row, 1 } },
221 { C::calldata_hashing_index_1_, 1 },
222 { C::calldata_hashing_index_2_, 2 },
224 { C::calldata_hashing_input_1_, 0 },
225 { C::calldata_hashing_input_2_, 0 },
226 { C::calldata_hashing_input_len, 1 },
227 { C::calldata_hashing_latch, 1 },
228 { C::calldata_hashing_sel_not_padding_1, 0 },
229 { C::calldata_hashing_sel_not_padding_2, 0 },
230 { C::calldata_hashing_sel_not_start, 0 },
231 { C::calldata_hashing_calldata_size, 0 },
232 { C::calldata_hashing_context_id, 1 },
233 { C::calldata_hashing_index_0_, 0 },
234 { C::calldata_hashing_output_hash,
hash },
235 { C::calldata_hashing_rounds_rem, 1 },
236 { C::calldata_hashing_sel, 1 },
237 { C::calldata_hashing_start, 1 },
241 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
244 check_relation<calldata_hashing>(
trace);
245 check_all_interactions<CalldataTraceBuilder>(
trace);
248TEST_F(CalldataHashingConstrainingTestTraceHelper, EmptyCalldataHash)
250 TestTraceContainer
trace = process_calldata_hashing_trace({}, { 1 });
252 check_relation<calldata_hashing>(
trace);
253 check_all_interactions<CalldataTraceBuilder>(
trace);
256TEST_F(CalldataHashingConstrainingTestTraceHelper, SingleCalldataHash100Fields)
259 FF hash =
FF(
"0x191383c9f8964afd3ea8879a03b7dda65d6724773966d18dcf80e452736fc1f3");
261 std::vector<FF> calldata_fields = {};
262 calldata_fields.reserve(100);
263 for (uint32_t i = 0; i < 100; i++) {
264 calldata_fields.push_back(
FF(i));
267 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
269 check_relation<calldata_hashing>(
trace);
270 check_all_interactions<CalldataTraceBuilder>(
trace);
271 EXPECT_EQ(
trace.
get(C::calldata_hashing_output_hash, 1),
hash);
274TEST_F(CalldataHashingConstrainingTestTraceHelper, MultipleCalldataHash)
281 TestTraceContainer
trace = process_calldata_hashing_trace(all_calldata_fields, { 1, 2, 3 });
283 check_relation<calldata_hashing>(
trace);
284 check_all_interactions<CalldataTraceBuilder>(
trace);
285 uint32_t latch_row = 17;
287 EXPECT_EQ(
trace.
get(C::calldata_hashing_latch, latch_row), 1);
288 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_2, latch_row), 1);
291 EXPECT_EQ(
trace.
get(C::calldata_hashing_latch, latch_row), 1);
292 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_2, latch_row), 0);
293 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_1, latch_row), 1);
296 EXPECT_EQ(
trace.
get(C::calldata_hashing_latch, latch_row), 1);
297 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_2, latch_row), 0);
298 EXPECT_EQ(
trace.
get(C::calldata_hashing_sel_not_padding_1, latch_row), 0);
302TEST_F(CalldataHashingConstrainingTest, NegativeLatchNotSel)
304 TestTraceContainer
trace(
305 { { { C::precomputed_first_row, 1 } }, { { C::calldata_hashing_latch, 1 }, { C::calldata_hashing_sel, 1 } } });
308 trace.
set(C::calldata_hashing_sel, 1, 0);
310 "SEL_TOGGLED_AT_LATCH");
314 { C::calldata_latch, 1 },
315 { C::calldata_sel, 1 },
322 "SEL_TOGGLED_AT_LATCH");
325TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInvalidStartAfterLatch)
329 check_relation<calldata_hashing>(
trace);
332 trace.
set(Column::calldata_hashing_start, 1, 0);
334 "START_AFTER_LATCH");
335 trace.
set(Column::calldata_hashing_start, 1, 1);
338 trace.
set(Column::calldata_hashing_start, 2, 0);
340 "START_AFTER_LATCH");
343TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInvalidStartIndex)
345 TestTraceContainer
trace = process_calldata_hashing_trace({
random_fields(10) }, { 1 });
346 check_relation<calldata_hashing>(
trace);
349 trace.
set(Column::calldata_hashing_index_0_, 1, 5);
351 "START_INDEX_IS_ZERO");
354TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeStartIsSeparator)
356 TestTraceContainer
trace = process_calldata_hashing_trace({
random_fields(10) }, { 1 });
357 check_relation<calldata_hashing>(
trace);
360 trace.
set(Column::calldata_hashing_input_0_, 1, 5);
362 "START_IS_SEPARATOR");
365TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInvalidIndexIncrements)
367 TestTraceContainer
trace = process_calldata_hashing_trace({
random_fields(10) }, { 1 });
368 check_relation<calldata_hashing>(
trace);
371 trace.
set(Column::calldata_hashing_index_1_, 1, 2);
373 "INDEX_INCREMENTS_1");
374 trace.
set(Column::calldata_hashing_index_1_, 1, 1);
375 trace.
set(Column::calldata_hashing_index_2_, 1, 3);
377 "INDEX_INCREMENTS_2");
378 trace.
set(Column::calldata_hashing_index_2_, 1, 2);
380 trace.
set(Column::calldata_hashing_index_0_, 2, 2);
385TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeConsistency)
388 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
389 check_relation<calldata_hashing>(
trace);
392 trace.
set(Column::calldata_hashing_context_id, 2, 2);
395 trace.
set(Column::calldata_hashing_context_id, 2, 1);
397 trace.
set(Column::calldata_hashing_output_hash, 2, 2);
400 trace.
set(Column::calldata_hashing_output_hash, 2,
trace.
get(Column::calldata_hashing_output_hash, 1));
402 trace.
set(Column::calldata_hashing_calldata_size, 2, 2);
405 trace.
set(Column::calldata_hashing_calldata_size, 2, 10);
408 trace.
set(Column::calldata_hashing_input_len, 1, 2);
411 "CALLDATA_HASH_INPUT_LENGTH_FIELDS");
414TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeCalldataInteraction)
417 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
418 check_all_interactions<CalldataTraceBuilder>(
trace);
422 trace.
set(Column::calldata_hashing_index_0_, 2, 0);
424 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_0_settings>(
trace)),
425 "Failed.*GET_CALLDATA_FIELD_0. Could not find tuple in destination.");
428 trace.
set(Column::calldata_hashing_input_1_, 2, 0);
430 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_1_settings>(
trace)),
431 "Failed.*GET_CALLDATA_FIELD_1. Could not find tuple in destination.");
434 trace.
set(Column::calldata_hashing_context_id, 2, 0);
436 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_2_settings>(
trace)),
437 "Failed.*GET_CALLDATA_FIELD_2. Could not find tuple in destination.");
440TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePaddingSelectors)
444 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
445 check_relation<calldata_hashing>(
trace);
446 check_all_interactions<CalldataTraceBuilder>(
trace);
449 trace.
set(Column::calldata_hashing_sel_not_padding_2, 2, 0);
451 trace.
set(Column::calldata_hashing_sel_not_padding_2, 2, 1);
454 trace.
set(Column::calldata_hashing_sel_not_padding_2, 4, 1);
456 "PADDING_CONSISTENCY");
457 trace.
set(Column::calldata_hashing_sel_not_padding_2, 4, 0);
460 trace.
set(Column::calldata_hashing_input_1_, 4, 1);
463 trace.
set(Column::calldata_hashing_input_2_, 4, 1);
468TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePaddingUnder)
473 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
474 check_relation<calldata_hashing>(
trace);
475 check_all_interactions<CalldataTraceBuilder>(
trace);
479 trace.
set(Column::calldata_hashing_sel_not_padding_1, 4, 1);
482 "CHECK_FINAL_INDEX");
484 for (uint32_t j = 1; j <= 4; j++) {
485 trace.
set(Column::calldata_hashing_calldata_size, j, 10);
486 trace.
set(Column::calldata_hashing_input_len, j, 11);
488 trace.
set(Column::poseidon2_hash_input_len, j, 11);
491 check_relation<calldata_hashing>(
trace);
494 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_get_calldata_field_1_settings>(
trace)),
495 "Failed.*GET_CALLDATA_FIELD_1. Could not find tuple in destination.");
498 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_check_final_size_settings>(
trace)),
499 "Failed.*CHECK_FINAL_SIZE. Could not find tuple in destination.");
502TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePaddingOver)
507 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
508 check_relation<calldata_hashing>(
trace);
509 check_all_interactions<CalldataTraceBuilder>(
trace);
513 trace.
set(Column::calldata_hashing_sel_not_padding_2, 3, 0);
518 trace.
set(Column::calldata_hashing_input_2_, 3, 0);
520 for (uint32_t j = 1; j <= 3; j++) {
521 trace.
set(Column::calldata_hashing_calldata_size, j, 7);
522 trace.
set(Column::calldata_hashing_input_len, j, 8);
524 trace.
set(Column::poseidon2_hash_input_len, j, 8);
527 check_relation<calldata_hashing>(
trace);
530 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_check_final_size_settings>(
trace)),
531 "Failed.*CHECK_FINAL_SIZE. Could not find tuple in destination.");
534TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeInputLen)
539 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
540 check_relation<calldata_hashing>(
trace);
541 check_all_interactions<CalldataTraceBuilder>(
trace);
544 trace.
set(Column::calldata_hashing_input_len, 1, 0);
546 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_poseidon2_hash_settings>(
trace)),
547 "Failed.*LOOKUP_CALLDATA_HASHING_POSEIDON2_HASH. Could not find tuple in destination.");
549 trace.
set(Column::calldata_hashing_input_len, 1, 9);
551 trace.
set(Column::calldata_hashing_input_len, 2, 4);
554 "CALLDATA_HASH_INPUT_LENGTH_FIELDS");
556 trace.
set(Column::calldata_hashing_calldata_size, 2, 3);
560 for (uint32_t j = 1; j <= 3; j++) {
561 trace.
set(Column::calldata_hashing_calldata_size, j, 7);
562 trace.
set(Column::calldata_hashing_input_len, j, 8);
564 trace.
set(Column::poseidon2_hash_input_len, j, 8);
567 trace.
set(Column::calldata_hashing_sel_not_padding_2, 3, 0);
568 trace.
set(Column::calldata_hashing_input_2_, 3, 0);
569 check_relation<calldata_hashing>(
trace);
572 (check_interaction<CalldataTraceBuilder, lookup_calldata_hashing_check_final_size_settings>(
trace)),
573 "Failed.*CHECK_FINAL_SIZE. Could not find tuple in destination.");
576TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeRounds)
579 TestTraceContainer
trace = process_calldata_hashing_trace({ calldata_fields }, { 1 });
580 check_relation<calldata_hashing>(
trace);
581 check_all_interactions<CalldataTraceBuilder>(
trace);
584 trace.
set(Column::calldata_hashing_rounds_rem, 1, 1);
589TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativeOutputHash)
596 auto trace = TestTraceContainer({
597 { { C::precomputed_first_row, 1 } },
599 { C::calldata_hashing_index_1_, 1 },
600 { C::calldata_hashing_index_2_, 2 },
602 { C::calldata_hashing_input_1_, calldata_fields[0] },
603 { C::calldata_hashing_input_2_, calldata_fields[1] },
604 { C::calldata_hashing_input_len, 6 },
605 { C::calldata_hashing_latch, 0 },
606 { C::calldata_hashing_sel_not_padding_1, 1 },
607 { C::calldata_hashing_sel_not_padding_2, 1 },
608 { C::calldata_hashing_sel_not_start, 0 },
609 { C::calldata_hashing_calldata_size, 5 },
610 { C::calldata_hashing_context_id, 1 },
611 { C::calldata_hashing_index_0_, 0 },
612 { C::calldata_hashing_rounds_rem, 2 },
613 { C::calldata_hashing_sel, 1 },
614 { C::calldata_hashing_start, 1 },
617 { C::calldata_hashing_index_1_, 4 },
618 { C::calldata_hashing_index_2_, 5 },
619 { C::calldata_hashing_input_0_, calldata_fields[2] },
620 { C::calldata_hashing_input_1_, calldata_fields[3] },
621 { C::calldata_hashing_input_2_, calldata_fields[4] },
622 { C::calldata_hashing_input_len, 6 },
623 { C::calldata_hashing_latch, 1 },
624 { C::calldata_hashing_sel_not_padding_1, 1 },
625 { C::calldata_hashing_sel_not_padding_2, 1 },
626 { C::calldata_hashing_sel_not_start, 1 },
627 { C::calldata_hashing_calldata_size, 5 },
628 { C::calldata_hashing_context_id, 1 },
629 { C::calldata_hashing_index_0_, 3 },
630 { C::calldata_hashing_rounds_rem, 1 },
631 { C::calldata_hashing_sel, 1 },
635 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
637 auto good_hash = poseidon2_int.hash({
646 auto bad_hash = poseidon2_int.hash({
655 trace.
set(Column::calldata_hashing_output_hash, 1, good_hash);
657 trace.
set(Column::calldata_hashing_output_hash, 2, bad_hash);
659 check_all_interactions<CalldataTraceBuilder>(
trace);
665TEST_F(CalldataHashingConstrainingTestTraceHelper, NegativePoseidonInteraction)
672 auto trace = TestTraceContainer({
673 { { C::precomputed_first_row, 1 } },
675 { C::calldata_hashing_index_1_, 1 },
676 { C::calldata_hashing_index_2_, 2 },
678 { C::calldata_hashing_input_1_, calldata_fields[0] },
679 { C::calldata_hashing_input_2_, calldata_fields[1] },
680 { C::calldata_hashing_input_len, 11 },
681 { C::calldata_hashing_latch, 0 },
682 { C::calldata_hashing_sel_not_padding_1, 1 },
683 { C::calldata_hashing_sel_not_padding_2, 1 },
684 { C::calldata_hashing_sel_not_start, 0 },
685 { C::calldata_hashing_calldata_size, 10 },
686 { C::calldata_hashing_context_id, 1 },
687 { C::calldata_hashing_index_0_, 0 },
688 { C::calldata_hashing_rounds_rem, 4 },
689 { C::calldata_hashing_sel, 1 },
690 { C::calldata_hashing_start, 1 },
693 { C::calldata_hashing_index_1_, 4 },
694 { C::calldata_hashing_index_2_, 5 },
695 { C::calldata_hashing_input_0_, calldata_fields[2] },
696 { C::calldata_hashing_input_1_, calldata_fields[3] },
697 { C::calldata_hashing_input_2_, calldata_fields[4] },
698 { C::calldata_hashing_input_len, 11 },
699 { C::calldata_hashing_latch, 0 },
700 { C::calldata_hashing_sel_not_padding_1, 1 },
701 { C::calldata_hashing_sel_not_padding_2, 1 },
702 { C::calldata_hashing_sel_not_start, 1 },
703 { C::calldata_hashing_calldata_size, 10 },
704 { C::calldata_hashing_context_id, 1 },
705 { C::calldata_hashing_index_0_, 3 },
706 { C::calldata_hashing_rounds_rem, 3 },
707 { C::calldata_hashing_sel, 1 },
710 { C::calldata_hashing_index_1_, 7 },
711 { C::calldata_hashing_index_2_, 8 },
712 { C::calldata_hashing_input_0_, calldata_fields[5] },
713 { C::calldata_hashing_input_1_, calldata_fields[6] },
714 { C::calldata_hashing_input_2_, calldata_fields[7] },
715 { C::calldata_hashing_input_len, 11 },
716 { C::calldata_hashing_latch, 0 },
717 { C::calldata_hashing_sel_not_padding_1, 1 },
718 { C::calldata_hashing_sel_not_padding_2, 1 },
719 { C::calldata_hashing_sel_not_start, 1 },
720 { C::calldata_hashing_calldata_size, 10 },
721 { C::calldata_hashing_context_id, 1 },
722 { C::calldata_hashing_index_0_, 6 },
723 { C::calldata_hashing_rounds_rem, 2 },
724 { C::calldata_hashing_sel, 1 },
727 { C::calldata_hashing_index_1_, 10 },
728 { C::calldata_hashing_index_2_, 11 },
729 { C::calldata_hashing_input_0_, calldata_fields[8] },
730 { C::calldata_hashing_input_1_, calldata_fields[9] },
731 { C::calldata_hashing_input_2_, 0 },
732 { C::calldata_hashing_input_len, 11 },
733 { C::calldata_hashing_latch, 1 },
734 { C::calldata_hashing_sel_not_padding_1, 1 },
735 { C::calldata_hashing_sel_not_padding_2, 0 },
736 { C::calldata_hashing_sel_not_start, 1 },
737 { C::calldata_hashing_calldata_size, 10 },
738 { C::calldata_hashing_context_id, 1 },
739 { C::calldata_hashing_index_0_, 9 },
740 { C::calldata_hashing_rounds_rem, 1 },
741 { C::calldata_hashing_sel, 1 },
745 builder.process_retrieval({ { .context_id = 1, .calldata = calldata_fields } },
trace);
747 auto bad_hash_prepended = poseidon2_int.hash({
763 auto bad_hash_misordered = poseidon2_int.hash({
777 check_relation<poseidon2>(
trace);
778 for (uint32_t j = 1; j <= 4; j++) {
779 trace.
set(Column::calldata_hashing_output_hash, j, bad_hash_prepended);
783 check_relation<calldata_hashing>(
trace);
785 "Failed.*LOOKUP_CALLDATA_HASHING_POSEIDON2_HASH. .*row 1");
787 for (uint32_t j = 1; j <= 4; j++) {
788 trace.
set(Column::calldata_hashing_output_hash, j, bad_hash_misordered);
791 check_relation<calldata_hashing>(
trace);
793 "Failed.*LOOKUP_CALLDATA_HASHING_POSEIDON2_HASH. .*row 2");
796 trace.
set(Column::calldata_hashing_rounds_rem, 2, 2);
797 trace.
set(Column::calldata_hashing_calldata_size, 2, 8);
798 trace.
set(Column::calldata_hashing_input_len, 2, 9);
800 trace.
set(Column::poseidon2_hash_input_len, 3 + 5, 9);
801 trace.
set(Column::calldata_hashing_rounds_rem, 3, 3);
802 trace.
set(Column::calldata_hashing_calldata_size, 3, 12);
803 trace.
set(Column::calldata_hashing_input_len, 3, 13);
805 trace.
set(Column::poseidon2_hash_input_len, 2 + 5, 13);
807 check_relation<poseidon2>(
trace);
809 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
std::vector< FF > calldata