1
1
#pragma once
2
+ #include " barretenberg/commitment_schemes/commitment_key.hpp"
2
3
#include " barretenberg/common/ref_vector.hpp"
3
4
#include " barretenberg/common/zip_view.hpp"
4
5
#include " barretenberg/polynomials/polynomial.hpp"
@@ -34,8 +35,8 @@ template <typename Curve> class ZeroMorphProver_ {
34
35
using Commitment = typename Curve::AffineElement;
35
36
using Polynomial = barretenberg::Polynomial<FF>;
36
37
37
- // TODO(#742): Set this N_max to be the number of G1 elements in the mocked zeromorph SRS once it's in place. (Then,
38
- // eventually, set it based on the real SRS). For now we set it to be large but more or less arbitrary.
38
+ // TODO(#742): Set this N_max to be the number of G1 elements in the mocked zeromorph SRS once it's in place.
39
+ // (Then, eventually, set it based on the real SRS). For now we set it to be large but more or less arbitrary.
39
40
static const size_t N_max = 1 << 22 ;
40
41
41
42
public:
@@ -59,7 +60,7 @@ template <typename Curve> class ZeroMorphProver_ {
59
60
* @param u_challenge Multivariate challenge u = (u_0, ..., u_{d-1})
60
61
* @return std::vector<Polynomial> The quotients q_k
61
62
*/
62
- static std::vector<Polynomial> compute_multilinear_quotients (Polynomial polynomial, std::span<FF> u_challenge)
63
+ static std::vector<Polynomial> compute_multilinear_quotients (Polynomial polynomial, std::span<const FF> u_challenge)
63
64
{
64
65
size_t log_N = numeric::get_msb (polynomial.size ());
65
66
// The size of the multilinear challenge must equal the log of the polynomial size
@@ -74,12 +75,12 @@ template <typename Curve> class ZeroMorphProver_ {
74
75
75
76
// Compute the coefficients of q_{n-1}
76
77
size_t size_q = 1 << (log_N - 1 );
77
- Polynomial q = Polynomial ( size_q) ;
78
+ Polynomial q{ size_q } ;
78
79
for (size_t l = 0 ; l < size_q; ++l) {
79
80
q[l] = polynomial[size_q + l] - polynomial[l];
80
81
}
81
82
82
- quotients[log_N - 1 ] = q;
83
+ quotients[log_N - 1 ] = q. share () ;
83
84
84
85
std::vector<FF> f_k;
85
86
f_k.resize (size_q);
@@ -94,13 +95,13 @@ template <typename Curve> class ZeroMorphProver_ {
94
95
}
95
96
96
97
size_q = size_q / 2 ;
97
- q = Polynomial ( size_q) ;
98
+ q = Polynomial{ size_q } ;
98
99
99
100
for (size_t l = 0 ; l < size_q; ++l) {
100
101
q[l] = f_k[size_q + l] - f_k[l];
101
102
}
102
103
103
- quotients[log_N - k - 1 ] = q;
104
+ quotients[log_N - k - 1 ] = q. share () ;
104
105
g = f_k;
105
106
}
106
107
@@ -206,7 +207,7 @@ template <typename Curve> class ZeroMorphProver_ {
206
207
Polynomial& g_batched,
207
208
std::vector<Polynomial>& quotients,
208
209
FF v_evaluation,
209
- std::span<FF> u_challenge,
210
+ std::span<const FF> u_challenge,
210
211
FF x_challenge,
211
212
std::vector<Polynomial> concatenation_groups_batched = {})
212
213
{
@@ -305,8 +306,8 @@ template <typename Curve> class ZeroMorphProver_ {
305
306
}
306
307
307
308
/* *
308
- * @brief Prove a set of multilinear evaluation claims for unshifted polynomials f_i and to-be-shifted polynomials
309
- * g_i
309
+ * @brief Prove a set of multilinear evaluation claims for unshifted polynomials f_i and to-be-shifted
310
+ * polynomials g_i
310
311
*
311
312
* @param f_polynomials Unshifted polynomials
312
313
* @param g_polynomials To-be-shifted polynomials (of which the shifts h_i were evaluated by sumcheck)
@@ -315,23 +316,22 @@ template <typename Curve> class ZeroMorphProver_ {
315
316
* @param commitment_key
316
317
* @param transcript
317
318
*/
318
- static void prove (const auto & f_polynomials,
319
- const auto & g_polynomials,
320
- auto & & f_evaluations,
321
- auto & & g_shift_evaluations,
322
- auto & multilinear_challenge,
323
- auto & commitment_key,
324
- auto transcript,
325
- const std::vector<std::span<FF> >& concatenated_polynomials = {},
319
+ static void prove (const std::vector<Polynomial> & f_polynomials,
320
+ const std::vector<Polynomial> & g_polynomials,
321
+ const std::vector<FF> & f_evaluations,
322
+ const std::vector<FF> & g_shift_evaluations,
323
+ const std::vector<FF> & multilinear_challenge,
324
+ const std::shared_ptr<CommitmentKey<Curve>> & commitment_key,
325
+ const std::shared_ptr<BaseTranscript>& transcript,
326
+ const std::vector<Polynomial >& concatenated_polynomials = {},
326
327
const std::vector<FF>& concatenated_evaluations = {},
327
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/743) remove span
328
- const std::vector<RefVector<std::span<FF>>>& concatenation_groups = {})
328
+ const std::vector<RefVector<Polynomial>>& concatenation_groups = {})
329
329
{
330
330
// Generate batching challenge \rho and powers 1,...,\rho^{m-1}
331
331
const FF rho = transcript->get_challenge (" rho" );
332
332
333
333
// Extract multilinear challenge u and claimed multilinear evaluations from Sumcheck output
334
- std::span<FF> u_challenge = multilinear_challenge;
334
+ std::span<const FF> u_challenge = multilinear_challenge;
335
335
size_t log_N = u_challenge.size ();
336
336
size_t N = 1 << log_N;
337
337
@@ -341,16 +341,16 @@ template <typename Curve> class ZeroMorphProver_ {
341
341
// v = sum_{i=0}^{m-1}\rho^i*f_i(u) + sum_{i=0}^{l-1}\rho^{m+i}*h_i(u).
342
342
// Note: g_batched is formed from the to-be-shifted polynomials, but the batched evaluation incorporates the
343
343
// evaluations produced by sumcheck of h_i = g_i_shifted.
344
- auto batched_evaluation = FF ( 0 ) ;
344
+ FF batched_evaluation{ 0 } ;
345
345
Polynomial f_batched (N); // batched unshifted polynomials
346
- FF batching_scalar = FF ( 1 ) ;
346
+ FF batching_scalar{ 1 } ;
347
347
for (auto [f_poly, f_eval] : zip_view (f_polynomials, f_evaluations)) {
348
348
f_batched.add_scaled (f_poly, batching_scalar);
349
349
batched_evaluation += batching_scalar * f_eval;
350
350
batching_scalar *= rho;
351
351
}
352
352
353
- Polynomial g_batched (N) ; // batched to-be-shifted polynomials
353
+ Polynomial g_batched{ N } ; // batched to-be-shifted polynomials
354
354
for (auto [g_poly, g_shift_eval] : zip_view (g_polynomials, g_shift_evaluations)) {
355
355
g_batched.add_scaled (g_poly, batching_scalar);
356
356
batched_evaluation += batching_scalar * g_shift_eval;
@@ -360,7 +360,6 @@ template <typename Curve> class ZeroMorphProver_ {
360
360
size_t num_groups = concatenation_groups.size ();
361
361
size_t num_chunks_per_group = concatenation_groups.empty () ? 0 : concatenation_groups[0 ].size ();
362
362
// Concatenated polynomials
363
- // std::vector<Polynomial> concatenated_polynomials;
364
363
Polynomial concatenated_batched (N);
365
364
366
365
// construct concatention_groups_batched
@@ -381,7 +380,7 @@ template <typename Curve> class ZeroMorphProver_ {
381
380
382
381
// Compute the full batched polynomial f = f_batched + g_batched.shifted() = f_batched + h_batched. This is the
383
382
// polynomial for which we compute the quotients q_k and prove f(u) = v_batched.
384
- auto f_polynomial = f_batched;
383
+ Polynomial f_polynomial = f_batched;
385
384
f_polynomial += g_batched.shifted ();
386
385
f_polynomial += concatenated_batched;
387
386
@@ -625,8 +624,8 @@ template <typename Curve> class ZeroMorphVerifier_ {
625
624
}
626
625
627
626
/* *
628
- * @brief Verify a set of multilinear evaluation claims for unshifted polynomials f_i and to-be-shifted polynomials
629
- * g_i
627
+ * @brief Verify a set of multilinear evaluation claims for unshifted polynomials f_i and to-be-shifted
628
+ * polynomials g_i
630
629
*
631
630
* @param commitments Commitments to polynomials f_i and g_i (unshifted and to-be-shifted)
632
631
* @param claimed_evaluations Claimed evaluations v_i = f_i(u) and w_i = h_i(u) = g_i_shifted(u)
@@ -710,4 +709,4 @@ template <typename Curve> class ZeroMorphVerifier_ {
710
709
}
711
710
};
712
711
713
- } // namespace proof_system::honk::pcs::zeromorph
712
+ } // namespace proof_system::honk::pcs::zeromorph
0 commit comments