@@ -95,6 +95,7 @@ template <class Fr> inline std::vector<Fr> powers_of_evaluation_challenge(const
95
95
96
96
template <typename Curve> class GeminiProver_ {
97
97
using Fr = typename Curve::ScalarField;
98
+ using Commitment = typename Curve::AffineElement;
98
99
using Polynomial = bb::Polynomial<Fr>;
99
100
using Claim = ProverOpeningClaim<Curve>;
100
101
@@ -168,7 +169,7 @@ template <typename Curve> class GeminiVerifier_ {
168
169
169
170
// compute vector of powers of random evaluation point r
170
171
const Fr r = transcript->template get_challenge <Fr>(" Gemini:r" );
171
- const std::vector<Fr> r_squares = gemini::powers_of_evaluation_challenge (r, num_variables );
172
+ const std::vector<Fr> r_squares = gemini::powers_of_evaluation_challenge (r, CONST_PROOF_SIZE_LOG_N );
172
173
173
174
// Get evaluations a_i, i = 0,...,m-1 from transcript
174
175
const std::vector<Fr> evaluations = get_gemini_evaluations (num_variables, transcript);
@@ -197,22 +198,24 @@ template <typename Curve> class GeminiVerifier_ {
197
198
return fold_polynomial_opening_claims;
198
199
}
199
200
200
- static std::vector<Commitment> get_fold_commitments (const size_t log_circuit_size, auto & transcript)
201
+ static std::vector<Commitment> get_fold_commitments ([[maybe_unused]] const size_t log_circuit_size,
202
+ auto & transcript)
201
203
{
202
204
std::vector<Commitment> fold_commitments;
203
- fold_commitments.reserve (log_circuit_size - 1 );
204
- for (size_t i = 0 ; i < log_circuit_size - 1 ; ++i) {
205
+ fold_commitments.reserve (CONST_PROOF_SIZE_LOG_N - 1 );
206
+ for (size_t i = 0 ; i < CONST_PROOF_SIZE_LOG_N - 1 ; ++i) {
205
207
const Commitment commitment =
206
208
transcript->template receive_from_prover <Commitment>(" Gemini:FOLD_" + std::to_string (i + 1 ));
207
209
fold_commitments.emplace_back (commitment);
208
210
}
209
211
return fold_commitments;
210
212
}
211
- static std::vector<Fr> get_gemini_evaluations (const size_t log_circuit_size, auto & transcript)
213
+ static std::vector<Fr> get_gemini_evaluations ([[maybe_unused]] const size_t log_circuit_size, auto & transcript)
212
214
{
213
215
std::vector<Fr> gemini_evaluations;
214
- gemini_evaluations.reserve (log_circuit_size);
215
- for (size_t i = 1 ; i <= log_circuit_size; ++i) {
216
+ gemini_evaluations.reserve (CONST_PROOF_SIZE_LOG_N);
217
+
218
+ for (size_t i = 1 ; i <= CONST_PROOF_SIZE_LOG_N; ++i) {
216
219
const Fr evaluation = transcript->template receive_from_prover <Fr>(" Gemini:a_" + std::to_string (i));
217
220
gemini_evaluations.emplace_back (evaluation);
218
221
}
@@ -241,29 +244,43 @@ template <typename Curve> class GeminiVerifier_ {
241
244
* @param fold_polynomial_evals Evaluations \f$ A_{i-1}(-r^{2^{i-1}}) \f$.
242
245
* @return Evaluation \f$ A_0(r) \f$.
243
246
*/
244
- static Fr compute_gemini_batched_univariate_evaluation (size_t evaluation_point_size,
245
- Fr& batched_eval_accumulator,
246
- std::span<const Fr> evaluation_point,
247
- std::span<const Fr> challenge_powers,
248
- std::span<const Fr> fold_polynomial_evals)
247
+ static Fr compute_gemini_batched_univariate_evaluation (
248
+ const size_t num_variables,
249
+ Fr& batched_eval_accumulator,
250
+ std::span<const Fr> evaluation_point, // CONST_PROOF_SIZE
251
+ std::span<const Fr> challenge_powers, // r_squares CONST_PROOF_SIZE_LOG_N
252
+ std::span<const Fr> fold_polynomial_evals)
249
253
{
250
- const size_t num_variables = evaluation_point_size;
251
-
252
254
const auto & evals = fold_polynomial_evals;
253
255
254
256
// Solve the sequence of linear equations
255
- for (size_t l = num_variables ; l != 0 ; --l) {
257
+ for (size_t l = CONST_PROOF_SIZE_LOG_N ; l != 0 ; --l) {
256
258
// Get r²⁽ˡ⁻¹⁾
257
259
const Fr& challenge_power = challenge_powers[l - 1 ];
258
- // Get A₍ₗ₋₁₎(−r²⁽ˡ⁻¹⁾)
259
- const Fr& eval_neg = evals[l - 1 ];
260
260
// Get uₗ₋₁
261
261
const Fr& u = evaluation_point[l - 1 ];
262
+ const Fr& eval_neg = evals[l - 1 ];
263
+ // Get A₍ₗ₋₁₎(−r²⁽ˡ⁻¹⁾)
262
264
// Compute the numerator
263
- batched_eval_accumulator =
265
+ Fr batched_eval_round_acc =
264
266
((challenge_power * batched_eval_accumulator * 2 ) - eval_neg * (challenge_power * (Fr (1 ) - u) - u));
265
267
// Divide by the denominator
266
- batched_eval_accumulator *= (challenge_power * (Fr (1 ) - u) + u).invert ();
268
+ batched_eval_round_acc *= (challenge_power * (Fr (1 ) - u) + u).invert ();
269
+
270
+ bool is_dummy_round = (l > num_variables);
271
+
272
+ if constexpr (Curve::is_stdlib_type) {
273
+ auto builder = evaluation_point[0 ].get_context ();
274
+ // TODO(https://github.com/AztecProtocol/barretenberg/issues/1114): insecure!
275
+ stdlib::bool_t dummy_round = stdlib::bool_t (builder, is_dummy_round);
276
+ batched_eval_accumulator =
277
+ Fr::conditional_assign (dummy_round, batched_eval_accumulator, batched_eval_round_acc);
278
+
279
+ } else {
280
+ if (!is_dummy_round) {
281
+ batched_eval_accumulator = batched_eval_round_acc;
282
+ }
283
+ }
267
284
}
268
285
269
286
return batched_eval_accumulator;
0 commit comments