17template <IsUltraOrMegaHonk Flavor,
size_t NUM_KEYS>
19 std::shared_ptr<DeciderVK>
vk,
20 const std::string& domain_separator)
28template <IsUltraOrMegaHonk Flavor,
size_t NUM_KEYS>
33 auto&
key = keys_to_fold[0];
35 auto& verifier_accum = vks_to_fold[0];
36 if (!
key->is_complete) {
37 run_oink_prover_on_one_incomplete_key(
key, verifier_accum, domain_separator);
39 key->gate_challenges =
40 transcript->template get_powers_of_challenge<FF>(domain_separator +
"_gate_challenge", CONST_PG_LOG_N);
45 for (
auto it = keys_to_fold.begin() + 1; it != keys_to_fold.end(); it++, idx++) {
48 run_oink_prover_on_one_incomplete_key(
key, vks_to_fold[idx], domain_separator);
51 accumulator = keys_to_fold[0];
54template <IsUltraOrMegaHonk Flavor,
size_t NUM_KEYS>
60 const std::vector<FF> deltas = transcript->template get_powers_of_challenge<FF>(
"delta", CONST_PG_LOG_N);
62 const Polynomial<FF> perturbator = accumulator->from_first_instance
63 ? pg_internal.compute_perturbator(accumulator, deltas)
69 for (
size_t idx = 1; idx <= CONST_PG_LOG_N; idx++) {
70 transcript->send_to_verifier(
"perturbator_" +
std::to_string(idx), perturbator[idx]);
73 return std::make_tuple(deltas, perturbator);
76template <IsUltraOrMegaHonk Flavor,
size_t NUM_KEYS>
83 const std::vector<FF>& deltas,
88 const FF perturbator_challenge = transcript->template get_challenge<FF>(
"perturbator_challenge");
90 const std::vector<FF> updated_gate_challenges =
95 PGInternal::template compute_extended_relation_parameters<UnivariateRelationParameters>(keys);
99 auto combiner = pg_internal.compute_combiner(keys, gate_separators, relation_parameters, alphas, accumulators);
101 const FF perturbator_evaluation = perturbator.evaluate(perturbator_challenge);
102 const CombinerQuotient combiner_quotient = PGInternal::compute_combiner_quotient(perturbator_evaluation, combiner);
104 for (
size_t idx =
NUM_KEYS; idx < DeciderProvingKeys::BATCHED_EXTENDED_LENGTH; idx++) {
105 transcript->send_to_verifier(
"combiner_quotient_" +
std::to_string(idx), combiner_quotient.
value_at(idx));
108 return std::make_tuple(
109 updated_gate_challenges, alphas, relation_parameters, perturbator_evaluation, combiner_quotient);
115template <IsUltraOrMegaHonk Flavor,
size_t NUM_KEYS>
121 const FF& perturbator_evaluation)
125 std::shared_ptr<DeciderPK> accumulator = keys[0];
126 std::shared_ptr<DeciderPK> incoming = keys[1];
127 accumulator->from_first_instance =
true;
130 BB_ASSERT_EQ(accumulator->polynomials.w_l.virtual_size(), incoming->polynomials.w_l.virtual_size());
132 const FF combiner_challenge = transcript->template get_challenge<FF>(
"combiner_quotient_challenge");
135 auto [vanishing_polynomial_at_challenge, lagranges] =
136 PGInternal::compute_vanishing_polynomial_and_lagranges(combiner_challenge);
137 accumulator->target_sum = perturbator_evaluation * lagranges[0] +
138 vanishing_polynomial_at_challenge * combiner_quotient.
evaluate(combiner_challenge);
145 if (incoming->get_overflow_size() > accumulator->get_overflow_size()) {
146 std::swap(accumulator->polynomials, incoming->polynomials);
147 std::swap(lagranges[0], lagranges[1]);
148 accumulator->set_dyadic_size(incoming->dyadic_size());
149 accumulator->set_overflow_size(incoming->get_overflow_size());
153 for (
auto& poly : accumulator->polynomials.get_unshifted()) {
154 poly *= lagranges[0];
156 for (
auto [acc_poly, key_poly] :
157 zip_view(accumulator->polynomials.get_unshifted(), incoming->polynomials.get_unshifted())) {
158 acc_poly.add_scaled(key_poly, lagranges[1]);
163 for (
auto [folded_alpha, key_alpha] :
zip_view(accumulator->alphas, alphas)) {
164 folded_alpha = key_alpha.evaluate(combiner_challenge);
168 for (
auto [univariate,
value] :
169 zip_view(univariate_relation_parameters.
get_to_fold(), accumulator->relation_parameters.get_to_fold())) {
170 value = univariate.evaluate(combiner_challenge);
179 size_t max_circuit_size = 0;
180 for (
size_t idx = 0; idx <
NUM_KEYS; ++idx) {
181 max_circuit_size =
std::max(max_circuit_size, keys_to_fold[idx]->dyadic_size());
183 for (
size_t idx = 0; idx <
NUM_KEYS; ++idx) {
184 if (keys_to_fold[idx]->dyadic_size() != max_circuit_size) {
185 info(
"ProtogalaxyProver: circuit size mismatch - increasing virtual size of key ",
188 keys_to_fold[idx]->dyadic_size(),
191 keys_to_fold[idx]->polynomials.increase_polynomials_virtual_size(max_circuit_size);
195 run_oink_prover_on_each_incomplete_key();
196 vinfo(
"oink prover on each incomplete key");
198 std::tie(deltas, perturbator) = perturbator_round(accumulator);
199 vinfo(
"perturbator round");
201 std::tie(accumulator->gate_challenges, alphas, relation_parameters, perturbator_evaluation, combiner_quotient) =
202 combiner_quotient_round(accumulator->gate_challenges, deltas, keys_to_fold);
203 vinfo(
"combiner quotient round");
205 update_target_sum_and_fold(keys_to_fold, combiner_quotient, alphas, relation_parameters, perturbator_evaluation);
#define BB_ASSERT_EQ(actual, expected,...)
Class for all the oink rounds, which are shared between the folding prover and ultra prover.
void prove()
Oink Prover function that runs all the rounds of the verifier.
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
BB_PROFILE FoldingResult< Flavor > prove()
Execute the folding prover.
void run_oink_prover_on_one_incomplete_key(std::shared_ptr< DeciderPK >, std::shared_ptr< DeciderVK >, const std::string &domain_separator)
For each key produced by a circuit, prior to folding, we need to complete the computation of its prov...
void update_target_sum_and_fold(const DeciderProvingKeys &keys, const CombinerQuotient &combiner_quotient, const UnivariateSubrelationSeparators &alphas, const UnivariateRelationParameters &univariate_relation_parameters, const FF &perturbator_evaluation)
Steps 12 - 13 of the paper plus the prover folding work.
std::array< Univariate< FF, DeciderProvingKeys::BATCHED_EXTENDED_LENGTH >, Flavor::NUM_SUBRELATIONS - 1 > UnivariateSubrelationSeparators
std::tuple< std::vector< FF >, UnivariateSubrelationSeparators, UnivariateRelationParameters, FF, CombinerQuotient > combiner_quotient_round(const std::vector< FF > &gate_challenges, const std::vector< FF > &deltas, const DeciderProvingKeys &keys)
Steps 6 - 11 of the paper.
typename Flavor::template ProtogalaxyTupleOfTuplesOfUnivariates< NUM_KEYS > TupleOfTuplesOfUnivariates
std::tuple< std::vector< FF >, Polynomial< FF > > perturbator_round(const std::shared_ptr< const DeciderPK > &accumulator)
Steps 2 - 5 of the paper.
void run_oink_prover_on_each_incomplete_key()
Create inputs to folding protocol (an Oink interaction).
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
Fr evaluate(const Fr &u) const
Evaluate a univariate at a point u not known at compile time and assumed not to be in the domain (els...
constexpr size_t NUM_KEYS
Entry point for Barretenberg command-line interface.
std::vector< FF > update_gate_challenges(const FF &perturbator_challenge, const std::vector< FF > &gate_challenges, const std::vector< FF > &init_challenges)
Compute the gate challenges used in the combiner calculation.
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
#define PROFILE_THIS_NAME(name)
The result of running the Protogalaxy prover containing a new accumulator as well as the proof data t...
std::shared_ptr< DeciderProvingKey_< Flavor > > accumulator
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.
RefArray< T, NUM_TO_FOLD > get_to_fold()