1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
40using ::testing::Return;
41using ::testing::StrictMock;
43using tracegen::BitwiseTraceBuilder;
44using tracegen::ExecutionTraceBuilder;
45using tracegen::KeccakF1600TraceBuilder;
46using tracegen::PrecomputedTraceBuilder;
47using tracegen::Sha256TraceBuilder;
48using tracegen::TestTraceContainer;
50using simulation::Bitwise;
51using simulation::BitwiseEvent;
52using simulation::EventEmitter;
53using simulation::FieldGreaterThan;
54using simulation::FieldGreaterThanEvent;
55using simulation::GreaterThan;
56using simulation::GreaterThanEvent;
57using simulation::MemoryStore;
58using simulation::MockExecutionIdManager;
59using simulation::RangeCheck;
60using simulation::RangeCheckEvent;
61using simulation::Sha256;
62using simulation::Sha256CompressionEvent;
70TEST(BitwiseConstrainingTest, EmptyRow)
76TEST(BitwiseConstrainingTest, AndWithTracegen)
78 TestTraceContainer
trace;
86 .a = MemoryValue::from<uint8_t>(85),
87 .b = MemoryValue::from<uint8_t>(175),
90 .a = MemoryValue::from<uint16_t>(5323),
91 .b = MemoryValue::from<uint16_t>(321),
94 .a = MemoryValue::from<uint32_t>(13793),
95 .b = MemoryValue::from<uint32_t>(10590617),
98 .a = MemoryValue::from<uint64_t>(0x7bff744e3cdf79LLU),
99 .b = MemoryValue::from<uint64_t>(0x14ccccccccb6LLU),
100 .res = 0x14444c0ccc30LLU },
102 .a = MemoryValue::from<uint128_t>((
uint128_t{ 0xb900000000000001 } << 64)),
103 .b = MemoryValue::from<uint128_t>((
uint128_t{ 0x1006021301080000 } << 64) +
104 uint128_t{ 0x000000000000001080876844827 }),
105 .res =
uint128_t{ 0x1000000000000000 } << 64 }
109 trace.
set(C::precomputed_first_row, 0, 1);
112 check_relation<bitwise>(trace);
116TEST(BitwiseConstrainingTest, OrWithTracegen)
118 TestTraceContainer
trace;
126 .a = MemoryValue::from<uint8_t>(128),
127 .b = MemoryValue::from<uint8_t>(127),
130 .a = MemoryValue::from<uint16_t>(5323),
131 .b = MemoryValue::from<uint16_t>(321),
134 .a = MemoryValue::from<uint32_t>(13793),
135 .b = MemoryValue::from<uint32_t>(10590617),
138 .a = MemoryValue::from<uint64_t>(0x7bff744e3cdf79LLU),
139 .b = MemoryValue::from<uint64_t>(0x14ccccccccb6LLU),
140 .res = 0x7bfffccefcdfffLLU },
142 .a = MemoryValue::from<uint128_t>((
uint128_t{ 0xb900000000000000 } << 64)),
143 .b = MemoryValue::from<uint128_t>((
uint128_t{ 0x1006021301080000 } << 64) +
144 uint128_t{ 0x000000000000001080876844827 }),
149 trace.
set(C::precomputed_first_row, 0, 1);
152 check_relation<bitwise>(trace);
156TEST(BitwiseConstrainingTest, XorWithTracegen)
158 TestTraceContainer
trace;
167 .a = MemoryValue::from<uint8_t>(85),
168 .b = MemoryValue::from<uint8_t>(175),
171 .a = MemoryValue::from<uint16_t>(5323),
172 .b = MemoryValue::from<uint16_t>(321),
175 .a = MemoryValue::from<uint32_t>(13793),
176 .b = MemoryValue::from<uint32_t>(10590617),
179 .a = MemoryValue::from<uint64_t>(0x7bff744e3cdf79LLU),
180 .b = MemoryValue::from<uint64_t>(0x14ccccccccb6LLU),
181 .res = 0x7bebb882f013cfLLU },
183 .a = MemoryValue::from<uint128_t>((
uint128_t{ 0xb900000000000001 } << 64)),
184 .b = MemoryValue::from<uint128_t>((
uint128_t{ 0x1006021301080000 } << 64) +
185 uint128_t{ 0x000000000000001080876844827 }),
190 trace.
set(C::precomputed_first_row, 0, 1);
193 check_relation<bitwise>(trace);
196TEST(BitwiseConstrainingTest, MixedOperationsWithTracegen)
198 TestTraceContainer
trace;
206 .a = MemoryValue::from<uint32_t>(13793),
207 .b = MemoryValue::from<uint32_t>(10590617),
210 .a = MemoryValue::from<uint16_t>(5323),
211 .b = MemoryValue::from<uint16_t>(321),
214 .a = MemoryValue::from<uint32_t>(13793),
215 .b = MemoryValue::from<uint32_t>(10590617),
218 .a = MemoryValue::from<uint8_t>(85),
219 .b = MemoryValue::from<uint8_t>(175),
222 .a = MemoryValue::from<uint8_t>(85),
223 .b = MemoryValue::from<uint8_t>(175),
228 trace.
set(C::precomputed_first_row, 0, 1);
231 check_relation<bitwise>(trace);
234TEST(BitwiseConstrainingTest, NegativeWrongInit)
236 TestTraceContainer
trace({
238 { C::bitwise_ia_byte, 25 },
239 { C::bitwise_ib_byte, 25 },
240 { C::bitwise_ic_byte, 25 },
241 { C::bitwise_end, 1 },
242 { C::bitwise_acc_ia, 25 },
243 { C::bitwise_acc_ib, 25 },
244 { C::bitwise_acc_ic, 25 },
250 trace.
set(C::bitwise_ia_byte, 0, 24);
251 trace.
set(C::bitwise_ib_byte, 0, 27);
252 trace.
set(C::bitwise_ic_byte, 0, 28);
259TEST(BitwiseConstrainingTest, NegativeTruncateCtr)
261 TestTraceContainer
trace({
263 { C::bitwise_sel, 1 },
264 { C::bitwise_ctr, 4 },
267 { C::bitwise_sel, 1 },
268 { C::bitwise_ctr, 3 },
271 { C::bitwise_sel, 1 },
272 { C::bitwise_ctr, 2 },
275 { C::bitwise_end, 1 },
276 { C::bitwise_sel, 1 },
277 { C::bitwise_ctr, 1 },
291TEST(BitwiseConstrainingTest, NegativeGapCtr)
293 TestTraceContainer
trace({
295 { C::bitwise_sel, 1 },
296 { C::bitwise_ctr, 4 },
299 { C::bitwise_end, 1 },
300 { C::bitwise_sel, 1 },
301 { C::bitwise_ctr, 3 },
310TEST(BitwiseConstrainingTest, NegativeLastSetBeforeEnd)
312 TestTraceContainer
trace({
314 { C::bitwise_ctr_min_one_inv,
FF(7).invert() },
315 { C::bitwise_sel, 1 },
316 { C::bitwise_sel_compute, 1 },
317 { C::bitwise_ctr, 8 },
320 { C::bitwise_ctr_min_one_inv,
FF(6).invert() },
321 { C::bitwise_sel, 1 },
322 { C::bitwise_sel_compute, 1 },
323 { C::bitwise_ctr, 7 },
326 { C::bitwise_ctr_min_one_inv,
FF(5).invert() },
327 { C::bitwise_sel, 1 },
328 { C::bitwise_sel_compute, 1 },
329 { C::bitwise_ctr, 6 },
338TEST(BitwiseConstrainingTest, NegativeTraceContinuity)
342 TestTraceContainer
trace({
345 { C::precomputed_first_row, 1 },
348 { C::bitwise_sel, 1 },
349 { C::bitwise_ctr, 3 },
352 { C::bitwise_sel, 1 },
353 { C::bitwise_ctr, 2 },
356 { C::bitwise_sel, 1 },
357 { C::bitwise_end, 1 },
358 { C::bitwise_ctr, 1 },
367TEST(BitwiseConstrainingTest, NegativeChangeOpIDBeforeEnd)
369 TestTraceContainer
trace({
371 { C::bitwise_sel, 1 },
375 { C::bitwise_sel, 1 },
379 { C::bitwise_sel, 1 },
380 { C::bitwise_end, 1 },
388 "BITW_OP_ID_REL_CONTINUITY");
391TEST(BitwiseConstrainingTest, NegativeWrongAccumulation)
393 TestTraceContainer
trace({
395 { C::bitwise_sel, 1 },
396 { C::bitwise_ia_byte, 0x11 },
397 { C::bitwise_ib_byte, 0x22 },
398 { C::bitwise_ic_byte, 0x33 },
399 { C::bitwise_acc_ia, 0xaa11 },
400 { C::bitwise_acc_ib, 0xbb22 },
401 { C::bitwise_acc_ic, 0xcc33 },
404 { C::bitwise_sel, 1 },
405 { C::bitwise_end, 1 },
406 { C::bitwise_acc_ia, 0xaa },
407 { C::bitwise_acc_ib, 0xbb },
408 { C::bitwise_acc_ic, 0xcc },
414 trace.
set(C::bitwise_acc_ia, 0, 0xaa1f);
415 trace.
set(C::bitwise_acc_ib, 0, 0xbb2f);
416 trace.
set(C::bitwise_acc_ic, 0, 0xcc3f);
426TEST(BitwiseConstrainingTest, NegativeInputTagCannotBeFF)
429 TestTraceContainer
trace;
444 trace.
set(C::bitwise_sel_tag_ff_err, 1, 0);
449 "INPUT_TAG_CANNOT_BE_FF");
455TEST(BitwiseConstrainingTest, NegativeInputTagsShouldMatch)
458 TestTraceContainer
trace;
472 trace.
set(C::bitwise_sel_tag_mismatch_err, 1, 0);
476 "INPUT_TAGS_SHOULD_MATCH");
480TEST(BitwiseConstrainingTest, NegativeResTagShouldMatchInput)
483 TestTraceContainer
trace;
487 .a = MemoryValue::from<uint8_t>(85),
488 .b = MemoryValue::from<uint8_t>(175),
501 "RES_TAG_SHOULD_MATCH_INPUT");
506TEST(BitwiseConstrainingTest, NegativeLastOnError)
509 TestTraceContainer
trace;
531TEST(BitwiseConstrainingTest, NegativeErrOnlyOnStart)
534 TestTraceContainer
trace({
536 { C::bitwise_sel, 1 },
537 { C::bitwise_start, 1 },
538 { C::bitwise_ctr, 2 },
541 { C::bitwise_sel, 1 },
542 { C::bitwise_end, 1 },
543 { C::bitwise_ctr, 1 },
551 trace.
set(C::bitwise_sel_tag_mismatch_err, 1, 1);
557TEST(BitwiseConstrainingTest, MixedOperationsInteractions)
559 TestTraceContainer
trace;
568 .a = MemoryValue::from<uint32_t>(13793),
569 .b = MemoryValue::from<uint32_t>(10590617),
572 .a = MemoryValue::from<uint16_t>(5323),
573 .b = MemoryValue::from<uint16_t>(321),
576 .a = MemoryValue::from<uint32_t>(13793),
577 .b = MemoryValue::from<uint32_t>(10590617),
580 .a = MemoryValue::from<uint8_t>(85),
581 .b = MemoryValue::from<uint8_t>(175),
584 .a = MemoryValue::from<uint8_t>(85),
585 .b = MemoryValue::from<uint8_t>(175),
596 check_all_interactions<BitwiseTraceBuilder>(trace);
597 check_relation<bitwise>(trace);
600TEST(BitwiseConstrainingTest, BitwiseExecInteraction)
602 TestTraceContainer
trace({ {
604 { C::bitwise_sel, 1 },
605 { C::bitwise_err, 1 },
606 { C::bitwise_start, 1 },
607 { C::bitwise_end, 1 },
610 { C::bitwise_acc_ia, 0x01 },
612 { C::bitwise_acc_ib, 0x01 },
613 { C::bitwise_acc_ic, 0x00 },
615 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::FF) },
616 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U8) },
618 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
619 { C::execution_register_0_, 0x01 },
620 { C::execution_register_1_, 0x01 },
621 { C::execution_register_2_, 0x00 },
622 { C::execution_sel_exec_dispatch_bitwise, 1 },
623 { C::execution_sel_opcode_error, 1 },
627 check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace);
630TEST(BitwiseConstrainingTest, InvalidBitwiseExecInteraction)
632 TestTraceContainer
trace({ {
634 { C::bitwise_sel, 1 },
635 { C::bitwise_acc_ib, 0x01 },
636 { C::bitwise_acc_ia, 0x01 },
639 { C::bitwise_acc_ic, 0x00 },
644 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
645 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U16) },
646 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
647 { C::execution_register_0_, 0x01 },
648 { C::execution_register_1_, 0x01 },
649 { C::execution_register_2_, 0x00 },
650 { C::execution_sel_exec_dispatch_bitwise, 1 },
655 (check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace)),
656 "Failed.*EXECUTION_DISPATCH_TO_BITWISE. Could not find tuple in destination.");
659TEST(BitwiseConstrainingTest, ErrorHandlingInputFF)
661 TestTraceContainer
trace;
672 trace.
set(C::precomputed_first_row, 0, 1);
676 check_relation<bitwise>(trace);
679TEST(BitwiseConstrainingTest, ErrorHandlingInputTagMismatch)
681 TestTraceContainer
trace;
691 trace.
set(C::precomputed_first_row, 0, 1);
693 check_relation<bitwise>(trace);
694 check_all_interactions<BitwiseTraceBuilder>(trace);
697TEST(BitwiseConstrainingTest, ErrorHandlingMultiple)
699 TestTraceContainer
trace;
709 trace.
set(C::precomputed_first_row, 0, 1);
711 check_relation<bitwise>(trace);
714TEST(BitwiseConstrainingTest, ExecBitwiseDispatchOnErrorMismatch)
720 TestTraceContainer
trace({ {
722 { C::execution_sel_exec_dispatch_bitwise, 1 },
724 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
a.get_tag()) },
725 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
b.get_tag()) },
726 { C::execution_register_0_,
a.as_ff() },
727 { C::execution_register_1_,
b.as_ff() },
730 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::FF) },
731 { C::execution_register_2_, 0x00 },
732 { C::execution_sel_opcode_error, 1 },
739 trace.
set(C::precomputed_first_row, 0, 1);
741 check_relation<bitwise>(trace);
742 check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace);
745TEST(BitwiseConstrainingTest, ExecBitwiseDispatchOnErrorFF)
752 TestTraceContainer
trace({ {
754 { C::execution_sel_exec_dispatch_bitwise, 1 },
756 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
a.get_tag()) },
757 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
b.get_tag()) },
758 { C::execution_register_0_,
a.as_ff() },
759 { C::execution_register_1_,
b.as_ff() },
762 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::FF) },
763 { C::execution_register_2_, 0x00 },
764 { C::execution_sel_opcode_error, 1 },
771 trace.
set(C::precomputed_first_row, 0, 1);
773 check_relation<bitwise>(trace);
774 check_interaction<ExecutionTraceBuilder, lookup_execution_dispatch_to_bitwise_settings>(trace);
791TEST(BitwiseConstrainingTest, VulnerabilityStartKeccakWithoutSel)
797 FF fake_input_a =
FF(0xAAAABBBBCCCCDDDDULL);
798 FF fake_input_b =
FF(0x1111222233334444ULL);
799 FF fake_output =
FF(0x999999999999ULL);
801 TestTraceContainer
trace({
806 { C::bitwise_sel, 1 },
807 { C::bitwise_start, 1 },
808 { C::bitwise_start_keccak, 1 },
813 { C::bitwise_sel_tag_mismatch_err, 1 },
814 { C::bitwise_sel_tag_ff_err, 0 },
815 { C::bitwise_err, 1 },
816 { C::bitwise_end, 1 },
817 { C::bitwise_sel_get_ctr, 0 },
818 { C::bitwise_ctr, 0 },
824 { C::bitwise_acc_ia, fake_input_a },
825 { C::bitwise_acc_ib, fake_input_b },
826 { C::bitwise_acc_ic, fake_output },
828 { C::bitwise_ia_byte, fake_input_a },
829 { C::bitwise_ib_byte, fake_input_b },
830 { C::bitwise_ic_byte, fake_output },
832 { C::bitwise_tag_c, 0 },
841TEST(BitwiseConstrainingTest, VulnerabilityStartSha256WithoutSel)
843 FF fake_input_a =
FF(0xAABBCCDD);
844 FF fake_input_b =
FF(0x11223344);
845 FF fake_output =
FF(0x99999999);
847 TestTraceContainer
trace({
849 { C::bitwise_sel, 1 },
850 { C::bitwise_start, 1 },
851 { C::bitwise_start_sha256, 1 },
854 { C::bitwise_sel_tag_mismatch_err, 1 },
855 { C::bitwise_sel_tag_ff_err, 0 },
856 { C::bitwise_err, 1 },
857 { C::bitwise_end, 1 },
858 { C::bitwise_sel_get_ctr, 0 },
859 { C::bitwise_ctr, 0 },
863 { C::bitwise_acc_ia, fake_input_a },
864 { C::bitwise_acc_ib, fake_input_b },
865 { C::bitwise_acc_ic, fake_output },
866 { C::bitwise_ia_byte, fake_input_a },
867 { C::bitwise_ib_byte, fake_input_b },
868 { C::bitwise_ic_byte, fake_output },
869 { C::bitwise_tag_c, 0 },
882TEST(BitwiseConstrainingTest, VulnerabilityFakeKeccakXorOutput)
887 TestTraceContainer
trace;
895 check_relation<keccakf1600>(trace);
896 check_relation<bitwise>(trace);
901 uint32_t keccak_start_row = 0;
903 if (
trace.
get(C::keccakf1600_start, i) ==
FF(1)) {
904 keccak_start_row = i;
908 ASSERT_EQ(
trace.
get(C::keccakf1600_start, keccak_start_row),
FF(1));
909 ASSERT_EQ(
trace.
get(C::keccakf1600_sel_no_error, keccak_start_row),
FF(1));
911 FF real_state_in_00 =
trace.
get(C::keccakf1600_state_in_00, keccak_start_row);
912 FF real_state_in_01 =
trace.
get(C::keccakf1600_state_in_01, keccak_start_row);
913 FF real_theta_xor_01 =
trace.
get(C::keccakf1600_theta_xor_01, keccak_start_row);
920 FF fake_theta_xor_01 =
FF(0xFA0E0BAD0DEADULL);
921 ASSERT_NE(fake_theta_xor_01, real_theta_xor_01);
922 trace.
set(C::keccakf1600_theta_xor_01, keccak_start_row, fake_theta_xor_01);
930 { C::bitwise_sel, 1 },
931 { C::bitwise_start, 1 },
932 { C::bitwise_start_keccak, 1 },
934 { C::bitwise_acc_ia, real_state_in_00 },
935 { C::bitwise_acc_ib, real_state_in_01 },
936 { C::bitwise_acc_ic, fake_theta_xor_01 },
937 { C::bitwise_ia_byte, real_state_in_00 },
938 { C::bitwise_ib_byte, real_state_in_01 },
939 { C::bitwise_ic_byte, fake_theta_xor_01 },
942 { C::bitwise_sel_tag_mismatch_err, 1 },
943 { C::bitwise_sel_tag_ff_err, 0 },
944 { C::bitwise_err, 1 },
945 { C::bitwise_end, 1 },
946 { C::bitwise_sel_get_ctr, 0 },
947 { C::bitwise_ctr, 0 },
950 { C::bitwise_tag_c, 0 },
957 check_relation<keccakf1600>(trace);
970 check_interaction<KeccakF1600TraceBuilder, lookup_keccakf1600_theta_xor_01_settings>(trace);
991TEST(BitwiseConstrainingTest, VulnerabilityFakeSha256XorOutput)
1010 EventEmitter<Sha256CompressionEvent> sha256_event_emitter;
1013 std::array<uint32_t, 8> state = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
1014 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
1016 for (uint32_t i = 0; i < 8; ++i) {
1017 mem.
set(state_addr + i, MemoryValue::from<uint32_t>(state[i]));
1020 std::array<uint32_t, 16> input = { 0x61626380, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18 };
1022 for (uint32_t i = 0; i < 16; ++i) {
1023 mem.
set(input_addr + i, MemoryValue::from<uint32_t>(input[i]));
1027 sha256_gadget.compression(
mem, state_addr, input_addr, output_addr);
1029 TestTraceContainer
trace;
1030 trace.
set(C::precomputed_first_row, 0, 1);
1032 Sha256TraceBuilder sha256_builder;
1033 sha256_builder.process(sha256_event_emitter.get_events(), trace);
1035 BitwiseTraceBuilder bitwise_builder;
1041 check_relation<sha256_relation>(trace);
1042 check_relation<bitwise>(trace);
1047 uint32_t sha256_row = 0;
1050 if (
trace.
get(C::sha256_sel_compute_w, i) ==
FF(1)) {
1056 ASSERT_TRUE(found) <<
"Could not find sha256 row with sel_compute_w=1";
1058 FF real_w_15_rotr_7 =
trace.
get(C::sha256_w_15_rotr_7, sha256_row);
1059 FF real_w_15_rotr_18 =
trace.
get(C::sha256_w_15_rotr_18, sha256_row);
1060 FF real_xor_output =
trace.
get(C::sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_row);
1065 FF fake_xor_output =
FF(0xDEADBEEF);
1066 ASSERT_NE(fake_xor_output, real_xor_output);
1067 trace.
set(C::sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_row, fake_xor_output);
1075 { C::bitwise_sel, 1 },
1076 { C::bitwise_start, 1 },
1077 { C::bitwise_start_sha256, 1 },
1079 { C::bitwise_acc_ia, real_w_15_rotr_7 },
1080 { C::bitwise_acc_ib, real_w_15_rotr_18 },
1081 { C::bitwise_acc_ic, fake_xor_output },
1082 { C::bitwise_ia_byte, real_w_15_rotr_7 },
1083 { C::bitwise_ib_byte, real_w_15_rotr_18 },
1084 { C::bitwise_ic_byte, fake_xor_output },
1087 { C::bitwise_sel_tag_mismatch_err, 1 },
1088 { C::bitwise_sel_tag_ff_err, 0 },
1089 { C::bitwise_err, 1 },
1090 { C::bitwise_end, 1 },
1091 { C::bitwise_sel_get_ctr, 0 },
1092 { C::bitwise_ctr, 0 },
1095 { C::bitwise_tag_c, 0 },
1103 check_relation<sha256_relation>(trace);
1122 tracegen::SharedIndexCache cache;
1123 tracegen::LookupIntoDynamicTableGeneric<lookup_sha256_w_s_0_xor_0_settings> lookup(cache, C::bitwise_start);
1124 lookup.process(trace);
1139TEST(BitwiseConstrainingTest, NegativeSelOnStartOrEnd)
1141 TestTraceContainer
trace({
1143 { C::bitwise_sel, 1 },
1144 { C::bitwise_start, 1 },
1145 { C::bitwise_ctr, 2 },
1148 { C::bitwise_sel, 1 },
1149 { C::bitwise_end, 1 },
1150 { C::bitwise_ctr, 1 },
1167TEST(BitwiseConstrainingTest, NegativeStartAfterLatch)
1170 TestTraceContainer
trace({
1172 { C::bitwise_sel, 1 },
1173 { C::bitwise_start, 1 },
1174 { C::bitwise_end, 1 },
1175 { C::bitwise_ctr, 1 },
1178 { C::bitwise_sel, 1 },
1179 { C::bitwise_start, 1 },
1180 { C::bitwise_end, 1 },
1181 { 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_LAST_ON_ERROR
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_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)
void process_bitwise(TraceContainer &trace)
void process_sel_range_16(TraceContainer &trace)
void process_tag_parameters(TraceContainer &trace)
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