diff --git a/barretenberg/cpp/pil/vm2/execution.pil b/barretenberg/cpp/pil/vm2/execution.pil index dca8fb2515f6..f2990aa42a01 100644 --- a/barretenberg/cpp/pil/vm2/execution.pil +++ b/barretenberg/cpp/pil/vm2/execution.pil @@ -16,6 +16,7 @@ include "poseidon2_hash.pil"; include "poseidon2_perm.pil"; include "scalar_mul.pil"; include "to_radix.pil"; +include "ff_gt.pil"; namespace execution; diff --git a/barretenberg/cpp/pil/vm2/ff_gt.pil b/barretenberg/cpp/pil/vm2/ff_gt.pil new file mode 100644 index 000000000000..06318f304b22 --- /dev/null +++ b/barretenberg/cpp/pil/vm2/ff_gt.pil @@ -0,0 +1,218 @@ +include "./range_check.pil"; + +// This module handles field gt +// GT also enables us to support LT (by swapping the inputs of GT) and LTE (by negating the result of GT) +// Lifecycle table: +// +-----+-----+--------+--------------+--------------+------------+------------+------+------+------------+------------+--------+--------+-------------+-----+--------+---------------+ +// | a | b | result | a_hi (range) | a_lo (range) | p_sub_a_hi | p_sub_a_lo | b_hi | b_lo | p_sub_b_hi | p_sub_b_lo | res_hi | res_lo | cmp_rng_ctr | sel | sel_gt | sel_shift_rng | +// +-----+-----+--------+--------------+--------------+------------+------------+------+------+------------+------------+--------+--------+-------------+-----+--------+---------------+ +// | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +// | 27 | 28 | 0 | 0 | 27 | x1 | x2 | 0 | 28 | y1 | y2 | 0 | 1 | 4 | 1 | 1 | 1 | <== lookup here +// | unc | unc | unc | x1 | x2 | 0 | 28 | y1 | y2 | 0 | 1 | unc | unc | 3 | 1 | 0 | 1 | +// | unc | unc | unc | 0 | 28 | y1 | y2 | 0 | 1 | unc | unc | unc | unc | 2 | 1 | 0 | 1 | +// | unc | unc | unc | y1 | y2 | 0 | 1 | unc | unc | unc | unc | unc | unc | 1 | 1 | 0 | 1 | +// | unc | unc | unc | 0 | 1 | unc | unc | unc | unc | unc | unc | unc | unc | 0 | 1 | 0 | 0 | +// | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +// +-----+-----+--------+--------------+--------------+------------+------------+------+------+------------+------------+--------+--------+-------------+-----+--------+---------------+ +// +// This trace should be looked up with the tuple (a,b,result,sel_gt) +namespace ff_gt; + pol commit sel; + sel * (1 - sel) = 0; + + #[skippable_if] + sel = 0; + + // These are the i/o for the gadget + pol commit a; + pol commit b; + pol commit result; + (result * (1 - result)) = 0; + + // Should be looked up based on this selector + // This will be off when doing the shifts for the remaning range constraints. + pol commit sel_gt; + sel_gt * (1 - sel_gt) = 0; + + // TODO: Commited because lookups don't support constants + pol commit constant_128; + sel * (128 - constant_128) = 0; + + pol POW_128 = 2 ** 128; + pol P_LO = 53438638232309528389504892708671455233; // Lower 128 bits of p + pol P_HI = 64323764613183177041862057485226039389; // Upper 128 bits of p + + // ========= A DECOMPOSITION ========= + + pol commit a_lo; + pol commit a_hi; + + #[A_DECOMPOSITION] + sel_gt * (a - (a_lo + POW_128 * a_hi)) = 0; + + // We only do 2 range checks per row. + // We'll shift the other 8 range checks necessary in 4 rows after the sel_gt one. + + #[A_LO_RANGE] + sel { a_lo, constant_128 } + in range_check.sel { range_check.value, range_check.rng_chk_bits }; + + #[A_HI_RANGE] + sel { a_hi, constant_128 } + in range_check.sel { range_check.value, range_check.rng_chk_bits }; + + pol commit p_a_borrow; + p_a_borrow * (1 - p_a_borrow) = 0; + + pol commit p_sub_a_lo; // p_lo - a_lo + pol commit p_sub_a_hi; // p_hi - a_hi + + #[P_SUB_A_LO] + sel_gt * (p_sub_a_lo - (P_LO - a_lo - 1 + p_a_borrow * POW_128)) = 0; + #[P_SUB_A_HI] + sel_gt * (p_sub_a_hi - (P_HI - a_hi - p_a_borrow)) = 0; + + // ========= B DECOMPOSITION ========= + + pol commit b_lo; + pol commit b_hi; + + #[B_DECOMPOSITION] + sel_gt * (b - (b_lo + POW_128 * b_hi)) = 0; + + pol commit p_b_borrow; + p_b_borrow * (1 - p_b_borrow) = 0; + + pol commit p_sub_b_lo; + pol commit p_sub_b_hi; + + // Check that decomposition of b into lo and hi limbs do not overflow/underflow p. + // This is achieved by checking (p_lo > b_lo && p_hi >= b_hi) || (p_lo <= b_lo && b_hi > b_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + #[P_SUB_B_LO] + sel_gt * (p_sub_b_lo - (P_LO - b_lo - 1 + p_b_borrow * POW_128)) = 0; + #[P_SUB_B_HI] + sel_gt * (p_sub_b_hi - (P_HI - b_hi - p_b_borrow)) = 0; + + // ========= GT OPERATION ========= + + pol commit borrow; + + // Calculate the combined relation: (a - b - 1) * q + (b - a ) * (1-q) + // Check that (a > b) by checking (a_lo > b_lo && a_hi >= bhi) || (alo <= b_lo && a_hi > b_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + pol A_SUB_B_LO = a_lo - b_lo - 1 + borrow * POW_128; + pol A_SUB_B_HI = a_hi - b_hi - borrow; + + // Check that (a <= b) by checking (b_lo >= a_lo && b_hi >= a_hi) || (b_lo < a_lo && b_hi > a_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + pol B_SUB_A_LO = b_lo - a_lo + borrow * POW_128; + pol B_SUB_A_HI = b_hi - a_hi - borrow; + + pol IS_GT = sel_gt * result; + // When IS_GT = 1, we enforce the condition that a > b and thus a - b - 1 does not underflow. + // When IS_GT = 0, we enforce the condition that a <= b and thus b - a does not underflow. + // ========= Analysing res_lo and res_hi scenarios for LTE ================================= + // (1) Assume a proof satisfies the constraints for LTE(x,y,1), i.e., x <= y + // Therefore ia = x, ib = y and ic = 1. + // (a) We do not swap the operands, so a = x and b = y, + // (b) IS_GT = 1 - ic = 0 + // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI + // (d) res_lo = y_lo - x_lo + borrow * 2**128 and res_hi = y_hi - x_hi - borrow. + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, x_hi, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> y_lo >= x_lo && y_hi >= x_hi + // (ii) borrow == 1 ==> y_hi >= x_hi + 1 ==> y_hi > x_hi + // This concludes the proof as for both cases, we must have: y >= x + // + // (2) Assume a proof satisfies the constraints for LTE(x,y,0), i.e. x > y. + // Therefore ia = x, ib = y and ic = 0. + // (a) We do not swap the operands, so a = x and b = y, + // (b) IS_GT = 1 - ic = 1 + // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI + // (d) res_lo = x_lo - y_lo - 1 + borrow * 2**128 and res_hi = x_hi - y_hi - borrow. + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, x_hi, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> x_lo > y_lo && x_hi >= y_hi + // (ii) borrow == 1 ==> x_hi > y_hi + // This concludes the proof as for both cases, we must have: x > y + // + + // ========= Analysing res_lo and res_hi scenarios for LT ================================== + // (1) Assume a proof satisfies the constraints for LT(x,y,1), i.e. x < y. + // Therefore ia = x, ib = y and ic = 1. + // (a) We DO swap the operands, so a = y and b = x, + // (b) IS_GT = ic = 1 + // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI, **remember we have swapped inputs** + // (d) res_lo = y_lo - x_lo - 1 + borrow * 2**128 and res_hi = y_hi - x_hi - borrow. + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, x_hi, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> y_lo > x_lo && y_hi >= x_hi + // (ii) borrow == 1 ==> y_hi > x_hi + // This concludes the proof as for both cases, we must have: x < y + // + // (2) Assume a proof satisfies the constraint for LT(x,y,0), i.e. x >= y. + // Therefore ia = x, ib = y and ic = 0. + // (a) We DO swap the operands, so a = y and b = x, + // (b) IS_GT = ic = 0 + // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI, **remember we have swapped inputs** + // (d) res_lo = a_lo - y_lo + borrow * 2**128 and res_hi = a_hi - y_hi - borrow. + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, x_hi, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> x_lo >= y_lo && x_hi >= y_hi + // (ii) borrow == 1 ==> x_hi > y_hi + // This concludes the proof as for both cases, we must have: x >= y + pol commit res_lo; + pol commit res_hi; + #[RES_LO] + sel_gt * (res_lo - (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT))) = 0; + #[RES_HI] + sel_gt * (res_hi - (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT))) = 0; + + + // ========= SHIFTS FOR RANGE CHECKS ========= + + // Each call to GT requires 5x 256-bit range checks. We keep track of how many are left here. + pol commit cmp_rng_ctr; + + // if this row is a comparison operation, the next range_check_remaining value is set to 5 + #[SET_RNG_CTR] + sel_gt * (cmp_rng_ctr - 4) = 0; + + // the number of range checks must decrement by 1 until it is equal to 0; + #[SUB_RNG_CTR] + cmp_rng_ctr * (cmp_rng_ctr - 1 - cmp_rng_ctr') = 0; + + pol commit sel_shift_rng; + sel_shift_rng * (1 - sel_shift_rng) = 0; + + pol commit cmp_rng_ctr_inv; + + // sel_shift_rng = 1 when cmp_rng_ctr != 0 and sel_shift_rng = 0 when cmp_rng_ctr = 0; + #[RNG_CTR_NON_ZERO] + cmp_rng_ctr * ((1 - sel_shift_rng) * (1 - cmp_rng_ctr_inv) + cmp_rng_ctr_inv) - sel_shift_rng = 0; + + // We shift the stuff that we have to range check to the left, so a_lo and a_hi (which are doing the range checks) + // receive the shifted values, two on every row. + #[SHIFT_0] + (a_lo' - p_sub_a_lo) * sel_shift_rng = 0; + (a_hi' - p_sub_a_hi) * sel_shift_rng = 0; + #[SHIFT_1] + (p_sub_a_lo' - b_lo) * sel_shift_rng = 0; + (p_sub_a_hi' - b_hi) * sel_shift_rng = 0; + #[SHIFT_2] + (b_lo' - p_sub_b_lo) * sel_shift_rng = 0; + (b_hi' - p_sub_b_hi) * sel_shift_rng = 0; + #[SHIFT_3] + (p_sub_b_lo' - res_lo) * sel_shift_rng = 0; + (p_sub_b_hi' - res_hi) * sel_shift_rng = 0; + + // ========= SELECTOR ========= + // Selector should be on on the whole 5 rows that are required for the gt operations + range checks. + // So if sel_gt is on, sel should be on, but also if the previous one had sel_shift_rng on. + #[SEL_CONSISTENCY] + sel_shift_rng + sel_gt' - sel' = 0; diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/field_gt.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/field_gt.test.cpp new file mode 100644 index 000000000000..5985f122de3f --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/field_gt.test.cpp @@ -0,0 +1,262 @@ +#include +#include + +#include "barretenberg/numeric/uint256/uint256.hpp" +#include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" +#include "barretenberg/vm2/common/aztec_types.hpp" +#include "barretenberg/vm2/constraining/testing/check_relation.hpp" +#include "barretenberg/vm2/generated/flavor_settings.hpp" +#include "barretenberg/vm2/generated/relations/lookups_ff_gt.hpp" +#include "barretenberg/vm2/simulation/events/field_gt_event.hpp" +#include "barretenberg/vm2/simulation/field_gt.hpp" +#include "barretenberg/vm2/simulation/lib/u256_decomposition.hpp" +#include "barretenberg/vm2/simulation/testing/mock_range_check.hpp" +#include "barretenberg/vm2/testing/fixtures.hpp" +#include "barretenberg/vm2/testing/macros.hpp" +#include "barretenberg/vm2/tracegen/field_gt_trace.hpp" +#include "barretenberg/vm2/tracegen/lib/lookup_builder.hpp" +#include "barretenberg/vm2/tracegen/precomputed_trace.hpp" +#include "barretenberg/vm2/tracegen/range_check_trace.hpp" +#include "barretenberg/vm2/tracegen/test_trace_container.hpp" + +namespace bb::avm2::constraining { +namespace { + +using ::testing::NiceMock; +using ::testing::TestWithParam; + +using tracegen::LookupIntoDynamicTableSequential; +using tracegen::TestTraceContainer; + +using simulation::EventEmitter; +using simulation::FieldGreaterThan; +using simulation::FieldGreaterThanEvent; +using simulation::MockRangeCheck; +using simulation::RangeCheck; +using simulation::RangeCheckEvent; + +using FF = AvmFlavorSettings::FF; +using C = Column; +using ff_gt = bb::avm2::ff_gt; + +using lookup_a_hi_range = bb::avm2::lookup_ff_gt_a_hi_range_relation; +using lookup_a_lo_range = bb::avm2::lookup_ff_gt_a_lo_range_relation; + +const uint256_t TWO_POW_128 = uint256_t{ 1 } << 128; + +TEST(FieldGreaterThanConstrainingTest, EmptyRow) +{ + check_relation(testing::empty_trace()); +} + +struct TestParams { + FF a; + FF b; + bool expected_result; +}; + +std::vector comparison_tests = { + // GT + TestParams{ 27, 0, true }, + TestParams{ TWO_POW_128, 0, true }, + TestParams{ -1, 0, true }, + // EQ + TestParams{ 27, 27, false }, + TestParams{ TWO_POW_128, TWO_POW_128, false }, + TestParams{ -1, -1, false }, + // LT + TestParams{ 0, 1, false }, + TestParams{ 0, TWO_POW_128, false }, + TestParams{ 0, -1, false } +}; + +class BasicTest : public TestWithParam {}; + +TEST_P(BasicTest, BasicComparison) +{ + const auto& param = GetParam(); + + NiceMock range_check; + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + EXPECT_EQ(field_gt_simulator.ff_gt(param.a, param.b), param.expected_result); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + builder.process(event_emitter.dump_events(), trace); + EXPECT_EQ(trace.get_num_rows(), /*start_row=*/1 + 5); + check_relation(trace); +} + +INSTANTIATE_TEST_SUITE_P(FieldGreaterThanConstrainingTest, BasicTest, ::testing::ValuesIn(comparison_tests)); + +class InteractionsTests : public TestWithParam {}; + +TEST_P(InteractionsTests, InteractionsWithRangeCheck) +{ + const auto& param = GetParam(); + + EventEmitter range_check_event_emitter; + RangeCheck range_check(range_check_event_emitter); + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + EXPECT_EQ(field_gt_simulator.ff_gt(param.a, param.b), param.expected_result); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + tracegen::RangeCheckTraceBuilder range_check_builder; + + builder.process(event_emitter.dump_events(), trace); + range_check_builder.process(range_check_event_emitter.dump_events(), trace); + + LookupIntoDynamicTableSequential().process(trace); + LookupIntoDynamicTableSequential().process(trace); + + check_relation(trace); + check_interaction(trace); + check_interaction(trace); +} + +INSTANTIATE_TEST_SUITE_P(FieldGreaterThanConstrainingTest, InteractionsTests, ::testing::ValuesIn(comparison_tests)); + +TEST(FieldGreaterThanConstrainingTest, NegativeManipulatedDecompositions) +{ + NiceMock range_check; + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + field_gt_simulator.ff_gt(0, 0); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + builder.process(event_emitter.dump_events(), trace); + + trace.set(Column::ff_gt_a_lo, 1, 1); + trace.set(Column::ff_gt_b_hi, 1, 1); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_A_DECOMPOSITION), "A_DECOMPOSITION"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_B_DECOMPOSITION), "B_DECOMPOSITION"); +} + +TEST(FieldGreaterThanConstrainingTest, NegativeManipulatedComparisonsWithP) +{ + NiceMock range_check; + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + field_gt_simulator.ff_gt(0, 0); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + builder.process(event_emitter.dump_events(), trace); + + auto p_limbs = simulation::decompose(FF::modulus); + uint256_t p_lo = uint256_t::from_uint128(p_limbs.lo); + uint256_t p_hi = uint256_t::from_uint128(p_limbs.hi); + + // Manipulate the decomposition in a way that passes the decomposition check due to overflow + trace.set(Column::ff_gt_a_lo, 1, p_lo); + trace.set(Column::ff_gt_a_hi, 1, p_hi); + trace.set(Column::ff_gt_b_lo, 1, p_lo); + trace.set(Column::ff_gt_b_hi, 1, p_hi); + + trace.set(Column::ff_gt_p_sub_a_hi, 1, p_lo - 1); + trace.set(Column::ff_gt_p_sub_a_lo, 1, p_hi - 1); + trace.set(Column::ff_gt_p_sub_b_hi, 1, p_lo - 1); + trace.set(Column::ff_gt_p_sub_b_lo, 1, p_hi - 1); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_P_SUB_A_LO), "P_SUB_A_LO"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_P_SUB_A_HI), "P_SUB_A_HI"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_P_SUB_B_LO), "P_SUB_B_LO"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_P_SUB_B_HI), "P_SUB_B_HI"); +} + +TEST(FieldGreaterThanConstrainingTest, NegativeLessRangeChecks) +{ + NiceMock range_check; + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + field_gt_simulator.ff_gt(0, 0); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + builder.process(event_emitter.dump_events(), trace); + + trace.set(Column::ff_gt_cmp_rng_ctr, 1, 3); + trace.set(Column::ff_gt_cmp_rng_ctr, 2, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SET_RNG_CTR), "SET_RNG_CTR"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SUB_RNG_CTR), "SUB_RNG_CTR"); +} + +TEST(FieldGreaterThanConstrainingTest, NegativeSelectorConsistency) +{ + NiceMock range_check; + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + field_gt_simulator.ff_gt(0, 0); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + builder.process(event_emitter.dump_events(), trace); + + // Disable the selector after the first row + trace.set(Column::ff_gt_sel, 2, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SEL_CONSISTENCY), "SEL_CONSISTENCY"); +} + +TEST(FieldGreaterThanConstrainingTest, NegativeEraseShift) +{ + NiceMock range_check; + EventEmitter event_emitter; + FieldGreaterThan field_gt_simulator(range_check, event_emitter); + + field_gt_simulator.ff_gt(42, 27); + + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + }); + + tracegen::FieldGreaterThanTraceBuilder builder; + builder.process(event_emitter.dump_events(), trace); + + trace.set(Column::ff_gt_a_lo, 2, 0); + trace.set(Column::ff_gt_a_hi, 2, 0); + trace.set(Column::ff_gt_p_sub_a_lo, 2, 0); + trace.set(Column::ff_gt_p_sub_a_hi, 2, 0); + trace.set(Column::ff_gt_b_lo, 2, 0); + trace.set(Column::ff_gt_b_hi, 2, 0); + trace.set(Column::ff_gt_p_sub_b_lo, 2, 0); + trace.set(Column::ff_gt_p_sub_b_hi, 2, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SHIFT_0), "SHIFT_0"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SHIFT_1), "SHIFT_1"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SHIFT_2), "SHIFT_2"); + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, ff_gt::SR_SHIFT_3), "SHIFT_3"); +} + +} // namespace +} // namespace bb::avm2::constraining diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index c1daefc191ad..886733346003 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,16 +10,16 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_out_of_range, instr_fetching_pc_size_in_bits, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, merkle_check_constant_2, merkle_check_current_index_in_layer, merkle_check_current_node, merkle_check_end, merkle_check_index_is_even, merkle_check_leaf, merkle_check_leaf_index, merkle_check_left_node, merkle_check_output_hash, merkle_check_remaining_path_len, merkle_check_remaining_path_len_inv, merkle_check_right_node, merkle_check_sel, merkle_check_sibling, merkle_check_start, merkle_check_tree_height, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_merkle_check_merkle_poseidon2_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_inv, lookup_instr_fetching_bytecode_size_from_bc_dec_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_merkle_check_merkle_poseidon2_inv, lookup_sha256_round_constant_inv -#define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, merkle_check_current_index_in_layer_shift, merkle_check_current_node_shift, merkle_check_leaf_shift, merkle_check_leaf_index_shift, merkle_check_remaining_path_len_shift, merkle_check_sel_shift, merkle_check_start_shift, merkle_check_tree_height_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift -#define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.merkle_check_current_index_in_layer, e.merkle_check_current_node, e.merkle_check_leaf, e.merkle_check_leaf_index, e.merkle_check_remaining_path_len, e.merkle_check_sel, e.merkle_check_start, e.merkle_check_tree_height, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, ff_gt_a, ff_gt_a_hi, ff_gt_a_lo, ff_gt_b, ff_gt_b_hi, ff_gt_b_lo, ff_gt_borrow, ff_gt_cmp_rng_ctr, ff_gt_cmp_rng_ctr_inv, ff_gt_constant_128, ff_gt_p_a_borrow, ff_gt_p_b_borrow, ff_gt_p_sub_a_hi, ff_gt_p_sub_a_lo, ff_gt_p_sub_b_hi, ff_gt_p_sub_b_lo, ff_gt_res_hi, ff_gt_res_lo, ff_gt_result, ff_gt_sel, ff_gt_sel_gt, ff_gt_sel_shift_rng, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_out_of_range, instr_fetching_pc_size_in_bits, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, merkle_check_constant_2, merkle_check_current_index_in_layer, merkle_check_current_node, merkle_check_end, merkle_check_index_is_even, merkle_check_leaf, merkle_check_leaf_index, merkle_check_left_node, merkle_check_output_hash, merkle_check_remaining_path_len, merkle_check_remaining_path_len_inv, merkle_check_right_node, merkle_check_sel, merkle_check_sibling, merkle_check_start, merkle_check_tree_height, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_merkle_check_merkle_poseidon2_counts, lookup_sha256_round_constant_counts, lookup_ff_gt_a_lo_range_counts, lookup_ff_gt_a_hi_range_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_inv, lookup_instr_fetching_bytecode_size_from_bc_dec_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_merkle_check_merkle_poseidon2_inv, lookup_sha256_round_constant_inv, lookup_ff_gt_a_lo_range_inv, lookup_ff_gt_a_hi_range_inv +#define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, ff_gt_a_hi_shift, ff_gt_a_lo_shift, ff_gt_b_hi_shift, ff_gt_b_lo_shift, ff_gt_cmp_rng_ctr_shift, ff_gt_p_sub_a_hi_shift, ff_gt_p_sub_a_lo_shift, ff_gt_p_sub_b_hi_shift, ff_gt_p_sub_b_lo_shift, ff_gt_sel_shift, ff_gt_sel_gt_shift, merkle_check_current_index_in_layer_shift, merkle_check_current_node_shift, merkle_check_leaf_shift, merkle_check_leaf_index_shift, merkle_check_remaining_path_len_shift, merkle_check_sel_shift, merkle_check_start_shift, merkle_check_tree_height_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift +#define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.ff_gt_a_hi, e.ff_gt_a_lo, e.ff_gt_b_hi, e.ff_gt_b_lo, e.ff_gt_cmp_rng_ctr, e.ff_gt_p_sub_a_hi, e.ff_gt_p_sub_a_lo, e.ff_gt_p_sub_b_hi, e.ff_gt_p_sub_b_lo, e.ff_gt_sel, e.ff_gt_sel_gt, e.merkle_check_current_index_in_layer, e.merkle_check_current_node, e.merkle_check_leaf, e.merkle_check_leaf_index, e.merkle_check_remaining_path_len, e.merkle_check_sel, e.merkle_check_start, e.merkle_check_tree_height, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES #define AVM2_UNSHIFTED_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES #define AVM2_WITNESS_ENTITIES AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES -#define AVM2_TO_BE_SHIFTED_COLUMNS Column::bc_decomposition_bytes, Column::bc_decomposition_bytes_pc_plus_1, Column::bc_decomposition_bytes_pc_plus_10, Column::bc_decomposition_bytes_pc_plus_11, Column::bc_decomposition_bytes_pc_plus_12, Column::bc_decomposition_bytes_pc_plus_13, Column::bc_decomposition_bytes_pc_plus_14, Column::bc_decomposition_bytes_pc_plus_15, Column::bc_decomposition_bytes_pc_plus_16, Column::bc_decomposition_bytes_pc_plus_17, Column::bc_decomposition_bytes_pc_plus_18, Column::bc_decomposition_bytes_pc_plus_19, Column::bc_decomposition_bytes_pc_plus_2, Column::bc_decomposition_bytes_pc_plus_20, Column::bc_decomposition_bytes_pc_plus_21, Column::bc_decomposition_bytes_pc_plus_22, Column::bc_decomposition_bytes_pc_plus_23, Column::bc_decomposition_bytes_pc_plus_24, Column::bc_decomposition_bytes_pc_plus_25, Column::bc_decomposition_bytes_pc_plus_26, Column::bc_decomposition_bytes_pc_plus_27, Column::bc_decomposition_bytes_pc_plus_28, Column::bc_decomposition_bytes_pc_plus_29, Column::bc_decomposition_bytes_pc_plus_3, Column::bc_decomposition_bytes_pc_plus_30, Column::bc_decomposition_bytes_pc_plus_31, Column::bc_decomposition_bytes_pc_plus_32, Column::bc_decomposition_bytes_pc_plus_33, Column::bc_decomposition_bytes_pc_plus_34, Column::bc_decomposition_bytes_pc_plus_35, Column::bc_decomposition_bytes_pc_plus_4, Column::bc_decomposition_bytes_pc_plus_5, Column::bc_decomposition_bytes_pc_plus_6, Column::bc_decomposition_bytes_pc_plus_7, Column::bc_decomposition_bytes_pc_plus_8, Column::bc_decomposition_bytes_pc_plus_9, Column::bc_decomposition_bytes_remaining, Column::bc_decomposition_id, Column::bc_decomposition_pc, Column::bc_decomposition_sel, Column::bc_hashing_bytecode_id, Column::bc_hashing_incremental_hash, Column::bc_hashing_pc_index, Column::bc_hashing_sel, Column::bc_hashing_start, Column::bitwise_acc_ia, Column::bitwise_acc_ib, Column::bitwise_acc_ic, Column::bitwise_ctr, Column::bitwise_op_id, Column::execution_sel, Column::merkle_check_current_index_in_layer, Column::merkle_check_current_node, Column::merkle_check_leaf, Column::merkle_check_leaf_index, Column::merkle_check_remaining_path_len, Column::merkle_check_sel, Column::merkle_check_start, Column::merkle_check_tree_height, Column::poseidon2_hash_a_0, Column::poseidon2_hash_a_1, Column::poseidon2_hash_a_2, Column::poseidon2_hash_a_3, Column::poseidon2_hash_input_0, Column::poseidon2_hash_input_1, Column::poseidon2_hash_input_2, Column::poseidon2_hash_num_perm_rounds_rem, Column::poseidon2_hash_output, Column::poseidon2_hash_sel, Column::poseidon2_hash_start, Column::scalar_mul_bit_idx, Column::scalar_mul_point_inf, Column::scalar_mul_point_x, Column::scalar_mul_point_y, Column::scalar_mul_res_inf, Column::scalar_mul_res_x, Column::scalar_mul_res_y, Column::scalar_mul_scalar, Column::scalar_mul_sel, Column::scalar_mul_start, Column::scalar_mul_temp_inf, Column::scalar_mul_temp_x, Column::scalar_mul_temp_y, Column::sha256_a, Column::sha256_b, Column::sha256_c, Column::sha256_d, Column::sha256_e, Column::sha256_f, Column::sha256_g, Column::sha256_h, Column::sha256_helper_w0, Column::sha256_helper_w1, Column::sha256_helper_w10, Column::sha256_helper_w11, Column::sha256_helper_w12, Column::sha256_helper_w13, Column::sha256_helper_w14, Column::sha256_helper_w15, Column::sha256_helper_w2, Column::sha256_helper_w3, Column::sha256_helper_w4, Column::sha256_helper_w5, Column::sha256_helper_w6, Column::sha256_helper_w7, Column::sha256_helper_w8, Column::sha256_helper_w9, Column::sha256_rounds_remaining, Column::sha256_sel, Column::sha256_start, Column::to_radix_acc, Column::to_radix_acc_under_p, Column::to_radix_exponent, Column::to_radix_limb, Column::to_radix_limb_eq_p, Column::to_radix_limb_index, Column::to_radix_limb_lt_p, Column::to_radix_not_padding_limb, Column::to_radix_radix, Column::to_radix_safe_limbs, Column::to_radix_sel, Column::to_radix_start, Column::to_radix_value -#define AVM2_SHIFTED_COLUMNS ColumnAndShifts::bc_decomposition_bytes_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_10_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_11_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_12_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_13_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_14_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_15_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_16_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_17_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_18_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_19_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_20_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_21_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_22_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_23_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_24_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_25_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_26_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_27_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_28_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_29_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_3_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_30_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_31_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_32_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_33_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_34_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_35_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_4_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_5_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_6_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_7_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_8_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_9_shift, ColumnAndShifts::bc_decomposition_bytes_remaining_shift, ColumnAndShifts::bc_decomposition_id_shift, ColumnAndShifts::bc_decomposition_pc_shift, ColumnAndShifts::bc_decomposition_sel_shift, ColumnAndShifts::bc_hashing_bytecode_id_shift, ColumnAndShifts::bc_hashing_incremental_hash_shift, ColumnAndShifts::bc_hashing_pc_index_shift, ColumnAndShifts::bc_hashing_sel_shift, ColumnAndShifts::bc_hashing_start_shift, ColumnAndShifts::bitwise_acc_ia_shift, ColumnAndShifts::bitwise_acc_ib_shift, ColumnAndShifts::bitwise_acc_ic_shift, ColumnAndShifts::bitwise_ctr_shift, ColumnAndShifts::bitwise_op_id_shift, ColumnAndShifts::execution_sel_shift, ColumnAndShifts::merkle_check_current_index_in_layer_shift, ColumnAndShifts::merkle_check_current_node_shift, ColumnAndShifts::merkle_check_leaf_shift, ColumnAndShifts::merkle_check_leaf_index_shift, ColumnAndShifts::merkle_check_remaining_path_len_shift, ColumnAndShifts::merkle_check_sel_shift, ColumnAndShifts::merkle_check_start_shift, ColumnAndShifts::merkle_check_tree_height_shift, ColumnAndShifts::poseidon2_hash_a_0_shift, ColumnAndShifts::poseidon2_hash_a_1_shift, ColumnAndShifts::poseidon2_hash_a_2_shift, ColumnAndShifts::poseidon2_hash_a_3_shift, ColumnAndShifts::poseidon2_hash_input_0_shift, ColumnAndShifts::poseidon2_hash_input_1_shift, ColumnAndShifts::poseidon2_hash_input_2_shift, ColumnAndShifts::poseidon2_hash_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_hash_output_shift, ColumnAndShifts::poseidon2_hash_sel_shift, ColumnAndShifts::poseidon2_hash_start_shift, ColumnAndShifts::scalar_mul_bit_idx_shift, ColumnAndShifts::scalar_mul_point_inf_shift, ColumnAndShifts::scalar_mul_point_x_shift, ColumnAndShifts::scalar_mul_point_y_shift, ColumnAndShifts::scalar_mul_res_inf_shift, ColumnAndShifts::scalar_mul_res_x_shift, ColumnAndShifts::scalar_mul_res_y_shift, ColumnAndShifts::scalar_mul_scalar_shift, ColumnAndShifts::scalar_mul_sel_shift, ColumnAndShifts::scalar_mul_start_shift, ColumnAndShifts::scalar_mul_temp_inf_shift, ColumnAndShifts::scalar_mul_temp_x_shift, ColumnAndShifts::scalar_mul_temp_y_shift, ColumnAndShifts::sha256_a_shift, ColumnAndShifts::sha256_b_shift, ColumnAndShifts::sha256_c_shift, ColumnAndShifts::sha256_d_shift, ColumnAndShifts::sha256_e_shift, ColumnAndShifts::sha256_f_shift, ColumnAndShifts::sha256_g_shift, ColumnAndShifts::sha256_h_shift, ColumnAndShifts::sha256_helper_w0_shift, ColumnAndShifts::sha256_helper_w1_shift, ColumnAndShifts::sha256_helper_w10_shift, ColumnAndShifts::sha256_helper_w11_shift, ColumnAndShifts::sha256_helper_w12_shift, ColumnAndShifts::sha256_helper_w13_shift, ColumnAndShifts::sha256_helper_w14_shift, ColumnAndShifts::sha256_helper_w15_shift, ColumnAndShifts::sha256_helper_w2_shift, ColumnAndShifts::sha256_helper_w3_shift, ColumnAndShifts::sha256_helper_w4_shift, ColumnAndShifts::sha256_helper_w5_shift, ColumnAndShifts::sha256_helper_w6_shift, ColumnAndShifts::sha256_helper_w7_shift, ColumnAndShifts::sha256_helper_w8_shift, ColumnAndShifts::sha256_helper_w9_shift, ColumnAndShifts::sha256_rounds_remaining_shift, ColumnAndShifts::sha256_sel_shift, ColumnAndShifts::sha256_start_shift, ColumnAndShifts::to_radix_acc_shift, ColumnAndShifts::to_radix_acc_under_p_shift, ColumnAndShifts::to_radix_exponent_shift, ColumnAndShifts::to_radix_limb_shift, ColumnAndShifts::to_radix_limb_eq_p_shift, ColumnAndShifts::to_radix_limb_index_shift, ColumnAndShifts::to_radix_limb_lt_p_shift, ColumnAndShifts::to_radix_not_padding_limb_shift, ColumnAndShifts::to_radix_radix_shift, ColumnAndShifts::to_radix_safe_limbs_shift, ColumnAndShifts::to_radix_sel_shift, ColumnAndShifts::to_radix_start_shift, ColumnAndShifts::to_radix_value_shift +#define AVM2_TO_BE_SHIFTED_COLUMNS Column::bc_decomposition_bytes, Column::bc_decomposition_bytes_pc_plus_1, Column::bc_decomposition_bytes_pc_plus_10, Column::bc_decomposition_bytes_pc_plus_11, Column::bc_decomposition_bytes_pc_plus_12, Column::bc_decomposition_bytes_pc_plus_13, Column::bc_decomposition_bytes_pc_plus_14, Column::bc_decomposition_bytes_pc_plus_15, Column::bc_decomposition_bytes_pc_plus_16, Column::bc_decomposition_bytes_pc_plus_17, Column::bc_decomposition_bytes_pc_plus_18, Column::bc_decomposition_bytes_pc_plus_19, Column::bc_decomposition_bytes_pc_plus_2, Column::bc_decomposition_bytes_pc_plus_20, Column::bc_decomposition_bytes_pc_plus_21, Column::bc_decomposition_bytes_pc_plus_22, Column::bc_decomposition_bytes_pc_plus_23, Column::bc_decomposition_bytes_pc_plus_24, Column::bc_decomposition_bytes_pc_plus_25, Column::bc_decomposition_bytes_pc_plus_26, Column::bc_decomposition_bytes_pc_plus_27, Column::bc_decomposition_bytes_pc_plus_28, Column::bc_decomposition_bytes_pc_plus_29, Column::bc_decomposition_bytes_pc_plus_3, Column::bc_decomposition_bytes_pc_plus_30, Column::bc_decomposition_bytes_pc_plus_31, Column::bc_decomposition_bytes_pc_plus_32, Column::bc_decomposition_bytes_pc_plus_33, Column::bc_decomposition_bytes_pc_plus_34, Column::bc_decomposition_bytes_pc_plus_35, Column::bc_decomposition_bytes_pc_plus_4, Column::bc_decomposition_bytes_pc_plus_5, Column::bc_decomposition_bytes_pc_plus_6, Column::bc_decomposition_bytes_pc_plus_7, Column::bc_decomposition_bytes_pc_plus_8, Column::bc_decomposition_bytes_pc_plus_9, Column::bc_decomposition_bytes_remaining, Column::bc_decomposition_id, Column::bc_decomposition_pc, Column::bc_decomposition_sel, Column::bc_hashing_bytecode_id, Column::bc_hashing_incremental_hash, Column::bc_hashing_pc_index, Column::bc_hashing_sel, Column::bc_hashing_start, Column::bitwise_acc_ia, Column::bitwise_acc_ib, Column::bitwise_acc_ic, Column::bitwise_ctr, Column::bitwise_op_id, Column::execution_sel, Column::ff_gt_a_hi, Column::ff_gt_a_lo, Column::ff_gt_b_hi, Column::ff_gt_b_lo, Column::ff_gt_cmp_rng_ctr, Column::ff_gt_p_sub_a_hi, Column::ff_gt_p_sub_a_lo, Column::ff_gt_p_sub_b_hi, Column::ff_gt_p_sub_b_lo, Column::ff_gt_sel, Column::ff_gt_sel_gt, Column::merkle_check_current_index_in_layer, Column::merkle_check_current_node, Column::merkle_check_leaf, Column::merkle_check_leaf_index, Column::merkle_check_remaining_path_len, Column::merkle_check_sel, Column::merkle_check_start, Column::merkle_check_tree_height, Column::poseidon2_hash_a_0, Column::poseidon2_hash_a_1, Column::poseidon2_hash_a_2, Column::poseidon2_hash_a_3, Column::poseidon2_hash_input_0, Column::poseidon2_hash_input_1, Column::poseidon2_hash_input_2, Column::poseidon2_hash_num_perm_rounds_rem, Column::poseidon2_hash_output, Column::poseidon2_hash_sel, Column::poseidon2_hash_start, Column::scalar_mul_bit_idx, Column::scalar_mul_point_inf, Column::scalar_mul_point_x, Column::scalar_mul_point_y, Column::scalar_mul_res_inf, Column::scalar_mul_res_x, Column::scalar_mul_res_y, Column::scalar_mul_scalar, Column::scalar_mul_sel, Column::scalar_mul_start, Column::scalar_mul_temp_inf, Column::scalar_mul_temp_x, Column::scalar_mul_temp_y, Column::sha256_a, Column::sha256_b, Column::sha256_c, Column::sha256_d, Column::sha256_e, Column::sha256_f, Column::sha256_g, Column::sha256_h, Column::sha256_helper_w0, Column::sha256_helper_w1, Column::sha256_helper_w10, Column::sha256_helper_w11, Column::sha256_helper_w12, Column::sha256_helper_w13, Column::sha256_helper_w14, Column::sha256_helper_w15, Column::sha256_helper_w2, Column::sha256_helper_w3, Column::sha256_helper_w4, Column::sha256_helper_w5, Column::sha256_helper_w6, Column::sha256_helper_w7, Column::sha256_helper_w8, Column::sha256_helper_w9, Column::sha256_rounds_remaining, Column::sha256_sel, Column::sha256_start, Column::to_radix_acc, Column::to_radix_acc_under_p, Column::to_radix_exponent, Column::to_radix_limb, Column::to_radix_limb_eq_p, Column::to_radix_limb_index, Column::to_radix_limb_lt_p, Column::to_radix_not_padding_limb, Column::to_radix_radix, Column::to_radix_safe_limbs, Column::to_radix_sel, Column::to_radix_start, Column::to_radix_value +#define AVM2_SHIFTED_COLUMNS ColumnAndShifts::bc_decomposition_bytes_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_10_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_11_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_12_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_13_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_14_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_15_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_16_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_17_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_18_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_19_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_20_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_21_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_22_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_23_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_24_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_25_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_26_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_27_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_28_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_29_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_3_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_30_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_31_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_32_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_33_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_34_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_35_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_4_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_5_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_6_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_7_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_8_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_9_shift, ColumnAndShifts::bc_decomposition_bytes_remaining_shift, ColumnAndShifts::bc_decomposition_id_shift, ColumnAndShifts::bc_decomposition_pc_shift, ColumnAndShifts::bc_decomposition_sel_shift, ColumnAndShifts::bc_hashing_bytecode_id_shift, ColumnAndShifts::bc_hashing_incremental_hash_shift, ColumnAndShifts::bc_hashing_pc_index_shift, ColumnAndShifts::bc_hashing_sel_shift, ColumnAndShifts::bc_hashing_start_shift, ColumnAndShifts::bitwise_acc_ia_shift, ColumnAndShifts::bitwise_acc_ib_shift, ColumnAndShifts::bitwise_acc_ic_shift, ColumnAndShifts::bitwise_ctr_shift, ColumnAndShifts::bitwise_op_id_shift, ColumnAndShifts::execution_sel_shift, ColumnAndShifts::ff_gt_a_hi_shift, ColumnAndShifts::ff_gt_a_lo_shift, ColumnAndShifts::ff_gt_b_hi_shift, ColumnAndShifts::ff_gt_b_lo_shift, ColumnAndShifts::ff_gt_cmp_rng_ctr_shift, ColumnAndShifts::ff_gt_p_sub_a_hi_shift, ColumnAndShifts::ff_gt_p_sub_a_lo_shift, ColumnAndShifts::ff_gt_p_sub_b_hi_shift, ColumnAndShifts::ff_gt_p_sub_b_lo_shift, ColumnAndShifts::ff_gt_sel_shift, ColumnAndShifts::ff_gt_sel_gt_shift, ColumnAndShifts::merkle_check_current_index_in_layer_shift, ColumnAndShifts::merkle_check_current_node_shift, ColumnAndShifts::merkle_check_leaf_shift, ColumnAndShifts::merkle_check_leaf_index_shift, ColumnAndShifts::merkle_check_remaining_path_len_shift, ColumnAndShifts::merkle_check_sel_shift, ColumnAndShifts::merkle_check_start_shift, ColumnAndShifts::merkle_check_tree_height_shift, ColumnAndShifts::poseidon2_hash_a_0_shift, ColumnAndShifts::poseidon2_hash_a_1_shift, ColumnAndShifts::poseidon2_hash_a_2_shift, ColumnAndShifts::poseidon2_hash_a_3_shift, ColumnAndShifts::poseidon2_hash_input_0_shift, ColumnAndShifts::poseidon2_hash_input_1_shift, ColumnAndShifts::poseidon2_hash_input_2_shift, ColumnAndShifts::poseidon2_hash_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_hash_output_shift, ColumnAndShifts::poseidon2_hash_sel_shift, ColumnAndShifts::poseidon2_hash_start_shift, ColumnAndShifts::scalar_mul_bit_idx_shift, ColumnAndShifts::scalar_mul_point_inf_shift, ColumnAndShifts::scalar_mul_point_x_shift, ColumnAndShifts::scalar_mul_point_y_shift, ColumnAndShifts::scalar_mul_res_inf_shift, ColumnAndShifts::scalar_mul_res_x_shift, ColumnAndShifts::scalar_mul_res_y_shift, ColumnAndShifts::scalar_mul_scalar_shift, ColumnAndShifts::scalar_mul_sel_shift, ColumnAndShifts::scalar_mul_start_shift, ColumnAndShifts::scalar_mul_temp_inf_shift, ColumnAndShifts::scalar_mul_temp_x_shift, ColumnAndShifts::scalar_mul_temp_y_shift, ColumnAndShifts::sha256_a_shift, ColumnAndShifts::sha256_b_shift, ColumnAndShifts::sha256_c_shift, ColumnAndShifts::sha256_d_shift, ColumnAndShifts::sha256_e_shift, ColumnAndShifts::sha256_f_shift, ColumnAndShifts::sha256_g_shift, ColumnAndShifts::sha256_h_shift, ColumnAndShifts::sha256_helper_w0_shift, ColumnAndShifts::sha256_helper_w1_shift, ColumnAndShifts::sha256_helper_w10_shift, ColumnAndShifts::sha256_helper_w11_shift, ColumnAndShifts::sha256_helper_w12_shift, ColumnAndShifts::sha256_helper_w13_shift, ColumnAndShifts::sha256_helper_w14_shift, ColumnAndShifts::sha256_helper_w15_shift, ColumnAndShifts::sha256_helper_w2_shift, ColumnAndShifts::sha256_helper_w3_shift, ColumnAndShifts::sha256_helper_w4_shift, ColumnAndShifts::sha256_helper_w5_shift, ColumnAndShifts::sha256_helper_w6_shift, ColumnAndShifts::sha256_helper_w7_shift, ColumnAndShifts::sha256_helper_w8_shift, ColumnAndShifts::sha256_helper_w9_shift, ColumnAndShifts::sha256_rounds_remaining_shift, ColumnAndShifts::sha256_sel_shift, ColumnAndShifts::sha256_start_shift, ColumnAndShifts::to_radix_acc_shift, ColumnAndShifts::to_radix_acc_under_p_shift, ColumnAndShifts::to_radix_exponent_shift, ColumnAndShifts::to_radix_limb_shift, ColumnAndShifts::to_radix_limb_eq_p_shift, ColumnAndShifts::to_radix_limb_index_shift, ColumnAndShifts::to_radix_limb_lt_p_shift, ColumnAndShifts::to_radix_not_padding_limb_shift, ColumnAndShifts::to_radix_radix_shift, ColumnAndShifts::to_radix_safe_limbs_shift, ColumnAndShifts::to_radix_sel_shift, ColumnAndShifts::to_radix_start_shift, ColumnAndShifts::to_radix_value_shift // clang-format on // All columns minus shifts. @@ -31,8 +31,8 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1055; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 932; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1092; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 958; constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_TO_BE_SHIFTED_COLUMNS }; }(); constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_SHIFTED_COLUMNS }; }(); static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index ddeffc89262d..2905d89576eb 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -27,6 +27,7 @@ #include "relations/class_id_derivation.hpp" #include "relations/ecc.hpp" #include "relations/execution.hpp" +#include "relations/ff_gt.hpp" #include "relations/instr_fetching.hpp" #include "relations/merkle_check.hpp" #include "relations/poseidon2_hash.hpp" @@ -43,6 +44,7 @@ #include "relations/lookups_bc_retrieval.hpp" #include "relations/lookups_bitwise.hpp" #include "relations/lookups_class_id_derivation.hpp" +#include "relations/lookups_ff_gt.hpp" #include "relations/lookups_instr_fetching.hpp" #include "relations/lookups_merkle_check.hpp" #include "relations/lookups_poseidon2_hash.hpp" @@ -92,12 +94,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 44; - static constexpr size_t NUM_WITNESS_ENTITIES = 888; - static constexpr size_t NUM_SHIFTED_ENTITIES = 123; + static constexpr size_t NUM_WITNESS_ENTITIES = 914; + static constexpr size_t NUM_SHIFTED_ENTITIES = 134; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 1055; + static constexpr size_t NUM_ALL_ENTITIES = 1092; // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is // evenly processed by all the threads. This constant defines the maximum number of rows @@ -122,6 +124,7 @@ class AvmFlavor { avm2::class_id_derivation, avm2::ecc, avm2::execution, + avm2::ff_gt, avm2::instr_fetching, avm2::merkle_check, avm2::poseidon2_hash, @@ -160,6 +163,8 @@ class AvmFlavor { lookup_bitwise_integral_tag_length_relation, lookup_class_id_derivation_class_id_poseidon2_0_relation, lookup_class_id_derivation_class_id_poseidon2_1_relation, + lookup_ff_gt_a_hi_range_relation, + lookup_ff_gt_a_lo_range_relation, lookup_instr_fetching_bytecode_size_from_bc_dec_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, lookup_instr_fetching_instr_abs_diff_positive_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/ff_gt.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/ff_gt.hpp new file mode 100644 index 000000000000..eaf6cde1aac3 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/ff_gt.hpp @@ -0,0 +1,284 @@ +// AUTOGENERATED FILE +#pragma once + +#include + +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" + +namespace bb::avm2 { + +template class ff_gtImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, + 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2 }; + + template inline static bool skip(const AllEntities& in) + { + const auto& new_term = in; + return (new_term.ff_gt_sel).is_zero(); + } + + template + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) + { + const auto ff_gt_POW_128 = FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }); + const auto ff_gt_P_LO = FF(uint256_t{ 4891460686036598785UL, 2896914383306846353UL, 0UL, 0UL }); + const auto ff_gt_P_HI = FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL }); + const auto ff_gt_A_SUB_B_LO = + ((new_term.ff_gt_a_lo - new_term.ff_gt_b_lo) - FF(1)) + new_term.ff_gt_borrow * ff_gt_POW_128; + const auto ff_gt_A_SUB_B_HI = ((new_term.ff_gt_a_hi - new_term.ff_gt_b_hi) - new_term.ff_gt_borrow); + const auto ff_gt_B_SUB_A_LO = + (new_term.ff_gt_b_lo - new_term.ff_gt_a_lo) + new_term.ff_gt_borrow * ff_gt_POW_128; + const auto ff_gt_B_SUB_A_HI = ((new_term.ff_gt_b_hi - new_term.ff_gt_a_hi) - new_term.ff_gt_borrow); + const auto ff_gt_IS_GT = new_term.ff_gt_sel_gt * new_term.ff_gt_result; + + { + using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel * (FF(1) - new_term.ff_gt_sel); + tmp *= scaling_factor; + std::get<0>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_result * (FF(1) - new_term.ff_gt_result); + tmp *= scaling_factor; + std::get<1>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * (FF(1) - new_term.ff_gt_sel_gt); + tmp *= scaling_factor; + std::get<2>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel * (FF(128) - new_term.ff_gt_constant_128); + tmp *= scaling_factor; + std::get<3>(evals) += typename Accumulator::View(tmp); + } + { // A_DECOMPOSITION + using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * + (new_term.ff_gt_a - (new_term.ff_gt_a_lo + ff_gt_POW_128 * new_term.ff_gt_a_hi)); + tmp *= scaling_factor; + std::get<4>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_p_a_borrow * (FF(1) - new_term.ff_gt_p_a_borrow); + tmp *= scaling_factor; + std::get<5>(evals) += typename Accumulator::View(tmp); + } + { // P_SUB_A_LO + using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * + (new_term.ff_gt_p_sub_a_lo - + (((ff_gt_P_LO - new_term.ff_gt_a_lo) - FF(1)) + new_term.ff_gt_p_a_borrow * ff_gt_POW_128)); + tmp *= scaling_factor; + std::get<6>(evals) += typename Accumulator::View(tmp); + } + { // P_SUB_A_HI + using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * + (new_term.ff_gt_p_sub_a_hi - ((ff_gt_P_HI - new_term.ff_gt_a_hi) - new_term.ff_gt_p_a_borrow)); + tmp *= scaling_factor; + std::get<7>(evals) += typename Accumulator::View(tmp); + } + { // B_DECOMPOSITION + using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * + (new_term.ff_gt_b - (new_term.ff_gt_b_lo + ff_gt_POW_128 * new_term.ff_gt_b_hi)); + tmp *= scaling_factor; + std::get<8>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_p_b_borrow * (FF(1) - new_term.ff_gt_p_b_borrow); + tmp *= scaling_factor; + std::get<9>(evals) += typename Accumulator::View(tmp); + } + { // P_SUB_B_LO + using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * + (new_term.ff_gt_p_sub_b_lo - + (((ff_gt_P_LO - new_term.ff_gt_b_lo) - FF(1)) + new_term.ff_gt_p_b_borrow * ff_gt_POW_128)); + tmp *= scaling_factor; + std::get<10>(evals) += typename Accumulator::View(tmp); + } + { // P_SUB_B_HI + using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * + (new_term.ff_gt_p_sub_b_hi - ((ff_gt_P_HI - new_term.ff_gt_b_hi) - new_term.ff_gt_p_b_borrow)); + tmp *= scaling_factor; + std::get<11>(evals) += typename Accumulator::View(tmp); + } + { // RES_LO + using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; + auto tmp = + new_term.ff_gt_sel_gt * + (new_term.ff_gt_res_lo - (ff_gt_A_SUB_B_LO * ff_gt_IS_GT + ff_gt_B_SUB_A_LO * (FF(1) - ff_gt_IS_GT))); + tmp *= scaling_factor; + std::get<12>(evals) += typename Accumulator::View(tmp); + } + { // RES_HI + using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; + auto tmp = + new_term.ff_gt_sel_gt * + (new_term.ff_gt_res_hi - (ff_gt_A_SUB_B_HI * ff_gt_IS_GT + ff_gt_B_SUB_A_HI * (FF(1) - ff_gt_IS_GT))); + tmp *= scaling_factor; + std::get<13>(evals) += typename Accumulator::View(tmp); + } + { // SET_RNG_CTR + using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_gt * (new_term.ff_gt_cmp_rng_ctr - FF(4)); + tmp *= scaling_factor; + std::get<14>(evals) += typename Accumulator::View(tmp); + } + { // SUB_RNG_CTR + using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; + auto tmp = + new_term.ff_gt_cmp_rng_ctr * ((new_term.ff_gt_cmp_rng_ctr - FF(1)) - new_term.ff_gt_cmp_rng_ctr_shift); + tmp *= scaling_factor; + std::get<15>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; + auto tmp = new_term.ff_gt_sel_shift_rng * (FF(1) - new_term.ff_gt_sel_shift_rng); + tmp *= scaling_factor; + std::get<16>(evals) += typename Accumulator::View(tmp); + } + { // RNG_CTR_NON_ZERO + using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_cmp_rng_ctr * + ((FF(1) - new_term.ff_gt_sel_shift_rng) * (FF(1) - new_term.ff_gt_cmp_rng_ctr_inv) + + new_term.ff_gt_cmp_rng_ctr_inv) - + new_term.ff_gt_sel_shift_rng); + tmp *= scaling_factor; + std::get<17>(evals) += typename Accumulator::View(tmp); + } + { // SHIFT_0 + using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_a_lo_shift - new_term.ff_gt_p_sub_a_lo) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<18>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_a_hi_shift - new_term.ff_gt_p_sub_a_hi) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<19>(evals) += typename Accumulator::View(tmp); + } + { // SHIFT_1 + using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_p_sub_a_lo_shift - new_term.ff_gt_b_lo) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<20>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_p_sub_a_hi_shift - new_term.ff_gt_b_hi) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<21>(evals) += typename Accumulator::View(tmp); + } + { // SHIFT_2 + using Accumulator = typename std::tuple_element_t<22, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_b_lo_shift - new_term.ff_gt_p_sub_b_lo) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<22>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<23, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_b_hi_shift - new_term.ff_gt_p_sub_b_hi) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<23>(evals) += typename Accumulator::View(tmp); + } + { // SHIFT_3 + using Accumulator = typename std::tuple_element_t<24, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_p_sub_b_lo_shift - new_term.ff_gt_res_lo) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<24>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<25, ContainerOverSubrelations>; + auto tmp = (new_term.ff_gt_p_sub_b_hi_shift - new_term.ff_gt_res_hi) * new_term.ff_gt_sel_shift_rng; + tmp *= scaling_factor; + std::get<25>(evals) += typename Accumulator::View(tmp); + } + { // SEL_CONSISTENCY + using Accumulator = typename std::tuple_element_t<26, ContainerOverSubrelations>; + auto tmp = ((new_term.ff_gt_sel_shift_rng + new_term.ff_gt_sel_gt_shift) - new_term.ff_gt_sel_shift); + tmp *= scaling_factor; + std::get<26>(evals) += typename Accumulator::View(tmp); + } + } +}; + +template class ff_gt : public Relation> { + public: + static constexpr const std::string_view NAME = "ff_gt"; + + static std::string get_subrelation_label(size_t index) + { + switch (index) { + case 4: + return "A_DECOMPOSITION"; + case 6: + return "P_SUB_A_LO"; + case 7: + return "P_SUB_A_HI"; + case 8: + return "B_DECOMPOSITION"; + case 10: + return "P_SUB_B_LO"; + case 11: + return "P_SUB_B_HI"; + case 12: + return "RES_LO"; + case 13: + return "RES_HI"; + case 14: + return "SET_RNG_CTR"; + case 15: + return "SUB_RNG_CTR"; + case 17: + return "RNG_CTR_NON_ZERO"; + case 18: + return "SHIFT_0"; + case 20: + return "SHIFT_1"; + case 22: + return "SHIFT_2"; + case 24: + return "SHIFT_3"; + case 26: + return "SEL_CONSISTENCY"; + } + return std::to_string(index); + } + + // Subrelation indices constants, to be used in tests. + static constexpr size_t SR_A_DECOMPOSITION = 4; + static constexpr size_t SR_P_SUB_A_LO = 6; + static constexpr size_t SR_P_SUB_A_HI = 7; + static constexpr size_t SR_B_DECOMPOSITION = 8; + static constexpr size_t SR_P_SUB_B_LO = 10; + static constexpr size_t SR_P_SUB_B_HI = 11; + static constexpr size_t SR_RES_LO = 12; + static constexpr size_t SR_RES_HI = 13; + static constexpr size_t SR_SET_RNG_CTR = 14; + static constexpr size_t SR_SUB_RNG_CTR = 15; + static constexpr size_t SR_RNG_CTR_NON_ZERO = 17; + static constexpr size_t SR_SHIFT_0 = 18; + static constexpr size_t SR_SHIFT_1 = 20; + static constexpr size_t SR_SHIFT_2 = 22; + static constexpr size_t SR_SHIFT_3 = 24; + static constexpr size_t SR_SEL_CONSISTENCY = 26; +}; + +} // namespace bb::avm2 diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_ff_gt.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_ff_gt.hpp new file mode 100644 index 000000000000..36f792b5ab42 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_ff_gt.hpp @@ -0,0 +1,189 @@ +// AUTOGENERATED FILE +#pragma once + +#include "../columns.hpp" +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include +#include + +namespace bb::avm2 { + +/////////////////// lookup_ff_gt_a_lo_range /////////////////// + +class lookup_ff_gt_a_lo_range_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_FF_GT_A_LO_RANGE"; + static constexpr std::string_view RELATION_NAME = "ff_gt"; + + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + // Columns using the Column enum. + static constexpr Column SRC_SELECTOR = Column::ff_gt_sel; + static constexpr Column DST_SELECTOR = Column::range_check_sel; + static constexpr Column COUNTS = Column::lookup_ff_gt_a_lo_range_counts; + static constexpr Column INVERSES = Column::lookup_ff_gt_a_lo_range_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::ff_gt_a_lo, ColumnAndShifts::ff_gt_constant_128 + }; + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::range_check_value, ColumnAndShifts::range_check_rng_chk_bits + }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._ff_gt_sel() == 1 || in._range_check_sel() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._ff_gt_sel()); + const auto is_table_entry = View(in._range_check_sel()); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_entities(AllEntities&& in) + { + return std::forward_as_tuple(in._lookup_ff_gt_a_lo_range_inv(), + in._lookup_ff_gt_a_lo_range_counts(), + in._ff_gt_sel(), + in._range_check_sel(), + in._ff_gt_a_lo(), + in._ff_gt_constant_128(), + in._range_check_value(), + in._range_check_rng_chk_bits()); + } +}; + +template +class lookup_ff_gt_a_lo_range_relation : public GenericLookupRelation { + public: + using Settings = lookup_ff_gt_a_lo_range_settings; + static constexpr std::string_view NAME = lookup_ff_gt_a_lo_range_settings::NAME; + static constexpr std::string_view RELATION_NAME = lookup_ff_gt_a_lo_range_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_ff_gt_a_lo_range_inv.is_zero(); + } + + static std::string get_subrelation_label(size_t index) + { + if (index == 0) { + return "INVERSES_ARE_CORRECT"; + } else if (index == 1) { + return "ACCUMULATION_IS_CORRECT"; + } + return std::to_string(index); + } +}; + +/////////////////// lookup_ff_gt_a_hi_range /////////////////// + +class lookup_ff_gt_a_hi_range_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_FF_GT_A_HI_RANGE"; + static constexpr std::string_view RELATION_NAME = "ff_gt"; + + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + // Columns using the Column enum. + static constexpr Column SRC_SELECTOR = Column::ff_gt_sel; + static constexpr Column DST_SELECTOR = Column::range_check_sel; + static constexpr Column COUNTS = Column::lookup_ff_gt_a_hi_range_counts; + static constexpr Column INVERSES = Column::lookup_ff_gt_a_hi_range_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::ff_gt_a_hi, ColumnAndShifts::ff_gt_constant_128 + }; + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::range_check_value, ColumnAndShifts::range_check_rng_chk_bits + }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._ff_gt_sel() == 1 || in._range_check_sel() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._ff_gt_sel()); + const auto is_table_entry = View(in._range_check_sel()); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_entities(AllEntities&& in) + { + return std::forward_as_tuple(in._lookup_ff_gt_a_hi_range_inv(), + in._lookup_ff_gt_a_hi_range_counts(), + in._ff_gt_sel(), + in._range_check_sel(), + in._ff_gt_a_hi(), + in._ff_gt_constant_128(), + in._range_check_value(), + in._range_check_rng_chk_bits()); + } +}; + +template +class lookup_ff_gt_a_hi_range_relation : public GenericLookupRelation { + public: + using Settings = lookup_ff_gt_a_hi_range_settings; + static constexpr std::string_view NAME = lookup_ff_gt_a_hi_range_settings::NAME; + static constexpr std::string_view RELATION_NAME = lookup_ff_gt_a_hi_range_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_ff_gt_a_hi_range_inv.is_zero(); + } + + static std::string get_subrelation_label(size_t index) + { + if (index == 0) { + return "INVERSES_ARE_CORRECT"; + } else if (index == 1) { + return "ACCUMULATION_IS_CORRECT"; + } + return std::to_string(index); + } +}; + +} // namespace bb::avm2 diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/merkle_check.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/merkle_check.hpp index ebc4a51b7dcd..db91838ec3c2 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/merkle_check.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/merkle_check.hpp @@ -37,7 +37,7 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<0>(evals) += typename Accumulator::View(tmp); } - { + { // TRACE_CONTINUITY using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>; auto tmp = (FF(1) - new_term.precomputed_first_row) * (FF(1) - new_term.merkle_check_sel) * new_term.merkle_check_sel_shift; @@ -62,60 +62,60 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<4>(evals) += typename Accumulator::View(tmp); } - { + { // START_AFTER_LATCH using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_sel_shift * (new_term.merkle_check_start_shift - merkle_check_LATCH_CONDITION); tmp *= scaling_factor; std::get<5>(evals) += typename Accumulator::View(tmp); } - { + { // SELECTOR_ON_END using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_end * (FF(1) - new_term.merkle_check_sel); tmp *= scaling_factor; std::get<6>(evals) += typename Accumulator::View(tmp); } - { + { // INITIALIZE_CURRENT_NODE using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_start * (new_term.merkle_check_current_node - new_term.merkle_check_leaf); tmp *= scaling_factor; std::get<7>(evals) += typename Accumulator::View(tmp); } - { + { // INITIALIZE_CURRENT_INDEX_IN_LAYER using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_start * (new_term.merkle_check_current_index_in_layer - new_term.merkle_check_leaf_index); tmp *= scaling_factor; std::get<8>(evals) += typename Accumulator::View(tmp); } - { + { // INITIALIZE_REMAINING_PATH_LEN using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_start * ((new_term.merkle_check_tree_height - new_term.merkle_check_remaining_path_len) - FF(1)); tmp *= scaling_factor; std::get<9>(evals) += typename Accumulator::View(tmp); } - { + { // PROPAGATE_LEAF using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; auto tmp = merkle_check_NOT_END * (new_term.merkle_check_leaf_shift - new_term.merkle_check_leaf); tmp *= scaling_factor; std::get<10>(evals) += typename Accumulator::View(tmp); } - { + { // PROPAGATE_LEAF_INDEX using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; auto tmp = merkle_check_NOT_END * (new_term.merkle_check_leaf_index_shift - new_term.merkle_check_leaf_index); tmp *= scaling_factor; std::get<11>(evals) += typename Accumulator::View(tmp); } - { + { // PROPAGATE_TREE_HEIGHT using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; auto tmp = merkle_check_NOT_END * (new_term.merkle_check_tree_height_shift - new_term.merkle_check_tree_height); tmp *= scaling_factor; std::get<12>(evals) += typename Accumulator::View(tmp); } - { + { // PATH_LEN_DECREMENTS using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; auto tmp = merkle_check_NOT_END * @@ -123,7 +123,7 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<13>(evals) += typename Accumulator::View(tmp); } - { + { // END_WHEN_PATH_EMPTY using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_sel * ((new_term.merkle_check_remaining_path_len * @@ -140,7 +140,7 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<15>(evals) += typename Accumulator::View(tmp); } - { + { // NEXT_INDEX_IS_HALVED using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; auto tmp = merkle_check_NOT_END * ((new_term.merkle_check_current_index_in_layer_shift * FF(2) + merkle_check_INDEX_IS_ODD) - @@ -148,14 +148,14 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<16>(evals) += typename Accumulator::View(tmp); } - { + { // FINAL_INDEX_IS_0_OR_1 using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_end * new_term.merkle_check_current_index_in_layer * (FF(1) - new_term.merkle_check_current_index_in_layer); tmp *= scaling_factor; std::get<17>(evals) += typename Accumulator::View(tmp); } - { + { // ASSIGN_CURRENT_NODE_LEFT_OR_RIGHT using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_sel * ((new_term.merkle_check_index_is_even * @@ -165,7 +165,7 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<18>(evals) += typename Accumulator::View(tmp); } - { + { // ASSIGN_SIBLING_LEFT_OR_RIGHT using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; auto tmp = new_term.merkle_check_sel * ((new_term.merkle_check_index_is_even * @@ -181,7 +181,7 @@ template class merkle_checkImpl { tmp *= scaling_factor; std::get<20>(evals) += typename Accumulator::View(tmp); } - { + { // OUTPUT_HASH_IS_NEXT_ROWS_CURRENT_NODE using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; auto tmp = merkle_check_NOT_END * (new_term.merkle_check_current_node_shift - new_term.merkle_check_output_hash); @@ -253,4 +253,4 @@ template class merkle_check : public Relation static constexpr size_t SR_OUTPUT_HASH_IS_NEXT_ROWS_CURRENT_NODE = 21; }; -} // namespace bb::avm2 \ No newline at end of file +} // namespace bb::avm2 diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp index b4c8c0ffcf1a..a55b344d5139 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp @@ -9,6 +9,7 @@ #include "barretenberg/vm2/simulation/events/ecc_events.hpp" #include "barretenberg/vm2/simulation/events/event_emitter.hpp" #include "barretenberg/vm2/simulation/events/execution_event.hpp" +#include "barretenberg/vm2/simulation/events/field_gt_event.hpp" #include "barretenberg/vm2/simulation/events/memory_event.hpp" #include "barretenberg/vm2/simulation/events/merkle_check_event.hpp" #include "barretenberg/vm2/simulation/events/poseidon2_event.hpp" @@ -37,6 +38,7 @@ struct EventsContainer { EventEmitterInterface::Container poseidon2_hash; EventEmitterInterface::Container poseidon2_permutation; EventEmitterInterface::Container to_radix; + EventEmitterInterface::Container field_gt; EventEmitterInterface::Container merkle_check; EventEmitterInterface::Container range_check; }; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/field_gt_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/field_gt_event.hpp new file mode 100644 index 000000000000..1c1d5a146735 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/field_gt_event.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "barretenberg/numeric/uint128/uint128.hpp" +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/simulation/lib/u256_decomposition.hpp" + +namespace bb::avm2::simulation { + +struct LimbsComparisonWitness { + uint128_t lo; + uint128_t hi; + bool borrow; + + bool operator==(const LimbsComparisonWitness& other) const = default; +}; + +struct FieldGreaterThanEvent { + FF a; + FF b; + U256Decomposition a_limbs; + LimbsComparisonWitness p_sub_a_witness; + U256Decomposition b_limbs; + LimbsComparisonWitness p_sub_b_witness; + LimbsComparisonWitness res_witness; + bool result; + + bool operator==(const FieldGreaterThanEvent& other) const = default; +}; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.cpp new file mode 100644 index 000000000000..b474a78091e7 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.cpp @@ -0,0 +1,63 @@ +#include "barretenberg/vm2/simulation/field_gt.hpp" + +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/simulation/lib/u256_decomposition.hpp" + +namespace bb::avm2::simulation { + +namespace { + +LimbsComparisonWitness limb_gt_witness(const U256Decomposition& a, const U256Decomposition& b, bool allow_eq) +{ + bool borrow = allow_eq ? (a.lo < b.lo) : (a.lo <= b.lo); + // No need to add borrow * TWO_POW_128 since uint128_t will wrap in the way we need + uint128_t x_lo = a.lo - b.lo - (allow_eq ? 0 : 1); + uint128_t x_hi = a.hi - b.hi - (borrow ? 1 : 0); + return { x_lo, x_hi, borrow }; +} + +} // namespace + +bool FieldGreaterThan::ff_gt(const FF& a, const FF& b) +{ + static auto p_limbs = decompose(FF::modulus); + + uint256_t a_integer(a); + uint256_t b_integer(b); + + bool result = a_integer > b_integer; + + auto a_limbs = decompose(a_integer); + range_check.assert_range(a_limbs.lo, 128); + range_check.assert_range(a_limbs.hi, 128); + + auto p_sub_a_witness = limb_gt_witness(p_limbs, a_limbs, false); + range_check.assert_range(p_sub_a_witness.lo, 128); + range_check.assert_range(p_sub_a_witness.hi, 128); + + auto b_limbs = decompose(b_integer); + range_check.assert_range(b_limbs.lo, 128); + range_check.assert_range(b_limbs.hi, 128); + + auto p_sub_b_witness = limb_gt_witness(p_limbs, b_limbs, false); + range_check.assert_range(p_sub_b_witness.lo, 128); + range_check.assert_range(p_sub_b_witness.hi, 128); + + auto res_witness = result ? limb_gt_witness(a_limbs, b_limbs, false) : limb_gt_witness(b_limbs, a_limbs, true); + range_check.assert_range(res_witness.lo, 128); + range_check.assert_range(res_witness.hi, 128); + + events.emit({ + .a = a, + .b = b, + .a_limbs = a_limbs, + .p_sub_a_witness = p_sub_a_witness, + .b_limbs = b_limbs, + .p_sub_b_witness = p_sub_b_witness, + .res_witness = res_witness, + .result = result, + }); + return result; +} + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.hpp new file mode 100644 index 000000000000..7403fb3cc785 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/simulation/events/event_emitter.hpp" +#include "barretenberg/vm2/simulation/events/field_gt_event.hpp" +#include "barretenberg/vm2/simulation/range_check.hpp" + +namespace bb::avm2::simulation { + +class FieldGreaterThanInterface { + public: + virtual ~FieldGreaterThanInterface() = default; + virtual bool ff_gt(const FF& a, const FF& b) = 0; +}; + +class FieldGreaterThan : public FieldGreaterThanInterface { + public: + FieldGreaterThan(RangeCheckInterface& range_check, EventEmitterInterface& event_emitter) + : range_check(range_check) + , events(event_emitter) + {} + + bool ff_gt(const FF& a, const FF& b) override; + + private: + RangeCheckInterface& range_check; + EventEmitterInterface& events; +}; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.test.cpp new file mode 100644 index 000000000000..b512a93971ae --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/field_gt.test.cpp @@ -0,0 +1,92 @@ +#include "barretenberg/vm2/simulation/field_gt.hpp" +#include "barretenberg/numeric/uint128/uint128.hpp" +#include "barretenberg/vm2/simulation/testing/mock_range_check.hpp" + +#include +#include + +namespace bb::avm2::simulation { + +using ::testing::_; +using ::testing::ElementsAre; +using ::testing::NiceMock; +using ::testing::SizeIs; + +namespace { + +TEST(AvmSimulationFieldGreaterThanTest, Basic) +{ + NiceMock range_check; + + EventEmitter event_emitter; + FieldGreaterThan field_gt(range_check, event_emitter); + + auto p_limbs = decompose(FF::modulus); + std::vector range_checks; + ON_CALL(range_check, assert_range(_, 128)).WillByDefault([&range_checks](uint128_t x, uint64_t) { + range_checks.push_back(x); + }); + FF a = 1; + FF b = 0; + EXPECT_TRUE(field_gt.ff_gt(a, b)); + + uint128_t a_lo = 1; + uint128_t a_hi = 0; + + uint128_t p_sub_a_witness_lo = p_limbs.lo - a_lo - 1; + uint128_t p_sub_a_witness_hi = p_limbs.hi - a_hi - 0; + + uint128_t b_lo = 0; + uint128_t b_hi = 0; + + uint128_t p_sub_b_witness_lo = p_limbs.lo - b_lo - 1; + uint128_t p_sub_b_witness_hi = p_limbs.hi - b_hi - 0; + + uint128_t res_witness_lo = a_lo - b_lo - 1; + uint128_t res_witness_hi = a_hi - b_hi - 0; + + EXPECT_THAT(range_checks, + ElementsAre(a_lo, + a_hi, + p_sub_a_witness_lo, + p_sub_a_witness_hi, + b_lo, + b_hi, + p_sub_b_witness_lo, + p_sub_b_witness_hi, + res_witness_lo, + res_witness_hi)); + + EXPECT_THAT(event_emitter.dump_events(), + ElementsAre(FieldGreaterThanEvent{ + .a = a, + .b = b, + .a_limbs = U256Decomposition{ a_lo, a_hi }, + .p_sub_a_witness = LimbsComparisonWitness{ p_sub_a_witness_lo, p_sub_a_witness_hi, false }, + .b_limbs = U256Decomposition{ b_lo, b_hi }, + .p_sub_b_witness = LimbsComparisonWitness{ p_sub_b_witness_lo, p_sub_b_witness_hi, false }, + .res_witness = LimbsComparisonWitness{ res_witness_lo, res_witness_hi, false }, + .result = true, + })); +} + +TEST(AvmSimulationFieldGreaterThanTest, Results) +{ + NiceMock range_check; + + EventEmitter event_emitter; + FieldGreaterThan field_gt(range_check, event_emitter); + + EXPECT_TRUE(field_gt.ff_gt(1, 0)); + EXPECT_TRUE(field_gt.ff_gt(-1, 0)); + + EXPECT_FALSE(field_gt.ff_gt(0, 0)); + EXPECT_FALSE(field_gt.ff_gt(-1, -1)); + EXPECT_FALSE(field_gt.ff_gt(0, 1)); + EXPECT_FALSE(field_gt.ff_gt(0, -1)); + + EXPECT_THAT(event_emitter.dump_events(), SizeIs(6)); +} + +} // namespace +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/u256_decomposition.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/u256_decomposition.cpp new file mode 100644 index 000000000000..ff79af85e446 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/u256_decomposition.cpp @@ -0,0 +1,14 @@ +#include "barretenberg/vm2/simulation/lib/u256_decomposition.hpp" + +namespace bb::avm2::simulation { + +const uint256_t TWO_POW_128 = uint256_t(1) << 128; + +U256Decomposition decompose(const uint256_t& x) +{ + uint128_t lo = static_cast(x % TWO_POW_128); + uint128_t hi = static_cast(x >> 128); + return { lo, hi }; +} + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/u256_decomposition.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/u256_decomposition.hpp new file mode 100644 index 000000000000..7f3f80ea80c9 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/u256_decomposition.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "barretenberg/numeric/uint128/uint128.hpp" +#include "barretenberg/numeric/uint256/uint256.hpp" + +namespace bb::avm2::simulation { + +struct U256Decomposition { + uint128_t lo; + uint128_t hi; + + bool operator==(const U256Decomposition& other) const = default; +}; + +U256Decomposition decompose(const uint256_t& x); + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp index 448d90ad1f01..d50f5e9516e7 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp @@ -1,12 +1,11 @@ #pragma once -#include +#include "barretenberg/vm2/simulation/range_check.hpp" #include +#include #include -#include "barretenberg/vm2/simulation/range_check.hpp" - namespace bb::avm2::simulation { class MockRangeCheck : public RangeCheckInterface { @@ -18,4 +17,4 @@ class MockRangeCheck : public RangeCheckInterface { MOCK_METHOD(void, assert_range, (uint128_t value, uint8_t num_bits), (override)); }; -} // namespace bb::avm2::simulation \ No newline at end of file +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp index a34a2c05e2d0..2697c69bd822 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp @@ -6,4 +6,4 @@ namespace bb::avm2::simulation { MockRangeCheck::MockRangeCheck() = default; MockRangeCheck::~MockRangeCheck() = default; -} // namespace bb::avm2::simulation \ No newline at end of file +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp index 5505288f60f8..c57566861dc1 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp @@ -19,6 +19,7 @@ #include "barretenberg/vm2/simulation/events/ecc_events.hpp" #include "barretenberg/vm2/simulation/events/event_emitter.hpp" #include "barretenberg/vm2/simulation/events/execution_event.hpp" +#include "barretenberg/vm2/simulation/events/field_gt_event.hpp" #include "barretenberg/vm2/simulation/events/memory_event.hpp" #include "barretenberg/vm2/simulation/events/merkle_check_event.hpp" #include "barretenberg/vm2/simulation/events/range_check_event.hpp" @@ -27,6 +28,7 @@ #include "barretenberg/vm2/simulation/events/to_radix_event.hpp" #include "barretenberg/vm2/simulation/execution.hpp" #include "barretenberg/vm2/simulation/execution_components.hpp" +#include "barretenberg/vm2/simulation/field_gt.hpp" #include "barretenberg/vm2/simulation/lib/instruction_info.hpp" #include "barretenberg/vm2/simulation/lib/raw_data_dbs.hpp" #include "barretenberg/vm2/simulation/merkle_check.hpp" @@ -76,6 +78,7 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting typename S::template DefaultEventEmitter poseidon2_hash_emitter; typename S::template DefaultEventEmitter poseidon2_perm_emitter; typename S::template DefaultEventEmitter to_radix_emitter; + typename S::template DefaultEventEmitter field_gt_emitter; typename S::template DefaultEventEmitter merkle_check_emitter; typename S::template DefaultDeduplicatingEventEmitter range_check_emitter; @@ -109,6 +112,7 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting Execution execution(alu, execution_components, instruction_info_db, execution_emitter); TxExecution tx_execution(execution); Sha256 sha256(sha256_compression_emitter); + FieldGreaterThan field_gt(range_check, field_gt_emitter); tx_execution.simulate({ .enqueued_calls = inputs.hints.enqueuedCalls }); @@ -129,6 +133,7 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting poseidon2_hash_emitter.dump_events(), poseidon2_perm_emitter.dump_events(), to_radix_emitter.dump_events(), + field_gt_emitter.dump_events(), merkle_check_emitter.dump_events(), range_check_emitter.dump_events() }; } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/field_gt_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/field_gt_trace.cpp new file mode 100644 index 000000000000..a50755b60675 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/field_gt_trace.cpp @@ -0,0 +1,79 @@ +#include "barretenberg/vm2/tracegen/field_gt_trace.hpp" +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/simulation/lib/u256_decomposition.hpp" + +namespace bb::avm2::tracegen { + +using simulation::LimbsComparisonWitness; +using simulation::U256Decomposition; + +void FieldGreaterThanTraceBuilder::process( + const simulation::EventEmitterInterface::Container& events, + TraceContainer& trace) +{ + using C = Column; + + uint32_t row = 1; + for (const auto& event : events) { + // Copy the things that will need range checks since we'll mutate them in the shifts + U256Decomposition a_limbs = event.a_limbs; + LimbsComparisonWitness p_sub_a_witness = event.p_sub_a_witness; + U256Decomposition b_limbs = event.b_limbs; + LimbsComparisonWitness p_sub_b_witness = event.p_sub_b_witness; + LimbsComparisonWitness res_witness = event.res_witness; + + bool sel_gt = true; + int8_t cmp_rng_ctr = 4; + + auto write_row = [&]() { + FF cmp_rng_ctr_inv = cmp_rng_ctr > 0 ? FF(cmp_rng_ctr).invert() : FF::zero(); + trace.set(row, + { { { C::ff_gt_sel, 1 }, + { C::ff_gt_a, event.a }, + { C::ff_gt_b, event.b }, + { C::ff_gt_result, event.result }, + { C::ff_gt_sel_gt, sel_gt }, + { C::ff_gt_constant_128, 128 }, + // No conversion available from uint128_t to FF. Yikes. + { C::ff_gt_a_lo, uint256_t::from_uint128(a_limbs.lo) }, + { C::ff_gt_a_hi, uint256_t::from_uint128(a_limbs.hi) }, + { C::ff_gt_p_a_borrow, p_sub_a_witness.borrow }, + { C::ff_gt_p_sub_a_lo, uint256_t::from_uint128(p_sub_a_witness.lo) }, + { C::ff_gt_p_sub_a_hi, uint256_t::from_uint128(p_sub_a_witness.hi) }, + { C::ff_gt_b_lo, uint256_t::from_uint128(b_limbs.lo) }, + { C::ff_gt_b_hi, uint256_t::from_uint128(b_limbs.hi) }, + { C::ff_gt_p_b_borrow, p_sub_b_witness.borrow }, + { C::ff_gt_p_sub_b_lo, uint256_t::from_uint128(p_sub_b_witness.lo) }, + { C::ff_gt_p_sub_b_hi, uint256_t::from_uint128(p_sub_b_witness.hi) }, + { C::ff_gt_borrow, res_witness.borrow }, + { C::ff_gt_res_lo, uint256_t::from_uint128(res_witness.lo) }, + { C::ff_gt_res_hi, uint256_t::from_uint128(res_witness.hi) }, + { C::ff_gt_cmp_rng_ctr, cmp_rng_ctr }, + { C::ff_gt_sel_shift_rng, cmp_rng_ctr > 0 }, + { C::ff_gt_cmp_rng_ctr_inv, cmp_rng_ctr_inv } } }); + }; + + while (cmp_rng_ctr >= 0) { + write_row(); + row++; + + sel_gt = false; + + // shift the limbs to be range checked + a_limbs.lo = p_sub_a_witness.lo; + a_limbs.hi = p_sub_a_witness.hi; + p_sub_a_witness.lo = b_limbs.lo; + p_sub_a_witness.hi = b_limbs.hi; + b_limbs.lo = p_sub_b_witness.lo; + b_limbs.hi = p_sub_b_witness.hi; + p_sub_b_witness.lo = res_witness.lo; + p_sub_b_witness.hi = res_witness.hi; + res_witness.lo = 0; + res_witness.hi = 0; + + cmp_rng_ctr--; + } + } +} + +} // namespace bb::avm2::tracegen diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/field_gt_trace.hpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/field_gt_trace.hpp new file mode 100644 index 000000000000..be8b16ea5d05 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/field_gt_trace.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "barretenberg/vm2/generated/columns.hpp" +#include "barretenberg/vm2/simulation/events/event_emitter.hpp" +#include "barretenberg/vm2/simulation/events/field_gt_event.hpp" +#include "barretenberg/vm2/tracegen/trace_container.hpp" + +namespace bb::avm2::tracegen { + +class FieldGreaterThanTraceBuilder final { + public: + void process(const simulation::EventEmitterInterface::Container& events, + TraceContainer& trace); +}; + +} // namespace bb::avm2::tracegen diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index 466aa2b7281d..75eb6fac280e 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -32,6 +32,7 @@ #include "barretenberg/vm2/tracegen/class_id_derivation_trace.hpp" #include "barretenberg/vm2/tracegen/ecc_trace.hpp" #include "barretenberg/vm2/tracegen/execution_trace.hpp" +#include "barretenberg/vm2/tracegen/field_gt_trace.hpp" #include "barretenberg/vm2/tracegen/lib/interaction_builder.hpp" #include "barretenberg/vm2/tracegen/lib/lookup_builder.hpp" #include "barretenberg/vm2/tracegen/lib/lookup_into_bitwise.hpp" @@ -250,6 +251,11 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) AVM_TRACK_TIME("tracegen/to_radix", to_radix_builder.process(events.to_radix, trace)); clear_events(events.to_radix); }, + [&]() { + FieldGreaterThanTraceBuilder field_gt_builder; + AVM_TRACK_TIME("tracegen/field_gt", field_gt_builder.process(events.field_gt, trace)); + clear_events(events.field_gt); + }, [&]() { MerkleCheckTraceBuilder merkle_check_builder; AVM_TRACK_TIME("tracegen/merkle_check", merkle_check_builder.process(events.merkle_check, trace)); @@ -343,6 +349,9 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) std::make_unique< LookupIntoDynamicTableSequential>(), std::make_unique>(), + // Field GT + std::make_unique>(), + std::make_unique>(), // Merkle checks std::make_unique>());