diff --git a/barretenberg/cpp/src/barretenberg/vm2/common/field.hpp b/barretenberg/cpp/src/barretenberg/vm2/common/field.hpp index 2cf50145994d..5c3674b2d329 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/common/field.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/common/field.hpp @@ -3,7 +3,7 @@ #pragma once #include "barretenberg/vm2/common/standard_affine_point.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" namespace bb::avm2 { diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/benchmark/relations_acc.bench.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/benchmark/relations_acc.bench.cpp index 1ae2f7f6994f..709492616bcc 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/benchmark/relations_acc.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/benchmark/relations_acc.bench.cpp @@ -7,9 +7,9 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/constraining/flavor.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor.hpp" using namespace benchmark; using namespace bb::avm2; diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/check_circuit.hpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/check_circuit.hpp index 5b90aa6e5e0b..0af52058c23a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/check_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/check_circuit.hpp @@ -2,7 +2,7 @@ #include -#include "barretenberg/vm2/generated/flavor.hpp" +#include "barretenberg/vm2/constraining/flavor.hpp" namespace bb::avm2::constraining { @@ -10,4 +10,4 @@ namespace bb::avm2::constraining { // It is the closest to "real proving" that we can get without actually running the prover. void run_check_circuit(AvmFlavor::ProverPolynomials& polys, size_t num_rows); -} // namespace bb::avm2::constraining \ No newline at end of file +} // namespace bb::avm2::constraining diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/flavor.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/vm2/generated/flavor.cpp rename to barretenberg/cpp/src/barretenberg/vm2/constraining/flavor.cpp diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/flavor.hpp similarity index 71% rename from barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp rename to barretenberg/cpp/src/barretenberg/vm2/constraining/flavor.hpp index f4364c52e8d9..87bff3f1d2c9 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/flavor.hpp @@ -1,4 +1,3 @@ -// AUTOGENERATED FILE #pragma once #include "barretenberg/commitment_schemes/kzg/kzg.hpp" @@ -14,46 +13,10 @@ #include "barretenberg/vm/aztec_constants.hpp" #include "barretenberg/vm2/common/macros.hpp" -#include "columns.hpp" -#include "flavor_settings.hpp" - -// Relations -#include "relations/address_derivation.hpp" -#include "relations/alu.hpp" -#include "relations/bc_decomposition.hpp" -#include "relations/bc_hashing.hpp" -#include "relations/bc_retrieval.hpp" -#include "relations/bitwise.hpp" -#include "relations/class_id_derivation.hpp" -#include "relations/context.hpp" -#include "relations/context_stack.hpp" -#include "relations/ecc.hpp" -#include "relations/execution.hpp" -#include "relations/ff_gt.hpp" -#include "relations/instr_fetching.hpp" -#include "relations/merkle_check.hpp" -#include "relations/poseidon2_hash.hpp" -#include "relations/poseidon2_perm.hpp" -#include "relations/range_check.hpp" -#include "relations/scalar_mul.hpp" -#include "relations/sha256.hpp" -#include "relations/to_radix.hpp" - -// Lookup and permutation relations -#include "relations/lookups_address_derivation.hpp" -#include "relations/lookups_bc_decomposition.hpp" -#include "relations/lookups_bc_hashing.hpp" -#include "relations/lookups_bc_retrieval.hpp" -#include "relations/lookups_bitwise.hpp" -#include "relations/lookups_class_id_derivation.hpp" -#include "relations/lookups_ff_gt.hpp" -#include "relations/lookups_instr_fetching.hpp" -#include "relations/lookups_merkle_check.hpp" -#include "relations/lookups_poseidon2_hash.hpp" -#include "relations/lookups_range_check.hpp" -#include "relations/lookups_scalar_mul.hpp" -#include "relations/lookups_sha256.hpp" -#include "relations/lookups_to_radix.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" + +#include "barretenberg/vm2/generated/columns.hpp" +#include "barretenberg/vm2/generated/flavor_variables.hpp" // Metaprogramming to concatenate tuple types. template using tuple_cat_t = decltype(std::tuple_cat(std::declval()...)); @@ -95,13 +58,11 @@ class AvmFlavor { // This flavor would not be used with ZK Sumcheck static constexpr bool HasZK = false; - static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 47; - static constexpr size_t NUM_WITNESS_ENTITIES = 942; - static constexpr size_t NUM_SHIFTED_ENTITIES = 135; - static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; - // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for - // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 1124; + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = AvmFlavorVariables::NUM_PRECOMPUTED_ENTITIES; + static constexpr size_t NUM_WITNESS_ENTITIES = AvmFlavorVariables::NUM_WITNESS_ENTITIES; + static constexpr size_t NUM_SHIFTED_ENTITIES = AvmFlavorVariables::NUM_SHIFTED_ENTITIES; + static constexpr size_t NUM_WIRES = AvmFlavorVariables::NUM_WIRES; + static constexpr size_t NUM_ALL_ENTITIES = AvmFlavorVariables::NUM_ALL_ENTITIES; // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is // evenly processed by all the threads. This constant defines the maximum number of rows @@ -114,89 +75,12 @@ class AvmFlavor { static constexpr size_t MAX_CHUNK_THREAD_PORTION_SIZE = 32; // Need to be templated for recursive verifier - template - using MainRelations_ = std::tuple< - // Relations - avm2::address_derivation, - avm2::alu, - avm2::bc_decomposition, - avm2::bc_hashing, - avm2::bc_retrieval, - avm2::bitwise, - avm2::class_id_derivation, - avm2::context, - avm2::context_stack, - avm2::ecc, - avm2::execution, - avm2::ff_gt, - avm2::instr_fetching, - avm2::merkle_check, - avm2::poseidon2_hash, - avm2::poseidon2_perm, - avm2::range_check, - avm2::scalar_mul, - avm2::sha256, - avm2::to_radix>; + template using MainRelations_ = AvmFlavorVariables::MainRelations_; using MainRelations = MainRelations_; // Need to be templated for recursive verifier - template - using LookupRelations_ = std::tuple< - // Lookups - lookup_address_derivation_address_ecadd_relation, - lookup_address_derivation_partial_address_poseidon2_relation, - lookup_address_derivation_preaddress_poseidon2_relation, - lookup_address_derivation_preaddress_scalar_mul_relation, - lookup_address_derivation_public_keys_hash_poseidon2_0_relation, - lookup_address_derivation_public_keys_hash_poseidon2_1_relation, - lookup_address_derivation_public_keys_hash_poseidon2_2_relation, - lookup_address_derivation_public_keys_hash_poseidon2_3_relation, - lookup_address_derivation_public_keys_hash_poseidon2_4_relation, - lookup_address_derivation_salted_initialization_hash_poseidon2_0_relation, - lookup_address_derivation_salted_initialization_hash_poseidon2_1_relation, - lookup_bc_decomposition_abs_diff_is_u16_relation, - lookup_bc_decomposition_bytes_are_bytes_relation, - lookup_bc_decomposition_bytes_to_read_as_unary_relation, - lookup_bc_hashing_get_packed_field_relation, - lookup_bc_hashing_iv_is_len_relation, - lookup_bc_hashing_poseidon2_hash_relation, - lookup_bc_retrieval_bytecode_hash_is_correct_relation, - lookup_bc_retrieval_class_id_derivation_relation, - lookup_bitwise_byte_operations_relation, - lookup_bitwise_integral_tag_length_relation, - lookup_class_id_derivation_class_id_poseidon2_0_relation, - lookup_class_id_derivation_class_id_poseidon2_1_relation, - lookup_ff_gt_a_hi_range_relation, - lookup_ff_gt_a_lo_range_relation, - lookup_instr_fetching_bytecode_size_from_bc_dec_relation, - lookup_instr_fetching_bytes_from_bc_dec_relation, - lookup_instr_fetching_instr_abs_diff_positive_relation, - lookup_instr_fetching_pc_abs_diff_positive_relation, - lookup_instr_fetching_tag_value_validation_relation, - lookup_instr_fetching_wire_instruction_info_relation, - lookup_merkle_check_merkle_poseidon2_read_relation, - lookup_merkle_check_merkle_poseidon2_write_relation, - lookup_poseidon2_hash_poseidon2_perm_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, - lookup_range_check_r1_is_u16_relation, - lookup_range_check_r2_is_u16_relation, - lookup_range_check_r3_is_u16_relation, - lookup_range_check_r4_is_u16_relation, - lookup_range_check_r5_is_u16_relation, - lookup_range_check_r6_is_u16_relation, - lookup_range_check_r7_is_u16_relation, - lookup_scalar_mul_add_relation, - lookup_scalar_mul_double_relation, - lookup_scalar_mul_to_radix_relation, - lookup_sha256_round_constant_relation, - lookup_to_radix_fetch_p_limb_relation, - lookup_to_radix_fetch_safe_limbs_relation, - lookup_to_radix_limb_less_than_radix_range_relation, - lookup_to_radix_limb_p_diff_range_relation, - lookup_to_radix_limb_range_relation>; + template using LookupRelations_ = AvmFlavorVariables::LookupRelations_; using LookupRelations = LookupRelations_; diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_settings.hpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/flavor_settings.hpp similarity index 89% rename from barretenberg/cpp/src/barretenberg/vm2/generated/flavor_settings.hpp rename to barretenberg/cpp/src/barretenberg/vm2/constraining/flavor_settings.hpp index 039e55922dc7..4bc7ba0dbdec 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_settings.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/flavor_settings.hpp @@ -1,4 +1,4 @@ -// AUTOGENERATED FILE +// This file exists so that we can have access to these definitions without including the whole flavor. #pragma once #include "barretenberg/commitment_schemes/kzg/kzg.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/prover.hpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/prover.hpp index b419a3eb36fb..508a789b0311 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/prover.hpp @@ -5,7 +5,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/vm2/generated/flavor.hpp" +#include "barretenberg/vm2/constraining/flavor.hpp" namespace bb::avm2 { diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/address_derivation.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/address_derivation.test.cpp index 4aeba05e7cbb..5ad343d8adf5 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/address_derivation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/address_derivation.test.cpp @@ -3,9 +3,9 @@ #include "barretenberg/crypto/poseidon2/poseidon2.hpp" #include "barretenberg/crypto/poseidon2/poseidon2_params.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/address_derivation.hpp" #include "barretenberg/vm2/generated/relations/lookups_address_derivation.hpp" #include "barretenberg/vm2/simulation/address_derivation.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/alu.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/alu.test.cpp index 880903ebb9f7..c5ab4c74b2d1 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/alu.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/alu.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/alu.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" @@ -53,4 +53,4 @@ TEST(AluConstrainingTest, NegativeAdd) } } // namespace -} // namespace bb::avm2::constraining \ No newline at end of file +} // namespace bb::avm2::constraining diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_decomposition.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_decomposition.test.cpp index 2182eb9cc657..56c3d351bd63 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_decomposition.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_decomposition.test.cpp @@ -5,9 +5,9 @@ #include #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/bc_decomposition.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" #include "barretenberg/vm2/testing/macros.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_hashing.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_hashing.test.cpp index bd4088c8d92d..03eb79afcc23 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_hashing.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bc_hashing.test.cpp @@ -5,9 +5,9 @@ #include #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/bc_hashing.hpp" #include "barretenberg/vm2/generated/relations/lookups_bc_hashing.hpp" #include "barretenberg/vm2/generated/relations/poseidon2_hash.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bitwise.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bitwise.test.cpp index 5e9239f6e267..2e00af9c7dab 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bitwise.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/bitwise.test.cpp @@ -5,8 +5,8 @@ #include "barretenberg/vm2/common/constants.hpp" #include "barretenberg/vm2/common/memory_types.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/bitwise.hpp" #include "barretenberg/vm2/generated/relations/lookups_bitwise.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/class_id_derivation.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/class_id_derivation.test.cpp index 303a587db0a4..f8e7ee08eed2 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/class_id_derivation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/class_id_derivation.test.cpp @@ -1,9 +1,9 @@ #include #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/class_id_derivation.hpp" #include "barretenberg/vm2/generated/relations/lookups_bc_retrieval.hpp" #include "barretenberg/vm2/generated/relations/lookups_class_id_derivation.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/ecc.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/ecc.test.cpp index 6db83cfa2454..a4e5c9c248d3 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/ecc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/ecc.test.cpp @@ -3,8 +3,8 @@ #include "barretenberg/vm2/common/aztec_types.hpp" #include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/ecc.hpp" #include "barretenberg/vm2/generated/relations/lookups_scalar_mul.hpp" #include "barretenberg/vm2/simulation/ecc.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/execution.test.cpp index 5d059f0dfb8a..c32d8af19140 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/execution.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/execution.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" 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 5985f122de3f..04c2bff59c6b 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 @@ -4,8 +4,8 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" #include "barretenberg/vm2/common/aztec_types.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/lookups_ff_gt.hpp" #include "barretenberg/vm2/simulation/events/field_gt_event.hpp" #include "barretenberg/vm2/simulation/field_gt.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index c7a003336099..510a07df3c63 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -6,9 +6,9 @@ #include #include "barretenberg/vm2/common/instruction_spec.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/instr_fetching.hpp" #include "barretenberg/vm2/simulation/events/range_check_event.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/merkle_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/merkle_check.test.cpp index 514c243acb9a..0c3926a28d49 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/merkle_check.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/merkle_check.test.cpp @@ -5,8 +5,8 @@ #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/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/lookups_merkle_check.hpp" #include "barretenberg/vm2/generated/relations/merkle_check.hpp" #include "barretenberg/vm2/simulation/lib/merkle.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/poseidon2.test.cpp index 0a850c81a3d5..1d6b2d455147 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/poseidon2.test.cpp @@ -4,8 +4,8 @@ #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/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/lookups_poseidon2_hash.hpp" #include "barretenberg/vm2/generated/relations/poseidon2_hash.hpp" #include "barretenberg/vm2/generated/relations/poseidon2_perm.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/range_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/range_check.test.cpp index 5838673d607a..3d0a20bf1d74 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/range_check.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/range_check.test.cpp @@ -4,8 +4,8 @@ #include #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/range_check.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" #include "barretenberg/vm2/testing/macros.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/sha256.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/sha256.test.cpp index 238a86df530a..3670716b207d 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/sha256.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/sha256.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/lookups_sha256.hpp" #include "barretenberg/vm2/generated/relations/sha256.hpp" #include "barretenberg/vm2/simulation/events/event_emitter.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/to_radix.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/to_radix.test.cpp index 4e45f22b8275..793c1bcbfeb1 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/to_radix.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/to_radix.test.cpp @@ -3,8 +3,8 @@ #include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" #include "barretenberg/vm2/common/aztec_types.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/testing/check_relation.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/lookups_to_radix.hpp" #include "barretenberg/vm2/simulation/to_radix.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/verifier.hpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/verifier.hpp index 6fd78f3b020e..dcd15171b133 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/verifier.hpp @@ -2,7 +2,7 @@ #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -#include "barretenberg/vm2/generated/flavor.hpp" +#include "barretenberg/vm2/constraining/flavor.hpp" namespace bb::avm2 { diff --git a/barretenberg/cpp/src/barretenberg/vm2/debugger.cpp b/barretenberg/cpp/src/barretenberg/vm2/debugger.cpp index 988a7938635d..bb1a09e30787 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/debugger.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/debugger.cpp @@ -8,9 +8,9 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/constraining/flavor.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor.hpp" #include "barretenberg/vm2/tracegen/lib/trace_conversion.hpp" namespace bb::avm2 { diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp new file mode 100644 index 000000000000..43314a50b03a --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp @@ -0,0 +1,137 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/flavor/flavor_macros.hpp" + +// Relations +#include "relations/address_derivation.hpp" +#include "relations/alu.hpp" +#include "relations/bc_decomposition.hpp" +#include "relations/bc_hashing.hpp" +#include "relations/bc_retrieval.hpp" +#include "relations/bitwise.hpp" +#include "relations/class_id_derivation.hpp" +#include "relations/context.hpp" +#include "relations/context_stack.hpp" +#include "relations/ecc.hpp" +#include "relations/execution.hpp" +#include "relations/ff_gt.hpp" +#include "relations/instr_fetching.hpp" +#include "relations/merkle_check.hpp" +#include "relations/poseidon2_hash.hpp" +#include "relations/poseidon2_perm.hpp" +#include "relations/range_check.hpp" +#include "relations/scalar_mul.hpp" +#include "relations/sha256.hpp" +#include "relations/to_radix.hpp" + +// Lookup and permutation relations +#include "relations/lookups_address_derivation.hpp" +#include "relations/lookups_bc_decomposition.hpp" +#include "relations/lookups_bc_hashing.hpp" +#include "relations/lookups_bc_retrieval.hpp" +#include "relations/lookups_bitwise.hpp" +#include "relations/lookups_class_id_derivation.hpp" +#include "relations/lookups_ff_gt.hpp" +#include "relations/lookups_instr_fetching.hpp" +#include "relations/lookups_merkle_check.hpp" +#include "relations/lookups_poseidon2_hash.hpp" +#include "relations/lookups_range_check.hpp" +#include "relations/lookups_scalar_mul.hpp" +#include "relations/lookups_sha256.hpp" +#include "relations/lookups_to_radix.hpp" + +namespace bb::avm2 { + +struct AvmFlavorVariables { + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 47; + static constexpr size_t NUM_WITNESS_ENTITIES = 942; + 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 = 1124; + + // Need to be templated for recursive verifier + template + using MainRelations_ = std::tuple< + // Relations + avm2::address_derivation, + avm2::alu, + avm2::bc_decomposition, + avm2::bc_hashing, + avm2::bc_retrieval, + avm2::bitwise, + avm2::class_id_derivation, + avm2::context, + avm2::context_stack, + avm2::ecc, + avm2::execution, + avm2::ff_gt, + avm2::instr_fetching, + avm2::merkle_check, + avm2::poseidon2_hash, + avm2::poseidon2_perm, + avm2::range_check, + avm2::scalar_mul, + avm2::sha256, + avm2::to_radix>; + + // Need to be templated for recursive verifier + template + using LookupRelations_ = std::tuple< + // Lookups + lookup_address_derivation_address_ecadd_relation, + lookup_address_derivation_partial_address_poseidon2_relation, + lookup_address_derivation_preaddress_poseidon2_relation, + lookup_address_derivation_preaddress_scalar_mul_relation, + lookup_address_derivation_public_keys_hash_poseidon2_0_relation, + lookup_address_derivation_public_keys_hash_poseidon2_1_relation, + lookup_address_derivation_public_keys_hash_poseidon2_2_relation, + lookup_address_derivation_public_keys_hash_poseidon2_3_relation, + lookup_address_derivation_public_keys_hash_poseidon2_4_relation, + lookup_address_derivation_salted_initialization_hash_poseidon2_0_relation, + lookup_address_derivation_salted_initialization_hash_poseidon2_1_relation, + lookup_bc_decomposition_abs_diff_is_u16_relation, + lookup_bc_decomposition_bytes_are_bytes_relation, + lookup_bc_decomposition_bytes_to_read_as_unary_relation, + lookup_bc_hashing_get_packed_field_relation, + lookup_bc_hashing_iv_is_len_relation, + lookup_bc_hashing_poseidon2_hash_relation, + lookup_bc_retrieval_bytecode_hash_is_correct_relation, + lookup_bc_retrieval_class_id_derivation_relation, + lookup_bitwise_byte_operations_relation, + lookup_bitwise_integral_tag_length_relation, + lookup_class_id_derivation_class_id_poseidon2_0_relation, + lookup_class_id_derivation_class_id_poseidon2_1_relation, + lookup_ff_gt_a_hi_range_relation, + lookup_ff_gt_a_lo_range_relation, + lookup_instr_fetching_bytecode_size_from_bc_dec_relation, + lookup_instr_fetching_bytes_from_bc_dec_relation, + lookup_instr_fetching_instr_abs_diff_positive_relation, + lookup_instr_fetching_pc_abs_diff_positive_relation, + lookup_instr_fetching_tag_value_validation_relation, + lookup_instr_fetching_wire_instruction_info_relation, + lookup_merkle_check_merkle_poseidon2_read_relation, + lookup_merkle_check_merkle_poseidon2_write_relation, + lookup_poseidon2_hash_poseidon2_perm_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, + lookup_range_check_r1_is_u16_relation, + lookup_range_check_r2_is_u16_relation, + lookup_range_check_r3_is_u16_relation, + lookup_range_check_r4_is_u16_relation, + lookup_range_check_r5_is_u16_relation, + lookup_range_check_r6_is_u16_relation, + lookup_range_check_r7_is_u16_relation, + lookup_scalar_mul_add_relation, + lookup_scalar_mul_double_relation, + lookup_scalar_mul_to_radix_relation, + lookup_sha256_round_constant_relation, + lookup_to_radix_fetch_p_limb_relation, + lookup_to_radix_fetch_safe_limbs_relation, + lookup_to_radix_limb_less_than_radix_range_relation, + lookup_to_radix_limb_p_diff_range_relation, + lookup_to_radix_limb_range_relation>; +}; + +} // namespace bb::avm2 diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/alu_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/alu_trace.test.cpp index a2e988616fd5..056519e978fa 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/alu_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/alu_trace.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/alu_trace.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bitwise_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bitwise_trace.test.cpp index d9151d60ee04..a7aaea4429e9 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bitwise_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bitwise_trace.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/bitwise_trace.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index 7e27010332ab..1de1ec7bc6cc 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -9,8 +9,8 @@ #include #include "barretenberg/vm2/common/instruction_spec.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/bytecode_trace.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/class_id_derivation_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/class_id_derivation_trace.test.cpp index 9fa6f92c8f39..bcac2ecac69e 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/class_id_derivation_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/class_id_derivation_trace.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/class_id_derivation_trace.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/merkle_check_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/merkle_check_trace.test.cpp index 7b06ce15cde7..4c6b32a73442 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/merkle_check_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/merkle_check_trace.test.cpp @@ -6,8 +6,8 @@ #include "barretenberg/crypto/poseidon2/poseidon2.hpp" #include "barretenberg/vm2/common/field.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/tracegen/merkle_check_trace.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/range_check_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/range_check_trace.test.cpp index 21b182ea855d..0933562cd6aa 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/range_check_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/range_check_trace.test.cpp @@ -3,8 +3,8 @@ #include +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/constraining/full_row.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/tracegen/range_check_trace.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/trace_container.hpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/trace_container.hpp index 4accde03a0d6..93da6f9015a1 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/trace_container.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/trace_container.hpp @@ -11,8 +11,8 @@ #include "barretenberg/vm2/common/field.hpp" #include "barretenberg/vm2/common/map.hpp" +#include "barretenberg/vm2/constraining/flavor_settings.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/tracegen/lib/trace_conversion.hpp" 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 4e0098612c78..be9daf6c9527 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -12,8 +12,8 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/vm/stats.hpp" #include "barretenberg/vm2/common/map.hpp" +#include "barretenberg/vm2/constraining/flavor.hpp" #include "barretenberg/vm2/generated/columns.hpp" -#include "barretenberg/vm2/generated/flavor.hpp" #include "barretenberg/vm2/generated/relations/lookups_address_derivation.hpp" #include "barretenberg/vm2/generated/relations/lookups_bc_decomposition.hpp" #include "barretenberg/vm2/generated/relations/lookups_bc_retrieval.hpp" diff --git a/bb-pilcom/bb-pil-backend/src/flavor_builder.rs b/bb-pilcom/bb-pil-backend/src/flavor_builder.rs index 53bd851344e9..fec93340c124 100644 --- a/bb-pilcom/bb-pil-backend/src/flavor_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/flavor_builder.rs @@ -5,7 +5,7 @@ use serde_json::json; pub trait FlavorBuilder { #[allow(clippy::too_many_arguments)] - fn create_flavor_hpp( + fn create_flavor_variables_hpp( &mut self, name: &str, relation_file_names: &[String], @@ -21,22 +21,6 @@ pub trait FlavorBuilder { all_cols_and_shifts: &[String], ); - fn create_flavor_cpp( - &mut self, - name: &str, - relation_file_names: &[String], - inverses: &[String], - fixed: &[String], - witness: &[String], - witness_without_inverses: &[String], - all_cols: &[String], - to_be_shifted: &[String], - shifted: &[String], - all_cols_and_shifts: &[String], - ); - - fn create_flavor_settings_hpp(&mut self, name: &str); - fn create_columns_hpp( &mut self, name: &str, @@ -54,7 +38,7 @@ pub trait FlavorBuilder { /// Build the boilerplate for the flavor file impl FlavorBuilder for BBFiles { - fn create_flavor_hpp( + fn create_flavor_variables_hpp( &mut self, name: &str, relation_file_names: &[String], @@ -93,79 +77,15 @@ impl FlavorBuilder for BBFiles { handlebars .register_template_string( - "flavor.hpp", - std::str::from_utf8(include_bytes!("../templates/flavor.hpp.hbs")).unwrap(), - ) - .unwrap(); - - let flavor_hpp = handlebars.render("flavor.hpp", data).unwrap(); - - self.write_file(None, "flavor.hpp", &flavor_hpp); - } - - fn create_flavor_cpp( - &mut self, - name: &str, - relation_file_names: &[String], - inverses: &[String], - fixed: &[String], - witness: &[String], - witness_without_inverses: &[String], - all_cols: &[String], - to_be_shifted: &[String], - shifted: &[String], - all_cols_and_shifts: &[String], - ) { - let mut handlebars = Handlebars::new(); - - let data = &json!({ - "name": name, - "relation_file_names": relation_file_names, - "inverses": inverses, - "fixed": fixed, - "witness": witness, - "all_cols": all_cols, - "to_be_shifted": to_be_shifted, - "shifted": shifted, - "all_cols_and_shifts": all_cols_and_shifts, - "witness_without_inverses": witness_without_inverses, - }); - - handlebars_helper!(join: |*args| - args.iter().map(|v| v.as_array().unwrap().to_owned()).collect_vec().concat() - ); - handlebars.register_helper("join", Box::new(join)); - - handlebars - .register_template_string( - "flavor.cpp", - std::str::from_utf8(include_bytes!("../templates/flavor.cpp.hbs")).unwrap(), - ) - .unwrap(); - - let flavor_cpp = handlebars.render("flavor.cpp", data).unwrap(); - - self.write_file(None, "flavor.cpp", &flavor_cpp); - } - - fn create_flavor_settings_hpp(&mut self, name: &str) { - let mut handlebars = Handlebars::new(); - - let data = &json!({ - "name": name, - }); - - handlebars - .register_template_string( - "flavor_settings.hpp", - std::str::from_utf8(include_bytes!("../templates/flavor_settings.hpp.hbs")) + "flavor_variables.hpp", + std::str::from_utf8(include_bytes!("../templates/flavor_variables.hpp.hbs")) .unwrap(), ) .unwrap(); - let flavor_hpp = handlebars.render("flavor_settings.hpp", data).unwrap(); + let flavor_hpp = handlebars.render("flavor_variables.hpp", data).unwrap(); - self.write_file(None, "flavor_settings.hpp", &flavor_hpp); + self.write_file(None, "flavor_variables.hpp", &flavor_hpp); } fn create_columns_hpp( diff --git a/bb-pilcom/bb-pil-backend/src/vm_builder.rs b/bb-pilcom/bb-pil-backend/src/vm_builder.rs index b55b592b24c0..8e55447c739a 100644 --- a/bb-pilcom/bb-pil-backend/src/vm_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/vm_builder.rs @@ -20,8 +20,6 @@ struct ColumnGroups { witness: Vec, /// witness or commit columns in pil, with out the inverse columns witnesses_without_inverses: Vec, - /// fixed + witness columns without lookup inverses - all_cols_without_inverses: Vec, /// fixed + witness columns with lookup inverses all_cols: Vec, /// Columns that will not be shifted @@ -34,8 +32,6 @@ struct ColumnGroups { all_cols_with_shifts: Vec, /// Inverses from lookups and permutations inverses: Vec, - /// Public inputs (in source order) - public_inputs: Vec<(usize, String)>, } /// Analyzed to cpp @@ -79,13 +75,11 @@ pub fn analyzed_to_cpp( witness, witnesses_without_inverses, all_cols, - all_cols_without_inverses, unshifted: _unshifted, to_be_shifted, shifted, all_cols_with_shifts, inverses, - public_inputs, } = get_all_col_names(analyzed, &permutations, &lookups); let lookup_and_perm_file_names = lookups @@ -97,7 +91,7 @@ pub fn analyzed_to_cpp( .collect_vec(); // ----------------------- Create the flavor files ----------------------- - bb_files.create_flavor_hpp( + bb_files.create_flavor_variables_hpp( vm_name, &relations, &inverses, @@ -112,20 +106,6 @@ pub fn analyzed_to_cpp( &all_cols_with_shifts, ); - bb_files.create_flavor_cpp( - vm_name, - &relations, - &inverses, - &fixed, - &witness, - &witnesses_without_inverses, - &all_cols, - &to_be_shifted, - &shifted, - &all_cols_with_shifts, - ); - - bb_files.create_flavor_settings_hpp(vm_name); bb_files.create_columns_hpp( vm_name, &lookup_and_permutations_names, @@ -202,8 +182,6 @@ fn get_all_col_names( ]); // Group columns by properties - let all_cols_without_inverses = - flatten(&[constant.clone(), witnesses_without_inverses.clone()]); let all_cols = flatten(&[constant.clone(), witnesses_with_inverses.clone()]); let unshifted = flatten(&[constant.clone(), witnesses_with_inverses.clone()]) .into_iter() @@ -218,7 +196,6 @@ fn get_all_col_names( ColumnGroups { fixed: constant, witness: witnesses_with_inverses, - all_cols_without_inverses: all_cols_without_inverses, witnesses_without_inverses: witnesses_without_inverses, all_cols: all_cols, unshifted: unshifted, @@ -226,6 +203,5 @@ fn get_all_col_names( shifted: shifted, all_cols_with_shifts: all_cols_with_shifts, inverses: inverses, - public_inputs: public.iter().cloned().enumerate().collect_vec(), } } diff --git a/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs deleted file mode 100644 index 49dcf22d14da..000000000000 --- a/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs +++ /dev/null @@ -1,124 +0,0 @@ -// AUTOGENERATED FILE -#include "flavor.hpp" - -namespace bb::{{snakeCase name}} { - -AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) -{ - for (auto [prover_poly, key_poly] : zip_view(this->get_unshifted(), proving_key.get_all())) { - ASSERT(flavor_get_label(*this, prover_poly) == flavor_get_label(proving_key, key_poly)); - prover_poly = key_poly.share(); - } - for (auto [prover_poly, key_poly] : zip_view(this->get_shifted(), proving_key.get_to_be_shifted())) { - ASSERT(flavor_get_label(*this, prover_poly) == (flavor_get_label(proving_key, key_poly) + "_shift")); - prover_poly = key_poly.shifted(); - } -} - -void AvmFlavor::Transcript::deserialize_full_transcript() { - size_t num_frs_read = 0; - circuit_size = deserialize_from_buffer(proof_data, num_frs_read); - - for (auto& commitment : commitments) { - commitment = deserialize_from_buffer(proof_data, num_frs_read); - } - - for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N; ++i) { - sumcheck_univariates.emplace_back( - deserialize_from_buffer>( - Transcript::proof_data, num_frs_read)); - } - - sumcheck_evaluations = - deserialize_from_buffer>(Transcript::proof_data, num_frs_read); - - for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N - 1; ++i) { - gemini_fold_comms.push_back(deserialize_from_buffer(proof_data, num_frs_read)); - } - - for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N; ++i) { - gemini_fold_evals.push_back(deserialize_from_buffer(proof_data, num_frs_read)); - } - - shplonk_q_comm = deserialize_from_buffer(proof_data, num_frs_read); - - kzg_w_comm = deserialize_from_buffer(proof_data, num_frs_read); -} - -void AvmFlavor::Transcript::serialize_full_transcript() { - size_t old_proof_length = proof_data.size(); - Transcript::proof_data.clear(); - - serialize_to_buffer(circuit_size, Transcript::proof_data); - - for (const auto& commitment : commitments) { - serialize_to_buffer(commitment, Transcript::proof_data); - } - - for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N; ++i) { - serialize_to_buffer(sumcheck_univariates[i], Transcript::proof_data); - } - - serialize_to_buffer(sumcheck_evaluations, Transcript::proof_data); - - for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N - 1; ++i) { - serialize_to_buffer(gemini_fold_comms[i], proof_data); - } - - for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N; ++i) { - serialize_to_buffer(gemini_fold_evals[i], proof_data); - } - - serialize_to_buffer(shplonk_q_comm, proof_data); - serialize_to_buffer(kzg_w_comm, proof_data); - - // sanity check to make sure we generate the same length of proof as before. - ASSERT(proof_data.size() == old_proof_length); -} - -AvmFlavor::PartiallyEvaluatedMultivariates::PartiallyEvaluatedMultivariates(const size_t circuit_size) -{ - // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto& poly : get_all()) { - poly = Polynomial(circuit_size / 2); - } -} - -AvmFlavor::PartiallyEvaluatedMultivariates::PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, - size_t circuit_size) -{ - for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) { - // After the initial sumcheck round, the new size is CEIL(size/2). - size_t desired_size = full_poly.end_index() / 2 + full_poly.end_index() % 2; - poly = Polynomial(desired_size, circuit_size / 2); - } -} - -AvmFlavor::ProvingKey::ProvingKey(const size_t circuit_size, const size_t num_public_inputs) - : circuit_size(circuit_size) - , log_circuit_size(numeric::get_msb(circuit_size)) - , num_public_inputs(num_public_inputs) - , evaluation_domain(bb::EvaluationDomain(circuit_size, circuit_size)) - , commitment_key(std::make_shared(circuit_size + 1)) -{ - // The proving key's polynomials are not allocated here because they are later overwritten - // AvmComposer::compute_witness(). We should probably refactor this flow. -}; - -/** - * @brief Serialize verification key to field elements - * - * @return std::vector - */ -std::vector AvmFlavor::VerificationKey::to_field_elements() const -{ - std::vector elements = { FF(circuit_size), FF(num_public_inputs) }; - - for (auto const& comm : get_all()) { - std::vector comm_as_fields = field_conversion::convert_to_bn254_frs(comm); - elements.insert(elements.end(), comm_as_fields.begin(), comm_as_fields.end()); - } - return elements; -} - -} // namespace bb::{{snakeCase name}} diff --git a/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs deleted file mode 100644 index e1d574d54e45..000000000000 --- a/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs +++ /dev/null @@ -1,400 +0,0 @@ -// AUTOGENERATED FILE -#pragma once - -#include "barretenberg/commitment_schemes/kzg/kzg.hpp" -#include "barretenberg/ecc/curves/bn254/g1.hpp" -#include "barretenberg/flavor/relation_definitions.hpp" -#include "barretenberg/polynomials/barycentric.hpp" -#include "barretenberg/polynomials/univariate.hpp" - -#include "barretenberg/flavor/flavor_macros.hpp" -#include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/polynomials/evaluation_domain.hpp" -#include "barretenberg/flavor/flavor.hpp" - -#include "flavor_settings.hpp" -#include "columns.hpp" -#include "barretenberg/vm/aztec_constants.hpp" -#include "barretenberg/vm2/common/macros.hpp" - -// Relations -{{#each relation_file_names as |r|}} -#include "relations/{{r}}.hpp" -{{/each}} - -// Lookup and permutation relations -{{#each lookup_and_perm_file_names as |file_name|}} -#include "relations/{{file_name}}" -{{/each}} - -// Metaprogramming to concatenate tuple types. -template using tuple_cat_t = decltype(std::tuple_cat(std::declval()...)); - -// clang-format off -// These getters are used to speedup logderivative inverses. -// See https://github.com/AztecProtocol/aztec-packages/pull/11605/ for a full explanation. -#define DEFAULT_GETTERS(ENTITY) \ - inline auto& _##ENTITY() { return ENTITY; } \ - inline auto& _##ENTITY() const { return ENTITY; } -#define ROW_PROXY_GETTERS(ENTITY) \ - inline auto& _##ENTITY() { return pp.ENTITY[row_idx]; } \ - inline auto& _##ENTITY() const { return pp.ENTITY[row_idx]; } -#define DEFINE_GETTERS(GETTER_MACRO, ENTITIES) \ - FOR_EACH(GETTER_MACRO, ENTITIES) -// clang-format on - -namespace bb::{{snakeCase name}} { - -class AvmFlavor { - public: - using Curve = AvmFlavorSettings::Curve; - using G1 = AvmFlavorSettings::G1; - using PCS = AvmFlavorSettings::PCS; - - using FF = AvmFlavorSettings::FF; - using Polynomial = AvmFlavorSettings::Polynomial; - using PolynomialHandle = AvmFlavorSettings::PolynomialHandle; - using GroupElement = AvmFlavorSettings::GroupElement; - using Commitment = AvmFlavorSettings::Commitment; - using CommitmentHandle = AvmFlavorSettings::CommitmentHandle; - using CommitmentKey = AvmFlavorSettings::CommitmentKey; - using VerifierCommitmentKey = AvmFlavorSettings::VerifierCommitmentKey; - using RelationSeparator = AvmFlavorSettings::RelationSeparator; - - // indicates when evaluating sumcheck, edges must be extended to be MAX_TOTAL_RELATION_LENGTH - static constexpr bool USE_SHORT_MONOMIALS = false; - - // This flavor would not be used with ZK Sumcheck - static constexpr bool HasZK = false; - - static constexpr size_t NUM_PRECOMPUTED_ENTITIES = {{len fixed}}; - static constexpr size_t NUM_WITNESS_ENTITIES = {{len witness}}; - static constexpr size_t NUM_SHIFTED_ENTITIES = {{len shifted}}; - static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; - // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = {{len all_cols_and_shifts}}; - - // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is - // evenly processed by all the threads. This constant defines the maximum number of rows - // that a given thread will process per chunk. This constant is assumed to be a power of 2 - // greater or equal to 2. - // The current constant 32 is the result of time measurements using 16 threads and against - // bulk test v2. It was performed at a stage where the trace was not large. - // We note that all the experiments with constants below 256 did not exhibit any significant differences. - // TODO: Fine-tune the following constant when avm is close to completion. - static constexpr size_t MAX_CHUNK_THREAD_PORTION_SIZE = 32; - - // Need to be templated for recursive verifier - template - using MainRelations_ = std::tuple< - // Relations - {{#each relation_file_names as |item|}}{{#if @index}},{{/if}}{{snakeCase ../name}}::{{item}}{{/each}} - >; - - using MainRelations = MainRelations_; - - // Need to be templated for recursive verifier - template - using LookupRelations_ = std::tuple< - // Lookups - {{#each lookups as |item|}}{{#if @index}},{{/if}}{{item}}_relation{{/each}} - >; - - using LookupRelations = LookupRelations_; - - // Need to be templated for recursive verifier - template using Relations_ = tuple_cat_t, LookupRelations_>; - using Relations = Relations_; - - static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); - - // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` - // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation - // length = 3 - static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; - static constexpr size_t NUM_RELATIONS = std::tuple_size_v; - - using SumcheckTupleOfTuplesOfUnivariates = decltype(create_sumcheck_tuple_of_tuples_of_univariates()); - using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); - - static constexpr bool has_zero_row = true; - - static constexpr size_t NUM_FRS_COM = field_conversion::calc_num_bn254_frs(); - static constexpr size_t NUM_FRS_FR = field_conversion::calc_num_bn254_frs(); - - // After any circuit changes, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS` in your IDE - // to see its value and then update `AVM_PROOF_LENGTH_IN_FIELDS` in constants.nr. - static constexpr size_t COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS = - (NUM_WITNESS_ENTITIES + 1) * NUM_FRS_COM + (NUM_ALL_ENTITIES + 1) * NUM_FRS_FR + - CONST_PROOF_SIZE_LOG_N * (NUM_FRS_COM + NUM_FRS_FR * (BATCHED_RELATION_PARTIAL_LENGTH + 1)); - - {{!-- TODO: recover asserts when we drop the old witgen. --}} - {{#if (ne name "Avm2")}} - static_assert(AVM_PROOF_LENGTH_IN_FIELDS == COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS, - "\nUnexpected AVM proof length. This might be due to some changes in the\n" - "AVM circuit layout. In this case, modify AVM_PROOF_LENGTH_IN_FIELDS \n" - "in constants.nr accordingly."); - - // VK is composed of - // - circuit size encoded as a fr field element - // - num of inputs encoded as a fr field element - // - NUM_PRECOMPUTED_ENTITIES commitments - static_assert(AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS == 2 * NUM_FRS_FR + NUM_PRECOMPUTED_ENTITIES * NUM_FRS_COM, - "\nUnexpected AVM VK length. This might be due to some changes in the\n" - "AVM circuit. In this case, modify AVM_VERIFICATION_LENGTH_IN_FIELDS \n" - "in constants.nr accordingly."); - {{/if}} - - template class PrecomputedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, {{shoutySnakeCase name}}_PRECOMPUTED_ENTITIES) - DEFINE_GETTERS(DEFAULT_GETTERS, {{shoutySnakeCase name}}_PRECOMPUTED_ENTITIES) - }; - - private: - template - class WireEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, {{shoutySnakeCase name}}_WIRE_ENTITIES) - DEFINE_GETTERS(DEFAULT_GETTERS, {{shoutySnakeCase name}}_WIRE_ENTITIES) - }; - - template - class DerivedWitnessEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, {{shoutySnakeCase name}}_DERIVED_WITNESS_ENTITIES) - DEFINE_GETTERS(DEFAULT_GETTERS, {{shoutySnakeCase name}}_DERIVED_WITNESS_ENTITIES) - }; - - template - class ShiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, {{shoutySnakeCase name}}_SHIFTED_ENTITIES) - DEFINE_GETTERS(DEFAULT_GETTERS, {{shoutySnakeCase name}}_SHIFTED_ENTITIES) - }; - - template - static auto get_to_be_shifted([[maybe_unused]] PrecomputedAndWitnessEntitiesSuperset& entities) { - return RefArray{ {{shoutySnakeCase name}}_TO_BE_SHIFTED(entities) }; - } - - public: - template - class WitnessEntities: public WireEntities, public DerivedWitnessEntities { - public: - DEFINE_COMPOUND_GET_ALL(WireEntities, DerivedWitnessEntities) - auto get_wires() { return WireEntities::get_all(); } - static const auto& get_wires_labels() { return WireEntities::get_labels(); } - auto get_derived() { return DerivedWitnessEntities::get_all(); } - static const auto& get_derived_labels() { return DerivedWitnessEntities::get_labels(); } - }; - - template - class AllEntities : public PrecomputedEntities - , public WitnessEntities - , public ShiftedEntities { - public: - DEFINE_COMPOUND_GET_ALL(PrecomputedEntities, WitnessEntities, ShiftedEntities) - - auto get_unshifted() - { - return concatenate(PrecomputedEntities::get_all(), WitnessEntities::get_all()); - } - - static const auto& get_unshifted_labels() - { - static const auto labels = - concatenate(PrecomputedEntities::get_labels(), WitnessEntities::get_labels()); - return labels; - } - - auto get_to_be_shifted() { return AvmFlavor::get_to_be_shifted(*this); } - auto get_shifted() { return ShiftedEntities::get_all(); } - auto get_precomputed() { return PrecomputedEntities::get_all(); } - }; - - class ProvingKey : public PrecomputedEntities, public WitnessEntities { - public: - using FF = typename Polynomial::FF; - DEFINE_COMPOUND_GET_ALL(PrecomputedEntities, WitnessEntities); - - ProvingKey() = default; - ProvingKey(const size_t circuit_size, const size_t num_public_inputs); - - size_t circuit_size; - size_t log_circuit_size; - size_t num_public_inputs; - bb::EvaluationDomain evaluation_domain; - std::shared_ptr commitment_key; - - // Offset off the public inputs from the start of the execution trace - size_t pub_inputs_offset = 0; - - // The number of public inputs has to be the same for all instances because they are - // folded element by element. - std::vector public_inputs; - - auto get_witness_polynomials() { return WitnessEntities::get_all(); } - auto get_precomputed_polynomials() { return PrecomputedEntities::get_all(); } - auto get_selectors() { return PrecomputedEntities::get_all(); } - auto get_to_be_shifted() { return AvmFlavor::get_to_be_shifted(*this); } - }; - - class VerificationKey : public VerificationKey_, VerifierCommitmentKey> { - public: - using FF = VerificationKey_::FF; - static constexpr size_t NUM_PRECOMPUTED_COMMITMENTS = NUM_PRECOMPUTED_ENTITIES; - - VerificationKey() = default; - - VerificationKey(const std::shared_ptr& proving_key) - : VerificationKey_(proving_key->circuit_size, static_cast(proving_key->num_public_inputs)) - { - for (auto [polynomial, commitment] : - zip_view(proving_key->get_precomputed_polynomials(), this->get_all())) { - commitment = proving_key->commitment_key->commit(polynomial); - } - pcs_verification_key = std::make_shared(); - } - - VerificationKey(const size_t circuit_size, - const size_t num_public_inputs, - std::array const& precomputed_cmts) - : VerificationKey_(circuit_size, num_public_inputs) - { - for (auto [vk_cmt, cmt] : zip_view(this->get_all(), precomputed_cmts)) { - vk_cmt = cmt; - } - pcs_verification_key = std::make_shared(); - } - - std::vector to_field_elements() const; - }; - - {{!-- Used by sumcheck --}} - class AllValues : public AllEntities { - public: - using Base = AllEntities; - using Base::Base; - }; - - // Only used by VM1 check_circuit. Remove. - class AllConstRefValues { - public: - using BaseDataType = const FF; - using DataType = BaseDataType&; - DEFINE_FLAVOR_MEMBERS(DataType, {{shoutySnakeCase name}}_ALL_ENTITIES) - DEFINE_GETTERS(DEFAULT_GETTERS, {{shoutySnakeCase name}}_ALL_ENTITIES) - }; - - template - class PolynomialEntitiesAtFixedRow { - public: - PolynomialEntitiesAtFixedRow(const size_t row_idx, const Polynomials& pp) : row_idx(row_idx), pp(pp) {} - DEFINE_GETTERS(ROW_PROXY_GETTERS, {{shoutySnakeCase name}}_ALL_ENTITIES) - - private: - const size_t row_idx; - const Polynomials& pp; - }; - - /** - * @brief A container for the prover polynomials handles. - */ - class ProverPolynomials : public AllEntities { - public: - // Define all operations as default, except copy construction/assignment - ProverPolynomials() = default; - ProverPolynomials& operator=(const ProverPolynomials&) = delete; - ProverPolynomials(const ProverPolynomials& o) = delete; - ProverPolynomials(ProverPolynomials&& o) noexcept = default; - ProverPolynomials& operator=(ProverPolynomials&& o) noexcept = default; - ~ProverPolynomials() = default; - - ProverPolynomials(ProvingKey& proving_key); - - size_t get_polynomial_size() const { return {{witness.0}}.size(); } - // This is only used in VM1 check_circuit. Remove. - AllConstRefValues get_standard_row(size_t row_idx) const { - return [row_idx](auto&... entities) -> AllConstRefValues { return { entities[row_idx]... }; }({{shoutySnakeCase name}}_ALL_ENTITIES); - } - auto get_row(size_t row_idx) const { - return PolynomialEntitiesAtFixedRow(row_idx, *this); - } - }; - - class PartiallyEvaluatedMultivariates : public AllEntities { - public: - PartiallyEvaluatedMultivariates() = default; - PartiallyEvaluatedMultivariates(const size_t circuit_size); - PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size); - }; - - /** - * @brief A container for univariates used during Protogalaxy folding and sumcheck. - * @details During folding and sumcheck, the prover evaluates the relations on these univariates. - */ - template - using ProverUnivariates = AllEntities>; - - /** - * @brief A container for univariates used during Protogalaxy folding and sumcheck with some of the computation - * optimistically ignored - * @details During folding and sumcheck, the prover evaluates the relations on these univariates. - */ - template - using ProverUnivariatesWithOptimisticSkipping = AllEntities>; - - /** - * @brief A container for univariates produced during the hot loop in sumcheck. - */ - using ExtendedEdges = ProverUnivariates; - - /** - * @brief A container for the witness commitments. - * - */ - using WitnessCommitments = WitnessEntities; - - // Templated for use in recursive verifier - template - class VerifierCommitments_ : public AllEntities { - private: - using Base = AllEntities; - - public: - VerifierCommitments_(const std::shared_ptr& verification_key) { - for (auto [commitment, vk_commitment] : zip_view(this->get_precomputed(), verification_key->get_all())) { - commitment = vk_commitment; - } - } - }; - - // Native version of the verifier commitments - using VerifierCommitments = VerifierCommitments_; - - class Transcript : public NativeTranscript { - public: - uint32_t circuit_size; - - std::array commitments; - - std::vector> sumcheck_univariates; - std::array sumcheck_evaluations; - std::vector gemini_fold_comms; - std::vector gemini_fold_evals; - Commitment shplonk_q_comm; - Commitment kzg_w_comm; - - Transcript() = default; - - Transcript(const std::vector& proof) - : NativeTranscript(proof) - {} - - void deserialize_full_transcript(); - void serialize_full_transcript(); - }; -}; - -} // namespace bb::::{{snakeCase name}} diff --git a/bb-pilcom/bb-pil-backend/templates/flavor_settings.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/flavor_settings.hpp.hbs deleted file mode 100644 index 97beb6aa856b..000000000000 --- a/bb-pilcom/bb-pil-backend/templates/flavor_settings.hpp.hbs +++ /dev/null @@ -1,30 +0,0 @@ -// AUTOGENERATED FILE -#pragma once - -#include "barretenberg/commitment_schemes/kzg/kzg.hpp" -#include "barretenberg/ecc/curves/bn254/g1.hpp" -#include "barretenberg/flavor/relation_definitions.hpp" -#include "barretenberg/polynomials/barycentric.hpp" -#include "barretenberg/polynomials/univariate.hpp" - -namespace bb::{{snakeCase name}} { - -class AvmFlavorSettings { - public: - using Curve = curve::BN254; - using EmbeddedCurve = curve::Grumpkin; - using G1 = Curve::Group; - using PCS = KZG; - - using FF = G1::subgroup_field; - using Polynomial = bb::Polynomial; - using PolynomialHandle = std::span; - using GroupElement = G1::element; - using Commitment = G1::affine_element; - using CommitmentHandle = G1::affine_element; - using CommitmentKey = bb::CommitmentKey; - using VerifierCommitmentKey = bb::VerifierCommitmentKey; - using RelationSeparator = FF; -}; - -} // namespace bb::{{snakeCase name}} diff --git a/bb-pilcom/bb-pil-backend/templates/flavor_variables.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/flavor_variables.hpp.hbs new file mode 100644 index 000000000000..ccf9a93ed023 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/flavor_variables.hpp.hbs @@ -0,0 +1,40 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/flavor/flavor_macros.hpp" + +// Relations +{{#each relation_file_names as |r|}} +#include "relations/{{r}}.hpp" +{{/each}} + +// Lookup and permutation relations +{{#each lookup_and_perm_file_names as |file_name|}} +#include "relations/{{file_name}}" +{{/each}} + +namespace bb::{{snakeCase name}} { + +struct AvmFlavorVariables { + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = {{len fixed}}; + static constexpr size_t NUM_WITNESS_ENTITIES = {{len witness}}; + static constexpr size_t NUM_SHIFTED_ENTITIES = {{len shifted}}; + static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; + static constexpr size_t NUM_ALL_ENTITIES = {{len all_cols_and_shifts}}; + + // Need to be templated for recursive verifier + template + using MainRelations_ = std::tuple< + // Relations + {{#each relation_file_names as |item|}}{{#if @index}},{{/if}}{{snakeCase ../name}}::{{item}}{{/each}} + >; + + // Need to be templated for recursive verifier + template + using LookupRelations_ = std::tuple< + // Lookups + {{#each lookups as |item|}}{{#if @index}},{{/if}}{{item}}_relation{{/each}} + >; +}; + +} // namespace bb::::{{snakeCase name}}