diff --git a/barretenberg/cpp/pil/avm/constants_gen.pil b/barretenberg/cpp/pil/avm/constants_gen.pil index fea63fbf6bcb..19ff8aed8913 100644 --- a/barretenberg/cpp/pil/avm/constants_gen.pil +++ b/barretenberg/cpp/pil/avm/constants_gen.pil @@ -11,6 +11,7 @@ namespace constants; pol MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL = 16; pol MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL = 16; pol MAX_PUBLIC_LOGS_PER_CALL = 4; + pol PUBLIC_DATA_TREE_HEIGHT = 40; pol MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000; pol MEM_TAG_FF = 0; pol MEM_TAG_U1 = 1; diff --git a/barretenberg/cpp/pil/vm2/constants_gen.pil b/barretenberg/cpp/pil/vm2/constants_gen.pil index fea63fbf6bcb..19ff8aed8913 100644 --- a/barretenberg/cpp/pil/vm2/constants_gen.pil +++ b/barretenberg/cpp/pil/vm2/constants_gen.pil @@ -11,6 +11,7 @@ namespace constants; pol MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL = 16; pol MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL = 16; pol MAX_PUBLIC_LOGS_PER_CALL = 4; + pol PUBLIC_DATA_TREE_HEIGHT = 40; pol MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000; pol MEM_TAG_FF = 0; pol MEM_TAG_U1 = 1; diff --git a/barretenberg/cpp/pil/vm2/execution.pil b/barretenberg/cpp/pil/vm2/execution.pil index 760d23ec8072..91ab0cb01555 100644 --- a/barretenberg/cpp/pil/vm2/execution.pil +++ b/barretenberg/cpp/pil/vm2/execution.pil @@ -19,6 +19,7 @@ include "to_radix.pil"; include "ff_gt.pil"; include "context.pil"; include "context_stack.pil"; +include "public_data_read.pil"; namespace execution; diff --git a/barretenberg/cpp/pil/vm2/public_data_read.pil b/barretenberg/cpp/pil/vm2/public_data_read.pil new file mode 100644 index 000000000000..a8ced4964fc1 --- /dev/null +++ b/barretenberg/cpp/pil/vm2/public_data_read.pil @@ -0,0 +1,100 @@ +include "merkle_check.pil"; +include "ff_gt.pil"; +include "poseidon2_hash.pil"; +include "constants_gen.pil"; +include "precomputed.pil"; + +// This gadget checks reads in the public data tree. The public data tree is an indexed tree where leaves +// have slot and value. Slot is the "key" and value is the stored data. When we read from the public data tree, +// we assume that a slot that has not been written before has value zero. +// For this we perform a low leaf membership proof and: +// - if the low leaf slot is equal to the slot, that means that slot has been written before, and we assert that +// the low leaf value is equal to the value we are reading. +// - if the low leaf slot is not equal to the slot, we assert that the low leaf is indeed a valid low leaf for the +// requested slot, proving non existence of the slot in the tree. In that case we check value to be zero. +// In order to validate that a leaf is a low leaf of the slot, we need to check that the low_leaf.slot is < slot +// and that low_leaf.next_slot is > slot. However, we need to consider the case where next_slot is zero, which +// means "infinity". The highest slot inserted in the tree will point to infinity as the "next_slot". +// +// Usage: +// sel { value, leaf_slot, public_data_tree_root } +// in public_data_read.sel { public_data_read.value, public_data_read.slot, public_data_read.root }; +// +namespace public_data_read; + pol commit sel; + sel * (1 - sel) = 0; + + #[skippable_if] + sel = 0; + + // Inputs to the gadget + pol commit value; + pol commit slot; + pol commit root; + + // Hints + pol commit low_leaf_slot; + pol commit low_leaf_value; + pol commit low_leaf_next_index; + pol commit low_leaf_next_slot; + + pol commit low_leaf_index; + + // ========= LOW LEAF MEMBERSHIP ========= + pol commit low_leaf_hash; + // TODO: We need this temporarily while we do not allow for aliases in the lookup tuple + pol commit tree_height; + sel * (tree_height - constants.PUBLIC_DATA_TREE_HEIGHT) = 0; + + #[LOW_LEAF_POSEIDON2_0] + sel { low_leaf_slot, low_leaf_value, low_leaf_next_index, low_leaf_hash } + in poseidon2_hash.start { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output }; + + #[LOW_LEAF_POSEIDON2_1] + sel { low_leaf_next_slot, precomputed.zero, precomputed.zero, low_leaf_hash } + in poseidon2_hash.end { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output }; + + #[LOW_LEAF_MEMBERSHIP] + sel { low_leaf_hash, low_leaf_index, tree_height, root } + in merkle_check.start { merkle_check.read_node, merkle_check.index, merkle_check.path_len, merkle_check.read_root }; + + // ========= LOW LEAF VALIDATION ========= + // We commit leaf not exists instead of leaf exists since it'll be used as a selector for a lookup + pol commit leaf_not_exists; + leaf_not_exists * (1 - leaf_not_exists) = 0; + pol LEAF_EXISTS = 1 - leaf_not_exists; + + pol commit slot_low_leaf_slot_diff_inv; + pol SLOT_LOW_LEAF_SLOT_DIFF = slot - low_leaf_slot; + + // SLOT_LOW_LEAF_SLOT_DIFF == 0 <==> LEAF_EXISTS == 1 + #[EXISTS_FLAG_CHECK] + sel * (SLOT_LOW_LEAF_SLOT_DIFF * (LEAF_EXISTS * (1 - slot_low_leaf_slot_diff_inv) + slot_low_leaf_slot_diff_inv) - 1 + LEAF_EXISTS) = 0; + + // value = LEAF_EXISTS ? low_leaf_value : 0 + #[VALUE_IS_CORRECT] + low_leaf_value * LEAF_EXISTS - value = 0; + + // If the leaf doesn't exist, we need to validate that the slot is greater than the low leaf slot + + // TODO: We need this temporarily while we do not allow for aliases in the lookup tuple + pol commit one; + sel * (1 - one) = 0; + + #[LOW_LEAF_SLOT_VALIDATION] + leaf_not_exists { slot, low_leaf_slot, one } + in ff_gt.sel_gt { ff_gt.a, ff_gt.b, ff_gt.result }; + + // If next slot is not zero (which would be infinity), it has to be greater than the slot. + // We commit next_slot_is_nonzero instead of next_slot_is_zero since it'll be used as a selector for a lookup + pol commit next_slot_is_nonzero; + next_slot_is_nonzero * (1 - next_slot_is_nonzero) = 0; + pol NEXT_SLOT_IS_ZERO = 1 - next_slot_is_nonzero; + + pol commit next_slot_inv; + #[NEXT_SLOT_IS_ZERO_CHECK] + leaf_not_exists * (low_leaf_next_slot * (NEXT_SLOT_IS_ZERO * (1 - next_slot_inv) + next_slot_inv) - 1 + NEXT_SLOT_IS_ZERO) = 0; + + #[LOW_LEAF_NEXT_SLOT_VALIDATION] + next_slot_is_nonzero { low_leaf_next_slot, slot, one } + in ff_gt.sel_gt { ff_gt.a, ff_gt.b, ff_gt.result }; diff --git a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp index 02d58b4bd13d..906192185de1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp @@ -12,6 +12,7 @@ #define MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL 16 #define MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL 16 #define MAX_PUBLIC_LOGS_PER_CALL 4 +#define PUBLIC_DATA_TREE_HEIGHT 40 #define MAX_NOTE_HASHES_PER_TX 64 #define MAX_NULLIFIERS_PER_TX 64 #define MAX_ENQUEUED_CALLS_PER_TX 32 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 index 28c735c57a9f..74ea911952ac 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/field_gt.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/field_gt.test.cpp @@ -70,9 +70,9 @@ std::vector comparison_tests = { TestParams{ 0, -1, false } }; -class BasicTest : public TestWithParam {}; +class FieldGreaterThanBasicTest : public TestWithParam {}; -TEST_P(BasicTest, BasicComparison) +TEST_P(FieldGreaterThanBasicTest, BasicComparison) { const auto& param = GetParam(); @@ -92,11 +92,13 @@ TEST_P(BasicTest, BasicComparison) check_relation(trace); } -INSTANTIATE_TEST_SUITE_P(FieldGreaterThanConstrainingTest, BasicTest, ::testing::ValuesIn(comparison_tests)); +INSTANTIATE_TEST_SUITE_P(FieldGreaterThanConstrainingTest, + FieldGreaterThanBasicTest, + ::testing::ValuesIn(comparison_tests)); -class InteractionsTests : public TestWithParam {}; +class FieldGreaterThanInteractionsTests : public TestWithParam {}; -TEST_P(InteractionsTests, InteractionsWithRangeCheck) +TEST_P(FieldGreaterThanInteractionsTests, InteractionsWithRangeCheck) { const auto& param = GetParam(); @@ -123,7 +125,9 @@ TEST_P(InteractionsTests, InteractionsWithRangeCheck) check_relation(trace); } -INSTANTIATE_TEST_SUITE_P(FieldGreaterThanConstrainingTest, InteractionsTests, ::testing::ValuesIn(comparison_tests)); +INSTANTIATE_TEST_SUITE_P(FieldGreaterThanConstrainingTest, + FieldGreaterThanInteractionsTests, + ::testing::ValuesIn(comparison_tests)); TEST(FieldGreaterThanConstrainingTest, NegativeManipulatedDecompositions) { diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/public_data_tree_read.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/public_data_tree_read.test.cpp new file mode 100644 index 000000000000..5dae6842c98e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/public_data_tree_read.test.cpp @@ -0,0 +1,236 @@ +#include +#include + +#include +#include + +#include "barretenberg/crypto/poseidon2/poseidon2.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" +#include "barretenberg/vm2/constraining/testing/check_relation.hpp" +#include "barretenberg/vm2/generated/relations/merkle_check.hpp" +#include "barretenberg/vm2/generated/relations/public_data_read.hpp" +#include "barretenberg/vm2/simulation/events/event_emitter.hpp" +#include "barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp" +#include "barretenberg/vm2/simulation/field_gt.hpp" +#include "barretenberg/vm2/simulation/lib/merkle.hpp" +#include "barretenberg/vm2/simulation/poseidon2.hpp" +#include "barretenberg/vm2/simulation/public_data_tree_check.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/merkle_check_trace.hpp" +#include "barretenberg/vm2/tracegen/poseidon2_trace.hpp" +#include "barretenberg/vm2/tracegen/public_data_tree_read_trace.hpp" +#include "barretenberg/vm2/tracegen/test_trace_container.hpp" + +namespace bb::avm2::constraining { +namespace { + +using ::testing::NiceMock; +using ::testing::TestWithParam; + +using simulation::EventEmitter; +using simulation::FieldGreaterThan; +using simulation::FieldGreaterThanEvent; +using simulation::MerkleCheck; +using simulation::MerkleCheckEvent; +using simulation::MockRangeCheck; +using simulation::NoopEventEmitter; +using simulation::Poseidon2; +using simulation::Poseidon2HashEvent; +using simulation::Poseidon2PermutationEvent; +using simulation::PublicDataTreeCheck; +using simulation::PublicDataTreeLeafPreimage; +using simulation::PublicDataTreeReadEvent; +using simulation::root_from_path; + +using tracegen::FieldGreaterThanTraceBuilder; +using tracegen::MerkleCheckTraceBuilder; +using tracegen::Poseidon2TraceBuilder; +using tracegen::PublicDataTreeReadTraceBuilder; +using tracegen::TestTraceContainer; + +using FF = AvmFlavorSettings::FF; +using C = Column; +using public_data_read = bb::avm2::public_data_read; +using poseidon2 = crypto::Poseidon2; +using PublicDataLeafValue = crypto::merkle_tree::PublicDataLeafValue; + +TEST(PublicDataTreeReadConstrainingTest, EmptyRow) +{ + check_relation(testing::empty_trace()); +} + +struct TestParams { + FF leaf_slot; + FF value; + PublicDataTreeLeafPreimage low_leaf; +}; + +std::vector positive_tests = { + // Exists = true, leaf pointers to infinity + TestParams{ + .leaf_slot = 42, .value = 27, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(42, 27), 0, 0) }, + // Exists = true, leaf points to higher value + TestParams{ + .leaf_slot = 42, .value = 27, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(42, 27), 28, 50) }, + // Exists = false, low leaf points to infinity + TestParams{ .leaf_slot = 42, .value = 0, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(10, 0), 0, 0) }, + // Exists = false, low leaf points to higher value + TestParams{ + .leaf_slot = 42, .value = 0, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(10, 0), 28, 50) } +}; + +class PublicDataReadPositiveTests : public TestWithParam {}; + +TEST_P(PublicDataReadPositiveTests, Positive) +{ + const auto& param = GetParam(); + + EventEmitter hash_event_emitter; + NoopEventEmitter perm_event_emitter; + Poseidon2 poseidon2(hash_event_emitter, perm_event_emitter); + + EventEmitter merkle_event_emitter; + MerkleCheck merkle_check(poseidon2, merkle_event_emitter); + + NiceMock range_check; + + EventEmitter field_gt_event_emitter; + FieldGreaterThan field_gt(range_check, field_gt_event_emitter); + + EventEmitter public_data_tree_read_event_emitter; + PublicDataTreeCheck public_data_tree_check_simulator( + poseidon2, merkle_check, field_gt, public_data_tree_read_event_emitter); + + TestTraceContainer trace({ { { C::precomputed_first_row, 1 } } }); + Poseidon2TraceBuilder poseidon2_builder; + MerkleCheckTraceBuilder merkle_check_builder; + FieldGreaterThanTraceBuilder field_gt_builder; + PublicDataTreeReadTraceBuilder public_data_tree_read_builder; + + FF low_leaf_hash = poseidon2.hash(param.low_leaf.get_hash_inputs()); + uint64_t leaf_index = 30; + std::vector sibling_path; + sibling_path.reserve(PUBLIC_DATA_TREE_HEIGHT); + for (size_t i = 0; i < PUBLIC_DATA_TREE_HEIGHT; ++i) { + sibling_path.emplace_back(i); + } + FF root = root_from_path(low_leaf_hash, leaf_index, sibling_path); + + public_data_tree_check_simulator.assert_read( + param.leaf_slot, param.value, param.low_leaf, leaf_index, sibling_path, root); + + poseidon2_builder.process_hash(hash_event_emitter.dump_events(), trace); + merkle_check_builder.process(merkle_event_emitter.dump_events(), trace); + field_gt_builder.process(field_gt_event_emitter.dump_events(), trace); + public_data_tree_read_builder.process(public_data_tree_read_event_emitter.dump_events(), trace); + + check_relation(trace); +} + +INSTANTIATE_TEST_SUITE_P(PublicDataTreeReadConstrainingTest, + PublicDataReadPositiveTests, + ::testing::ValuesIn(positive_tests)); + +TEST(PublicDataTreeReadConstrainingTest, NegativeExistsFlagCheck) +{ + // Test constraint: sel * (SLOT_LOW_LEAF_SLOT_DIFF * (LEAF_EXISTS * (1 - slot_low_leaf_slot_diff_inv) + + // slot_low_leaf_slot_diff_inv) - 1 + LEAF_EXISTS) = 0 + TestTraceContainer trace({ + { { C::public_data_read_sel, 1 }, + { C::public_data_read_slot, 27 }, + { C::public_data_read_low_leaf_slot, 27 }, + { C::public_data_read_slot_low_leaf_slot_diff_inv, 0 }, + { C::public_data_read_leaf_not_exists, 0 } }, + { { C::public_data_read_sel, 1 }, + { C::public_data_read_slot, 28 }, + { C::public_data_read_low_leaf_slot, 27 }, + { C::public_data_read_slot_low_leaf_slot_diff_inv, FF(1).invert() }, + { C::public_data_read_leaf_not_exists, 1 } }, + }); + + check_relation(trace, public_data_read::SR_EXISTS_FLAG_CHECK); + + trace.set(C::public_data_read_leaf_not_exists, 0, 1); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, public_data_read::SR_EXISTS_FLAG_CHECK), + "EXISTS_FLAG_CHECK"); + + trace.set(C::public_data_read_leaf_not_exists, 0, 0); + trace.set(C::public_data_read_leaf_not_exists, 1, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, public_data_read::SR_EXISTS_FLAG_CHECK), + "EXISTS_FLAG_CHECK"); +} + +TEST(PublicDataTreeReadConstrainingTest, NegativeNextSlotIsZero) +{ + // Test constraint: leaf_not_exists * (low_leaf_next_slot * (NEXT_SLOT_IS_ZERO * (1 - next_slot_inv) + + // next_slot_inv) - 1 + NEXT_SLOT_IS_ZERO) = 0 + TestTraceContainer trace({ + { + { C::public_data_read_leaf_not_exists, 1 }, + { C::public_data_read_low_leaf_next_slot, 0 }, + { C::public_data_read_next_slot_inv, 0 }, + { C::public_data_read_next_slot_is_nonzero, 0 }, + }, + { + { C::public_data_read_leaf_not_exists, 1 }, + { C::public_data_read_low_leaf_next_slot, 1 }, + { C::public_data_read_next_slot_inv, FF(1).invert() }, + { C::public_data_read_next_slot_is_nonzero, 1 }, + }, + }); + + check_relation(trace, public_data_read::SR_NEXT_SLOT_IS_ZERO_CHECK); + + trace.set(C::public_data_read_next_slot_is_nonzero, 0, 1); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, public_data_read::SR_NEXT_SLOT_IS_ZERO_CHECK), + "NEXT_SLOT_IS_ZERO_CHECK"); + + trace.set(C::public_data_read_next_slot_is_nonzero, 0, 0); + trace.set(C::public_data_read_next_slot_is_nonzero, 1, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, public_data_read::SR_NEXT_SLOT_IS_ZERO_CHECK), + "NEXT_SLOT_IS_ZERO_CHECK"); +} + +TEST(PublicDataTreeReadConstrainingTest, NegativeValueIsCorrect) +{ + // Test constraint: leaf_not_exists * (low_leaf_next_slot * (NEXT_SLOT_IS_ZERO * (1 - next_slot_inv) + + // next_slot_inv) - 1 + NEXT_SLOT_IS_ZERO) = 0 + TestTraceContainer trace({ + { + { C::public_data_read_low_leaf_value, 27 }, + { C::public_data_read_leaf_not_exists, 0 }, + { C::public_data_read_value, 27 }, + }, + { + { C::public_data_read_low_leaf_value, 27 }, + { C::public_data_read_leaf_not_exists, 1 }, + { C::public_data_read_value, 0 }, + }, + }); + + check_relation(trace, public_data_read::SR_VALUE_IS_CORRECT); + + // Invalid, if leaf exists, the value should be the low leaf value + trace.set(C::public_data_read_value, 0, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, public_data_read::SR_VALUE_IS_CORRECT), + "VALUE_IS_CORRECT"); + + trace.set(C::public_data_read_value, 0, 27); + // Invalid, if leaf does not exists, the value should be zero + trace.set(C::public_data_read_value, 1, 27); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, public_data_read::SR_VALUE_IS_CORRECT), + "VALUE_IS_CORRECT"); +} + +} // 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 acf4b9096986..1d0d78b5629f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,8 +10,8 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES 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_has_tag, precomputed_sel_integral_tag, precomputed_sel_mem_tag_out_of_range, 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_tag_is_op2, precomputed_sel_to_radix_safe_limbs, 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_ia, alu_ib, 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_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_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, context_stack_context_id, context_stack_contract_address, context_stack_is_static, context_stack_msg_sender, context_stack_parent_calldata_offset_addr, context_stack_parent_calldata_size_addr, context_stack_pc, 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_context_id, execution_contract_address, execution_ex_opcode, execution_indirect, execution_is_static, execution_last, execution_last_child_returndata_offset_addr, execution_last_child_returndata_size_addr, execution_last_child_success, execution_msg_sender, 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_parent_calldata_offset_addr, execution_parent_calldata_size_addr, 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_has_tag, 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_pc_in_range, instr_fetching_sel_tag_is_op2, instr_fetching_tag_out_of_range, instr_fetching_tag_value, merkle_check_constant_2, merkle_check_end, merkle_check_index, merkle_check_index_is_even, merkle_check_path_len, merkle_check_read_left_node, merkle_check_read_node, merkle_check_read_output_hash, merkle_check_read_right_node, merkle_check_read_root, merkle_check_remaining_path_len_inv, merkle_check_sel, merkle_check_sibling, merkle_check_start, merkle_check_write, merkle_check_write_left_node, merkle_check_write_node, merkle_check_write_output_hash, merkle_check_write_right_node, merkle_check_write_root, 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_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_pc_abs_diff_positive_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_tag_value_validation_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_read_counts, lookup_merkle_check_merkle_poseidon2_write_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_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_pc_abs_diff_positive_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_tag_value_validation_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_read_inv, lookup_merkle_check_merkle_poseidon2_write_inv, lookup_sha256_round_constant_inv, lookup_ff_gt_a_lo_range_inv, lookup_ff_gt_a_hi_range_inv +#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_ia, alu_ib, 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_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_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, context_stack_context_id, context_stack_contract_address, context_stack_is_static, context_stack_msg_sender, context_stack_parent_calldata_offset_addr, context_stack_parent_calldata_size_addr, context_stack_pc, 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_context_id, execution_contract_address, execution_ex_opcode, execution_indirect, execution_is_static, execution_last, execution_last_child_returndata_offset_addr, execution_last_child_returndata_size_addr, execution_last_child_success, execution_msg_sender, 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_parent_calldata_offset_addr, execution_parent_calldata_size_addr, 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_has_tag, 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_pc_in_range, instr_fetching_sel_tag_is_op2, instr_fetching_tag_out_of_range, instr_fetching_tag_value, merkle_check_constant_2, merkle_check_end, merkle_check_index, merkle_check_index_is_even, merkle_check_path_len, merkle_check_read_left_node, merkle_check_read_node, merkle_check_read_output_hash, merkle_check_read_right_node, merkle_check_read_root, merkle_check_remaining_path_len_inv, merkle_check_sel, merkle_check_sibling, merkle_check_start, merkle_check_write, merkle_check_write_left_node, merkle_check_write_node, merkle_check_write_output_hash, merkle_check_write_right_node, merkle_check_write_root, 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, public_data_read_leaf_not_exists, public_data_read_low_leaf_hash, public_data_read_low_leaf_index, public_data_read_low_leaf_next_index, public_data_read_low_leaf_next_slot, public_data_read_low_leaf_slot, public_data_read_low_leaf_value, public_data_read_next_slot_inv, public_data_read_next_slot_is_nonzero, public_data_read_one, public_data_read_root, public_data_read_sel, public_data_read_slot, public_data_read_slot_low_leaf_slot_diff_inv, public_data_read_tree_height, public_data_read_value, 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_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_pc_abs_diff_positive_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_tag_value_validation_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_read_counts, lookup_merkle_check_merkle_poseidon2_write_counts, lookup_sha256_round_constant_counts, lookup_ff_gt_a_lo_range_counts, lookup_ff_gt_a_hi_range_counts, lookup_public_data_read_low_leaf_poseidon2_0_counts, lookup_public_data_read_low_leaf_poseidon2_1_counts, lookup_public_data_read_low_leaf_membership_counts, lookup_public_data_read_low_leaf_slot_validation_counts, lookup_public_data_read_low_leaf_next_slot_validation_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_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_pc_abs_diff_positive_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_tag_value_validation_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_read_inv, lookup_merkle_check_merkle_poseidon2_write_inv, lookup_sha256_round_constant_inv, lookup_ff_gt_a_lo_range_inv, lookup_ff_gt_a_hi_range_inv, lookup_public_data_read_low_leaf_poseidon2_0_inv, lookup_public_data_read_low_leaf_poseidon2_1_inv, lookup_public_data_read_low_leaf_membership_inv, lookup_public_data_read_low_leaf_slot_validation_inv, lookup_public_data_read_low_leaf_next_slot_validation_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_index_shift, merkle_check_path_len_shift, merkle_check_read_node_shift, merkle_check_read_root_shift, merkle_check_sel_shift, merkle_check_start_shift, merkle_check_write_shift, merkle_check_write_node_shift, merkle_check_write_root_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_index, e.merkle_check_path_len, e.merkle_check_read_node, e.merkle_check_read_root, e.merkle_check_sel, e.merkle_check_start, e.merkle_check_write, e.merkle_check_write_node, e.merkle_check_write_root, 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 @@ -31,8 +31,8 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1080; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 945; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1106; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 971; 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_variables.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp index 21788fe14183..47915746fee1 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp @@ -20,6 +20,7 @@ #include "relations/merkle_check.hpp" #include "relations/poseidon2_hash.hpp" #include "relations/poseidon2_perm.hpp" +#include "relations/public_data_read.hpp" #include "relations/range_check.hpp" #include "relations/scalar_mul.hpp" #include "relations/sha256.hpp" @@ -36,6 +37,7 @@ #include "relations/lookups_instr_fetching.hpp" #include "relations/lookups_merkle_check.hpp" #include "relations/lookups_poseidon2_hash.hpp" +#include "relations/lookups_public_data_read.hpp" #include "relations/lookups_range_check.hpp" #include "relations/lookups_scalar_mul.hpp" #include "relations/lookups_sha256.hpp" @@ -45,10 +47,10 @@ namespace bb::avm2 { struct AvmFlavorVariables { static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 45; - static constexpr size_t NUM_WITNESS_ENTITIES = 900; + static constexpr size_t NUM_WITNESS_ENTITIES = 926; static constexpr size_t NUM_SHIFTED_ENTITIES = 135; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; - static constexpr size_t NUM_ALL_ENTITIES = 1080; + static constexpr size_t NUM_ALL_ENTITIES = 1106; // Need to be templated for recursive verifier template @@ -70,6 +72,7 @@ struct AvmFlavorVariables { avm2::merkle_check, avm2::poseidon2_hash, avm2::poseidon2_perm, + avm2::public_data_read, avm2::range_check, avm2::scalar_mul, avm2::sha256, @@ -112,6 +115,11 @@ struct AvmFlavorVariables { lookup_merkle_check_merkle_poseidon2_read_relation, lookup_merkle_check_merkle_poseidon2_write_relation, lookup_poseidon2_hash_poseidon2_perm_relation, + lookup_public_data_read_low_leaf_membership_relation, + lookup_public_data_read_low_leaf_next_slot_validation_relation, + lookup_public_data_read_low_leaf_poseidon2_0_relation, + lookup_public_data_read_low_leaf_poseidon2_1_relation, + lookup_public_data_read_low_leaf_slot_validation_relation, lookup_range_check_dyn_diff_is_u16_relation, lookup_range_check_dyn_rng_chk_pow_2_relation, lookup_range_check_r0_is_u16_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_public_data_read.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_public_data_read.hpp new file mode 100644 index 000000000000..9d2358c4cc77 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_public_data_read.hpp @@ -0,0 +1,501 @@ +// AUTOGENERATED FILE +#pragma once + +#include "../columns.hpp" +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include +#include + +namespace bb::avm2 { + +/////////////////// lookup_public_data_read_low_leaf_poseidon2_0 /////////////////// + +class lookup_public_data_read_low_leaf_poseidon2_0_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_PUBLIC_DATA_READ_LOW_LEAF_POSEIDON2_0"; + static constexpr std::string_view RELATION_NAME = "public_data_read"; + + 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 = 4; + 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::public_data_read_sel; + static constexpr Column DST_SELECTOR = Column::poseidon2_hash_start; + static constexpr Column COUNTS = Column::lookup_public_data_read_low_leaf_poseidon2_0_counts; + static constexpr Column INVERSES = Column::lookup_public_data_read_low_leaf_poseidon2_0_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::public_data_read_low_leaf_slot, + ColumnAndShifts::public_data_read_low_leaf_value, + ColumnAndShifts::public_data_read_low_leaf_next_index, + ColumnAndShifts::public_data_read_low_leaf_hash + }; + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::poseidon2_hash_input_0, + ColumnAndShifts::poseidon2_hash_input_1, + ColumnAndShifts::poseidon2_hash_input_2, + ColumnAndShifts::poseidon2_hash_output + }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._public_data_read_sel() == 1 || in._poseidon2_hash_start() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._public_data_read_sel()); + const auto is_table_entry = View(in._poseidon2_hash_start()); + 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_public_data_read_low_leaf_poseidon2_0_inv(), + in._lookup_public_data_read_low_leaf_poseidon2_0_counts(), + in._public_data_read_sel(), + in._poseidon2_hash_start(), + in._public_data_read_low_leaf_slot(), + in._public_data_read_low_leaf_value(), + in._public_data_read_low_leaf_next_index(), + in._public_data_read_low_leaf_hash(), + in._poseidon2_hash_input_0(), + in._poseidon2_hash_input_1(), + in._poseidon2_hash_input_2(), + in._poseidon2_hash_output()); + } +}; + +template +class lookup_public_data_read_low_leaf_poseidon2_0_relation + : public GenericLookupRelation { + public: + using Settings = lookup_public_data_read_low_leaf_poseidon2_0_settings; + static constexpr std::string_view NAME = lookup_public_data_read_low_leaf_poseidon2_0_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_public_data_read_low_leaf_poseidon2_0_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_public_data_read_low_leaf_poseidon2_0_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_public_data_read_low_leaf_poseidon2_1 /////////////////// + +class lookup_public_data_read_low_leaf_poseidon2_1_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_PUBLIC_DATA_READ_LOW_LEAF_POSEIDON2_1"; + static constexpr std::string_view RELATION_NAME = "public_data_read"; + + 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 = 4; + 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::public_data_read_sel; + static constexpr Column DST_SELECTOR = Column::poseidon2_hash_end; + static constexpr Column COUNTS = Column::lookup_public_data_read_low_leaf_poseidon2_1_counts; + static constexpr Column INVERSES = Column::lookup_public_data_read_low_leaf_poseidon2_1_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::public_data_read_low_leaf_next_slot, + ColumnAndShifts::precomputed_zero, + ColumnAndShifts::precomputed_zero, + ColumnAndShifts::public_data_read_low_leaf_hash + }; + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::poseidon2_hash_input_0, + ColumnAndShifts::poseidon2_hash_input_1, + ColumnAndShifts::poseidon2_hash_input_2, + ColumnAndShifts::poseidon2_hash_output + }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._public_data_read_sel() == 1 || in._poseidon2_hash_end() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._public_data_read_sel()); + const auto is_table_entry = View(in._poseidon2_hash_end()); + 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_public_data_read_low_leaf_poseidon2_1_inv(), + in._lookup_public_data_read_low_leaf_poseidon2_1_counts(), + in._public_data_read_sel(), + in._poseidon2_hash_end(), + in._public_data_read_low_leaf_next_slot(), + in._precomputed_zero(), + in._precomputed_zero(), + in._public_data_read_low_leaf_hash(), + in._poseidon2_hash_input_0(), + in._poseidon2_hash_input_1(), + in._poseidon2_hash_input_2(), + in._poseidon2_hash_output()); + } +}; + +template +class lookup_public_data_read_low_leaf_poseidon2_1_relation + : public GenericLookupRelation { + public: + using Settings = lookup_public_data_read_low_leaf_poseidon2_1_settings; + static constexpr std::string_view NAME = lookup_public_data_read_low_leaf_poseidon2_1_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_public_data_read_low_leaf_poseidon2_1_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_public_data_read_low_leaf_poseidon2_1_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_public_data_read_low_leaf_membership /////////////////// + +class lookup_public_data_read_low_leaf_membership_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_PUBLIC_DATA_READ_LOW_LEAF_MEMBERSHIP"; + static constexpr std::string_view RELATION_NAME = "public_data_read"; + + 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 = 4; + 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::public_data_read_sel; + static constexpr Column DST_SELECTOR = Column::merkle_check_start; + static constexpr Column COUNTS = Column::lookup_public_data_read_low_leaf_membership_counts; + static constexpr Column INVERSES = Column::lookup_public_data_read_low_leaf_membership_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::public_data_read_low_leaf_hash, + ColumnAndShifts::public_data_read_low_leaf_index, + ColumnAndShifts::public_data_read_tree_height, + ColumnAndShifts::public_data_read_root + }; + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::merkle_check_read_node, + ColumnAndShifts::merkle_check_index, + ColumnAndShifts::merkle_check_path_len, + ColumnAndShifts::merkle_check_read_root + }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._public_data_read_sel() == 1 || in._merkle_check_start() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._public_data_read_sel()); + const auto is_table_entry = View(in._merkle_check_start()); + 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_public_data_read_low_leaf_membership_inv(), + in._lookup_public_data_read_low_leaf_membership_counts(), + in._public_data_read_sel(), + in._merkle_check_start(), + in._public_data_read_low_leaf_hash(), + in._public_data_read_low_leaf_index(), + in._public_data_read_tree_height(), + in._public_data_read_root(), + in._merkle_check_read_node(), + in._merkle_check_index(), + in._merkle_check_path_len(), + in._merkle_check_read_root()); + } +}; + +template +class lookup_public_data_read_low_leaf_membership_relation + : public GenericLookupRelation { + public: + using Settings = lookup_public_data_read_low_leaf_membership_settings; + static constexpr std::string_view NAME = lookup_public_data_read_low_leaf_membership_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_public_data_read_low_leaf_membership_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_public_data_read_low_leaf_membership_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_public_data_read_low_leaf_slot_validation /////////////////// + +class lookup_public_data_read_low_leaf_slot_validation_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_PUBLIC_DATA_READ_LOW_LEAF_SLOT_VALIDATION"; + static constexpr std::string_view RELATION_NAME = "public_data_read"; + + 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 = 3; + 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::public_data_read_leaf_not_exists; + static constexpr Column DST_SELECTOR = Column::ff_gt_sel_gt; + static constexpr Column COUNTS = Column::lookup_public_data_read_low_leaf_slot_validation_counts; + static constexpr Column INVERSES = Column::lookup_public_data_read_low_leaf_slot_validation_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::public_data_read_slot, + ColumnAndShifts::public_data_read_low_leaf_slot, + ColumnAndShifts::public_data_read_one + }; + static constexpr std::array DST_COLUMNS = { ColumnAndShifts::ff_gt_a, + ColumnAndShifts::ff_gt_b, + ColumnAndShifts::ff_gt_result }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._public_data_read_leaf_not_exists() == 1 || in._ff_gt_sel_gt() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._public_data_read_leaf_not_exists()); + const auto is_table_entry = View(in._ff_gt_sel_gt()); + 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_public_data_read_low_leaf_slot_validation_inv(), + in._lookup_public_data_read_low_leaf_slot_validation_counts(), + in._public_data_read_leaf_not_exists(), + in._ff_gt_sel_gt(), + in._public_data_read_slot(), + in._public_data_read_low_leaf_slot(), + in._public_data_read_one(), + in._ff_gt_a(), + in._ff_gt_b(), + in._ff_gt_result()); + } +}; + +template +class lookup_public_data_read_low_leaf_slot_validation_relation + : public GenericLookupRelation { + public: + using Settings = lookup_public_data_read_low_leaf_slot_validation_settings; + static constexpr std::string_view NAME = lookup_public_data_read_low_leaf_slot_validation_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_public_data_read_low_leaf_slot_validation_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_public_data_read_low_leaf_slot_validation_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_public_data_read_low_leaf_next_slot_validation /////////////////// + +class lookup_public_data_read_low_leaf_next_slot_validation_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_PUBLIC_DATA_READ_LOW_LEAF_NEXT_SLOT_VALIDATION"; + static constexpr std::string_view RELATION_NAME = "public_data_read"; + + 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 = 3; + 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::public_data_read_next_slot_is_nonzero; + static constexpr Column DST_SELECTOR = Column::ff_gt_sel_gt; + static constexpr Column COUNTS = Column::lookup_public_data_read_low_leaf_next_slot_validation_counts; + static constexpr Column INVERSES = Column::lookup_public_data_read_low_leaf_next_slot_validation_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::public_data_read_low_leaf_next_slot, + ColumnAndShifts::public_data_read_slot, + ColumnAndShifts::public_data_read_one + }; + static constexpr std::array DST_COLUMNS = { ColumnAndShifts::ff_gt_a, + ColumnAndShifts::ff_gt_b, + ColumnAndShifts::ff_gt_result }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._public_data_read_next_slot_is_nonzero() == 1 || in._ff_gt_sel_gt() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._public_data_read_next_slot_is_nonzero()); + const auto is_table_entry = View(in._ff_gt_sel_gt()); + 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_public_data_read_low_leaf_next_slot_validation_inv(), + in._lookup_public_data_read_low_leaf_next_slot_validation_counts(), + in._public_data_read_next_slot_is_nonzero(), + in._ff_gt_sel_gt(), + in._public_data_read_low_leaf_next_slot(), + in._public_data_read_slot(), + in._public_data_read_one(), + in._ff_gt_a(), + in._ff_gt_b(), + in._ff_gt_result()); + } +}; + +template +class lookup_public_data_read_low_leaf_next_slot_validation_relation + : public GenericLookupRelation { + public: + using Settings = lookup_public_data_read_low_leaf_next_slot_validation_settings; + static constexpr std::string_view NAME = lookup_public_data_read_low_leaf_next_slot_validation_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_public_data_read_low_leaf_next_slot_validation_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_public_data_read_low_leaf_next_slot_validation_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/public_data_read.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/public_data_read.hpp new file mode 100644 index 000000000000..f7e52ff59ef1 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/public_data_read.hpp @@ -0,0 +1,123 @@ +// AUTOGENERATED FILE +#pragma once + +#include + +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" + +namespace bb::avm2 { + +template class public_data_readImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 5, 3, 3, 3, 5 }; + + template inline static bool skip(const AllEntities& in) + { + const auto& new_term = in; + return (new_term.public_data_read_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 constants_PUBLIC_DATA_TREE_HEIGHT = FF(40); + const auto public_data_read_LEAF_EXISTS = (FF(1) - new_term.public_data_read_leaf_not_exists); + const auto public_data_read_SLOT_LOW_LEAF_SLOT_DIFF = + (new_term.public_data_read_slot - new_term.public_data_read_low_leaf_slot); + const auto public_data_read_NEXT_SLOT_IS_ZERO = (FF(1) - new_term.public_data_read_next_slot_is_nonzero); + + { + using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>; + auto tmp = new_term.public_data_read_sel * (FF(1) - new_term.public_data_read_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.public_data_read_sel * + (new_term.public_data_read_tree_height - constants_PUBLIC_DATA_TREE_HEIGHT); + tmp *= scaling_factor; + std::get<1>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>; + auto tmp = new_term.public_data_read_leaf_not_exists * (FF(1) - new_term.public_data_read_leaf_not_exists); + tmp *= scaling_factor; + std::get<2>(evals) += typename Accumulator::View(tmp); + } + { // EXISTS_FLAG_CHECK + using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>; + auto tmp = + new_term.public_data_read_sel * + ((public_data_read_SLOT_LOW_LEAF_SLOT_DIFF * + (public_data_read_LEAF_EXISTS * (FF(1) - new_term.public_data_read_slot_low_leaf_slot_diff_inv) + + new_term.public_data_read_slot_low_leaf_slot_diff_inv) - + FF(1)) + + public_data_read_LEAF_EXISTS); + tmp *= scaling_factor; + std::get<3>(evals) += typename Accumulator::View(tmp); + } + { // VALUE_IS_CORRECT + using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; + auto tmp = (new_term.public_data_read_low_leaf_value * public_data_read_LEAF_EXISTS - + new_term.public_data_read_value); + tmp *= scaling_factor; + std::get<4>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; + auto tmp = new_term.public_data_read_sel * (FF(1) - new_term.public_data_read_one); + tmp *= scaling_factor; + std::get<5>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; + auto tmp = new_term.public_data_read_next_slot_is_nonzero * + (FF(1) - new_term.public_data_read_next_slot_is_nonzero); + tmp *= scaling_factor; + std::get<6>(evals) += typename Accumulator::View(tmp); + } + { // NEXT_SLOT_IS_ZERO_CHECK + using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; + auto tmp = new_term.public_data_read_leaf_not_exists * + ((new_term.public_data_read_low_leaf_next_slot * + (public_data_read_NEXT_SLOT_IS_ZERO * (FF(1) - new_term.public_data_read_next_slot_inv) + + new_term.public_data_read_next_slot_inv) - + FF(1)) + + public_data_read_NEXT_SLOT_IS_ZERO); + tmp *= scaling_factor; + std::get<7>(evals) += typename Accumulator::View(tmp); + } + } +}; + +template class public_data_read : public Relation> { + public: + static constexpr const std::string_view NAME = "public_data_read"; + + static std::string get_subrelation_label(size_t index) + { + switch (index) { + case 3: + return "EXISTS_FLAG_CHECK"; + case 4: + return "VALUE_IS_CORRECT"; + case 7: + return "NEXT_SLOT_IS_ZERO_CHECK"; + } + return std::to_string(index); + } + + // Subrelation indices constants, to be used in tests. + static constexpr size_t SR_EXISTS_FLAG_CHECK = 3; + static constexpr size_t SR_VALUE_IS_CORRECT = 4; + static constexpr size_t SR_NEXT_SLOT_IS_ZERO_CHECK = 7; +}; + +} // namespace bb::avm2 diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.cpp index a995678e2b9f..d20c8c529008 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.cpp @@ -38,12 +38,15 @@ const TreeSnapshots& MerkleDB::get_tree_roots() const FF MerkleDB::storage_read(const FF& leaf_slot) const { - // TODO(fcarreiro): constrain everything below. auto [present, index] = raw_merkle_db.get_low_indexed_leaf(world_state::MerkleTreeId::PUBLIC_DATA_TREE, leaf_slot); auto path = raw_merkle_db.get_sibling_path(world_state::MerkleTreeId::PUBLIC_DATA_TREE, index); auto preimage = raw_merkle_db.get_leaf_preimage_public_data_tree(index); - return present ? preimage.value.value : 0; + FF value = present ? preimage.value.value : 0; + + public_data_tree_check.assert_read(leaf_slot, value, preimage, index, path, get_tree_roots().publicDataTree.root); + + return value; } } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.hpp index 6ce0c93943e9..4b904df8944b 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/concrete_dbs.hpp @@ -5,6 +5,7 @@ #include "barretenberg/vm2/simulation/class_id_derivation.hpp" #include "barretenberg/vm2/simulation/lib/db_interfaces.hpp" #include "barretenberg/vm2/simulation/lib/raw_data_dbs.hpp" +#include "barretenberg/vm2/simulation/public_data_tree_check.hpp" namespace bb::avm2::simulation { @@ -38,8 +39,9 @@ class ContractDB final : public ContractDBInterface { // Generates events. class MerkleDB final : public HighLevelMerkleDBInterface { public: - MerkleDB(LowLevelMerkleDBInterface& raw_merkle_db) + MerkleDB(LowLevelMerkleDBInterface& raw_merkle_db, PublicDataTreeCheckInterface& public_data_tree_check) : raw_merkle_db(raw_merkle_db) + , public_data_tree_check(public_data_tree_check) {} // Unconstrained. @@ -54,6 +56,7 @@ class MerkleDB final : public HighLevelMerkleDBInterface { LowLevelMerkleDBInterface& raw_merkle_db; // TODO: when you have a merkle gadget, consider marking it "mutable" so that read can be const. // It's usually ok for mutexes but a gadget is big... + PublicDataTreeCheckInterface& public_data_tree_check; }; } // namespace bb::avm2::simulation 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 007a9c4e33a6..45f2035c7040 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp @@ -13,6 +13,7 @@ #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" +#include "barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp" #include "barretenberg/vm2/simulation/events/range_check_event.hpp" #include "barretenberg/vm2/simulation/events/sha256_event.hpp" #include "barretenberg/vm2/simulation/events/siloing_event.hpp" @@ -42,6 +43,7 @@ struct EventsContainer { EventEmitterInterface::Container merkle_check; EventEmitterInterface::Container range_check; EventEmitterInterface::Container context_stack; + EventEmitterInterface::Container public_data_read_events; }; } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp new file mode 100644 index 000000000000..737c62c556d1 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/world_state/types.hpp" + +#include +#include + +namespace bb::avm2::simulation { + +using PublicDataTreeLeafPreimage = crypto::merkle_tree::IndexedLeaf; + +struct PublicDataTreeReadEvent { + FF value; + FF slot; + FF root; + + PublicDataTreeLeafPreimage low_leaf_preimage; + FF low_leaf_hash; + uint64_t low_leaf_index; + + bool operator==(const PublicDataTreeReadEvent& other) const = default; +}; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/merkle_check.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/merkle_check.cpp index 8e20614b16ec..9edc087e5d99 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/merkle_check.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/merkle_check.cpp @@ -1,8 +1,9 @@ +#include "barretenberg/vm2/simulation/merkle_check.hpp" + #include #include #include "barretenberg/vm2/common/constants.hpp" -#include "barretenberg/vm2/simulation/merkle_check.hpp" namespace bb::avm2::simulation { diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.cpp new file mode 100644 index 000000000000..2c8bff84b403 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.cpp @@ -0,0 +1,48 @@ +#include "barretenberg/vm2/simulation/public_data_tree_check.hpp" + +#include "barretenberg/vm2/common/constants.hpp" +#include + +namespace bb::avm2::simulation { + +void PublicDataTreeCheck::assert_read(const FF& leaf_slot, + const FF& value, + const PublicDataTreeLeafPreimage& low_leaf_preimage, + uint64_t low_leaf_index, + std::span sibling_path, + const FF& root) +{ + // Low leaf membership + FF low_leaf_hash = poseidon2.hash(low_leaf_preimage.get_hash_inputs()); + merkle_check.assert_membership(low_leaf_hash, low_leaf_index, sibling_path, root); + + // Low leaf and value validation + bool exists = low_leaf_preimage.value.slot == leaf_slot; + if (exists) { + if (low_leaf_preimage.value.value != value) { + throw std::runtime_error("Leaf value does not match value"); + } + } else { + if (!field_gt.ff_gt(leaf_slot, low_leaf_preimage.value.slot)) { + throw std::runtime_error("Low leaf slot is GTE leaf slot"); + } + // indexed_leaf calls nextKey/nextSlot as nextValue, which is counter intuitive in public data tree + if (low_leaf_preimage.nextValue != 0 && !field_gt.ff_gt(low_leaf_preimage.nextValue, leaf_slot)) { + throw std::runtime_error("Leaf slot is GTE low leaf next slot"); + } + if (value != 0) { + throw std::runtime_error("Value is nonzero for a non existing slot"); + } + } + + read_events.emit({ + .value = value, + .slot = leaf_slot, + .root = root, + .low_leaf_preimage = low_leaf_preimage, + .low_leaf_hash = low_leaf_hash, + .low_leaf_index = low_leaf_index, + }); +} + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.hpp new file mode 100644 index 000000000000..639112ee0e61 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp" +#include "barretenberg/vm2/simulation/field_gt.hpp" +#include "barretenberg/vm2/simulation/merkle_check.hpp" +#include "barretenberg/vm2/simulation/poseidon2.hpp" +#include "barretenberg/world_state/types.hpp" + +namespace bb::avm2::simulation { + +class PublicDataTreeCheckInterface { + public: + virtual ~PublicDataTreeCheckInterface() = default; + virtual void assert_read(const FF& leaf_slot, + const FF& value, + const PublicDataTreeLeafPreimage& low_leaf_preimage, + uint64_t low_leaf_index, + std::span sibling_path, + const FF& root) = 0; +}; + +class PublicDataTreeCheck : public PublicDataTreeCheckInterface { + public: + PublicDataTreeCheck(Poseidon2Interface& poseidon2, + MerkleCheckInterface& merkle_check, + FieldGreaterThanInterface& field_gt, + EventEmitterInterface& read_event_emitter) + : read_events(read_event_emitter) + , poseidon2(poseidon2) + , merkle_check(merkle_check) + , field_gt(field_gt) + {} + + void assert_read(const FF& leaf_slot, + const FF& value, + const PublicDataTreeLeafPreimage& low_leaf_preimage, + uint64_t low_leaf_index, + std::span sibling_path, + const FF& root); + + private: + EventEmitterInterface& read_events; + Poseidon2Interface& poseidon2; + MerkleCheckInterface& merkle_check; + FieldGreaterThanInterface& field_gt; +}; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.test.cpp new file mode 100644 index 000000000000..bd57bed6f55a --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/public_data_tree_check.test.cpp @@ -0,0 +1,157 @@ +#include "barretenberg/vm2/simulation/public_data_tree_check.hpp" +#include "barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp" +#include "barretenberg/vm2/simulation/testing/mock_field_gt.hpp" +#include "barretenberg/vm2/simulation/testing/mock_merkle_check.hpp" +#include "barretenberg/vm2/simulation/testing/mock_poseidon2.hpp" +#include "barretenberg/vm2/testing/macros.hpp" + +#include "gmock/gmock.h" +#include + +namespace bb::avm2::simulation { + +using ::testing::_; +using ::testing::AllOf; +using ::testing::ElementsAre; +using ::testing::Return; +using ::testing::SizeIs; +using ::testing::StrictMock; + +using PublicDataLeafValue = crypto::merkle_tree::PublicDataLeafValue; +using RawPoseidon2 = crypto::Poseidon2; + +namespace { + +TEST(AvmSimulationPublicDataTree, Exists) +{ + StrictMock poseidon2; + StrictMock merkle_check; + StrictMock field_gt; + + EventEmitter event_emitter; + PublicDataTreeCheck public_data_tree_check(poseidon2, merkle_check, field_gt, event_emitter); + + PublicDataTreeLeafPreimage low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(42, 27), 0, 0); + FF low_leaf_hash = RawPoseidon2::hash(low_leaf.get_hash_inputs()); + uint64_t low_leaf_index = 30; + std::vector sibling_path = { 1, 2, 3, 4, 5 }; + FF root = 123456; + FF leaf_slot = 42; + FF value = 27; + + EXPECT_CALL(poseidon2, hash(low_leaf.get_hash_inputs())).WillRepeatedly(Return(FF(low_leaf_hash))); + EXPECT_CALL(merkle_check, assert_membership(low_leaf_hash, low_leaf_index, _, root)).WillRepeatedly(Return()); + + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root); + + PublicDataTreeReadEvent expect_event = { + .value = value, + .slot = leaf_slot, + .root = root, + .low_leaf_preimage = low_leaf, + .low_leaf_hash = low_leaf_hash, + .low_leaf_index = low_leaf_index, + }; + EXPECT_THAT(event_emitter.dump_events(), ElementsAre(expect_event)); + + // Negative test: wrong value + value = 28; + EXPECT_THROW_WITH_MESSAGE( + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root), + "Leaf value does not match value"); +} + +TEST(AvmSimulationPublicDataTree, NotExistsLowPointsToInfinity) +{ + StrictMock poseidon2; + StrictMock merkle_check; + StrictMock field_gt; + + EventEmitter event_emitter; + PublicDataTreeCheck public_data_tree_check(poseidon2, merkle_check, field_gt, event_emitter); + + PublicDataTreeLeafPreimage low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(40, 27), 0, 0); + FF low_leaf_hash = RawPoseidon2::hash(low_leaf.get_hash_inputs()); + uint64_t low_leaf_index = 30; + std::vector sibling_path = { 1, 2, 3, 4, 5 }; + FF root = 123456; + FF leaf_slot = 42; + FF value = 0; + + EXPECT_CALL(poseidon2, hash(low_leaf.get_hash_inputs())).WillRepeatedly(Return(FF(low_leaf_hash))); + EXPECT_CALL(merkle_check, assert_membership(low_leaf_hash, low_leaf_index, _, root)).WillRepeatedly(Return()); + EXPECT_CALL(field_gt, ff_gt(leaf_slot, low_leaf.value.slot)).WillRepeatedly(Return(true)); + + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root); + PublicDataTreeReadEvent expect_event = { + .value = value, + .slot = leaf_slot, + .root = root, + .low_leaf_preimage = low_leaf, + .low_leaf_hash = low_leaf_hash, + .low_leaf_index = low_leaf_index, + }; + EXPECT_THAT(event_emitter.dump_events(), ElementsAre(expect_event)); + + // Negative test: wrong value + value = 1; + EXPECT_THROW_WITH_MESSAGE( + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root), + "Value is nonzero for a non existing slot"); + + // Negative test: failed leaf_slot > low_leaf_preimage.value.slot + EXPECT_CALL(field_gt, ff_gt(leaf_slot, low_leaf.value.slot)).WillOnce(Return(false)); + EXPECT_THROW_WITH_MESSAGE( + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root), + "Low leaf slot is GTE leaf slot"); +} + +TEST(AvmSimulationPublicDataTree, NotExistsLowPointsToAnotherLeaf) +{ + StrictMock poseidon2; + StrictMock merkle_check; + StrictMock field_gt; + + EventEmitter event_emitter; + PublicDataTreeCheck public_data_tree_check(poseidon2, merkle_check, field_gt, event_emitter); + + PublicDataTreeLeafPreimage low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(40, 27), 28, 50); + FF low_leaf_hash = RawPoseidon2::hash(low_leaf.get_hash_inputs()); + uint64_t low_leaf_index = 30; + std::vector sibling_path = { 1, 2, 3, 4, 5 }; + FF root = 123456; + FF leaf_slot = 42; + FF value = 0; + + EXPECT_CALL(poseidon2, hash(low_leaf.get_hash_inputs())).WillRepeatedly(Return(FF(low_leaf_hash))); + EXPECT_CALL(merkle_check, assert_membership(low_leaf_hash, low_leaf_index, _, root)).WillRepeatedly(Return()); + EXPECT_CALL(field_gt, ff_gt(leaf_slot, low_leaf.value.slot)).WillRepeatedly(Return(true)); + EXPECT_CALL(field_gt, ff_gt(low_leaf.nextValue, leaf_slot)).WillRepeatedly(Return(true)); + + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root); + PublicDataTreeReadEvent expect_event = { + .value = value, + .slot = leaf_slot, + .root = root, + .low_leaf_preimage = low_leaf, + .low_leaf_hash = low_leaf_hash, + .low_leaf_index = low_leaf_index, + }; + EXPECT_THAT(event_emitter.dump_events(), ElementsAre(expect_event)); + + // Negative test: wrong value + value = 1; + EXPECT_THROW_WITH_MESSAGE( + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root), + "Value is nonzero for a non existing slot"); + + // Negative test: failed low_leaf_preimage.nextValue > leaf_slot + EXPECT_CALL(field_gt, ff_gt(low_leaf.nextValue, leaf_slot)).WillOnce(Return(false)); + EXPECT_THROW_WITH_MESSAGE( + public_data_tree_check.assert_read(leaf_slot, value, low_leaf, low_leaf_index, sibling_path, root), + "Leaf slot is GTE low leaf next slot"); +} + +} // namespace + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_field_gt.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_field_gt.hpp new file mode 100644 index 000000000000..738d26a9a3f8 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_field_gt.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +#include "barretenberg/vm2/simulation/field_gt.hpp" + +namespace bb::avm2::simulation { + +class MockFieldGreaterThan : public FieldGreaterThanInterface { + public: + MockFieldGreaterThan(); + ~MockFieldGreaterThan() override; + + MOCK_METHOD(bool, ff_gt, (const FF& a, const FF& b), (override)); +}; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_field_gt.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_field_gt.test.cpp new file mode 100644 index 000000000000..06376523c6bc --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_field_gt.test.cpp @@ -0,0 +1,9 @@ +// This is not a test file but we need to use .test.cpp so that it is not included in non-test builds. +#include "barretenberg/vm2/simulation/testing/mock_field_gt.hpp" + +namespace bb::avm2::simulation { + +MockFieldGreaterThan::MockFieldGreaterThan() = default; +MockFieldGreaterThan::~MockFieldGreaterThan() = default; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_merkle_check.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_merkle_check.hpp new file mode 100644 index 000000000000..ba6f8039528f --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_merkle_check.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include + +#include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/simulation/merkle_check.hpp" + +namespace bb::avm2::simulation { + +class MockMerkleCheck : public MerkleCheckInterface { + public: + MockMerkleCheck(); + ~MockMerkleCheck() override; + + MOCK_METHOD(void, + assert_membership, + (const FF& leaf_value, const uint64_t leaf_index, std::span sibling_path, const FF& root), + (override)); + MOCK_METHOD(FF, + write, + (const FF& current_value, + const FF& new_value, + const uint64_t leaf_index, + std::span sibling_path, + const FF& current_root), + (override)); +}; + +} // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_merkle_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_merkle_check.test.cpp new file mode 100644 index 000000000000..242a25cd4002 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_merkle_check.test.cpp @@ -0,0 +1,9 @@ +// This is not a test file but we need to use .test.cpp so that it is not included in non-test builds. +#include "barretenberg/vm2/simulation/testing/mock_merkle_check.hpp" + +namespace bb::avm2::simulation { + +MockMerkleCheck::MockMerkleCheck() = default; +MockMerkleCheck::~MockMerkleCheck() = default; + +} // 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 b11c7ad1110f..455e405f0b90 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp @@ -22,6 +22,7 @@ #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/public_data_tree_read_event.hpp" #include "barretenberg/vm2/simulation/events/range_check_event.hpp" #include "barretenberg/vm2/simulation/events/sha256_event.hpp" #include "barretenberg/vm2/simulation/events/siloing_event.hpp" @@ -82,19 +83,22 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting typename S::template DefaultEventEmitter merkle_check_emitter; typename S::template DefaultDeduplicatingEventEmitter range_check_emitter; typename S::template DefaultEventEmitter context_stack_emitter; + typename S::template DefaultEventEmitter public_data_read_emitter; Poseidon2 poseidon2(poseidon2_hash_emitter, poseidon2_perm_emitter); ToRadix to_radix(to_radix_emitter); Ecc ecc(to_radix, ecc_add_emitter, scalar_mul_emitter); MerkleCheck merkle_check(poseidon2, merkle_check_emitter); RangeCheck range_check(range_check_emitter); + FieldGreaterThan field_gt(range_check, field_gt_emitter); + PublicDataTreeCheck public_data_tree_check(poseidon2, merkle_check, field_gt, public_data_read_emitter); AddressDerivation address_derivation(poseidon2, ecc, address_derivation_emitter); ClassIdDerivation class_id_derivation(poseidon2, class_id_derivation_emitter); HintedRawContractDB raw_contract_db(inputs.hints); HintedRawMerkleDB raw_merkle_db(inputs.hints, inputs.publicInputs.startTreeSnapshots); ContractDB contract_db(raw_contract_db, address_derivation, class_id_derivation); - MerkleDB merkle_db(raw_merkle_db); + MerkleDB merkle_db(raw_merkle_db, public_data_tree_check); BytecodeHasher bytecode_hasher(poseidon2, bytecode_hashing_emitter); Siloing siloing(siloing_emitter); @@ -113,7 +117,6 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting Execution execution(alu, execution_components, instruction_info_db, execution_emitter, context_stack_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 }); @@ -137,7 +140,8 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting field_gt_emitter.dump_events(), merkle_check_emitter.dump_events(), range_check_emitter.dump_events(), - context_stack_emitter.dump_events() }; + context_stack_emitter.dump_events(), + public_data_read_emitter.dump_events() }; } EventsContainer AvmSimulationHelper::simulate() diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.cpp new file mode 100644 index 000000000000..79f513cdda7a --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.cpp @@ -0,0 +1,47 @@ +#include "barretenberg/vm2/tracegen/public_data_tree_read_trace.hpp" + +#include "barretenberg/vm/aztec_constants.hpp" + +namespace bb::avm2::tracegen { + +void PublicDataTreeReadTraceBuilder::process( + const simulation::EventEmitterInterface::Container& events, + TraceContainer& trace) +{ + using C = Column; + + uint32_t row = 0; + + for (const auto& event : events) { + bool exists = event.low_leaf_preimage.value.slot == event.slot; + FF slot_low_leaf_slot_diff_inv = exists ? 0 : (event.slot - event.low_leaf_preimage.value.slot).invert(); + + bool next_slot_is_nonzero = false; + FF next_slot_inv = 0; + if (!exists) { + next_slot_is_nonzero = event.low_leaf_preimage.nextValue != 0; + next_slot_inv = next_slot_is_nonzero ? event.low_leaf_preimage.nextValue.invert() : 0; + } + + trace.set(row, + { { { C::public_data_read_sel, 1 }, + { C::public_data_read_value, event.value }, + { C::public_data_read_slot, event.slot }, + { C::public_data_read_root, event.root }, + { C::public_data_read_low_leaf_slot, event.low_leaf_preimage.value.slot }, + { C::public_data_read_low_leaf_value, event.low_leaf_preimage.value.value }, + { C::public_data_read_low_leaf_next_index, event.low_leaf_preimage.nextIndex }, + { C::public_data_read_low_leaf_next_slot, event.low_leaf_preimage.nextValue }, + { C::public_data_read_low_leaf_index, event.low_leaf_index }, + { C::public_data_read_low_leaf_hash, event.low_leaf_hash }, + { C::public_data_read_tree_height, PUBLIC_DATA_TREE_HEIGHT }, + { C::public_data_read_leaf_not_exists, !exists }, + { C::public_data_read_slot_low_leaf_slot_diff_inv, slot_low_leaf_slot_diff_inv }, + { C::public_data_read_one, 1 }, + { C::public_data_read_next_slot_is_nonzero, next_slot_is_nonzero }, + { C::public_data_read_next_slot_inv, next_slot_inv } } }); + row++; + } +} + +} // namespace bb::avm2::tracegen diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.hpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.hpp new file mode 100644 index 000000000000..665fc64563e8 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_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/public_data_tree_read_event.hpp" +#include "barretenberg/vm2/tracegen/trace_container.hpp" + +namespace bb::avm2::tracegen { + +class PublicDataTreeReadTraceBuilder final { + public: + void process(const simulation::EventEmitterInterface::Container& events, + TraceContainer& trace); +}; + +} // namespace bb::avm2::tracegen diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.test.cpp new file mode 100644 index 000000000000..c96df8af4dd1 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/public_data_tree_read_trace.test.cpp @@ -0,0 +1,138 @@ +#include +#include + +#include +#include + +#include "barretenberg/crypto/poseidon2/poseidon2.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" +#include "barretenberg/vm2/generated/relations/lookups_public_data_read.hpp" +#include "barretenberg/vm2/generated/relations/merkle_check.hpp" +#include "barretenberg/vm2/generated/relations/public_data_read.hpp" +#include "barretenberg/vm2/simulation/events/event_emitter.hpp" +#include "barretenberg/vm2/simulation/events/public_data_tree_read_event.hpp" +#include "barretenberg/vm2/simulation/field_gt.hpp" +#include "barretenberg/vm2/simulation/lib/merkle.hpp" +#include "barretenberg/vm2/simulation/poseidon2.hpp" +#include "barretenberg/vm2/simulation/public_data_tree_check.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/merkle_check_trace.hpp" +#include "barretenberg/vm2/tracegen/poseidon2_trace.hpp" +#include "barretenberg/vm2/tracegen/public_data_tree_read_trace.hpp" +#include "barretenberg/vm2/tracegen/test_trace_container.hpp" + +namespace bb::avm2::tracegen { +namespace { + +using ::testing::NiceMock; +using ::testing::TestWithParam; + +using simulation::EventEmitter; +using simulation::FieldGreaterThan; +using simulation::FieldGreaterThanEvent; +using simulation::MerkleCheck; +using simulation::MerkleCheckEvent; +using simulation::MockRangeCheck; +using simulation::NoopEventEmitter; +using simulation::Poseidon2; +using simulation::Poseidon2HashEvent; +using simulation::Poseidon2PermutationEvent; +using simulation::PublicDataTreeCheck; +using simulation::PublicDataTreeLeafPreimage; +using simulation::PublicDataTreeReadEvent; +using simulation::root_from_path; + +using FF = AvmFlavorSettings::FF; +using C = Column; +using public_data_read = bb::avm2::public_data_read; +using poseidon2 = crypto::Poseidon2; +using PublicDataLeafValue = crypto::merkle_tree::PublicDataLeafValue; + +using lookup_low_leaf_poseidon2_0 = lookup_public_data_read_low_leaf_poseidon2_0_relation; +using lookup_low_leaf_poseidon2_1 = lookup_public_data_read_low_leaf_poseidon2_1_relation; +using lookup_low_leaf_membership = lookup_public_data_read_low_leaf_membership_relation; +using lookup_low_leaf_slot_validation = lookup_public_data_read_low_leaf_slot_validation_relation; +using lookup_low_leaf_next_slot_validation = lookup_public_data_read_low_leaf_next_slot_validation_relation; + +struct TestParams { + FF leaf_slot; + FF value; + PublicDataTreeLeafPreimage low_leaf; +}; + +std::vector positive_tests = { + // Exists = true, leaf pointers to infinity + TestParams{ + .leaf_slot = 42, .value = 27, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(42, 27), 0, 0) }, + // Exists = true, leaf points to higher value + TestParams{ + .leaf_slot = 42, .value = 27, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(42, 27), 28, 50) }, + // Exists = false, low leaf points to infinity + TestParams{ .leaf_slot = 42, .value = 0, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(10, 0), 0, 0) }, + // Exists = false, low leaf points to higher value + TestParams{ + .leaf_slot = 42, .value = 0, .low_leaf = PublicDataTreeLeafPreimage(PublicDataLeafValue(10, 0), 28, 50) } +}; + +class PublicDataReadInteractionsTests : public TestWithParam {}; + +TEST_P(PublicDataReadInteractionsTests, PositiveWithInteractions) +{ + const auto& param = GetParam(); + + EventEmitter hash_event_emitter; + NoopEventEmitter perm_event_emitter; + Poseidon2 poseidon2(hash_event_emitter, perm_event_emitter); + + EventEmitter merkle_event_emitter; + MerkleCheck merkle_check(poseidon2, merkle_event_emitter); + + NiceMock range_check; + + EventEmitter field_gt_event_emitter; + FieldGreaterThan field_gt(range_check, field_gt_event_emitter); + + EventEmitter public_data_tree_read_event_emitter; + PublicDataTreeCheck public_data_tree_check_simulator( + poseidon2, merkle_check, field_gt, public_data_tree_read_event_emitter); + + TestTraceContainer trace({ { { C::precomputed_first_row, 1 } } }); + Poseidon2TraceBuilder poseidon2_builder; + MerkleCheckTraceBuilder merkle_check_builder; + FieldGreaterThanTraceBuilder field_gt_builder; + PublicDataTreeReadTraceBuilder public_data_tree_read_builder; + + FF low_leaf_hash = poseidon2.hash(param.low_leaf.get_hash_inputs()); + uint64_t leaf_index = 30; + std::vector sibling_path; + sibling_path.reserve(PUBLIC_DATA_TREE_HEIGHT); + for (size_t i = 0; i < PUBLIC_DATA_TREE_HEIGHT; ++i) { + sibling_path.emplace_back(i); + } + FF root = root_from_path(low_leaf_hash, leaf_index, sibling_path); + + public_data_tree_check_simulator.assert_read( + param.leaf_slot, param.value, param.low_leaf, leaf_index, sibling_path, root); + + poseidon2_builder.process_hash(hash_event_emitter.dump_events(), trace); + merkle_check_builder.process(merkle_event_emitter.dump_events(), trace); + field_gt_builder.process(field_gt_event_emitter.dump_events(), trace); + public_data_tree_read_builder.process(public_data_tree_read_event_emitter.dump_events(), trace); + + LookupIntoDynamicTableSequential().process(trace); + LookupIntoDynamicTableSequential().process(trace); + LookupIntoDynamicTableSequential().process(trace); + LookupIntoDynamicTableSequential().process(trace); + LookupIntoDynamicTableSequential().process(trace); +} + +INSTANTIATE_TEST_SUITE_P(PublicDataTreeReadTracegenTest, + PublicDataReadInteractionsTests, + ::testing::ValuesIn(positive_tests)); + +} // namespace +} // 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 0db902ac2a4b..e7bb017fa709 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -22,6 +22,7 @@ #include "barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp" #include "barretenberg/vm2/generated/relations/lookups_merkle_check.hpp" #include "barretenberg/vm2/generated/relations/lookups_poseidon2_hash.hpp" +#include "barretenberg/vm2/generated/relations/lookups_public_data_read.hpp" #include "barretenberg/vm2/generated/relations/lookups_range_check.hpp" #include "barretenberg/vm2/generated/relations/lookups_scalar_mul.hpp" #include "barretenberg/vm2/generated/relations/lookups_sha256.hpp" @@ -42,6 +43,7 @@ #include "barretenberg/vm2/tracegen/merkle_check_trace.hpp" #include "barretenberg/vm2/tracegen/poseidon2_trace.hpp" #include "barretenberg/vm2/tracegen/precomputed_trace.hpp" +#include "barretenberg/vm2/tracegen/public_data_tree_read_trace.hpp" #include "barretenberg/vm2/tracegen/range_check_trace.hpp" #include "barretenberg/vm2/tracegen/sha256_trace.hpp" #include "barretenberg/vm2/tracegen/to_radix_trace.hpp" @@ -267,6 +269,12 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) AVM_TRACK_TIME("tracegen/range_check", range_check_builder.process(events.range_check, trace)); clear_events(events.range_check); }, + [&]() { + PublicDataTreeReadTraceBuilder public_data_tree_read_trace_builder; + AVM_TRACK_TIME("tracegen/public_data_read", + public_data_tree_read_trace_builder.process(events.public_data_read_events, trace)); + clear_events(events.public_data_read_events); + }, }); AVM_TRACK_TIME("tracegen/traces", execute_jobs(jobs)); } @@ -355,7 +363,15 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) std::make_unique>(), // Merkle checks std::make_unique>(), - std::make_unique>()); + std::make_unique>(), + // Public data read + std::make_unique>(), + std::make_unique>(), + std::make_unique>(), + std::make_unique< + LookupIntoDynamicTableSequential>(), + std::make_unique< + LookupIntoDynamicTableSequential>()); AVM_TRACK_TIME("tracegen/interactions", parallel_for(jobs_interactions.size(), [&](size_t i) { jobs_interactions[i]->process(trace); })); diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index b05a689147f6..41c87df959bf 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -92,16 +92,11 @@ export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; export const MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 3000; export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 19; export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 12; -export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = - 11121068431693264234253912047066709627593769337094408533543930778360n; -export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = - 2889881020989534926461066592611988634597302675057895885580456197069n; -export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = - 24399338136397901754495080759185489776044879232766421623673792970137n; -export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = - 14061769416655647708490531650437236735160113654556896985372298487345n; -export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = - 1534834688047131268740281708431107902615560100979874281215533519862n; +export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = 11121068431693264234253912047066709627593769337094408533543930778360n; +export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = 2889881020989534926461066592611988634597302675057895885580456197069n; +export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = 24399338136397901754495080759185489776044879232766421623673792970137n; +export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = 14061769416655647708490531650437236735160113654556896985372298487345n; +export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = 1534834688047131268740281708431107902615560100979874281215533519862n; export const MAX_PROTOCOL_CONTRACTS = 7; export const CANONICAL_AUTH_REGISTRY_ADDRESS = 1; export const DEPLOYER_CONTRACT_ADDRESS = 2; @@ -416,4 +411,4 @@ export enum GeneratorIndex { SYMMETRIC_KEY_2 = 55, PUBLIC_TX_HASH = 56, PRIVATE_TX_HASH = 57, -} +} \ No newline at end of file diff --git a/yarn-project/constants/src/scripts/constants.in.ts b/yarn-project/constants/src/scripts/constants.in.ts index 683081fba9f1..05108bb921d6 100644 --- a/yarn-project/constants/src/scripts/constants.in.ts +++ b/yarn-project/constants/src/scripts/constants.in.ts @@ -96,6 +96,7 @@ const CPP_CONSTANTS = [ 'MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS', 'UPDATED_CLASS_IDS_SLOT', 'UPDATES_SHARED_MUTABLE_VALUES_LEN', + 'PUBLIC_DATA_TREE_HEIGHT', ]; const CPP_GENERATORS: string[] = [ @@ -157,6 +158,7 @@ const PIL_CONSTANTS = [ 'GRUMPKIN_ONE_X', 'GRUMPKIN_ONE_Y', 'AVM_PC_SIZE_IN_BITS', + 'PUBLIC_DATA_TREE_HEIGHT', ]; const PIL_GENERATORS: string[] = [