1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
44using ::testing::Return;
45using ::testing::StrictMock;
47using tracegen::BitwiseTraceBuilder;
48using tracegen::ExecutionTraceBuilder;
49using tracegen::KeccakF1600TraceBuilder;
50using tracegen::PrecomputedTraceBuilder;
51using tracegen::Sha256TraceBuilder;
52using tracegen::TestTraceContainer;
54using simulation::Bitwise;
55using simulation::BitwiseEvent;
56using simulation::EventEmitter;
57using simulation::FieldGreaterThan;
58using simulation::FieldGreaterThanEvent;
59using simulation::GreaterThan;
60using simulation::GreaterThanEvent;
61using simulation::MemoryStore;
62using simulation::MockExecutionIdManager;
63using simulation::RangeCheck;
64using simulation::RangeCheckEvent;
65using simulation::Sha256;
66using simulation::Sha256CompressionEvent;
74TEST(BitwiseConstrainingTest, EmptyRow)
80TEST(BitwiseConstrainingTest, AndWithTracegen)
82 TestTraceContainer
trace;
90 .a = MemoryValue::from<uint8_t>(85),
91 .b = MemoryValue::from<uint8_t>(175),
94 .a = MemoryValue::from<uint16_t>(5323),
95 .b = MemoryValue::from<uint16_t>(321),
98 .a = MemoryValue::from<uint32_t>(13793),
99 .b = MemoryValue::from<uint32_t>(10590617),
102 .a = MemoryValue::from<uint64_t>(0x7bff744e3cdf79LLU),
103 .b = MemoryValue::from<uint64_t>(0x14ccccccccb6LLU),
104 .res = 0x14444c0ccc30LLU },
106 .a = MemoryValue::from<uint128_t>((
uint128_t{ 0xb900000000000001 } << 64)),
107 .b = MemoryValue::from<uint128_t>((
uint128_t{ 0x1006021301080000 } << 64) +
108 uint128_t{ 0x000000000000001080876844827 }),
109 .res =
uint128_t{ 0x1000000000000000 } << 64 }
113 trace.
set(C::precomputed_first_row, 0, 1);
116 check_relation<bitwise>(trace);
120TEST(BitwiseConstrainingTest, OrWithTracegen)
122 TestTraceContainer
trace;
130 .a = MemoryValue::from<uint8_t>(128),
131 .b = MemoryValue::from<uint8_t>(127),
134 .a = MemoryValue::from<uint16_t>(5323),
135 .b = MemoryValue::from<uint16_t>(321),
138 .a = MemoryValue::from<uint32_t>(13793),
139 .b = MemoryValue::from<uint32_t>(10590617),
142 .a = MemoryValue::from<uint64_t>(0x7bff744e3cdf79LLU),
143 .b = MemoryValue::from<uint64_t>(0x14ccccccccb6LLU),
144 .res = 0x7bfffccefcdfffLLU },
146 .a = MemoryValue::from<uint128_t>((
uint128_t{ 0xb900000000000000 } << 64)),
147 .b = MemoryValue::from<uint128_t>((
uint128_t{ 0x1006021301080000 } << 64) +
148 uint128_t{ 0x000000000000001080876844827 }),
153 trace.
set(C::precomputed_first_row, 0, 1);
156 check_relation<bitwise>(trace);
160TEST(BitwiseConstrainingTest, XorWithTracegen)
162 TestTraceContainer
trace;
171 .a = MemoryValue::from<uint8_t>(85),
172 .b = MemoryValue::from<uint8_t>(175),
175 .a = MemoryValue::from<uint16_t>(5323),
176 .b = MemoryValue::from<uint16_t>(321),
179 .a = MemoryValue::from<uint32_t>(13793),
180 .b = MemoryValue::from<uint32_t>(10590617),
183 .a = MemoryValue::from<uint64_t>(0x7bff744e3cdf79LLU),
184 .b = MemoryValue::from<uint64_t>(0x14ccccccccb6LLU),
185 .res = 0x7bebb882f013cfLLU },
187 .a = MemoryValue::from<uint128_t>((
uint128_t{ 0xb900000000000001 } << 64)),
188 .b = MemoryValue::from<uint128_t>((
uint128_t{ 0x1006021301080000 } << 64) +
189 uint128_t{ 0x000000000000001080876844827 }),
194 trace.
set(C::precomputed_first_row, 0, 1);
197 check_relation<bitwise>(trace);
200TEST(BitwiseConstrainingTest, MixedOperationsWithTracegen)
202 TestTraceContainer
trace;
210 .a = MemoryValue::from<uint32_t>(13793),
211 .b = MemoryValue::from<uint32_t>(10590617),
214 .a = MemoryValue::from<uint16_t>(5323),
215 .b = MemoryValue::from<uint16_t>(321),
218 .a = MemoryValue::from<uint32_t>(13793),
219 .b = MemoryValue::from<uint32_t>(10590617),
222 .a = MemoryValue::from<uint8_t>(85),
223 .b = MemoryValue::from<uint8_t>(175),
226 .a = MemoryValue::from<uint8_t>(85),
227 .b = MemoryValue::from<uint8_t>(175),
232 trace.
set(C::precomputed_first_row, 0, 1);
235 check_relation<bitwise>(trace);
238TEST(BitwiseConstrainingTest, NegativeWrongInit)
240 TestTraceContainer
trace({
242 { C::bitwise_ia_byte, 25 },
243 { C::bitwise_ib_byte, 25 },
244 { C::bitwise_ic_byte, 25 },
245 { C::bitwise_end, 1 },
246 { C::bitwise_acc_ia, 25 },
247 { C::bitwise_acc_ib, 25 },
248 { C::bitwise_acc_ic, 25 },
254 trace.
set(C::bitwise_ia_byte, 0, 24);
255 trace.
set(C::bitwise_ib_byte, 0, 27);
256 trace.
set(C::bitwise_ic_byte, 0, 28);
263TEST(BitwiseConstrainingTest, NegativeTruncateCtr)
265 TestTraceContainer
trace({
267 { C::bitwise_sel, 1 },
268 { C::bitwise_ctr, 4 },
271 { C::bitwise_sel, 1 },
272 { C::bitwise_ctr, 3 },
275 { C::bitwise_sel, 1 },
276 { C::bitwise_ctr, 2 },
279 { C::bitwise_end, 1 },
280 { C::bitwise_sel, 1 },
281 { C::bitwise_ctr, 1 },
295TEST(BitwiseConstrainingTest, NegativeGapCtr)
297 TestTraceContainer
trace({
299 { C::bitwise_sel, 1 },
300 { C::bitwise_ctr, 4 },
303 { C::bitwise_end, 1 },
304 { C::bitwise_sel, 1 },
305 { C::bitwise_ctr, 3 },
314TEST(BitwiseConstrainingTest, NegativeEndSetBeforeEnd)
316 TestTraceContainer
trace({
318 { C::bitwise_ctr_min_one_inv,
FF(7).invert() },
319 { C::bitwise_sel, 1 },
320 { C::bitwise_sel_compute, 1 },
321 { C::bitwise_ctr, 8 },
324 { C::bitwise_ctr_min_one_inv,
FF(6).invert() },
325 { C::bitwise_sel, 1 },
326 { C::bitwise_sel_compute, 1 },
327 { C::bitwise_ctr, 7 },
330 { C::bitwise_ctr_min_one_inv,
FF(5).invert() },
331 { C::bitwise_sel, 1 },
332 { C::bitwise_sel_compute, 1 },
333 { C::bitwise_ctr, 6 },
342TEST(BitwiseConstrainingTest, NegativeTraceContinuity)
346 TestTraceContainer
trace({
349 { C::precomputed_first_row, 1 },
352 { C::bitwise_sel, 1 },
353 { C::bitwise_ctr, 3 },
356 { C::bitwise_sel, 1 },
357 { C::bitwise_ctr, 2 },
360 { C::bitwise_sel, 1 },
361 { C::bitwise_end, 1 },
362 { C::bitwise_ctr, 1 },
371TEST(BitwiseConstrainingTest, NegativeChangeOpIDBeforeEnd)
373 TestTraceContainer
trace({
375 { C::bitwise_sel, 1 },
379 { C::bitwise_sel, 1 },
383 { C::bitwise_sel, 1 },
384 { C::bitwise_end, 1 },
392 "BITW_OP_ID_REL_CONTINUITY");
395TEST(BitwiseConstrainingTest, NegativeWrongAccumulation)
397 TestTraceContainer
trace({
399 { C::bitwise_sel, 1 },
400 { C::bitwise_ia_byte, 0x11 },
401 { C::bitwise_ib_byte, 0x22 },
402 { C::bitwise_ic_byte, 0x33 },
403 { C::bitwise_acc_ia, 0xaa11 },
404 { C::bitwise_acc_ib, 0xbb22 },
405 { C::bitwise_acc_ic, 0xcc33 },
408 { C::bitwise_sel, 1 },
409 { C::bitwise_end, 1 },
410 { C::bitwise_acc_ia, 0xaa },
411 { C::bitwise_acc_ib, 0xbb },
412 { C::bitwise_acc_ic, 0xcc },
418 trace.
set(C::bitwise_acc_ia, 0, 0xaa1f);
419 trace.
set(C::bitwise_acc_ib, 0, 0xbb2f);
420 trace.
set(C::bitwise_acc_ic, 0, 0xcc3f);
430TEST(BitwiseConstrainingTest, NegativeInputTagCannotBeFF)
433 TestTraceContainer
trace;
448 trace.
set(C::bitwise_sel_tag_ff_err, 1, 0);
453 "INPUT_TAG_CANNOT_BE_FF");
459TEST(BitwiseConstrainingTest, NegativeInputTagsShouldMatch)
462 TestTraceContainer
trace;
476 trace.
set(C::bitwise_sel_tag_mismatch_err, 1, 0);
480 "INPUT_TAGS_SHOULD_MATCH");
484TEST(BitwiseConstrainingTest, NegativeResTagShouldMatchInput)
487 TestTraceContainer
trace;
491 .a = MemoryValue::from<uint8_t>(85),
492 .b = MemoryValue::from<uint8_t>(175),
505 "RES_TAG_SHOULD_MATCH_INPUT");
510TEST(BitwiseConstrainingTest, NegativeEndOnError)
513 TestTraceContainer
trace;
535TEST(BitwiseConstrainingTest, NegativeErrOnlyOnStart)
538 TestTraceContainer
trace({
540 { C::bitwise_sel, 1 },
541 { C::bitwise_start, 1 },
542 { C::bitwise_ctr, 2 },
545 { C::bitwise_sel, 1 },
546 { C::bitwise_end, 1 },
547 { C::bitwise_ctr, 1 },
555 trace.
set(C::bitwise_sel_tag_mismatch_err, 1, 1);
561TEST(BitwiseConstrainingTest, MixedOperationsInteractions)
563 TestTraceContainer
trace;
572 .a = MemoryValue::from<uint32_t>(13793),
573 .b = MemoryValue::from<uint32_t>(10590617),
576 .a = MemoryValue::from<uint16_t>(5323),
577 .b = MemoryValue::from<uint16_t>(321),
580 .a = MemoryValue::from<uint32_t>(13793),
581 .b = MemoryValue::from<uint32_t>(10590617),
584 .a = MemoryValue::from<uint8_t>(85),
585 .b = MemoryValue::from<uint8_t>(175),
588 .a = MemoryValue::from<uint8_t>(85),
589 .b = MemoryValue::from<uint8_t>(175),
600 check_all_interactions<BitwiseTraceBuilder>(trace);
601 check_relation<bitwise>(trace);
604TEST(BitwiseConstrainingTest, BitwiseExecInteraction)
606 TestTraceContainer
trace({ {
608 { C::bitwise_sel, 1 },
609 { C::bitwise_err, 1 },
610 { C::bitwise_start, 1 },
611 { C::bitwise_end, 1 },
614 { C::bitwise_acc_ia, 0x01 },
616 { C::bitwise_acc_ib, 0x01 },
617 { C::bitwise_acc_ic, 0x00 },
619 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::FF) },
620 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U8) },
622 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
623 { C::execution_register_0_, 0x01 },
624 { C::execution_register_1_, 0x01 },
625 { C::execution_register_2_, 0x00 },
626 { C::execution_sel_exec_dispatch_bitwise, 1 },
627 { C::execution_sel_opcode_error, 1 },
631 check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace);
634TEST(BitwiseConstrainingTest, InvalidBitwiseExecInteraction)
636 TestTraceContainer
trace({ {
638 { C::bitwise_sel, 1 },
639 { C::bitwise_acc_ib, 0x01 },
640 { C::bitwise_acc_ia, 0x01 },
643 { C::bitwise_acc_ic, 0x00 },
648 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
649 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U16) },
650 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
651 { C::execution_register_0_, 0x01 },
652 { C::execution_register_1_, 0x01 },
653 { C::execution_register_2_, 0x00 },
654 { C::execution_sel_exec_dispatch_bitwise, 1 },
659 (check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace)),
660 "Failed.*EXECUTION_DISPATCH_TO_BITWISE. Could not find tuple in destination.");
663TEST(BitwiseConstrainingTest, ErrorHandlingInputFF)
665 TestTraceContainer
trace;
676 trace.
set(C::precomputed_first_row, 0, 1);
680 check_relation<bitwise>(trace);
683TEST(BitwiseConstrainingTest, ErrorHandlingInputTagMismatch)
685 TestTraceContainer
trace;
695 trace.
set(C::precomputed_first_row, 0, 1);
697 check_relation<bitwise>(trace);
698 check_all_interactions<BitwiseTraceBuilder>(trace);
701TEST(BitwiseConstrainingTest, ErrorHandlingMultiple)
703 TestTraceContainer
trace;
713 trace.
set(C::precomputed_first_row, 0, 1);
715 check_relation<bitwise>(trace);
718TEST(BitwiseConstrainingTest, ExecBitwiseDispatchOnErrorMismatch)
724 TestTraceContainer
trace({ {
726 { C::execution_sel_exec_dispatch_bitwise, 1 },
728 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
a.get_tag()) },
729 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
b.get_tag()) },
730 { C::execution_register_0_,
a.as_ff() },
731 { C::execution_register_1_,
b.as_ff() },
734 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::FF) },
735 { C::execution_register_2_, 0x00 },
736 { C::execution_sel_opcode_error, 1 },
743 trace.
set(C::precomputed_first_row, 0, 1);
745 check_relation<bitwise>(trace);
746 check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace);
749TEST(BitwiseConstrainingTest, ExecBitwiseDispatchOnErrorFF)
756 TestTraceContainer
trace({ {
758 { C::execution_sel_exec_dispatch_bitwise, 1 },
760 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
a.get_tag()) },
761 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
b.get_tag()) },
762 { C::execution_register_0_,
a.as_ff() },
763 { C::execution_register_1_,
b.as_ff() },
766 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::FF) },
767 { C::execution_register_2_, 0x00 },
768 { C::execution_sel_opcode_error, 1 },
775 trace.
set(C::precomputed_first_row, 0, 1);
777 check_relation<bitwise>(trace);
778 check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace);
795TEST(BitwiseConstrainingTest, VulnerabilityStartKeccakWithoutSel)
801 FF fake_input_a =
FF(0xAAAABBBBCCCCDDDDULL);
802 FF fake_input_b =
FF(0x1111222233334444ULL);
803 FF fake_output =
FF(0x999999999999ULL);
805 TestTraceContainer
trace({
810 { C::bitwise_sel, 1 },
811 { C::bitwise_start, 1 },
812 { C::bitwise_start_keccak, 1 },
817 { C::bitwise_sel_tag_mismatch_err, 1 },
818 { C::bitwise_sel_tag_ff_err, 0 },
819 { C::bitwise_err, 1 },
820 { C::bitwise_end, 1 },
821 { C::bitwise_sel_get_ctr, 0 },
822 { C::bitwise_ctr, 0 },
828 { C::bitwise_acc_ia, fake_input_a },
829 { C::bitwise_acc_ib, fake_input_b },
830 { C::bitwise_acc_ic, fake_output },
832 { C::bitwise_ia_byte, fake_input_a },
833 { C::bitwise_ib_byte, fake_input_b },
834 { C::bitwise_ic_byte, fake_output },
836 { C::bitwise_tag_c, 0 },
845TEST(BitwiseConstrainingTest, VulnerabilityStartSha256WithoutSel)
847 FF fake_input_a =
FF(0xAABBCCDD);
848 FF fake_input_b =
FF(0x11223344);
849 FF fake_output =
FF(0x99999999);
851 TestTraceContainer
trace({
853 { C::bitwise_sel, 1 },
854 { C::bitwise_start, 1 },
855 { C::bitwise_start_sha256, 1 },
858 { C::bitwise_sel_tag_mismatch_err, 1 },
859 { C::bitwise_sel_tag_ff_err, 0 },
860 { C::bitwise_err, 1 },
861 { C::bitwise_end, 1 },
862 { C::bitwise_sel_get_ctr, 0 },
863 { C::bitwise_ctr, 0 },
867 { C::bitwise_acc_ia, fake_input_a },
868 { C::bitwise_acc_ib, fake_input_b },
869 { C::bitwise_acc_ic, fake_output },
870 { C::bitwise_ia_byte, fake_input_a },
871 { C::bitwise_ib_byte, fake_input_b },
872 { C::bitwise_ic_byte, fake_output },
873 { C::bitwise_tag_c, 0 },
886TEST(BitwiseConstrainingTest, VulnerabilityFakeKeccakXorOutput)
891 TestTraceContainer
trace;
899 check_relation<keccakf1600>(trace);
900 check_relation<bitwise>(trace);
905 uint32_t keccak_start_row = 0;
907 if (
trace.
get(C::keccakf1600_start, i) ==
FF(1)) {
908 keccak_start_row = i;
912 ASSERT_EQ(
trace.
get(C::keccakf1600_start, keccak_start_row),
FF(1));
913 ASSERT_EQ(
trace.
get(C::keccakf1600_sel_no_error, keccak_start_row),
FF(1));
915 FF real_state_in_00 =
trace.
get(C::keccakf1600_state_in_00, keccak_start_row);
916 FF real_state_in_01 =
trace.
get(C::keccakf1600_state_in_01, keccak_start_row);
917 FF real_theta_xor_01 =
trace.
get(C::keccakf1600_theta_xor_01, keccak_start_row);
924 FF fake_theta_xor_01 =
FF(0xFA0E0BAD0DEADULL);
925 ASSERT_NE(fake_theta_xor_01, real_theta_xor_01);
926 trace.
set(C::keccakf1600_theta_xor_01, keccak_start_row, fake_theta_xor_01);
934 { C::bitwise_sel, 1 },
935 { C::bitwise_start, 1 },
936 { C::bitwise_start_keccak, 1 },
938 { C::bitwise_acc_ia, real_state_in_00 },
939 { C::bitwise_acc_ib, real_state_in_01 },
940 { C::bitwise_acc_ic, fake_theta_xor_01 },
941 { C::bitwise_ia_byte, real_state_in_00 },
942 { C::bitwise_ib_byte, real_state_in_01 },
943 { C::bitwise_ic_byte, fake_theta_xor_01 },
946 { C::bitwise_sel_tag_mismatch_err, 1 },
947 { C::bitwise_sel_tag_ff_err, 0 },
948 { C::bitwise_err, 1 },
949 { C::bitwise_end, 1 },
950 { C::bitwise_sel_get_ctr, 0 },
951 { C::bitwise_ctr, 0 },
954 { C::bitwise_tag_c, 0 },
961 check_relation<keccakf1600>(trace);
974 check_interaction<KeccakF1600TraceBuilder, lookup_keccakf1600_theta_xor_01_settings>(trace);
995TEST(BitwiseConstrainingTest, VulnerabilityFakeSha256XorOutput)
1014 EventEmitter<Sha256CompressionEvent> sha256_event_emitter;
1017 std::array<uint32_t, 8> state = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
1018 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
1020 for (uint32_t i = 0; i < 8; ++i) {
1021 mem.
set(state_addr + i, MemoryValue::from<uint32_t>(state[i]));
1024 std::array<uint32_t, 16> input = { 0x61626380, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18 };
1026 for (uint32_t i = 0; i < 16; ++i) {
1027 mem.
set(input_addr + i, MemoryValue::from<uint32_t>(input[i]));
1031 sha256_gadget.compression(
mem, state_addr, input_addr, output_addr);
1033 TestTraceContainer
trace;
1034 trace.
set(C::precomputed_first_row, 0, 1);
1036 Sha256TraceBuilder sha256_builder;
1037 sha256_builder.process(sha256_event_emitter.get_events(), trace);
1039 BitwiseTraceBuilder bitwise_builder;
1045 check_relation<sha256_relation>(trace);
1046 check_relation<bitwise>(trace);
1051 uint32_t sha256_row = 0;
1054 if (
trace.
get(C::sha256_sel_compute_w, i) ==
FF(1)) {
1060 ASSERT_TRUE(found) <<
"Could not find sha256 row with sel_compute_w=1";
1062 FF real_w_15_rotr_7 =
trace.
get(C::sha256_w_15_rotr_7, sha256_row);
1063 FF real_w_15_rotr_18 =
trace.
get(C::sha256_w_15_rotr_18, sha256_row);
1064 FF real_xor_output =
trace.
get(C::sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_row);
1069 FF fake_xor_output =
FF(0xDEADBEEF);
1070 ASSERT_NE(fake_xor_output, real_xor_output);
1071 trace.
set(C::sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_row, fake_xor_output);
1079 { C::bitwise_sel, 1 },
1080 { C::bitwise_start, 1 },
1081 { C::bitwise_start_sha256, 1 },
1083 { C::bitwise_acc_ia, real_w_15_rotr_7 },
1084 { C::bitwise_acc_ib, real_w_15_rotr_18 },
1085 { C::bitwise_acc_ic, fake_xor_output },
1086 { C::bitwise_ia_byte, real_w_15_rotr_7 },
1087 { C::bitwise_ib_byte, real_w_15_rotr_18 },
1088 { C::bitwise_ic_byte, fake_xor_output },
1091 { C::bitwise_sel_tag_mismatch_err, 1 },
1092 { C::bitwise_sel_tag_ff_err, 0 },
1093 { C::bitwise_err, 1 },
1094 { C::bitwise_end, 1 },
1095 { C::bitwise_sel_get_ctr, 0 },
1096 { C::bitwise_ctr, 0 },
1099 { C::bitwise_tag_c, 0 },
1107 check_relation<sha256_relation>(trace);
1126 tracegen::SharedIndexCache cache;
1127 tracegen::LookupIntoDynamicTableGeneric<lookup_sha256_w_s_0_xor_0_settings> lookup(cache, C::bitwise_start);
1128 lookup.process(trace);
1143TEST(BitwiseConstrainingTest, NegativeSelOnStartOrEnd)
1145 TestTraceContainer
trace({
1147 { C::bitwise_sel, 1 },
1148 { C::bitwise_start, 1 },
1149 { C::bitwise_ctr, 2 },
1152 { C::bitwise_sel, 1 },
1153 { C::bitwise_end, 1 },
1154 { C::bitwise_ctr, 1 },
1171TEST(BitwiseConstrainingTest, NegativeStartAfterLatch)
1174 TestTraceContainer
trace({
1176 { C::bitwise_sel, 1 },
1177 { C::bitwise_start, 1 },
1178 { C::bitwise_end, 1 },
1179 { C::bitwise_ctr, 1 },
1182 { C::bitwise_sel, 1 },
1183 { C::bitwise_start, 1 },
1184 { C::bitwise_end, 1 },
1185 { C::bitwise_ctr, 1 },
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
#define AVM_BITWISE_XOR_OP_ID
FieldGreaterThan field_gt
static TaggedValue from(T value)
static TaggedValue from_tag(ValueTag tag, FF value)
static constexpr size_t SR_BITW_CTR_DECREMENT
static constexpr size_t SR_BITW_ACC_REL_C
static constexpr size_t SR_BITW_ACC_REL_B
static constexpr size_t SR_BITW_ACC_REL_A
static constexpr size_t SR_TRACE_CONTINUITY
static constexpr size_t SR_INPUT_TAG_CANNOT_BE_FF
static constexpr size_t SR_BITW_INIT_C
static constexpr size_t SR_BITW_OP_ID_REL_CONTINUITY
static constexpr size_t SR_BITW_END_FOR_CTR_ONE
static constexpr size_t SR_BITW_INIT_B
static constexpr size_t SR_END_ON_ERROR
static constexpr size_t SR_SEL_ON_START_OR_END
static constexpr size_t SR_START_AFTER_LATCH
static constexpr size_t SR_RES_TAG_SHOULD_MATCH_INPUT
static constexpr size_t SR_BITW_INIT_A
static constexpr size_t SR_ERR_ONLY_ON_START
static constexpr size_t SR_INPUT_TAGS_SHOULD_MATCH
void set(MemoryAddress index, MemoryValue value) override
void process(const simulation::EventEmitterInterface< simulation::AluEvent >::Container &events, TraceContainer &trace)
Process the ALU events and populate the ALU relevant columns in the trace.
void process_misc(TraceContainer &trace, const uint32_t num_rows=PRECOMPUTED_TRACE_SIZE)
Populate miscellaneous precomputed columns: first_row selector and idx (row index).
void process_bitwise(TraceContainer &trace)
Populate the 8-bit bitwise lookup table (AND, OR, XOR).
void process_sel_range_16(TraceContainer &trace)
Generate a selector column that activates the first 2^16 (65536) rows.
void process_tag_parameters(TraceContainer &trace)
Populate the memory tag parameters table (byte length, max bits, max value per tag).
const FF & get(Column col, uint32_t row) const
uint32_t get_num_rows() const
void set(Column col, uint32_t row, const FF &value)
PrecomputedTraceBuilder precomputed_builder
EventEmitter< GreaterThanEvent > gt_event_emitter
ExecutionIdManager execution_id_manager
EventEmitter< RangeCheckEvent > range_check_event_emitter
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
void generate_keccak_trace(TestTraceContainer &trace, const std::vector< MemoryAddress > &dst_addresses, const std::vector< MemoryAddress > &src_addresses, uint16_t space_id)
TestTraceContainer empty_trace()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
simulation::PublicDataTreeReadWriteEvent event
unsigned __int128 uint128_t
NoopEventEmitter< FieldGreaterThanEvent > field_gt_event_emitter
NoopEventEmitter< BitwiseEvent > bitwise_event_emitter
constexpr field invert() const noexcept