From 030c9124ef197d3921609353f5ffa201a0948211 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 30 Nov 2023 19:07:03 +0000 Subject: [PATCH] chore: remove usage of pointer_view --- .../cpp/src/barretenberg/common/ref_array.hpp | 13 ++-- .../src/barretenberg/common/ref_vector.hpp | 2 +- .../cpp/src/barretenberg/common/serialize.hpp | 10 +-- .../src/barretenberg/eccvm/eccvm_prover.cpp | 13 ++-- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 17 ++--- .../cpp/src/barretenberg/flavor/flavor.hpp | 10 +-- .../src/barretenberg/flavor/flavor.test.cpp | 4 +- .../src/barretenberg/flavor/flavor_macros.hpp | 24 +------ .../flavor/generated/AvmMini_flavor.hpp | 8 +-- .../flavor/generated/Fib_flavor.hpp | 8 +-- .../barretenberg/flavor/goblin_translator.hpp | 19 ++---- .../src/barretenberg/flavor/goblin_ultra.hpp | 8 +-- .../cpp/src/barretenberg/flavor/ultra.hpp | 8 +-- .../honk/proof_system/permutation_library.hpp | 4 +- .../src/barretenberg/honk/utils/testing.hpp | 15 ++--- .../barretenberg/honk/utils/testing.test.cpp | 2 +- .../eccvm/eccvm_circuit_builder.hpp | 4 +- .../generated/AvmMini_circuit_builder.hpp | 4 +- .../generated/Fib_circuit_builder.hpp | 4 +- .../proof_system/composer/composer_lib.hpp | 6 +- .../library/grand_product_library.hpp | 7 +- .../protogalaxy/protogalaxy_prover.hpp | 5 +- .../sumcheck/instance/instances.hpp | 16 ++--- .../sumcheck/partial_evaluation.test.cpp | 24 +++---- .../src/barretenberg/sumcheck/sumcheck.hpp | 21 +++--- .../barretenberg/sumcheck/sumcheck.test.cpp | 29 ++++---- .../barretenberg/sumcheck/sumcheck_round.hpp | 7 +- .../ultra_honk/relation_correctness.test.cpp | 66 +++++++++---------- 28 files changed, 152 insertions(+), 206 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp index f9c9fa11f3b..95224d8f7da 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp @@ -25,15 +25,11 @@ template class RefArray { storage[i++] = &elem; } } - RefArray(std::initializer_list init) + template RefArray(T& ref, Ts&... rest) { - if (init.size() != N) { - throw std::invalid_argument("Initializer list size does not match RefArray size"); - } - std::size_t i = 0; - for (auto& elem : init) { - storage[i++] = &elem; - } + storage[0] = &ref; + int i = 1; + ((storage[i++] = &rest), ...); } T& operator[](std::size_t idx) const @@ -82,6 +78,7 @@ template class RefArray { std::size_t pos; }; + constexpr std::size_t size() const { return N; } /** * @brief Returns an iterator to the beginning of the RefArray. * diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index fa47379ba83..5304f8ea77a 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -84,7 +84,7 @@ template class RefVector { std::size_t pos; }; - [[nodiscard]] std::size_t size() const { return storage.size(); } + std::size_t size() const { return storage.size(); } void push_back(T& element) { storage.push_back(element); } iterator begin() const { return iterator(this, 0); } diff --git a/barretenberg/cpp/src/barretenberg/common/serialize.hpp b/barretenberg/cpp/src/barretenberg/common/serialize.hpp index 7142b99cb32..2489b3703b1 100644 --- a/barretenberg/cpp/src/barretenberg/common/serialize.hpp +++ b/barretenberg/cpp/src/barretenberg/common/serialize.hpp @@ -371,14 +371,14 @@ template inline void read(B& it, std::optional& opt_ } template -concept HasPointerView = requires(T t) { t.pointer_view(); }; +concept HasGetAll = requires(T t) { t.get_all(); }; -// Write out a struct that defines pointer_view() -template inline void write(B& buf, T const& value) +// Write out a struct that defines get_all() +template inline void write(B& buf, T const& value) { using serialize::write; - for (auto* pointer : value.pointer_view()) { - write(buf, *pointer); + for (auto& reference : value.get_all()) { + write(buf, reference); } } diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index f06aea8497b..3aadb40a639 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -1,6 +1,7 @@ #include "eccvm_prover.hpp" #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/commitment_schemes/commitment_key.hpp" +#include "barretenberg/common/ref_array.hpp" #include "barretenberg/honk/proof_system/lookup_library.hpp" #include "barretenberg/honk/proof_system/permutation_library.hpp" #include "barretenberg/honk/proof_system/power_polynomial.hpp" @@ -344,18 +345,16 @@ template void ECCVMProver_::execute_transcript_cons FF batching_challenge = transcript.get_challenge("Translation:batching_challenge"); // Collect the polynomials and evaluations to be batched - const size_t NUM_UNIVARIATES = 6; // 5 transcript polynomials plus the constant hack poly - std::array univariate_polynomials = { &key->transcript_op, &key->transcript_Px, - &key->transcript_Py, &key->transcript_z1, - &key->transcript_z2, &hack }; - std::array univariate_evaluations; + RefArray univariate_polynomials{ key->transcript_op, key->transcript_Px, key->transcript_Py, + key->transcript_z1, key->transcript_z2, hack }; + std::array univariate_evaluations; // Constuct the batched polynomial and batched evaluation Polynomial batched_univariate{ key->circuit_size }; FF batched_evaluation{ 0 }; auto batching_scalar = FF(1); - for (auto [eval, polynomial] : zip_view(univariate_evaluations, univariate_polynomials)) { - batched_univariate.add_scaled(*polynomial, batching_scalar); + for (auto [polynomial, eval] : zip_view(univariate_polynomials, univariate_evaluations)) { + batched_univariate.add_scaled(polynomial, batching_scalar); batched_evaluation += eval * batching_scalar; batching_scalar *= batching_challenge; } diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 0b938556ae5..ef2360bdb55 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -202,8 +202,6 @@ template class ECCVMBa class WitnessEntities : public WireEntities, public DerivedWitnessEntities { public: DEFINE_COMPOUND_GET_ALL(WireEntities::get_all(), DerivedWitnessEntities::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(WireEntities::pointer_view(), - DerivedWitnessEntities::pointer_view()) RefVector get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. RefVector get_sorted_polynomials() { return {}; }; @@ -268,9 +266,6 @@ template class ECCVMBa DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), WitnessEntities::get_all(), ShiftedEntities::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), - WitnessEntities::pointer_view(), - ShiftedEntities::pointer_view()) // Gemini-specific getters. RefVector get_unshifted() { @@ -369,8 +364,8 @@ template class ECCVMBa AllValues get_row(const size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), this->pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), this->get_all())) { + result_field = polynomial[row_idx]; } return result; } @@ -391,8 +386,8 @@ template class ECCVMBa PartiallyEvaluatedMultivariates(const size_t circuit_size) { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto* poly : this->pointer_view()) { - *poly = Polynomial(circuit_size / 2); + for (auto& poly : this->get_all()) { + poly = Polynomial(circuit_size / 2); } } }; @@ -419,8 +414,8 @@ template class ECCVMBa AllValues get_row(const size_t row_idx) { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), this->pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), this->get_all())) { + result_field = polynomial[row_idx]; } return result; } diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index 4d29ca7ffb2..d2b16d473cf 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -105,7 +105,7 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { std::vector recursive_proof_public_input_indices; barretenberg::EvaluationDomain evaluation_domain; - auto precomputed_polynomials_pointer_view() { return PrecomputedPolynomials::pointer_view(); } + auto precomputed_polynomials_get_all() { return PrecomputedPolynomials::get_all(); } ProvingKey_() = default; ProvingKey_(const size_t circuit_size, const size_t num_public_inputs) { @@ -114,12 +114,12 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { this->log_circuit_size = numeric::get_msb(circuit_size); this->num_public_inputs = num_public_inputs; // Allocate memory for precomputed polynomials - for (auto* poly : PrecomputedPolynomials::pointer_view()) { - *poly = Polynomial(circuit_size); + for (auto& poly : PrecomputedPolynomials::get_all()) { + poly = Polynomial(circuit_size); } // Allocate memory for witness polynomials - for (auto* poly : WitnessPolynomials::pointer_view()) { - *poly = Polynomial(circuit_size); + for (auto& poly : WitnessPolynomials::get_all()) { + poly = Polynomial(circuit_size); } }; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index 4b2c8fc2752..ad4692dc26b 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -135,8 +135,8 @@ TEST(Flavor, GetRow) return std::vector({ FF::random_element(), FF::random_element() }); }); Flavor::ProverPolynomials prover_polynomials; - for (auto [poly, entry] : zip_view(prover_polynomials.pointer_view(), data)) { - *poly = entry; + for (auto [poly, entry] : zip_view(prover_polynomials.get_all(), data)) { + poly = entry; } auto row0 = prover_polynomials.get_row(0); auto row1 = prover_polynomials.get_row(1); diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index c378aa51489..d25bb4eb513 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -3,7 +3,7 @@ // Macros for defining the flavor classes. // These are used to derive iterator methods along with the body of a 'flavor' class. // DEFINE_FLAVOR_MEMBERS lets you define a flavor entity as a collection of individual members, and derive an iterator. -// while DEFINE_COMPOUND_GET_ALL and DEFINE_COMPOUND_POINTER_VIEW let you combine the iterators of substructures or base +// while DEFINE_COMPOUND_GET_ALL lets you combine the iterators of substructures or base // classes. #include "barretenberg/common/ref_vector.hpp" @@ -17,17 +17,6 @@ template auto _refs_to_pointer_array(Refs&... refs) return std::array{ &refs... }; } -// @deprecated this was less natural than the ref view -#define DEFINE_POINTER_VIEW(...) \ - [[nodiscard]] auto pointer_view() \ - { \ - return _refs_to_pointer_array(__VA_ARGS__); \ - } \ - [[nodiscard]] auto pointer_view() const \ - { \ - return _refs_to_pointer_array(__VA_ARGS__); \ - } - #define DEFINE_REF_VIEW(...) \ [[nodiscard]] auto get_all() \ { \ @@ -47,19 +36,8 @@ template auto _refs_to_pointer_array(Refs&... refs) */ #define DEFINE_FLAVOR_MEMBERS(DataType, ...) \ DataType __VA_ARGS__; \ - DEFINE_POINTER_VIEW(__VA_ARGS__) \ DEFINE_REF_VIEW(__VA_ARGS__) -#define DEFINE_COMPOUND_POINTER_VIEW(...) \ - [[nodiscard]] auto pointer_view() \ - { \ - return concatenate(__VA_ARGS__); \ - } \ - [[nodiscard]] auto pointer_view() const \ - { \ - return concatenate(__VA_ARGS__); \ - } - #define DEFINE_COMPOUND_GET_ALL(...) \ [[nodiscard]] auto get_all() \ { \ diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index 7f2b128a3f2..8eba8ee485c 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -222,8 +222,8 @@ class AvmMiniFlavor { [[nodiscard]] AllValues get_row(const size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), get_all())) { + result_field = polynomial[row_idx]; } return result; } @@ -237,8 +237,8 @@ class AvmMiniFlavor { PartiallyEvaluatedMultivariates(const size_t circuit_size) { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto* poly : pointer_view()) { - *poly = Polynomial(circuit_size / 2); + for (auto& poly : get_all()) { + poly = Polynomial(circuit_size / 2); } } }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp index 031410e2df2..064a9c101c3 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp @@ -164,8 +164,8 @@ class FibFlavor { [[nodiscard]] AllValues get_row(const size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), get_all())) { + result_field = polynomial[row_idx]; } return result; } @@ -179,8 +179,8 @@ class FibFlavor { PartiallyEvaluatedMultivariates(const size_t circuit_size) { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto* poly : pointer_view()) { - *poly = Polynomial(circuit_size / 2); + for (auto& poly : get_all()) { + poly = Polynomial(circuit_size / 2); } } }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index d649a88f392..bfdcfd4e438 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -250,10 +250,6 @@ class GoblinTranslator { WireToBeShiftedEntities::get_all(), DerivedWitnessEntities::get_all(), ConcatenatedRangeConstraints::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(WireNonshiftedEntities::pointer_view(), - WireToBeShiftedEntities::pointer_view(), - DerivedWitnessEntities::pointer_view(), - ConcatenatedRangeConstraints::pointer_view()) RefVector get_wires() { @@ -654,9 +650,6 @@ class GoblinTranslator { DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), WitnessEntities::get_all(), ShiftedEntities::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), - WitnessEntities::pointer_view(), - ShiftedEntities::pointer_view()) /** * @brief Get the polynomials that are concatenated for the permutation relation * @@ -1036,8 +1029,8 @@ class GoblinTranslator { [[nodiscard]] AllValues get_row(size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), this->pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), this->get_all())) { + result_field = polynomial[row_idx]; } return result; } @@ -1064,8 +1057,8 @@ class GoblinTranslator { [[nodiscard]] AllValues get_row(const size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), this->pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), this->get_all())) { + result_field = polynomial[row_idx]; } return result; } @@ -1086,8 +1079,8 @@ class GoblinTranslator { PartiallyEvaluatedMultivariates(const size_t circuit_size) { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto* poly : this->pointer_view()) { - *poly = Polynomial(circuit_size / 2); + for (auto& poly : this->get_all()) { + poly = Polynomial(circuit_size / 2); } } }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 96cf254eb1d..68dd2dfa2f1 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -333,8 +333,8 @@ class GoblinUltra { PartiallyEvaluatedMultivariates(const size_t circuit_size) { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto* poly : this->pointer_view()) { - *poly = Polynomial(circuit_size / 2); + for (auto& poly : this->get_all()) { + poly = Polynomial(circuit_size / 2); } } }; @@ -369,8 +369,8 @@ class GoblinUltra { [[nodiscard]] AllValues get_row(size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), this->pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), this->get_all())) { + result_field = polynomial[row_idx]; } return result; } diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 93a716820cd..d8c2d87668b 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -272,8 +272,8 @@ class Ultra { [[nodiscard]] AllValues get_row(const size_t row_idx) const { AllValues result; - for (auto [result_field, polynomial] : zip_view(result.pointer_view(), pointer_view())) { - *result_field = (*polynomial)[row_idx]; + for (auto [result_field, polynomial] : zip_view(result.get_all(), get_all())) { + result_field = polynomial[row_idx]; } return result; } @@ -289,8 +289,8 @@ class Ultra { PartiallyEvaluatedMultivariates(const size_t circuit_size) { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) - for (auto* poly : this->pointer_view()) { - *poly = Polynomial(circuit_size / 2); + for (auto& poly : this->get_all()) { + poly = Polynomial(circuit_size / 2); } } }; diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp index de07bda2534..5c1c4392a8f 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp @@ -70,8 +70,8 @@ void compute_permutation_grand_product(const size_t circuit_size, for (size_t i = start; i < end; ++i) { typename Flavor::AllValues evaluations; - for (auto [eval, poly] : zip_view(evaluations.pointer_view(), full_polynomials.pointer_view())) { - *eval = poly->size() > i ? (*poly)[i] : 0; + for (auto [eval, poly] : zip_view(evaluations.get_all(), full_polynomials.get_all())) { + eval = poly.size() > i ? poly[i] : 0; } numerator[i] = GrandProdRelation::template compute_permutation_numerator(evaluations, relation_parameters); diff --git a/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp b/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp index fa7c124a843..37c056609ee 100644 --- a/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp @@ -1,4 +1,5 @@ #pragma once +#include "barretenberg/common/zip_view.hpp" #include "barretenberg/polynomials/polynomial.hpp" namespace proof_system::honk { @@ -27,11 +28,8 @@ get_sequential_prover_polynomials(const size_t log_circuit_size, const size_t st } ProverPolynomials prover_polynomials; - auto prover_polynomials_pointers = prover_polynomials.pointer_view(); - size_t poly_idx = 0; - for (auto& polynomial : storage) { - *prover_polynomials_pointers[poly_idx] = polynomial; - poly_idx++; + for (auto [prover_poly, storage_poly] : zip_view(prover_polynomials.get_all(), storage)) { + prover_poly = storage_poly; } return std::pair(std::move(storage), prover_polynomials); @@ -56,11 +54,8 @@ get_zero_prover_polynomials(const size_t log_circuit_size) } ProverPolynomials prover_polynomials; - size_t poly_idx = 0; - auto prover_polynomial_pointers = prover_polynomials.pointer_view(); - for (auto& polynomial : storage) { - *prover_polynomial_pointers[poly_idx] = polynomial; - poly_idx++; + for (auto [prover_poly, storage_poly] : zip_view(prover_polynomials.get_all(), storage)) { + prover_poly = storage_poly; } return std::pair(std::move(storage), prover_polynomials); diff --git a/barretenberg/cpp/src/barretenberg/honk/utils/testing.test.cpp b/barretenberg/cpp/src/barretenberg/honk/utils/testing.test.cpp index 01e816c5fb8..c4b5fda266c 100644 --- a/barretenberg/cpp/src/barretenberg/honk/utils/testing.test.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/utils/testing.test.cpp @@ -9,7 +9,7 @@ TEST(HonkTestingUtils, ProverPolynomials) using Flavor = proof_system::honk::flavor::Ultra; auto [storage, prover_polynomials] = proof_system::honk::get_sequential_prover_polynomials(/*log_circuit_size=*/2, /*starting_value=*/0); - auto& first_polynomial = *prover_polynomials.pointer_view()[0]; + auto& first_polynomial = prover_polynomials.get_all()[0]; EXPECT_EQ(storage[0][0], first_polynomial[0]); EXPECT_EQ(storage[0][1], first_polynomial[1]); }; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp index 9468df3aa6e..4abbd5bc91f 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp @@ -340,8 +340,8 @@ template class ECCVMCircuitBuilder { size_t num_rows_pow2 = 1UL << (num_rows_log2 + (1UL << num_rows_log2 == num_rows ? 0 : 1)); AllPolynomials polys; - for (auto* poly : polys.pointer_view()) { - *poly = Polynomial(num_rows_pow2); + for (auto& poly : polys.get_all()) { + poly = Polynomial(num_rows_pow2); } polys.lagrange_first[0] = 1; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp index 1bf6093681e..7495c9a23f2 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp @@ -36,8 +36,8 @@ class AvmMiniCircuitBuilder { AllPolynomials polys; // Allocate mem for each column - for (auto* poly : polys.pointer_view()) { - *poly = Polynomial(num_rows); + for (auto& poly : polys.get_all()) { + poly = Polynomial(num_rows); } for (size_t i = 0; i < rows.size(); i++) { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Fib_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Fib_circuit_builder.hpp index 3af3ba87fac..a233692ebf7 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Fib_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Fib_circuit_builder.hpp @@ -36,8 +36,8 @@ class FibCircuitBuilder { AllPolynomials polys; // Allocate mem for each column - for (auto* poly : polys.pointer_view()) { - *poly = Polynomial(num_rows); + for (auto& poly : polys.get_all()) { + poly = Polynomial(num_rows); } for (size_t i = 0; i < rows.size(); i++) { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp index 93884466ba0..728a5cbfda3 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp @@ -40,8 +40,8 @@ void construct_selector_polynomials(const typename Flavor::CircuitBuilder& circu // TODO(#398): Loose coupling here! Would rather build up pk from arithmetization if constexpr (IsHonkFlavor) { - for (auto [poly_ptr, selector_values] : - zip_view(proving_key->precomputed_polynomials_pointer_view(), circuit_constructor.selectors.get())) { + for (auto [poly, selector_values] : + zip_view(proving_key->precomputed_polynomials_get_all(), circuit_constructor.selectors.get())) { ASSERT(proving_key->circuit_size >= selector_values.size()); // Copy the selector values for all gates, keeping the rows at which we store public inputs as 0. @@ -50,7 +50,7 @@ void construct_selector_polynomials(const typename Flavor::CircuitBuilder& circu for (size_t i = 0; i < selector_values.size(); ++i) { selector_poly_lagrange[i + gate_offset] = selector_values[i]; } - *poly_ptr = selector_poly_lagrange; + poly = selector_poly_lagrange; } } else if constexpr (IsPlonkFlavor) { size_t selector_idx = 0; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp index e20214639f8..e1c2ac20115 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp @@ -64,16 +64,15 @@ void compute_grand_product(const size_t circuit_size, // Populate `numerator` and `denominator` with the algebra described by Relation const size_t num_threads = circuit_size >= get_num_cpus_pow2() ? get_num_cpus_pow2() : 1; const size_t block_size = circuit_size / num_threads; - auto full_polynomial_pointers = full_polynomials.pointer_view(); + auto full_polynomial_pointers = full_polynomials.get_all(); parallel_for(num_threads, [&](size_t thread_idx) { const size_t start = thread_idx * block_size; const size_t end = (thread_idx + 1) * block_size; for (size_t i = start; i < end; ++i) { typename Flavor::AllValues evaluations; - auto evaluations_pointer = evaluations.pointer_view(); + auto evaluations_pointer = evaluations.get_all(); for (size_t k = 0; k < Flavor::NUM_ALL_ENTITIES; ++k) { - *evaluations_pointer[k] = - (*full_polynomial_pointers[k]).size() > i ? (*full_polynomial_pointers[k])[i] : 0; + evaluations_pointer[k] = full_polynomial_pointers[k].size() > i ? full_polynomial_pointers[k][i] : 0; } numerator[i] = GrandProdRelation::template compute_grand_product_numerator( evaluations, relation_parameters); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp index 5429be9161f..0a5c8777768 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp @@ -213,9 +213,8 @@ template class ProtoGalaxyProver_ { const size_t row_idx) { auto base_univariates = instances.row_to_univariates(row_idx); - for (auto [extended_univariate, base_univariate] : - zip_view(extended_univariates.pointer_view(), base_univariates)) { - *extended_univariate = base_univariate.template extend_to(); + for (auto [extended_univariate, base_univariate] : zip_view(extended_univariates.get_all(), base_univariates)) { + extended_univariate = base_univariate.template extend_to(); } } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp index 0a30c6d3ecb..1fc658eae9c 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp @@ -54,17 +54,17 @@ template struct ProverInstances_ { */ std::vector> row_to_univariates(size_t row_idx) const { - auto instance_polynomial_views = get_polynomial_pointer_views(); + auto instance_polynomial_views = get_polynomial_views(); std::vector> results; // Initialize to our amount of columns results.resize(instance_polynomial_views[0].size()); size_t instance_idx = 0; // Iterate instances - for (auto& pointer_view : instance_polynomial_views) { + for (auto& get_all : instance_polynomial_views) { // Iterate columns - for (auto [result, poly_ptr] : zip_view(results, pointer_view)) { + for (auto [result, poly_ptr] : zip_view(results, get_all)) { // Assign row for each instance - result.evaluations[instance_idx] = (*poly_ptr)[row_idx]; + result.evaluations[instance_idx] = (poly_ptr)[row_idx]; } instance_idx++; } @@ -72,15 +72,15 @@ template struct ProverInstances_ { } private: - auto get_polynomial_pointer_views() const + auto get_polynomial_views() const { // As a practical measure, get the first instance's pointer view to deduce the vector type - std::vector pointer_views{ _data[0]->prover_polynomials.pointer_view() }; + std::vector get_alls{ _data[0]->prover_polynomials.get_all() }; // complete the views, starting from the second item for (size_t i = 1; i < NUM; i++) { - pointer_views.push_back(_data[i]->prover_polynomials.pointer_view()); + get_alls.push_back(_data[i]->prover_polynomials.get_all()); } - return pointer_views; + return get_alls; } }; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp index 52c92c707ec..c262d274d05 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp @@ -66,7 +66,7 @@ TYPED_TEST(PartialEvaluationTests, TwoRoundsSpecial) sumcheck.partially_evaluate(full_polynomials, multivariate_n, round_challenge_0); - auto& first_polynomial = *sumcheck.partially_evaluated_polynomials.pointer_view()[0]; + auto& first_polynomial = sumcheck.partially_evaluated_polynomials.get_all()[0]; EXPECT_EQ(first_polynomial[0], round_challenge_0); EXPECT_EQ(first_polynomial[1], FF(0)); @@ -102,7 +102,7 @@ TYPED_TEST(PartialEvaluationTests, TwoRoundsGeneric) FF expected_hi = v01 * (FF(1) - round_challenge_0) + v11 * round_challenge_0; sumcheck.partially_evaluate(full_polynomials, multivariate_n, round_challenge_0); - auto& first_polynomial = *sumcheck.partially_evaluated_polynomials.pointer_view()[0]; + auto& first_polynomial = sumcheck.partially_evaluated_polynomials.get_all()[0]; EXPECT_EQ(first_polynomial[0], expected_lo); EXPECT_EQ(first_polynomial[1], expected_hi); @@ -167,7 +167,7 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsSpecial) sumcheck.partially_evaluate(full_polynomials, multivariate_n, round_challenge_0); - auto& first_polynomial = *sumcheck.partially_evaluated_polynomials.pointer_view()[0]; + auto& first_polynomial = sumcheck.partially_evaluated_polynomials.get_all()[0]; EXPECT_EQ(first_polynomial[0], expected_q1); EXPECT_EQ(first_polynomial[1], expected_q2); EXPECT_EQ(first_polynomial[2], expected_q3); @@ -217,7 +217,7 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGeneric) FF expected_q3 = v001 * (FF(1) - round_challenge_0) + v101 * round_challenge_0; FF expected_q4 = v011 * (FF(1) - round_challenge_0) + v111 * round_challenge_0; - auto& first_polynomial = *sumcheck.partially_evaluated_polynomials.pointer_view()[0]; + auto& first_polynomial = sumcheck.partially_evaluated_polynomials.get_all()[0]; sumcheck.partially_evaluate(full_polynomials, multivariate_n, round_challenge_0); EXPECT_EQ(first_polynomial[0], expected_q1); @@ -287,12 +287,12 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) } sumcheck.partially_evaluate(full_polynomials, multivariate_n, round_challenge_0); - auto polynomial_pointer_view = sumcheck.partially_evaluated_polynomials.pointer_view(); + auto polynomial_get_all = sumcheck.partially_evaluated_polynomials.get_all(); for (size_t i = 0; i < 3; i++) { - EXPECT_EQ((*polynomial_pointer_view[i])[0], expected_q1[i]); - EXPECT_EQ((*polynomial_pointer_view[i])[1], expected_q2[i]); - EXPECT_EQ((*polynomial_pointer_view[i])[2], expected_q3[i]); - EXPECT_EQ((*polynomial_pointer_view[i])[3], expected_q4[i]); + EXPECT_EQ((polynomial_get_all[i])[0], expected_q1[i]); + EXPECT_EQ((polynomial_get_all[i])[1], expected_q2[i]); + EXPECT_EQ((polynomial_get_all[i])[2], expected_q3[i]); + EXPECT_EQ((polynomial_get_all[i])[3], expected_q4[i]); } FF round_challenge_1 = FF::random_element(); @@ -304,8 +304,8 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) } sumcheck.partially_evaluate(sumcheck.partially_evaluated_polynomials, multivariate_n >> 1, round_challenge_1); for (size_t i = 0; i < 3; i++) { - EXPECT_EQ((*polynomial_pointer_view[i])[0], expected_lo[i]); - EXPECT_EQ((*polynomial_pointer_view[i])[1], expected_hi[i]); + EXPECT_EQ((polynomial_get_all[i])[0], expected_lo[i]); + EXPECT_EQ((polynomial_get_all[i])[1], expected_hi[i]); } FF round_challenge_2 = FF::random_element(); std::array expected_val; @@ -314,7 +314,7 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) } sumcheck.partially_evaluate(sumcheck.partially_evaluated_polynomials, multivariate_n >> 2, round_challenge_2); for (size_t i = 0; i < 3; i++) { - EXPECT_EQ((*polynomial_pointer_view[i])[0], expected_val[i]); + EXPECT_EQ((polynomial_get_all[i])[0], expected_val[i]); } } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp index 980afc3490b..da4e2a9e61b 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp @@ -108,8 +108,8 @@ template class SumcheckProver { // Final round: Extract multivariate evaluations from partially_evaluated_polynomials and add to transcript ClaimedEvaluations multivariate_evaluations; for (auto [eval, poly] : - zip_view(multivariate_evaluations.pointer_view(), partially_evaluated_polynomials.pointer_view())) { - *eval = (*poly)[0]; + zip_view(multivariate_evaluations.get_all(), partially_evaluated_polynomials.get_all())) { + eval = (poly)[0]; } transcript.send_to_verifier("Sumcheck:evaluations", multivariate_evaluations); @@ -142,13 +142,12 @@ template class SumcheckProver { */ void partially_evaluate(auto& polynomials, size_t round_size, FF round_challenge) { - auto pep_view = partially_evaluated_polynomials.pointer_view(); - auto poly_view = polynomials.pointer_view(); + auto pep_view = partially_evaluated_polynomials.get_all(); + auto poly_view = polynomials.get_all(); // after the first round, operate in place on partially_evaluated_polynomials parallel_for(poly_view.size(), [&](size_t j) { for (size_t i = 0; i < round_size; i += 2) { - (*pep_view[j])[i >> 1] = - (*poly_view[j])[i] + round_challenge * ((*poly_view[j])[i + 1] - (*poly_view[j])[i]); + pep_view[j][i >> 1] = poly_view[j][i] + round_challenge * (poly_view[j][i + 1] - poly_view[j][i]); } }); }; @@ -159,12 +158,11 @@ template class SumcheckProver { template void partially_evaluate(std::array& polynomials, size_t round_size, FF round_challenge) { - auto pep_view = partially_evaluated_polynomials.pointer_view(); + auto pep_view = partially_evaluated_polynomials.get_all(); // after the first round, operate in place on partially_evaluated_polynomials parallel_for(polynomials.size(), [&](size_t j) { for (size_t i = 0; i < round_size; i += 2) { - (*pep_view[j])[i >> 1] = - polynomials[j][i] + round_challenge * (polynomials[j][i + 1] - polynomials[j][i]); + pep_view[j][i >> 1] = polynomials[j][i] + round_challenge * (polynomials[j][i + 1] - polynomials[j][i]); } }); }; @@ -236,9 +234,8 @@ template class SumcheckVerifier { ClaimedEvaluations purported_evaluations; auto transcript_evaluations = transcript.template receive_from_prover>("Sumcheck:evaluations"); - for (auto [eval_ptr, transcript_eval] : - zip_view(purported_evaluations.pointer_view(), transcript_evaluations)) { - *eval_ptr = transcript_eval; + for (auto [eval, transcript_eval] : zip_view(purported_evaluations.get_all(), transcript_evaluations)) { + eval = transcript_eval; } FF full_honk_relation_purported_value = round.compute_full_honk_relation_purported_value( diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 33864bb8442..15e150e679d 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -136,26 +136,21 @@ TEST_F(SumcheckTests, PolynomialNormalization) FF l_7 = ( u_0) * ( u_1) * ( u_2); // clang-format on FF hand_computed_value; - auto partially_evaluated_polynomials_array = sumcheck.partially_evaluated_polynomials.pointer_view(); - size_t i = 0; - for (auto* full_polynomial_pointer : full_polynomials.pointer_view()) { + for (auto [full_poly, partial_eval_poly] : + zip_view(full_polynomials.get_all(), sumcheck.partially_evaluated_polynomials.get_all())) { // full_polynomials[0][0] = w_l[0], full_polynomials[1][1] = w_r[1], and so on. - hand_computed_value = l_0 * (*full_polynomial_pointer)[0] + l_1 * (*full_polynomial_pointer)[1] + - l_2 * (*full_polynomial_pointer)[2] + l_3 * (*full_polynomial_pointer)[3] + - l_4 * (*full_polynomial_pointer)[4] + l_5 * (*full_polynomial_pointer)[5] + - l_6 * (*full_polynomial_pointer)[6] + l_7 * (*full_polynomial_pointer)[7]; - EXPECT_EQ(hand_computed_value, (*partially_evaluated_polynomials_array[i])[0]); - i++; + hand_computed_value = l_0 * full_poly[0] + l_1 * full_poly[1] + l_2 * full_poly[2] + l_3 * full_poly[3] + + l_4 * full_poly[4] + l_5 * full_poly[5] + l_6 * full_poly[6] + l_7 * full_poly[7]; + EXPECT_EQ(hand_computed_value, partial_eval_poly[0]); } // We can also check the correctness of the multilinear evaluations produced by Sumcheck by directly evaluating the // full polynomials at challenge u via the evaluate_mle() function std::vector u_challenge = { u_0, u_1, u_2 }; - for (auto [full_poly, claimed_eval] : - zip_view(full_polynomials.pointer_view(), output.claimed_evaluations.pointer_view())) { - barretenberg::Polynomial poly(*full_poly); + for (auto [full_poly, claimed_eval] : zip_view(full_polynomials.get_all(), output.claimed_evaluations.get_all())) { + barretenberg::Polynomial poly(full_poly); auto v_expected = poly.evaluate_mle(u_challenge); - EXPECT_EQ(v_expected, *claimed_eval); + EXPECT_EQ(v_expected, claimed_eval); } } @@ -181,8 +176,8 @@ TEST_F(SumcheckTests, Prover) FF u_0 = output.challenge[0]; FF u_1 = output.challenge[1]; std::vector expected_values; - for (auto* polynomial_ptr : full_polynomials.pointer_view()) { - auto& polynomial = *polynomial_ptr; + for (auto& polynomial_ptr : full_polynomials.get_all()) { + auto& polynomial = polynomial_ptr; // using knowledge of inputs here to derive the evaluation FF expected_lo = polynomial[0] * (FF(1) - u_0) + polynomial[1] * u_0; expected_lo *= (FF(1) - u_1); @@ -191,8 +186,8 @@ TEST_F(SumcheckTests, Prover) expected_values.emplace_back(expected_lo + expected_hi); } - for (auto [eval, expected] : zip_view(output.claimed_evaluations.pointer_view(), expected_values)) { - *eval = expected; + for (auto [eval, expected] : zip_view(output.claimed_evaluations.get_all(), expected_values)) { + eval = expected; } } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 66ceeedcf52..b5c366be750 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -88,10 +88,9 @@ template class SumcheckProverRound { const ProverPolynomialsOrPartiallyEvaluatedMultivariates& multivariates, size_t edge_idx) { - for (auto [extended_edge, multivariate] : - zip_view(extended_edges.pointer_view(), multivariates.pointer_view())) { - auto edge = barretenberg::Univariate({ (*multivariate)[edge_idx], (*multivariate)[edge_idx + 1] }); - *extended_edge = edge.template extend_to(); + for (auto [extended_edge, multivariate] : zip_view(extended_edges.get_all(), multivariates.get_all())) { + auto edge = barretenberg::Univariate({ multivariate[edge_idx], multivariate[edge_idx + 1] }); + extended_edge = edge.template extend_to(); } } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index d2f7bd8afb6..67848bfecd4 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -38,8 +38,8 @@ template void check_relation(auto circuit_s // Extract an array containing all the polynomial evaluations at a given row i AllValues evaluations_at_index_i; - for (auto [eval, poly] : zip_view(evaluations_at_index_i.pointer_view(), polynomials.pointer_view())) { - *eval = (*poly)[i]; + for (auto [eval, poly] : zip_view(evaluations_at_index_i.get_all(), polynomials.get_all())) { + eval = poly[i]; } // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero @@ -81,8 +81,8 @@ void check_linearly_dependent_relation(auto circuit_size, auto polynomials, auto // Extract an array containing all the polynomial evaluations at a given row i AllValues evaluations_at_index_i; - for (auto [eval, poly] : zip_view(evaluations_at_index_i.pointer_view(), polynomials.pointer_view())) { - *eval = (*poly)[i]; + for (auto [eval, poly] : zip_view(evaluations_at_index_i.get_all(), polynomials.get_all())) { + eval = poly[i]; } // Evaluate each constraint in the relation and check that each is satisfied @@ -389,17 +389,17 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) // Create storage for polynomials ProverPolynomials prover_polynomials; std::vector polynomial_container; - auto polynomial_pointer_view = prover_polynomials.pointer_view(); + auto polynomial_get_all = prover_polynomials.get_all(); size_t z_perm_index = 0; - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + for (size_t i = 0; i < polynomial_get_all.size(); i++) { // TODO(https://github.com/AztecProtocol/barretenberg/issues/743) wouldn't be needed if ProverPolynomials held // memory - if (&prover_polynomials.z_perm == polynomial_pointer_view[i]) { + if (&prover_polynomials.z_perm == &polynomial_get_all[i]) { z_perm_index = i; } Polynomial temporary_polynomial(circuit_size); polynomial_container.push_back(temporary_polynomial); - *polynomial_pointer_view[i] = polynomial_container[i]; + polynomial_get_all[i] = polynomial_container[i]; } // Fill in lagrange polynomials used in the permutation relation @@ -515,18 +515,18 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) ProverPolynomials prover_polynomials; std::vector polynomial_container; - auto polynomial_pointer_view = prover_polynomials.pointer_view(); + auto polynomial_get_all = prover_polynomials.get_all(); size_t ordered_range_constraints_index = 0; // Allocate polynomials - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + for (size_t i = 0; i < polynomial_get_all.size(); i++) { Polynomial temporary_polynomial(circuit_size); // TODO(https://github.com/AztecProtocol/barretenberg/issues/743) wouldn't be needed if ProverPolynomials held // memory - if (&prover_polynomials.ordered_range_constraints_0 == polynomial_pointer_view[i]) { + if (&prover_polynomials.ordered_range_constraints_0 == &polynomial_get_all[i]) { ordered_range_constraints_index = i; } polynomial_container.push_back(temporary_polynomial); - *polynomial_pointer_view[i] = polynomial_container[i]; + polynomial_get_all[i] = polynomial_container[i]; } // Construct lagrange polynomials that are needed for Goblin Translator's GenPermSort Relation @@ -616,16 +616,16 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) ProverPolynomials prover_polynomials; // We use polynomial ids to make shifting the polynomials easier ProverPolynomialIds prover_polynomial_ids; - auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); + auto polynomial_id_get_all = prover_polynomial_ids.get_all(); std::vector polynomial_container; std::vector polynomial_ids; - for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { + for (size_t i = 0; i < polynomial_id_get_all.size(); i++) { Polynomial temporary_polynomial(circuit_size); // Allocate polynomials polynomial_container.push_back(temporary_polynomial); // Push sequential ids to polynomial ids polynomial_ids.push_back(i); - *polynomial_id_pointer_view[i] = polynomial_ids[i]; + polynomial_id_get_all[i] = polynomial_ids[i]; } // Get ids of shifted polynomials and put them in a set auto shifted_ids = prover_polynomial_ids.get_shifted(); @@ -634,10 +634,10 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) shifted_id_set.emplace(id); } // Assign spans to non-shifted prover polynomials - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + auto polynomial_get_all = prover_polynomials.get_all(); + for (size_t i = 0; i < polynomial_get_all.size(); i++) { if (!shifted_id_set.contains(i)) { - *polynomial_pointer_view[i] = polynomial_container[i]; + polynomial_get_all[i] = polynomial_container[i]; } } @@ -645,7 +645,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) for (size_t i = 0; i < shifted_ids.size(); i++) { auto shifted_id = shifted_ids[i]; auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; - *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); + polynomial_get_all[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); } // Fill in lagrange even polynomial @@ -716,15 +716,15 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes ProverPolynomialIds prover_polynomial_ids; std::vector polynomial_container; std::vector polynomial_ids; - auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { + auto polynomial_id_get_all = prover_polynomial_ids.get_all(); + auto polynomial_get_all = prover_polynomials.get_all(); + for (size_t i = 0; i < polynomial_id_get_all.size(); i++) { Polynomial temporary_polynomial(circuit_size); // Allocate polynomials polynomial_container.push_back(temporary_polynomial); // Push sequential ids to polynomial ids polynomial_ids.push_back(i); - *polynomial_id_pointer_view[i] = polynomial_ids[i]; + polynomial_id_get_all[i] = polynomial_ids[i]; } // Get ids of shifted polynomials and put them in a set auto shifted_ids = prover_polynomial_ids.get_shifted(); @@ -733,9 +733,9 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes shifted_id_set.emplace(id); } // Assign spans to non-shifted prover polynomials - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + for (size_t i = 0; i < polynomial_get_all.size(); i++) { if (!shifted_id_set.contains(i)) { - *polynomial_pointer_view[i] = polynomial_container[i]; + polynomial_get_all[i] = polynomial_container[i]; } } @@ -743,7 +743,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes for (size_t i = 0; i < shifted_ids.size(); i++) { auto shifted_id = shifted_ids[i]; auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; - *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); + polynomial_get_all[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); } // Fill in lagrange odd polynomial (the only non-witness one we are using) @@ -1135,15 +1135,15 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) ProverPolynomialIds prover_polynomial_ids; std::vector polynomial_container; std::vector polynomial_ids; - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + auto polynomial_get_all = prover_polynomials.get_all(); + auto polynomial_id_get_all = prover_polynomial_ids.get_all(); + for (size_t i = 0; i < polynomial_get_all.size(); i++) { Polynomial temporary_polynomial(circuit_size); // Allocate polynomials polynomial_container.push_back(temporary_polynomial); // Push sequential ids to polynomial ids polynomial_ids.push_back(i); - *polynomial_id_pointer_view[i] = polynomial_ids[i]; + polynomial_id_get_all[i] = polynomial_ids[i]; } // Get ids of shifted polynomials and put them in a set auto shifted_ids = prover_polynomial_ids.get_shifted(); @@ -1152,9 +1152,9 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) shifted_id_set.emplace(id); } // Assign spans to non-shifted prover polynomials - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + for (size_t i = 0; i < polynomial_get_all.size(); i++) { if (!shifted_id_set.contains(i)) { - *polynomial_pointer_view[i] = polynomial_container[i]; + polynomial_get_all[i] = polynomial_container[i]; } } @@ -1162,7 +1162,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) for (size_t i = 0; i < shifted_ids.size(); i++) { auto shifted_id = shifted_ids[i]; auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; - *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); + polynomial_get_all[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); } // Copy values of wires used in the non-native field relation from the circuit builder