Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy_prover_internal.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
17
18namespace bb {
19
25template <class DeciderProvingKeys_> class ProtogalaxyProverInternal {
26 public:
28 using Flavor = typename DeciderPKs::Flavor;
29 using FF = typename Flavor::FF;
33 using Relations = typename Flavor::Relations;
34 using AllValues = typename Flavor::AllValues;
36 static constexpr size_t NUM_KEYS = DeciderProvingKeys_::NUM;
43
44 // The length of ExtendedUnivariate is the largest length (==max_relation_degree + 1) of a univariate polynomial
45 // obtained by composing a relation with Lagrange polynomial-linear combination of NUM-many decider pks, with
46 // relation parameters regarded as variables.
48 // Represents the total length of the combiner univariate, obtained by combining the already folded relations with
49 // the folded relation batching challenge.
52
73 using ShortUnivariates = typename Flavor::template ProverUnivariates<DeciderPKs::NUM>;
74
76 typename Flavor::template ProverUnivariatesWithOptimisticSkipping<ExtendedUnivariate::LENGTH,
77 /* SKIP_COUNT= */ DeciderPKs::NUM - 1>;
78
81
82 using TupleOfTuplesOfUnivariates = typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariates<DeciderPKs::NUM>;
84 typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariatesNoOptimisticSkipping<DeciderPKs::NUM>;
85
86 using RelationEvaluations = decltype(create_tuple_of_arrays_of_values<typename Flavor::Relations>());
87
89
91
95
110 const SubrelationSeparators& challenges,
111 FF& linearly_dependent_contribution)
112 {
113 // Initialize result with the contribution from the first subrelation
114 FF linearly_independent_contribution = std::get<0>(evals)[0];
115 size_t idx = 0;
116
117 auto scale_by_challenge_and_accumulate =
118 [&]<size_t relation_idx, size_t subrelation_idx, typename Element>(Element& element) {
119 if constexpr (!(relation_idx == 0 && subrelation_idx == 0)) {
121 // Accumulate scaled subrelation contribution
122 const Element contribution = element * challenges[idx++];
123 if constexpr (subrelation_is_linearly_independent<Relation, subrelation_idx>()) {
124 linearly_independent_contribution += contribution;
125 } else {
126 linearly_dependent_contribution += contribution;
127 }
128 }
129 };
130 RelationUtils::apply_to_tuple_of_arrays_elements(scale_by_challenge_and_accumulate, evals);
131 return linearly_independent_contribution;
132 }
133
147 const SubrelationSeparators& alphas,
148 const RelationParameters<FF>& relation_parameters)
149
150 {
151
152 PROFILE_THIS_NAME("ProtogalaxyProver_::compute_row_evaluations");
153
154 const size_t polynomial_size = polynomials.get_polynomial_size();
155 Polynomial<FF> aggregated_relation_evaluations(polynomial_size);
156
157 // Determine the number of threads over which to distribute the work
158 const size_t num_threads = compute_num_threads(polynomial_size);
159
160 std::vector<FF> linearly_dependent_contribution_accumulators(num_threads);
161
162 // Distribute the execution trace rows across threads so that each handles an equal number of active rows
164 num_threads, polynomial_size, /*use_prev_accumulator_tracker=*/true);
165
166 parallel_for(num_threads, [&](size_t thread_idx) {
168 for (size_t idx = range.first; idx < range.second; idx++) {
169 const AllValues row = polynomials.get_row(idx);
170 // Evaluate all subrelations on given row. Separator is 1 since we are not summing across rows here.
171 const RelationEvaluations evals =
172 RelationUtils::accumulate_relation_evaluations(row, relation_parameters, FF(1));
173
174 // Sum against challenges alpha
175 aggregated_relation_evaluations.at(idx) = process_subrelation_evaluations(
176 evals, alphas, linearly_dependent_contribution_accumulators[thread_idx]);
177 }
178 }
179 });
180
181 aggregated_relation_evaluations.at(0) += sum(linearly_dependent_contribution_accumulators);
182
183 return aggregated_relation_evaluations;
184 }
191 std::span<const FF> deltas,
192 const std::vector<std::vector<FF>>& prev_level_coeffs,
193 size_t level = 1)
194 {
195 if (level == betas.size()) {
196 return prev_level_coeffs[0];
197 }
198
199 auto degree = level + 1;
200 auto prev_level_width = prev_level_coeffs.size();
201 std::vector<std::vector<FF>> level_coeffs(prev_level_width / 2, std::vector<FF>(degree + 1, 0));
203 prev_level_width / 2,
204 [&](size_t parent) {
205 size_t node = parent * 2;
206 std::copy(prev_level_coeffs[node].begin(), prev_level_coeffs[node].end(), level_coeffs[parent].begin());
207 for (size_t d = 0; d < degree; d++) {
208 level_coeffs[parent][d] += prev_level_coeffs[node + 1][d] * betas[level];
209 level_coeffs[parent][d + 1] += prev_level_coeffs[node + 1][d] * deltas[level];
210 }
211 },
212 /* overestimate */ thread_heuristics::FF_MULTIPLICATION_COST * degree * 3);
213 return construct_coefficients_tree(betas, deltas, level_coeffs, level + 1);
214 }
215
227 std::span<const FF> deltas,
228 const Polynomial<FF>& full_honk_evaluations)
229 {
230 auto width = full_honk_evaluations.size();
231 std::vector<std::vector<FF>> first_level_coeffs(width / 2, std::vector<FF>(2, 0));
233 width / 2,
234 [&](size_t parent) {
235 size_t node = parent * 2;
236 first_level_coeffs[parent][0] =
237 full_honk_evaluations[node] + full_honk_evaluations[node + 1] * betas[0];
238 first_level_coeffs[parent][1] = full_honk_evaluations[node + 1] * deltas[0];
239 },
240 /* overestimate */ thread_heuristics::FF_MULTIPLICATION_COST * 3);
241 return construct_coefficients_tree(betas, deltas, first_level_coeffs);
242 }
243
248 const std::vector<FF>& deltas)
249 {
250 PROFILE_THIS();
251 auto full_honk_evaluations =
252 compute_row_evaluations(accumulator->polynomials, accumulator->alphas, accumulator->relation_parameters);
253 const auto betas = accumulator->gate_challenges;
254 BB_ASSERT_EQ(betas.size(), deltas.size());
255 const size_t log_circuit_size = accumulator->log_dyadic_size();
256
257 // Compute the perturbator using only the first log_circuit_size-many betas/deltas
258 std::vector<FF> perturbator = construct_perturbator_coefficients(std::span{ betas.data(), log_circuit_size },
259 std::span{ deltas.data(), log_circuit_size },
260 full_honk_evaluations);
261
262 // Populate the remaining coefficients with zeros to reach the required constant size
263 for (size_t idx = log_circuit_size; idx < CONST_PG_LOG_N; ++idx) {
264 perturbator.emplace_back(FF(0));
265 }
266 return Polynomial<FF>{ perturbator };
267 }
268
277 template <size_t skip_count = 0>
278 BB_INLINE static void extend_univariates(ExtendedUnivariatesType& extended_univariates,
279 const DeciderPKs& keys,
280 const size_t row_idx)
281 {
282 if constexpr (Flavor::USE_SHORT_MONOMIALS) {
283 extended_univariates = std::move(keys.row_to_short_univariates(row_idx));
284 } else {
285 auto incoming_univariates =
286 keys.template row_to_univariates<ExtendedUnivariate::LENGTH, skip_count>(row_idx);
287 for (auto [extended_univariate, incoming_univariate] :
288 zip_view(extended_univariates.get_all(), incoming_univariates)) {
289 incoming_univariate.template self_extend_from<NUM_KEYS>();
290 extended_univariate = std::move(incoming_univariate);
291 }
292 }
293 }
294
308 template <size_t relation_idx = 0>
310 const ExtendedUnivariatesType& extended_univariates,
311 const UnivariateRelationParameters& relation_parameters,
312 const FF& scaling_factor)
313 {
315
316 // Check if the relation is skippable to speed up accumulation
317 if constexpr (!isSkippable<Relation, decltype(extended_univariates)>) {
318 // If not, accumulate normally
319 Relation::accumulate(std::get<relation_idx>(univariate_accumulators),
320 extended_univariates,
321 relation_parameters,
322 scaling_factor);
323 } else {
324 // If so, only compute the contribution if the relation is active
325 if (!Relation::skip(extended_univariates)) {
326 Relation::accumulate(std::get<relation_idx>(univariate_accumulators),
327 extended_univariates,
328 relation_parameters,
329 scaling_factor);
330 }
331 }
332
333 // Repeat for the next relation.
334 if constexpr (relation_idx + 1 < Flavor::NUM_RELATIONS) {
335 accumulate_relation_univariates<relation_idx + 1>(
336 univariate_accumulators, extended_univariates, relation_parameters, scaling_factor);
337 }
338 }
339
352 const GateSeparatorPolynomial<FF>& gate_separators,
353 const UnivariateRelationParameters& relation_parameters,
355 TupleOfTuplesOfUnivariates& univariate_accumulators)
356 {
357 PROFILE_THIS();
358
359 // Determine the number of threads over which to distribute the work
360 // The polynomial size is given by the virtual size since the computation includes
361 // the incoming key which could have nontrivial values on the larger domain in case of overflow.
362 const size_t common_polynomial_size = keys[0]->polynomials.w_l.virtual_size();
363 const size_t num_threads = compute_num_threads(common_polynomial_size);
364
365 // Univariates are optimized for usual PG, but we need the unoptimized version for tests (it's a version that
366 // doesn't skip computation), so we need to define types depending on the template instantiation
367 using ThreadAccumulators = TupleOfTuplesOfUnivariates;
368
369 // Construct univariate accumulator containers; one per thread
370 // Note: std::vector will trigger {}-initialization of the contents. Therefore no need to zero the univariates.
371 std::vector<ThreadAccumulators> thread_univariate_accumulators(num_threads);
372
373 // Distribute the execution trace rows across threads so that each handles an equal number of active rows
374 trace_usage_tracker.construct_thread_ranges(num_threads, common_polynomial_size);
375
376 // Accumulate the contribution from each sub-relation
377 parallel_for(num_threads, [&](size_t thread_idx) {
378 // Construct extended univariates containers; one per thread
379 ExtendedUnivariatesType extended_univariates;
380
382 for (size_t idx = range.first; idx < range.second; idx++) {
383 // Instantiate univariates, possibly with skipping toto ignore computation in those indices
384 // (they are still available for skipping relations, but all derived univariate will ignore
385 // those evaluations) No need to initialize extended_univariates to 0, as it's assigned to.
386 constexpr size_t skip_count = DeciderPKs::NUM - 1;
387 extend_univariates<skip_count>(extended_univariates, keys, idx);
388
389 const FF pow_challenge = gate_separators[idx];
390
391 // Accumulate the i-th row's univariate contribution. Note that the relation parameters passed
392 // to this function have already been folded. Moreover, linear-dependent relations that act over
393 // the entire execution trace rather than on rows, will not be multiplied by the pow challenge.
394 accumulate_relation_univariates(thread_univariate_accumulators[thread_idx],
395 extended_univariates,
396 relation_parameters, // these parameters have already been folded
397 pow_challenge);
398 }
399 }
400 });
401
402 RelationUtils::zero_univariates(univariate_accumulators);
403 // Accumulate the per-thread univariate accumulators into a single set of accumulators
404 for (auto& accumulators : thread_univariate_accumulators) {
405 RelationUtils::add_nested_tuples(univariate_accumulators, accumulators);
406 }
407 // This does nothing if TupleOfTuples is TupleOfTuplesOfUnivariates
408 TupleOfTuplesOfUnivariatesNoOptimisticSkipping deoptimized_univariates =
409 deoptimize_univariates(univariate_accumulators);
410 // Batch the univariate contributions from each sub-relation to obtain the round univariate
411 return batch_over_relations(deoptimized_univariates, alphas);
412 }
413
415 const GateSeparatorPolynomial<FF>& gate_separators,
416 const UnivariateRelationParameters& relation_parameters,
418 {
419 // Note: {} is required to initialize the tuple contents. Otherwise the univariates contain garbage.
420 TupleOfTuplesOfUnivariates accumulators{};
421 return compute_combiner(keys, gate_separators, relation_parameters, alphas, accumulators);
422 }
423
429 template <typename TupleOfTuplesOfUnivariatePossiblyOptimistic>
431 const TupleOfTuplesOfUnivariatePossiblyOptimistic& tup)
432 {
433 // If input does not have optimized operators, return the input
434 if constexpr (std::same_as<TupleOfTuplesOfUnivariatePossiblyOptimistic,
436 return tup;
437 }
438
439 const auto deoptimize = [&]<size_t outer_idx, size_t inner_idx>(auto& element) {
440 auto& element_with_skipping = std::get<inner_idx>(std::get<outer_idx>(tup));
441 element = element_with_skipping.convert();
442 };
443
444 // Note: {} is required to initialize the tuple contents. Otherwise the univariates contain garbage.
446 RelationUtils::apply_to_tuple_of_tuples(result, deoptimize);
447 return result;
448 }
449
451 TupleOfTuplesOfUnivariatesNoOptimisticSkipping& univariate_accumulators,
453 {
454 auto result =
455 std::get<0>(std::get<0>(univariate_accumulators)).template extend_to<DeciderPKs::BATCHED_EXTENDED_LENGTH>();
456
457 size_t idx = 0;
458 const auto scale_and_sum = [&]<size_t outer_idx, size_t inner_idx>(auto& element) {
459 if constexpr (outer_idx == 0 && inner_idx == 0) {
460 return;
461 }
462
463 auto extended = element.template extend_to<DeciderPKs::BATCHED_EXTENDED_LENGTH>();
464 extended *= alphas[idx];
465 result += extended;
466 idx++;
467 };
468
469 RelationUtils::apply_to_tuple_of_tuples(univariate_accumulators, scale_and_sum);
470 RelationUtils::zero_univariates(univariate_accumulators);
471
472 return result;
473 }
474
477 {
478 FF vanishing_polynomial_at_challenge;
480 constexpr FF inverse_two = FF(2).invert();
481
482 if constexpr (DeciderPKs::NUM == 2) {
483 vanishing_polynomial_at_challenge = challenge * (challenge - FF(1));
484 lagranges = { FF(1) - challenge, challenge };
485 } else if constexpr (DeciderPKs::NUM == 3) {
486 vanishing_polynomial_at_challenge = challenge * (challenge - FF(1)) * (challenge - FF(2));
487 lagranges = { (FF(1) - challenge) * (FF(2) - challenge) * inverse_two,
488 challenge * (FF(2) - challenge),
489 challenge * (challenge - FF(1)) / FF(2) };
490 } else if constexpr (DeciderPKs::NUM == 4) {
491 constexpr FF inverse_six = FF(6).invert();
492 vanishing_polynomial_at_challenge =
493 challenge * (challenge - FF(1)) * (challenge - FF(2)) * (challenge - FF(3));
494 lagranges = { (FF(1) - challenge) * (FF(2) - challenge) * (FF(3) - challenge) * inverse_six,
495 challenge * (FF(2) - challenge) * (FF(3) - challenge) * inverse_two,
496 challenge * (challenge - FF(1)) * (FF(3) - challenge) * inverse_two,
497 challenge * (challenge - FF(1)) * (challenge - FF(2)) * inverse_six };
498 }
499 static_assert(DeciderPKs::NUM < 5);
500
501 return { vanishing_polynomial_at_challenge, lagranges };
502 }
503
508 FF perturbator_evaluation, ExtendedUnivariateWithRandomization combiner)
509 {
510 std::array<FF, DeciderPKs::BATCHED_EXTENDED_LENGTH - DeciderPKs::NUM> combiner_quotient_evals = {};
511
512 constexpr FF inverse_two = FF(2).invert();
513 constexpr FF inverse_six = FF(6).invert();
514 for (size_t point = DeciderPKs::NUM; point < combiner.size(); point++) {
515 auto idx = point - DeciderPKs::NUM;
516 FF lagrange_0;
517 FF vanishing_polynomial;
518 if constexpr (DeciderPKs::NUM == 2) {
519 lagrange_0 = FF(1) - FF(point);
520 vanishing_polynomial = FF(point) * (FF(point) - 1);
521 } else if constexpr (DeciderPKs::NUM == 3) {
522 lagrange_0 = (FF(1) - FF(point)) * (FF(2) - FF(point)) * inverse_two;
523 vanishing_polynomial = FF(point) * (FF(point) - 1) * (FF(point) - 2);
524 } else if constexpr (DeciderPKs::NUM == 4) {
525 lagrange_0 = (FF(1) - FF(point)) * (FF(2) - FF(point)) * (FF(3) - FF(point)) * inverse_six;
526 vanishing_polynomial = FF(point) * (FF(point) - 1) * (FF(point) - 2) * (FF(point) - 3);
527 }
528 static_assert(DeciderPKs::NUM < 5);
529
530 combiner_quotient_evals[idx] =
531 (combiner.value_at(point) - perturbator_evaluation * lagrange_0) * vanishing_polynomial.invert();
532 }
533
535 }
536
541 template <typename ExtendedRelationParameters>
542 static ExtendedRelationParameters compute_extended_relation_parameters(const DeciderPKs& keys)
543 {
544 using UnivariateParameter = typename ExtendedRelationParameters::DataType;
545 ExtendedRelationParameters result;
546 size_t param_idx = 0;
547 for (auto& param : result.get_to_fold()) {
549 size_t key_idx = 0;
550 for (auto& key : keys) {
551 tmp.value_at(key_idx) = key->relation_parameters.get_to_fold()[param_idx];
552 key_idx++;
553 }
554 param = tmp.template extend_to<UnivariateParameter::LENGTH, UnivariateParameter::SKIP_COUNT>();
555 param_idx++;
556 }
557 return result;
558 }
559
565 {
567 size_t alpha_idx = 0;
568 for (auto& alpha : result) {
570 size_t key_idx = 0;
571 for (auto& key : keys) {
572 tmp.value_at(key_idx) = key->alphas[alpha_idx];
573 key_idx++;
574 }
575 alpha = tmp.template extend_to<DeciderPKs::BATCHED_EXTENDED_LENGTH>();
576 alpha_idx++;
577 }
578 return result;
579 }
580
588 static size_t compute_num_threads(const size_t domain_size)
589 {
590 const size_t max_num_threads = get_num_cpus_pow2(); // number of available threads (power of 2)
591 const size_t min_iterations_per_thread =
592 1 << 6; // min number of iterations for which we'll spin up a unique thread
593 const size_t desired_num_threads = domain_size / min_iterations_per_thread;
594 size_t num_threads = std::min(desired_num_threads, max_num_threads); // fewer than max if justified
595 num_threads = num_threads > 0 ? num_threads : 1; // ensure num threads is >= 1
596
597 return num_threads;
598 }
599};
600} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:59
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
A container for the prover polynomials handles.
Curve::ScalarField FF
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
static constexpr size_t MAX_TOTAL_RELATION_LENGTH
static constexpr size_t NUM_SUBRELATIONS
static constexpr size_t NUM_RELATIONS
Relations_< FF > Relations
static constexpr bool USE_SHORT_MONOMIALS
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
std::size_t size() const
A purely static class (never add state to this!) consisting of functions used by the Protogalaxy prov...
static Univariate< FF, DeciderPKs::BATCHED_EXTENDED_LENGTH, DeciderPKs::NUM > compute_combiner_quotient(FF perturbator_evaluation, ExtendedUnivariateWithRandomization combiner)
Compute the combiner quotient defined as $K$ polynomial in the paper.
ExtendedUnivariateWithRandomization compute_combiner(const DeciderPKs &keys, const GateSeparatorPolynomial< FF > &gate_separators, const UnivariateRelationParameters &relation_parameters, const UnivariateSubrelationSeparators &alphas, TupleOfTuplesOfUnivariates &univariate_accumulators)
Compute the combiner polynomial $G$ in the Protogalaxy paper.
static std::vector< FF > construct_coefficients_tree(std::span< const FF > betas, std::span< const FF > deltas, const std::vector< std::vector< FF > > &prev_level_coeffs, size_t level=1)
Recursively compute the parent nodes of each level in the tree, starting from the leaves....
static BB_INLINE void accumulate_relation_univariates(TupleOfTuplesOfUnivariates &univariate_accumulators, const ExtendedUnivariatesType &extended_univariates, const UnivariateRelationParameters &relation_parameters, const FF &scaling_factor)
Add the value of each relation over univariates to an appropriate accumulator.
decltype(create_tuple_of_arrays_of_values< typename Flavor::Relations >()) RelationEvaluations
ExecutionTraceUsageTracker trace_usage_tracker
static ExtendedUnivariateWithRandomization batch_over_relations(TupleOfTuplesOfUnivariatesNoOptimisticSkipping &univariate_accumulators, const UnivariateSubrelationSeparators &alphas)
typename Flavor::template ProverUnivariatesWithOptimisticSkipping< ExtendedUnivariate::LENGTH, DeciderPKs::NUM - 1 > ExtendedUnivariates
static size_t compute_num_threads(const size_t domain_size)
Determine number of threads for multithreading of perterbator/combiner operations.
typename Flavor::ProverPolynomials ProverPolynomials
static ExtendedRelationParameters compute_extended_relation_parameters(const DeciderPKs &keys)
For each parameter, collect the value in each decider pvogin key in a univariate and extend for use i...
typename Flavor::SubrelationSeparators SubrelationSeparators
std::array< Univariate< FF, DeciderPKs::BATCHED_EXTENDED_LENGTH >, Flavor::NUM_SUBRELATIONS - 1 > UnivariateSubrelationSeparators
static BB_INLINE void extend_univariates(ExtendedUnivariatesType &extended_univariates, const DeciderPKs &keys, const size_t row_idx)
Prepare a univariate polynomial for relation execution in one step of the combiner construction.
Polynomial< FF > compute_perturbator(const std::shared_ptr< const DeciderPK > &accumulator, const std::vector< FF > &deltas)
Construct the power perturbator polynomial F(X) in coefficient form from the accumulator.
typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariates< DeciderPKs::NUM > TupleOfTuplesOfUnivariates
typename DeciderPKs::DeciderPK DeciderPK
static std::pair< typename DeciderPKs::FF, std::array< typename DeciderPKs::FF, DeciderPKs::NUM > > compute_vanishing_polynomial_and_lagranges(const FF &challenge)
static UnivariateSubrelationSeparators compute_and_extend_alphas(const DeciderPKs &keys)
Combine the relation batching parameters (alphas) from each decider proving key into a univariate for...
std::conditional_t< Flavor::USE_SHORT_MONOMIALS, ShortUnivariates, ExtendedUnivariates > ExtendedUnivariatesType
typename Flavor::template ProverUnivariates< DeciderPKs::NUM > ShortUnivariates
ShortUnivariates is an optimisation to improve the evaluation of Flavor relations when the output is ...
ProtogalaxyProverInternal(ExecutionTraceUsageTracker trace_usage_tracker=ExecutionTraceUsageTracker{})
typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariatesNoOptimisticSkipping< DeciderPKs::NUM > TupleOfTuplesOfUnivariatesNoOptimisticSkipping
static FF process_subrelation_evaluations(const RelationEvaluations &evals, const SubrelationSeparators &challenges, FF &linearly_dependent_contribution)
A scale subrelations evaluations by challenges ('alphas') and part of the linearly dependent relation...
static std::vector< FF > construct_perturbator_coefficients(std::span< const FF > betas, std::span< const FF > deltas, const Polynomial< FF > &full_honk_evaluations)
We construct the coefficients of the perturbator polynomial in O(n) time following the technique in C...
ExtendedUnivariateWithRandomization compute_combiner(const DeciderPKs &keys, const GateSeparatorPolynomial< FF > &gate_separators, const UnivariateRelationParameters &relation_parameters, const UnivariateSubrelationSeparators &alphas)
static TupleOfTuplesOfUnivariatesNoOptimisticSkipping deoptimize_univariates(const TupleOfTuplesOfUnivariatePossiblyOptimistic &tup)
Convert univariates from optimized form to regular.
Polynomial< FF > compute_row_evaluations(const ProverPolynomials &polynomials, const SubrelationSeparators &alphas, const RelationParameters< FF > &relation_parameters)
Compute the values of the aggregated relation evaluations at each row in the execution trace,...
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static void apply_to_tuple_of_arrays_elements(Operation &&operation, const tuple_type &tuple)
Recursive template function to apply a specific operation on each element of several arrays in a tupl...
Definition utils.hpp:259
static void zero_univariates(auto &tuple)
Set all coefficients of Univariates to zero.
Definition utils.hpp:61
static constexpr void add_nested_tuples(Tuple &tuple_1, const Tuple &tuple_2)
Componentwise addition of nested tuples (tuples of tuples)
Definition utils.hpp:117
static void apply_to_tuple_of_tuples(auto &tuple, Operation &&operation)
General purpose method for applying an operation to a tuple of tuples of Univariates.
Definition utils.hpp:43
static RelationEvaluations accumulate_relation_evaluations(const PolynomialEvaluations &evaluations, const Parameters &relation_parameters, const FF &partial_evaluation_result)
Calculate the contribution of each relation to the expected value of the full Honk relation.
Definition utils.hpp:155
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
Fr & value_at(size_t i)
static constexpr size_t LENGTH
#define BB_INLINE
The templates defined herein facilitate sharing the relation arithmetic between the prover and the ve...
std::vector< FF > betas
The challenges .
constexpr size_t FF_MULTIPLICATION_COST
Definition thread.hpp:136
Entry point for Barretenberg command-line interface.
size_t get_num_cpus_pow2()
Definition thread.hpp:18
Inner sum(Cont< Inner, Args... > const &in)
Definition container.hpp:70
void parallel_for_heuristic(size_t num_points, const std::function< void(size_t, size_t, size_t)> &func, size_t heuristic_cost)
Split a loop into several loops running in parallel based on operations in 1 iteration.
Definition thread.cpp:132
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
Definition thread.cpp:72
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define PROFILE_THIS()
Definition op_count.hpp:15
#define PROFILE_THIS_NAME(name)
Definition op_count.hpp:16
Curve::Element Element
static constexpr size_t BATCHED_EXTENDED_LENGTH
Flavor::template ProverUnivariates< 2 > row_to_short_univariates(size_t row_idx) const
static constexpr size_t EXTENDED_LENGTH
DeciderProvingKey_< Flavor > DeciderPK
static constexpr size_t NUM_SUBRELATIONS
static constexpr size_t NUM
Tracks the cumulative usage of the execution trace across a series of circuits.
std::vector< std::vector< Range > > thread_ranges
void construct_thread_ranges(const size_t num_threads, const size_t full_domain_size, bool use_prev_accumulator=false)
Construct ranges of execution trace rows that evenly distribute the active content of the trace acros...
Implementation of the methods for the -polynomials used in Protogalaxy and -polynomials used in Sumch...
Container for parameters used by the grand product (permutation, lookup) Honk relations.
constexpr field invert() const noexcept