Skip to content

Commit 946e1f3

Browse files
committed
tighter bounds
1 parent 4c353b0 commit 946e1f3

File tree

8 files changed

+17
-31
lines changed

8 files changed

+17
-31
lines changed

barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,8 @@ class ECCVMFlavor {
714714
}
715715
PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
716716
{
717-
size_t halved_circuit_size = circuit_size / 2;
718717
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
719-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
720-
poly = Polynomial(desired_size, halved_circuit_size);
718+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
721719
}
722720
}
723721
};

barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,8 @@ class MegaFlavor {
631631
}
632632
PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
633633
{
634-
size_t halved_circuit_size = circuit_size / 2;
635634
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
636-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
637-
poly = Polynomial(desired_size, halved_circuit_size);
635+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
638636
}
639637
}
640638
};

barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,8 @@ class UltraFlavor {
507507
PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
508508
{
509509
PROFILE_THIS_NAME("PartiallyEvaluatedMultivariates constructor");
510-
size_t halved_circuit_size = circuit_size / 2;
511510
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
512-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
513-
poly = Polynomial(desired_size, halved_circuit_size);
511+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
514512
}
515513
}
516514
};

barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ template <typename Flavor> class SumcheckProver {
354354
transcript->template get_challenge<FF>("Sumcheck:u_" + std::to_string(round_idx));
355355
multivariate_challenge.emplace_back(round_challenge);
356356
// Prepare sumcheck book-keeping table for the next round
357-
partially_evaluate(partially_evaluated_polynomials, round.round_size, round_challenge);
357+
partially_evaluate(partially_evaluated_polynomials, round_idx, round_challenge);
358358
// Prepare evaluation masking and libra structures for the next round (for ZK Flavors)
359359
zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
360360
row_disabling_polynomial.update_evaluations(round_challenge, round_idx);
@@ -444,18 +444,18 @@ template <typename Flavor> class SumcheckProver {
444444
* After the final update, i.e. when \f$ i = d-1 \f$, the upper row of the table contains the evaluations of Honk
445445
* polynomials at the challenge point \f$ (u_0,\ldots, u_{d-1}) \f$.
446446
* @param polynomials Honk polynomials at initialization; partially evaluated polynomials in subsequent rounds
447-
* @param round_size \f$2^{d-i}\f$
447+
* @param round_index \f$d-i\f$
448448
* @param round_challenge \f$u_i\f$
449449
*/
450-
void partially_evaluate(auto& polynomials, size_t round_size, FF round_challenge)
450+
void partially_evaluate(auto& polynomials, size_t round_index, FF round_challenge)
451451
{
452452
auto pep_view = partially_evaluated_polynomials.get_all();
453453
auto poly_view = polynomials.get_all();
454454
// after the first round, operate in place on partially_evaluated_polynomials
455455
parallel_for(poly_view.size(), [&](size_t j) {
456-
for (size_t i = 0; i < round_size; i += 2) {
457-
pep_view[j].set_if_valid_index(
458-
i >> 1, poly_view[j][i] + round_challenge * (poly_view[j][i + 1] - poly_view[j][i]));
456+
const auto& poly = poly_view[j];
457+
for (size_t i = 0; i < poly.end_index() / round_index; i += 2) {
458+
pep_view[j].set_if_valid_index(i >> 1, poly[i] + round_challenge * (poly[i + 1] - poly[i]));
459459
}
460460
});
461461
};
@@ -464,14 +464,14 @@ template <typename Flavor> class SumcheckProver {
464464
* Specialization for array, see \ref bb::SumcheckProver<Flavor>::partially_evaluate "generic version".
465465
*/
466466
template <typename PolynomialT, std::size_t N>
467-
void partially_evaluate(std::array<PolynomialT, N>& polynomials, size_t round_size, FF round_challenge)
467+
void partially_evaluate(std::array<PolynomialT, N>& polynomials, size_t round_index, FF round_challenge)
468468
{
469469
auto pep_view = partially_evaluated_polynomials.get_all();
470470
// after the first round, operate in place on partially_evaluated_polynomials
471471
parallel_for(polynomials.size(), [&](size_t j) {
472-
for (size_t i = 0; i < round_size; i += 2) {
473-
pep_view[j].set_if_valid_index(
474-
i >> 1, polynomials[j][i] + round_challenge * (polynomials[j][i + 1] - polynomials[j][i]));
472+
const auto& poly = polynomials[j];
473+
for (size_t i = 0; i < poly.end_index() / round_index; i += 2) {
474+
pep_view[j].set_if_valid_index(i >> 1, poly[i] + round_challenge * (poly[i + 1] - poly[i]));
475475
}
476476
});
477477
};

barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,8 @@ class TranslatorFlavor {
743743
}
744744
PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
745745
{
746-
size_t halved_circuit_size = circuit_size / 2;
747746
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
748-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
749-
poly = Polynomial(desired_size, halved_circuit_size);
747+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
750748
}
751749
}
752750
};

barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,8 @@ class AvmFlavor {
406406
PartiallyEvaluatedMultivariates(const size_t circuit_size);
407407
PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
408408
{
409-
size_t halved_circuit_size = circuit_size / 2;
410409
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
411-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
412-
poly = Polynomial(desired_size, halved_circuit_size);
410+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
413411
}
414412
}
415413
};

barretenberg/cpp/src/barretenberg/vm2/generated/flavor.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ AvmFlavor::PartiallyEvaluatedMultivariates::PartiallyEvaluatedMultivariates(cons
8888
AvmFlavor::PartiallyEvaluatedMultivariates::PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials,
8989
size_t circuit_size)
9090
{
91-
size_t halved_circuit_size = circuit_size / 2;
9291
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
93-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
94-
poly = Polynomial(desired_size, halved_circuit_size);
92+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
9593
}
9694
}
9795

bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs

+1-3
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ AvmFlavor::PartiallyEvaluatedMultivariates::PartiallyEvaluatedMultivariates(cons
8787
AvmFlavor::PartiallyEvaluatedMultivariates::PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials,
8888
size_t circuit_size)
8989
{
90-
size_t halved_circuit_size = circuit_size / 2;
9190
for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
92-
size_t desired_size = std::min(full_poly.end_index(), halved_circuit_size);
93-
poly = Polynomial(desired_size, halved_circuit_size);
91+
poly = Polynomial(full_poly.size() / 2, circuit_size / 2, full_poly.start_index() / 2);
9492
}
9593
}
9694

0 commit comments

Comments
 (0)