@@ -171,8 +171,7 @@ template <typename Flavor> class SumcheckProver {
171
171
: multivariate_n(multivariate_n)
172
172
, multivariate_d(numeric::get_msb(multivariate_n))
173
173
, transcript(transcript)
174
- , round(multivariate_n)
175
- , partially_evaluated_polynomials(multivariate_n){};
174
+ , round(multivariate_n){};
176
175
177
176
/* *
178
177
* @brief Non-ZK version: Compute round univariate, place it in transcript, compute challenge, partially evaluate.
@@ -189,17 +188,19 @@ template <typename Flavor> class SumcheckProver {
189
188
const RelationSeparator alpha,
190
189
const std::vector<FF>& gate_challenges)
191
190
{
192
-
193
191
bb::GateSeparatorPolynomial<FF> gate_separators (gate_challenges, multivariate_d);
194
192
195
193
multivariate_challenge.reserve (multivariate_d);
196
194
// In the first round, we compute the first univariate polynomial and populate the book-keeping table of
197
195
// #partially_evaluated_polynomials, which has \f$ n/2 \f$ rows and \f$ N \f$ columns. When the Flavor has ZK,
198
196
// compute_univariate also takes into account the zk_sumcheck_data.
199
197
auto round_univariate = round .compute_univariate (full_polynomials, relation_parameters, gate_separators, alpha);
198
+ // Initialize the partially evaluated polynomials which will be used in the following rounds.
199
+ // This will use the information in the structured full polynomials to save memory if possible.
200
+ partially_evaluated_polynomials = PartiallyEvaluatedMultivariates (full_polynomials, multivariate_n);
201
+
200
202
vinfo (" starting sumcheck rounds..." );
201
203
{
202
-
203
204
PROFILE_THIS_NAME (" rest of sumcheck round 1" );
204
205
205
206
// Place the evaluations of the round univariate into transcript.
@@ -210,11 +211,10 @@ template <typename Flavor> class SumcheckProver {
210
211
partially_evaluate (full_polynomials, multivariate_n, round_challenge);
211
212
gate_separators.partially_evaluate (round_challenge);
212
213
round .round_size = round .round_size >> 1 ; // TODO(#224)(Cody): Maybe partially_evaluate should do this and
213
- // release memory? // All but final round
214
- // We operate on partially_evaluated_polynomials in place.
214
+ // release memory? // All but final round
215
+ // We operate on partially_evaluated_polynomials in place.
215
216
}
216
217
for (size_t round_idx = 1 ; round_idx < multivariate_d; round_idx++) {
217
-
218
218
PROFILE_THIS_NAME (" sumcheck loop" );
219
219
220
220
// Write the round univariate to the transcript
@@ -296,9 +296,12 @@ template <typename Flavor> class SumcheckProver {
296
296
alpha,
297
297
zk_sumcheck_data,
298
298
row_disabling_polynomial);
299
+ // Initialize the partially evaluated polynomials which will be used in the following rounds.
300
+ // This will use the information in the structured full polynomials to save memory if possible.
301
+ partially_evaluated_polynomials = PartiallyEvaluatedMultivariates (full_polynomials, multivariate_n);
302
+
299
303
vinfo (" starting sumcheck rounds..." );
300
304
{
301
-
302
305
PROFILE_THIS_NAME (" rest of sumcheck round 1" );
303
306
304
307
if constexpr (!IsGrumpkinFlavor<Flavor>) {
@@ -451,7 +454,8 @@ template <typename Flavor> class SumcheckProver {
451
454
// after the first round, operate in place on partially_evaluated_polynomials
452
455
parallel_for (poly_view.size (), [&](size_t j) {
453
456
for (size_t i = 0 ; i < round_size; i += 2 ) {
454
- pep_view[j].at (i >> 1 ) = poly_view[j][i] + round_challenge * (poly_view[j][i + 1 ] - poly_view[j][i]);
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]));
455
459
}
456
460
});
457
461
};
@@ -466,23 +470,23 @@ template <typename Flavor> class SumcheckProver {
466
470
// after the first round, operate in place on partially_evaluated_polynomials
467
471
parallel_for (polynomials.size (), [&](size_t j) {
468
472
for (size_t i = 0 ; i < round_size; i += 2 ) {
469
- pep_view[j].at (i >> 1 ) =
470
- polynomials[j][i] + round_challenge * (polynomials[j][i + 1 ] - polynomials[j][i]);
473
+ pep_view[j].set_if_valid_index (
474
+ i >> 1 , polynomials[j][i] + round_challenge * (polynomials[j][i + 1 ] - polynomials[j][i]) );
471
475
}
472
476
});
473
477
};
474
478
475
479
/* *
476
- * @brief This method takes the book-keeping table containing partially evaluated prover polynomials and creates a
477
- * vector containing the evaluations of all prover polynomials at the point \f$ (u_0, \ldots, u_{d-1} )\f$.
478
- * For ZK Flavors: this method takes the book-keeping table containing partially evaluated prover polynomials
479
- and creates a vector containing the evaluations of all witness polynomials at the point \f$ (u_0, \ldots, u_{d-1} )\f$
480
- masked by the terms \f$ \texttt{eval_masking_scalars}_j\cdot \sum u_i(1-u_i)\f$ and the evaluations of all non-witness
481
- polynomials that are sent in clear.
482
- *
483
- * @param partially_evaluated_polynomials
484
- * @param multivariate_evaluations
485
- */
480
+ * @brief This method takes the book-keeping table containing partially evaluated prover polynomials and creates a
481
+ * vector containing the evaluations of all prover polynomials at the point \f$ (u_0, \ldots, u_{d-1} )\f$.
482
+ * For ZK Flavors: this method takes the book-keeping table containing partially evaluated prover polynomials
483
+ * and creates a vector containing the evaluations of all witness polynomials at the point \f$ (u_0, \ldots, u_{d-1}
484
+ * )\f$ masked by the terms \f$ \texttt{eval_masking_scalars}_j\cdot \sum u_i(1-u_i)\f$ and the evaluations of all
485
+ * non-witness polynomials that are sent in clear.
486
+ *
487
+ * @param partially_evaluated_polynomials
488
+ * @param multivariate_evaluations
489
+ */
486
490
ClaimedEvaluations extract_claimed_evaluations (PartiallyEvaluatedMultivariates& partially_evaluated_polynomials)
487
491
{
488
492
ClaimedEvaluations multivariate_evaluations;
@@ -513,7 +517,6 @@ polynomials that are sent in clear.
513
517
std::vector<bb::Polynomial<FF>>& round_univariates,
514
518
std::vector<std::array<FF, 3 >>& round_univariate_evaluations)
515
519
{
516
-
517
520
const std::string idx = std::to_string (round_idx);
518
521
519
522
// Transform to monomial form and commit to it
0 commit comments