From 6742cae9da30a04873433cdf9ee7a7d34091bf6b Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 10 Sep 2024 18:03:53 +0000 Subject: [PATCH] remove poly downsizing, other changes --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 2 +- .../src/barretenberg/eccvm/eccvm_flavor.hpp | 2 +- .../composer/composer_lib.hpp | 5 +---- .../library/grand_product_library.hpp | 2 +- .../barretenberg/polynomials/polynomial.hpp | 21 +++++++++---------- .../stdlib_circuit_builders/ultra_flavor.hpp | 2 +- .../ultra_keccak_flavor.hpp | 2 +- .../translator_vm/translator_flavor.hpp | 2 +- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index bf67d4664fa..d318d9e337a 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -643,7 +643,7 @@ void prove(const std::string& bytecodePath, const std::string& witnessPath, cons acir_proofs::AcirComposer acir_composer{ 0, verbose_logging }; acir_composer.create_circuit(constraint_system, witness); - init_bn254_crs(acir_composer.get_dyadic_circuit_size() * 2); + init_bn254_crs(acir_composer.get_dyadic_circuit_size()); acir_composer.init_proving_key(); auto proof = acir_composer.create_proof(); diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp index a31ab916815..8ffc37964e9 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp @@ -350,7 +350,7 @@ class ECCVMFlavor { { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) for (auto& poly : this->get_all()) { - poly = Polynomial(circuit_size / 2, circuit_size / 2); + poly = Polynomial(circuit_size / 2); } } }; 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 24623f5509d..35c2a5ec02a 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 @@ -53,9 +53,6 @@ void construct_lookup_read_counts(typename Flavor::Polynomial& read_counts, { // 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(); - read_counts = typename Flavor::Polynomial(circuit.get_tables_size(), dyadic_circuit_size, /*start index*/ offset); - // TODO(AD) we dont need to initialize read_tags - read_tags = typename Flavor::Polynomial(circuit.get_tables_size(), dyadic_circuit_size, /*start index*/ offset); size_t table_offset = offset; // offset of the present table in the table polynomials // loop over all tables used in the circuit; each table contains data about the lookups made on it @@ -71,7 +68,7 @@ void construct_lookup_read_counts(typename Flavor::Polynomial& read_counts, // increment the read count at the corresponding index in the full polynomial size_t index_in_poly = table_offset + index_in_table; - read_counts.at(index_in_poly) = read_counts[index_in_poly] + 1; + read_counts.at(index_in_poly)++; read_tags.at(index_in_poly) = 1; // tag is 1 if entry has been read 1 or more times } table_offset += table.size(); // set the offset of the next table within the polynomials diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp index 3bb700812b4..bf2859365d0 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp @@ -73,7 +73,7 @@ void compute_grand_product(typename Flavor::ProverPolynomials& full_polynomials, // calling get_row which creates full copies. avoid? for (size_t i = start; i < end; ++i) { for (auto [eval, full_poly] : zip_view(evaluations.get_all(), full_polynomials.get_all())) { - eval = full_poly.size() > i ? full_poly.get(i) : 0; + eval = full_poly.size() > i ? full_poly[i] : 0; } numerator.at(i) = GrandProdRelation::template compute_grand_product_numerator( evaluations, relation_parameters); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index 0ad42be2823..fa6608456c5 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -172,17 +172,16 @@ template class Polynomial { Fr compute_kate_opening_coefficients(const Fr& z) requires polynomial_arithmetic::SupportsFFT; - // /** - // * @brief Divides p(X) by (X-r₁)⋯(X−rₘ) in-place. - // * Assumes that p(rⱼ)=0 for all j - // * - // * @details we specialize the method when only a single root is given. - // * if one of the roots is 0, then we first factor all other roots. - // * dividing by X requires only a left shift of all coefficient. - // * - // * @param roots list of roots (r₁,…,rₘ) - // */ - // void factor_roots(std::span roots) { polynomial_arithmetic::factor_roots(std::span{ *this }, roots); }; + /** + * @brief Divides p(X) by (X-r) in-place. + * Assumes that p(rⱼ)=0 for all j + * + * @details we specialize the method when only a single root is given. + * if one of the roots is 0, then we first factor all other roots. + * dividing by X requires only a left shift of all coefficient. + * + * @param root a single root r + */ void factor_roots(const Fr& root) { polynomial_arithmetic::factor_roots(coeffs(), root); }; Fr evaluate(const Fr& z, size_t target_size) const; 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 3360b9e4434..06458e92161 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp @@ -563,7 +563,7 @@ class UltraFlavor { // Storage is only needed after the first partial evaluation, hence polynomials of // size (n / 2) for (auto& poly : this->get_all()) { - poly = Polynomial(circuit_size / 2, circuit_size / 2); + poly = Polynomial(circuit_size / 2); } } }; 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 b4e99238c75..0b9485e4122 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 @@ -521,7 +521,7 @@ class UltraKeccakFlavor { // Storage is only needed after the first partial evaluation, hence polynomials of // size (n / 2) for (auto& poly : this->get_all()) { - poly = Polynomial(circuit_size / 2, circuit_size / 2); + poly = Polynomial(circuit_size / 2); } } }; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp index 2f1c206fa13..205d0dd9853 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp @@ -919,7 +919,7 @@ class TranslatorFlavor { { // Storage is only needed after the first partial evaluation, hence polynomials of size (n / 2) for (auto& poly : this->get_all()) { - poly = Polynomial(circuit_size / 2, circuit_size / 2); + poly = Polynomial(circuit_size / 2); } } };