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
18
19namespace bb {
20
26template <class ProverInstance> class ProtogalaxyProverInternal {
27 public:
29 using FF = typename Flavor::FF;
32 using Relations = typename Flavor::Relations;
33 using AllValues = typename Flavor::AllValues;
36
37 static constexpr size_t EXTENDED_LENGTH = computed_extended_length<Flavor>();
38 static constexpr size_t BATCHED_EXTENDED_LENGTH = computed_batched_extended_length<Flavor>();
39 static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS;
40
43 bb::RelationParameters<Univariate<FF, EXTENDED_LENGTH, 0, /*skip_count=*/SKIP_COUNT>>;
45
46 // Univariates that interpolate polynomial evaluations at a given vertex across two instances
48 // Combiner univariate
50
70 using ShortUnivariates = typename Flavor::template ProverUnivariates<NUM_INSTANCES>;
71
73 typename Flavor::template ProverUnivariatesWithOptimisticSkipping<ExtendedUnivariate::LENGTH,
74 /*skip_count=*/SKIP_COUNT>;
75
78
79 using TupleOfTuplesOfUnivariates = typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariates<NUM_INSTANCES>;
81 typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariatesNoOptimisticSkipping<NUM_INSTANCES>;
82
83 using RelationEvaluations = decltype(create_tuple_of_arrays_of_values<typename Flavor::Relations>());
84
86
90
101 template <size_t skip_count = 0> static auto row_to_univariates(const ProverInstances& instances, size_t row_idx)
102 {
103 using ContainerType =
105 typename Flavor::template ProverUnivariates<2>,
107 // As a practical measure, get the first prover instance's view to deduce the array type
108 std::array<decltype(instances[0]->polynomials.get_all()), NUM_INSTANCES> views;
109 views[0] = instances[0]->polynomials.get_all();
110 views[1] = instances[1]->polynomials.get_all();
111
112 ContainerType results;
113 // Set the size corresponding to the number of rows in the execution trace
114 // Iterate over the prover polynomials' views corresponding to each prover instance
115 for (size_t inst_idx = 0; auto& get_all : views) {
116 // Iterate over all columns in the trace execution of an prover instance and extract their value at row_idx.
117 if constexpr (Flavor::USE_SHORT_MONOMIALS) {
118 // In this case, the elements of the ContainerType are AllEntities, so we need to get the underlying
119 // polynomials via get_all()
120 for (auto [result, poly_ptr] : zip_view(results.get_all(), get_all)) {
121 result.evaluations[inst_idx] = poly_ptr[row_idx];
122 }
123 } else {
124 for (auto [result, poly_ptr] : zip_view(results, get_all)) {
125 result.evaluations[inst_idx] = poly_ptr[row_idx];
126 }
127 }
128 inst_idx++;
129 }
130 return results;
131 }
132
147 const SubrelationSeparators& challenges,
148 FF& linearly_dependent_contribution)
149 {
150 // Initialize result with the contribution from the first subrelation
151 FF linearly_independent_contribution = std::get<0>(evals)[0];
152 size_t idx = 0;
153
154 auto scale_by_challenge_and_accumulate =
155 [&]<size_t relation_idx, size_t subrelation_idx, typename Element>(Element& element) {
156 if constexpr (!(relation_idx == 0 && subrelation_idx == 0)) {
158 // Accumulate scaled subrelation contribution
159 const Element contribution = element * challenges[idx++];
160 if constexpr (subrelation_is_linearly_independent<Relation, subrelation_idx>()) {
161 linearly_independent_contribution += contribution;
162 } else {
163 linearly_dependent_contribution += contribution;
164 }
165 }
166 };
167 RelationUtils::apply_to_tuple_of_arrays_elements(scale_by_challenge_and_accumulate, evals);
168 return linearly_independent_contribution;
169 }
170
184 const SubrelationSeparators& alphas,
185 const RelationParameters<FF>& relation_parameters)
186
187 {
188
189 BB_BENCH_NAME("ProtogalaxyProver_::compute_row_evaluations");
190
191 const size_t polynomial_size = polynomials.get_polynomial_size();
192 Polynomial<FF> aggregated_relation_evaluations(polynomial_size);
193
194 // Determine the number of threads over which to distribute the work
195 const size_t num_threads = compute_num_threads(polynomial_size);
196
197 std::vector<FF> linearly_dependent_contribution_accumulators(num_threads);
198
199 // Distribute the execution trace rows across threads so that each handles an equal number of active rows
200 trace_usage_tracker.construct_thread_ranges(num_threads, polynomial_size, /*use_prev_accumulator=*/true);
201
202 parallel_for(num_threads, [&](size_t thread_idx) {
204 for (size_t idx = range.first; idx < range.second; idx++) {
205 const AllValues row = polynomials.get_row(idx);
206 // Evaluate all subrelations on given row. Separator is 1 since we are not summing across rows here.
207 const RelationEvaluations evals =
208 RelationUtils::accumulate_relation_evaluations(row, relation_parameters, FF(1));
209
210 // Sum against challenges alpha
211 aggregated_relation_evaluations.at(idx) = process_subrelation_evaluations(
212 evals, alphas, linearly_dependent_contribution_accumulators[thread_idx]);
213 }
214 }
215 });
216
217 aggregated_relation_evaluations.at(0) += sum(linearly_dependent_contribution_accumulators);
218
219 return aggregated_relation_evaluations;
220 }
266 std::span<const FF> deltas,
267 std::vector<FF>& current_level_buffer,
268 size_t current_width,
269 size_t current_degree)
270 {
271 if (betas.size() == 1) {
272 return std::vector<FF>(current_level_buffer.begin(),
273 current_level_buffer.begin() + static_cast<std::ptrdiff_t>(current_degree));
274 }
275
276 size_t num_levels = betas.size();
277
278 // Pre-allocate buffers with maximum size needed
279 // At each level i, we have width/(2^i) nodes, each with degree i+1
280 // Calculate total size needed for the next level buffer
281 size_t max_next_buffer_size = 0;
282 size_t temp_width = current_width;
283 for (size_t level = 1; level < num_levels; ++level) {
284 temp_width /= 2;
285 size_t degree = level + 1;
286 max_next_buffer_size = std::max(max_next_buffer_size, temp_width * (degree + 1));
287 }
288
289 std::vector<FF> next_level_buffer(max_next_buffer_size);
290
291 // Iterate through levels 1 to num_levels-1
292 for (size_t level = 1; level < num_levels; ++level) {
293 size_t next_degree = level + 1;
294 size_t next_width = current_width / 2;
295 size_t next_stride = next_degree + 1;
296 size_t current_stride = current_degree;
297
298 // Parallel initialization and computation
300 next_width,
301 [&](size_t parent) {
302 size_t node = parent * 2;
303 size_t parent_offset = parent * next_stride;
304 size_t left_child_offset = node * current_stride;
305 size_t right_child_offset = (node + 1) * current_stride;
306
307 // Copy left child coefficients and zero-initialize remaining
308 for (size_t d = 0; d < current_stride; d++) {
309 next_level_buffer[parent_offset + d] = current_level_buffer[left_child_offset + d];
310 }
311 for (size_t d = current_stride; d < next_stride; d++) {
312 next_level_buffer[parent_offset + d] = FF(0);
313 }
314
315 // Add right child contribution: n_r * (β_i + δ_i X)
316 for (size_t d = 0; d < current_stride; d++) {
317 next_level_buffer[parent_offset + d] +=
318 current_level_buffer[right_child_offset + d] * betas[level];
319 next_level_buffer[parent_offset + d + 1] +=
320 current_level_buffer[right_child_offset + d] * deltas[level];
321 }
322 },
323 /* overestimate */ thread_heuristics::FF_MULTIPLICATION_COST * next_degree * 3);
324
325 // Swap buffers: next becomes current
326 std::swap(current_level_buffer, next_level_buffer);
327 current_width = next_width;
328 current_degree = next_stride;
329 }
330
331 // Return the final result (the root node)
332 return std::vector<FF>(current_level_buffer.begin(),
333 current_level_buffer.begin() + static_cast<std::ptrdiff_t>(current_degree));
334 }
335
391 std::span<const FF> deltas,
392 const Polynomial<FF>& full_honk_evaluations)
393 {
394 BB_BENCH();
395
396 auto width = full_honk_evaluations.size();
397
398 // Construct first level coefficients (degree 1 polynomials from leaf pairs)
399 // Use flat buffer: each node has 2 coefficients (degree 1)
400 size_t first_level_width = width / 2;
401 std::vector<FF> first_level_buffer(first_level_width * 2);
402
404 first_level_width,
405 [&](size_t parent) {
406 size_t node = parent * 2;
407 size_t offset = parent * 2;
408 first_level_buffer[offset] = full_honk_evaluations[node] + full_honk_evaluations[node + 1] * betas[0];
409 first_level_buffer[offset + 1] = full_honk_evaluations[node + 1] * deltas[0];
410 },
411 /* overestimate */ thread_heuristics::FF_MULTIPLICATION_COST * 3);
412
413 // Build the tree iteratively in-place
414 return construct_coefficients_tree(betas, deltas, first_level_buffer, first_level_width, 2);
415 }
416
422 const std::vector<FF>& deltas)
423 {
424 BB_BENCH();
425 auto full_honk_evaluations =
426 compute_row_evaluations(accumulator->polynomials, accumulator->alphas, accumulator->relation_parameters);
427 const auto betas = accumulator->gate_challenges;
428 BB_ASSERT_EQ(betas.size(), deltas.size());
429 const size_t log_circuit_size = accumulator->log_dyadic_size();
430
431 // Compute the perturbator using only the first log_circuit_size-many betas/deltas
432 std::vector<FF> perturbator = construct_perturbator_coefficients(std::span{ betas.data(), log_circuit_size },
433 std::span{ deltas.data(), log_circuit_size },
434 full_honk_evaluations);
435
436 // Populate the remaining coefficients with zeros to reach the required constant size
437 for (size_t idx = log_circuit_size; idx < CONST_PG_LOG_N; ++idx) {
438 perturbator.emplace_back(FF(0));
439 }
440
441 // Check that the perturbator zeroth coefficient is equal to the target sum stored in the accumulator
442 BB_ASSERT_EQ(perturbator[0],
443 accumulator->target_sum,
444 "ProtogalaxyProver: the zeroth coefficient of the perturbator is different from the target sum "
445 "stored in the accumulator.");
446
447 return Polynomial<FF>{ perturbator };
448 }
449
456 template <size_t skip_count = 0>
457 BB_INLINE static void extend_univariates(ExtendedUnivariatesType& extended_univariates,
458 const ProverInstances& instances,
459 const size_t row_idx)
460 {
461 if constexpr (Flavor::USE_SHORT_MONOMIALS) {
462 extended_univariates = std::move(row_to_univariates(instances, row_idx));
463 } else {
464 auto incoming_univariates = row_to_univariates<skip_count>(instances, row_idx);
465 for (auto [extended_univariate, incoming_univariate] :
466 zip_view(extended_univariates.get_all(), incoming_univariates)) {
467 incoming_univariate.template self_extend_from<NUM_INSTANCES>();
468 extended_univariate = std::move(incoming_univariate);
469 }
470 }
471 }
472
486 template <size_t relation_idx = 0>
488 const ExtendedUnivariatesType& extended_univariates,
489 const UnivariateRelationParameters& relation_parameters,
490 const FF& scaling_factor)
491 {
493
494 // Check if the relation is skippable to speed up accumulation
495 if constexpr (!isSkippable<Relation, decltype(extended_univariates)>) {
496 // If not, accumulate normally
497 Relation::accumulate(std::get<relation_idx>(univariate_accumulators),
498 extended_univariates,
499 relation_parameters,
500 scaling_factor);
501 } else {
502 // If so, only compute the contribution if the relation is active
503 if (!Relation::skip(extended_univariates)) {
504 Relation::accumulate(std::get<relation_idx>(univariate_accumulators),
505 extended_univariates,
506 relation_parameters,
507 scaling_factor);
508 }
509 }
510
511 // Repeat for the next relation.
512 if constexpr (relation_idx + 1 < Flavor::NUM_RELATIONS) {
513 accumulate_relation_univariates<relation_idx + 1>(
514 univariate_accumulators, extended_univariates, relation_parameters, scaling_factor);
515 }
516 }
517
533 const GateSeparatorPolynomial<FF>& gate_separators,
534 const UnivariateRelationParameters& relation_parameters,
536 TupleOfTuplesOfUnivariates& univariate_accumulators)
537 {
538 BB_BENCH();
539
540 // Determine the number of threads over which to distribute the work
541 // The polynomial size is given by the virtual size since the computation includes
542 // the incoming key which could have nontrivial values on the larger domain in case of overflow.
543 const size_t common_polynomial_size = instances[0]->polynomials.w_l.virtual_size();
544 const size_t num_threads = compute_num_threads(common_polynomial_size);
545
546 using ThreadAccumulators = TupleOfTuplesOfUnivariates;
547
548 // Construct univariate accumulator containers; one per thread
549 // Note: std::vector will trigger {}-initialization of the contents. Therefore no need to zero the univariates.
550 std::vector<ThreadAccumulators> thread_univariate_accumulators(num_threads);
551
552 // Distribute the execution trace rows across threads so that each handles an equal number of active rows
553 trace_usage_tracker.construct_thread_ranges(num_threads, common_polynomial_size);
554
555 // Accumulate the contribution from each sub-relation
556 parallel_for(num_threads, [&](size_t thread_idx) {
557 // Construct extended univariates containers; one per thread
558 ExtendedUnivariatesType extended_univariates;
559
561 for (size_t idx = range.first; idx < range.second; idx++) {
562 // Instantiate extended univariates: they contain the evaluations of the prover polynomials from the
563 // instances being folded and are extended to length EXTENDED_LENGTH, which is the maximum length of
564 // a folded subrelation polynomial. We set skip_count to NUM_INSTANCES - 1 = 1 because the
565 // relations evaluate to zero on valid keys, and the evaluations of the combiner on the point 1,
566 // is exactly the relation contributions coming from the key being folded (note that the Univariate
567 // class skips computing evaluations between 1 and skip_count).
568 //
569 // The values of the evaluations are still available for skipping relations, but all
570 // derived univariates (coming from addition, multiplication, etc) will ignore those evaluations.
571 //
572 // No need to initialize extended_univariates to 0, as it's assigned to a value in the following
573 // function.
574 extend_univariates<SKIP_COUNT>(extended_univariates, instances, idx);
575
576 const FF pow_challenge = gate_separators[idx];
577
578 // Accumulate the i-th row's univariate contribution. Note that the relation parameters passed
579 // to this function have already been folded. Moreover, linear-dependent relations that act over
580 // the entire execution trace rather than on rows will not be multiplied by the pow challenge.
581 accumulate_relation_univariates(thread_univariate_accumulators[thread_idx],
582 extended_univariates,
583 relation_parameters, // these parameters have already been folded
584 pow_challenge);
585 }
586 }
587 });
588
589 RelationUtils::zero_univariates(univariate_accumulators);
590 // Accumulate the per-thread univariate accumulators into a single set of accumulators
591 for (auto& accumulators : thread_univariate_accumulators) {
592 RelationUtils::add_nested_tuples(univariate_accumulators, accumulators);
593 }
594 // This does nothing if TupleOfTuples is TupleOfTuplesOfUnivariates
595 TupleOfTuplesOfUnivariatesNoOptimisticSkipping deoptimized_univariates =
596 deoptimize_univariates(univariate_accumulators);
597 // Batch the univariate contributions from each folded sub-relation using the folded batching challenges to
598 // obtain the combiner
599 return batch_over_relations(deoptimized_univariates, alphas);
600 }
601
607 template <typename TupleOfTuplesOfUnivariatePossiblyOptimistic>
609 const TupleOfTuplesOfUnivariatePossiblyOptimistic& tup)
610 {
611 // If input does not have optimized operators, return the input
612 if constexpr (std::same_as<TupleOfTuplesOfUnivariatePossiblyOptimistic,
614 return tup;
615 }
616
617 const auto deoptimize = [&]<size_t outer_idx, size_t inner_idx>(auto& element) {
618 auto& element_with_skipping = std::get<inner_idx>(std::get<outer_idx>(tup));
619 element = element_with_skipping.convert();
620 };
621
622 // Note: {} is required to initialize the tuple contents. Otherwise the univariates contain garbage.
624 RelationUtils::apply_to_tuple_of_tuples(result, deoptimize);
625 return result;
626 }
627
641 TupleOfTuplesOfUnivariatesNoOptimisticSkipping& univariate_accumulators,
643 {
644 auto result = std::get<0>(std::get<0>(univariate_accumulators)).template extend_to<BATCHED_EXTENDED_LENGTH>();
645
646 size_t idx = 0;
647 const auto scale_and_sum = [&]<size_t outer_idx, size_t inner_idx>(auto& element) {
648 if constexpr (outer_idx == 0 && inner_idx == 0) {
649 return;
650 }
651
652 // Extend folded subrelation polynomials to the length of the combiner
653 auto extended = element.template extend_to<BATCHED_EXTENDED_LENGTH>();
654 extended *= alphas[idx];
655 result += extended;
656 idx++;
657 };
658
659 RelationUtils::apply_to_tuple_of_tuples(univariate_accumulators, scale_and_sum);
660 RelationUtils::zero_univariates(univariate_accumulators);
661
662 return result;
663 }
664
671 {
672 FF vanishing_polynomial_at_challenge;
674 vanishing_polynomial_at_challenge = challenge * (challenge - FF(1));
675 lagranges = { FF(1) - challenge, challenge };
676
677 return { vanishing_polynomial_at_challenge, lagranges };
678 }
679
691 FF perturbator_evaluation, ExtendedUnivariateWithRandomization combiner)
692 {
693 std::array<FF, BATCHED_EXTENDED_LENGTH - NUM_INSTANCES> combiner_quotient_evals = {};
694
695 for (size_t point = NUM_INSTANCES; point < combiner.size(); point++) {
696 auto idx = point - NUM_INSTANCES;
697 FF lagrange_0 = FF(1) - FF(point);
698 FF vanishing_polynomial = FF(point) * (FF(point) - 1);
699 combiner_quotient_evals[idx] =
700 (combiner.value_at(point) - perturbator_evaluation * lagrange_0) * vanishing_polynomial.invert();
701 }
702
703 return Univariate<FF, BATCHED_EXTENDED_LENGTH, NUM_INSTANCES>(combiner_quotient_evals);
704 }
705
719 template <typename ExtendedRelationParameters>
720 static ExtendedRelationParameters compute_extended_relation_parameters(const ProverInstances& instances)
721 {
722 using UnivariateParameter = typename ExtendedRelationParameters::DataType;
723 ExtendedRelationParameters result;
724 size_t param_idx = 0;
725 for (auto& param : result.get_to_fold()) {
727 tmp.value_at(0) = instances[0]->relation_parameters.get_to_fold()[param_idx];
728 tmp.value_at(1) = instances[1]->relation_parameters.get_to_fold()[param_idx];
729 param = tmp.template extend_to<UnivariateParameter::LENGTH, UnivariateParameter::SKIP_COUNT>();
730 param_idx++;
731 }
732 return result;
733 }
734
749 {
751 size_t alpha_idx = 0;
752 for (auto& alpha : result) {
754 tmp.value_at(0) = instances[0]->alphas[alpha_idx];
755 tmp.value_at(1) = instances[1]->alphas[alpha_idx];
756 alpha = tmp.template extend_to<BATCHED_EXTENDED_LENGTH>();
757 alpha_idx++;
758 }
759 return result;
760 }
761
769 static size_t compute_num_threads(const size_t domain_size)
770 {
771 const size_t max_num_threads = get_num_cpus_pow2(); // number of available threads (power of 2)
772 const size_t min_iterations_per_thread =
773 1 << 6; // min number of iterations for which we'll spin up a unique thread
774 const size_t desired_num_threads = domain_size / min_iterations_per_thread;
775 size_t num_threads = std::min(desired_num_threads, max_num_threads); // fewer than max if justified
776 num_threads = num_threads > 0 ? num_threads : 1; // ensure num threads is >= 1
777
778 return num_threads;
779 }
780};
781} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:88
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:218
#define BB_BENCH()
Definition bb_bench.hpp:222
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 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...
std::conditional_t< Flavor::USE_SHORT_MONOMIALS, ShortUnivariates, ExtendedUnivariates > ExtendedUnivariatesType
ExtendedUnivariateWithRandomization compute_combiner(const ProverInstances &instances, const GateSeparatorPolynomial< FF > &gate_separators, const UnivariateRelationParameters &relation_parameters, const UnivariateSubrelationSeparators &alphas, TupleOfTuplesOfUnivariates &univariate_accumulators)
Compute the combiner polynomial in the Protogalaxy paper.
Polynomial< FF > compute_perturbator(const std::shared_ptr< const ProverInstance > &accumulator, const std::vector< FF > &deltas)
Construct the perturbator polynomial F(X) in coefficient form from the accumulator resulted from a pr...
static BB_INLINE void extend_univariates(ExtendedUnivariatesType &extended_univariates, const ProverInstances &instances, const size_t row_idx)
Prepare a univariate polynomial for relation execution in one step of the combiner construction.
static auto row_to_univariates(const ProverInstances &instances, size_t row_idx)
Constructs univariates that interpolate the values of each instance across a given row.
std::array< Univariate< FF, BATCHED_EXTENDED_LENGTH >, NUM_SUBRELATIONS - 1 > UnivariateSubrelationSeparators
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,...
static std::pair< typename ProverInstance::FF, std::array< typename ProverInstance::FF, NUM_INSTANCES > > compute_vanishing_polynomial_and_lagranges(const FF &challenge)
Compute the vanishing polynomial and Lagranges at the challenge.
static size_t compute_num_threads(const size_t domain_size)
Determine number of threads for multithreading of perterbator/combiner operations.
static std::vector< FF > construct_coefficients_tree(std::span< const FF > betas, std::span< const FF > deltas, std::vector< FF > &current_level_buffer, size_t current_width, size_t current_degree)
Non-recursively compute the parent nodes of each level in the tree, starting from the leaves.
static UnivariateSubrelationSeparators compute_and_extend_alphas(const ProverInstances &instances)
Combine the relation batching parameters (alphas) from each prover instance into a univariate for the...
static TupleOfTuplesOfUnivariatesNoOptimisticSkipping deoptimize_univariates(const TupleOfTuplesOfUnivariatePossiblyOptimistic &tup)
Convert univariates from optimized form to regular.
typename Flavor::template ProverUnivariates< NUM_INSTANCES > ShortUnivariates
ShortUnivariates is an optimisation to improve the evaluation of Flavor relations when the output is ...
static FF process_subrelation_evaluations(const RelationEvaluations &evals, const SubrelationSeparators &challenges, FF &linearly_dependent_contribution)
Scale all linearly independent subrelations evaluations by challenges ('alphas').
ExecutionTraceUsageTracker trace_usage_tracker
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.
typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariates< NUM_INSTANCES > TupleOfTuplesOfUnivariates
typename ProverInstance::Flavor Flavor
ProtogalaxyProverInternal(ExecutionTraceUsageTracker trace_usage_tracker=ExecutionTraceUsageTracker{})
static std::vector< FF > construct_perturbator_coefficients(std::span< const FF > betas, std::span< const FF > deltas, const Polynomial< FF > &full_honk_evaluations)
Construct the perturbator polynomial F(X) coefficients in O(n) time using binary tree reduction.
decltype(create_tuple_of_arrays_of_values< typename Flavor::Relations >()) RelationEvaluations
static Univariate< FF, BATCHED_EXTENDED_LENGTH, NUM_INSTANCES > compute_combiner_quotient(FF perturbator_evaluation, ExtendedUnivariateWithRandomization combiner)
Compute the combiner quotient defined as $K$ polynomial in the paper specialised for only folding two...
typename Flavor::SubrelationSeparators SubrelationSeparators
static ExtendedRelationParameters compute_extended_relation_parameters(const ProverInstances &instances)
For each parameter, collect the value in each ProverInstance in a univariate and extend for use in th...
static ExtendedUnivariateWithRandomization batch_over_relations(TupleOfTuplesOfUnivariatesNoOptimisticSkipping &univariate_accumulators, const UnivariateSubrelationSeparators &alphas)
Given the univariate accumulators and the batching challenges, compute the combiner by batching the s...
typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariatesNoOptimisticSkipping< NUM_INSTANCES > TupleOfTuplesOfUnivariatesNoOptimisticSkipping
typename Flavor::template ProverUnivariatesWithOptimisticSkipping< ExtendedUnivariate::LENGTH, SKIP_COUNT > ExtendedUnivariates
typename Flavor::ProverPolynomials ProverPolynomials
std::array< std::shared_ptr< ProverInstance >, NUM_INSTANCES > ProverInstances
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:258
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 RelationEvaluations accumulate_relation_evaluations(const PolynomialEvaluations &evaluations, const Parameters &relation_parameters, const FF &scaling_factor)
Calculate the contribution of each relation to the expected value of the full Honk relation.
Definition utils.hpp:159
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
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...
ssize_t offset
Definition engine.cpp:36
constexpr size_t FF_MULTIPLICATION_COST
Definition thread.hpp:143
Entry point for Barretenberg command-line interface.
size_t get_num_cpus_pow2()
Definition thread.hpp:25
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:171
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
Definition thread.cpp:111
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Curve::Element Element
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 in Sumcheck.
Container for parameters used by the grand product (permutation, lookup) Honk relations.
constexpr field invert() const noexcept