diff --git a/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp b/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp index 70146181fccb..e097f67f3046 100644 --- a/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp @@ -56,6 +56,16 @@ typename ExecutionTrace_::TraceData ExecutionTrace_::construct_t Builder& builder, typename Flavor::ProvingKey& proving_key, bool is_structured) { ZoneScopedN("construct_trace_data"); + // Allocate the wires and selectors polynomials + if constexpr (IsHonkFlavor) { + for (auto wire : proving_key.polynomials.get_wires()) { + wire = Polynomial(proving_key.circuit_size); + } + for (auto selector : proving_key.polynomials.get_selectors()) { + selector = Polynomial(proving_key.circuit_size); + } + } + TraceData trace_data{ builder, proving_key }; // Complete the public inputs execution trace block from builder.public_inputs @@ -134,6 +144,13 @@ void ExecutionTrace_::add_ecc_op_wires_to_proving_key(Builder& builder, typename Flavor::ProvingKey& proving_key) requires IsGoblinFlavor { + // Allocate the ecc op wires and selector + if constexpr (IsHonkFlavor) { + for (auto wire : proving_key.polynomials.get_ecc_op_wires()) { + wire = Polynomial(proving_key.circuit_size); + } + proving_key.polynomials.lagrange_ecc_op = Polynomial(proving_key.circuit_size); + } // Copy the ecc op data from the conventional wires into the op wires over the range of ecc op gates auto& ecc_op_selector = proving_key.polynomials.lagrange_ecc_op; const size_t op_wire_offset = Flavor::has_zero_row ? 1 : 0; diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp index 35c2a5ec02ad..e63c1ec54abb 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp @@ -14,6 +14,12 @@ void construct_lookup_table_polynomials(const RefArray) { + for (auto& poly : table_polynomials) { + poly = typename Flavor::Polynomial(dyadic_circuit_size); + } + } // Create lookup selector polynomials which interpolate each table column. // Our selector polys always need to interpolate the full subgroup size, so here we offset so as to // put the table column's values at the end. (The first gates are for non-lookup constraints). @@ -51,6 +57,11 @@ void construct_lookup_read_counts(typename Flavor::Polynomial& read_counts, typename Flavor::CircuitBuilder& circuit, size_t dyadic_circuit_size) { + // Allocate the read counts and tags polynomials + if constexpr (IsHonkFlavor) { + read_counts = typename Flavor::Polynomial(dyadic_circuit_size); + read_tags = typename Flavor::Polynomial(dyadic_circuit_size); + } // TODO(https://github.com/AztecProtocol/barretenberg/issues/1033): construct tables and counts at top of trace size_t offset = dyadic_circuit_size - circuit.get_tables_size(); diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/permutation_lib.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/permutation_lib.hpp index 1590a4d57638..f105f2d78efd 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/permutation_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/permutation_lib.hpp @@ -384,6 +384,13 @@ void compute_permutation_argument_polynomials(const typename Flavor::CircuitBuil compute_monomial_and_coset_fft_polynomials_from_lagrange("id", key); } } else if constexpr (IsUltraFlavor) { // any UltraHonk flavor + // Allocate sigma and id polynomials + for (auto& sigma : key->polynomials.get_sigmas()) { + sigma = Polynomial(key->circuit_size); + } + for (auto& id : key->polynomials.get_ids()) { + id = Polynomial(key->circuit_size); + } // Compute Honk-style sigma and ID polynomials from the corresponding mappings { ZoneScopedN("compute_honk_style_permutation_lagrange_polynomials_from_mapping"); diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp index 0ff86bf90706..bcb3a63f56de 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp @@ -431,8 +431,7 @@ class MegaFlavor { ProvingKey(const size_t circuit_size, const size_t num_public_inputs, std::shared_ptr commitment_key = nullptr) - : Base(circuit_size, num_public_inputs, commitment_key) - , polynomials(circuit_size){}; + : Base(circuit_size, num_public_inputs, commitment_key){}; std::vector memory_read_records; std::vector memory_write_records; diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp index 2bb9cb89721d..b76f330146bd 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp @@ -345,8 +345,7 @@ class UltraFlavor { ProvingKey(const size_t circuit_size, const size_t num_public_inputs, std::shared_ptr commitment_key = nullptr) - : Base(circuit_size, num_public_inputs, std::move(commitment_key)) - , polynomials(circuit_size){}; + : Base(circuit_size, num_public_inputs, std::move(commitment_key)){}; std::vector memory_read_records; std::vector memory_write_records; diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_keccak_flavor.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_keccak_flavor.hpp index 0b9485e41227..c97fd852b1e4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_keccak_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_keccak_flavor.hpp @@ -311,8 +311,7 @@ class UltraKeccakFlavor { ProvingKey(const size_t circuit_size, const size_t num_public_inputs, std::shared_ptr commitment_key = nullptr) - : Base(circuit_size, num_public_inputs, commitment_key) - , polynomials(circuit_size){}; + : Base(circuit_size, num_public_inputs, commitment_key){}; std::vector memory_read_records; std::vector memory_write_records; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp index 1dcdaad737b2..f74bda0eccbf 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp @@ -41,6 +41,12 @@ template void DeciderProvingKey_::construct_databus_polynomials(Circuit& circuit) requires IsGoblinFlavor { + // Allocate the databus polynomials and databus_id + for (auto& databus_poly : proving_key.polynomials.get_databus_entities()) { + databus_poly = Polynomial(proving_key.circuit_size); + } + proving_key.polynomials.databus_id = Polynomial(proving_key.circuit_size); + auto& public_calldata = proving_key.polynomials.calldata; auto& calldata_read_counts = proving_key.polynomials.calldata_read_counts; auto& calldata_read_tags = proving_key.polynomials.calldata_read_tags; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp index fa2e344b5a3f..c2e689e8a49d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp @@ -83,6 +83,8 @@ template class DeciderProvingKey_ { } // First and last lagrange polynomials (in the full circuit size) + proving_key.polynomials.lagrange_first = Polynomial(dyadic_circuit_size); + proving_key.polynomials.lagrange_last = Polynomial(dyadic_circuit_size); proving_key.polynomials.lagrange_first.at(0) = 1; proving_key.polynomials.lagrange_last.at(dyadic_circuit_size - 1) = 1; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 26e0f1cca5af..8b5a7d7bac37 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -164,6 +164,9 @@ template void OinkProver::execute_log_derivative_ proving_key->relation_parameters.beta = beta; proving_key->relation_parameters.gamma = gamma; + // Allocate the lookup_inverses polynomial + proving_key->proving_key.polynomials.lookup_inverses = + typename Flavor::Polynomial(proving_key->proving_key.circuit_size); // Compute the inverses used in log-derivative lookup relations proving_key->proving_key.compute_logderivative_inverses(proving_key->relation_parameters); @@ -177,11 +180,14 @@ template void OinkProver::execute_log_derivative_ // If Mega, commit to the databus inverse polynomials and send if constexpr (IsGoblinFlavor) { + // Allocate the databus inverse polynomials for (auto [commitment, polynomial, label] : zip_view(witness_commitments.get_databus_inverses(), proving_key->proving_key.polynomials.get_databus_inverses(), commitment_labels.get_databus_inverses())) { { + // Allocate the databus inverse polynomial + polynomial = typename Flavor::Polynomial(proving_key->proving_key.circuit_size); BB_OP_COUNT_TIME_NAME("COMMIT::databus_inverses"); commitment = commitment_key->commit_sparse(polynomial); } @@ -197,6 +203,9 @@ template void OinkProver::execute_log_derivative_ template void OinkProver::execute_grand_product_computation_round() { BB_OP_COUNT_TIME_NAME("OinkProver::execute_grand_product_computation_round"); + // Allocate the z_perm polynomial + proving_key->proving_key.polynomials.z_perm = typename Flavor::Polynomial(proving_key->proving_key.circuit_size); + // Compute the permutation and lookup grand product polynomials proving_key->proving_key.compute_grand_product_polynomials(proving_key->relation_parameters); {