70 template <
typename InstanceFlavor>
75 BB_BENCH_NAME(
"HypernovaFoldingProver::instance_to_accumulator");
76 vinfo(
"HypernovaFoldingProver: converting instance to accumulator...");
86 instance->gate_challenges =
transcript->template get_dyadic_powers_of_challenge<FF>(
87 "HypernovaFoldingProver:gate_challenge", InstanceFlavor::VIRTUAL_LOG_N);
89 auto sumcheck_output = [&] {
92 instance->polynomials,
95 instance->gate_challenges,
96 instance->relation_parameters,
97 InstanceFlavor::VIRTUAL_LOG_N);
98 return sumcheck.
prove();
105 sumcheck_output_to_accumulator<InstanceFlavor>(sumcheck_output, instance, precomputed_vk);
106 vinfo(
"HypernovaFoldingProver: accumulator constructed.");
114 template <
typename InstanceFlavor>
118 cached_claims.emplace_back(instance_to_accumulator<InstanceFlavor>(instance, honk_vk));
133 claims.reserve((previous_accumulator.has_value() ? 1 : 0) +
cached_claims.size());
134 if (previous_accumulator.has_value()) {
135 claims.emplace_back(
std::move(*previous_accumulator));
141 BB_ASSERT(!claims.empty(),
"HypernovaFoldingProver::finalize: nothing to fold");
143 if (claims.size() == 1) {
167 template <
typename InstanceFlavor>
172 BB_BENCH_NAME(
"HypernovaFoldingProver::sumcheck_output_to_accumulator");
174 auto [unshifted_challenges, shifted_challenges] = get_hypernova_batching_challenges<FF>(
175 transcript, InstanceFlavor::NUM_UNSHIFTED_ENTITIES, InstanceFlavor::NUM_SHIFTED_ENTITIES);
177 Polynomial<FF> batched_unshifted_polynomial = batch_polynomials<InstanceFlavor::NUM_UNSHIFTED_ENTITIES>(
178 instance->polynomials.get_unshifted(), instance->dyadic_size(), unshifted_challenges);
179 Polynomial<FF> batched_shifted_polynomial = batch_polynomials<InstanceFlavor::NUM_SHIFTED_ENTITIES>(
180 instance->polynomials.get_to_be_shifted(), instance->dyadic_size(), shifted_challenges);
182 FF batched_unshifted_evaluation(0);
183 FF batched_shifted_evaluation(0);
184 for (
auto [eval, challenge] :
186 batched_unshifted_evaluation += eval * challenge;
189 batched_shifted_evaluation += eval * challenge;
195 Commitment batched_unshifted_commitment =
batch_mul(verifier_commitments.get_unshifted(), unshifted_challenges);
196 Commitment batched_shifted_commitment =
batch_mul(verifier_commitments.get_to_be_shifted(), shifted_challenges);
200 .non_shifted_evaluation = batched_unshifted_evaluation,
201 .shifted_evaluation = batched_shifted_evaluation,
202 .non_shifted_polynomial =
std::move(batched_unshifted_polynomial),
203 .shifted_polynomial =
std::move(batched_shifted_polynomial),
204 .non_shifted_commitment = batched_unshifted_commitment,
205 .shifted_commitment = batched_shifted_commitment,
206 .dyadic_size = instance->dyadic_size(),
215 const size_t& full_batched_size,
216 const std::vector<FF>& challenges)
220 polynomials_to_batch[0].virtual_size(),
221 "The virtual size of the first polynomial is different from the full batched size.");
224 "The number of challenges provided does not match the number of polynomials to batch.");
226 size_t min_start = polynomials_to_batch[0].start_index();
227 size_t max_end = polynomials_to_batch[0].end_index();
228 for (
size_t idx = 1; idx <
N; idx++) {
229 min_start = std::min(min_start, polynomials_to_batch[idx].start_index());
230 max_end =
std::max(max_end, polynomials_to_batch[idx].end_index());
234 sources.reserve(
N - 1);
235 for (
size_t i = 1; i <
N; ++i) {
236 sources.emplace_back(polynomials_to_batch[i]);
240 if (min_start < polynomials_to_batch[0].start_index() || max_end > polynomials_to_batch[0].end_index()) {
242 result += polynomials_to_batch[0];
247 return polynomials_to_batch[0];
255 std::vector<Commitment> points(
N);
256 for (
size_t idx = 0; idx <
N; ++idx) {
257 points[idx] = _points[idx];
259 return Commitment::batch_mul(points, scalars);
#define BB_ASSERT(expression,...)
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_BENCH_NAME(name)
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
HyperNova folding prover. Folds circuit instances into accumulators, deferring PCS verification.
std::pair< HonkProof, Accumulator > finalize(std::optional< Accumulator > previous_accumulator=std::nullopt)
Batch the previous accumulator (if any) and the cached claims into a single accumulator.
MegaFlavor::Commitment Commitment
static Polynomial< FF > batch_polynomials(RefArray< Polynomial< FF >, N > polynomials_to_batch, const size_t &full_batched_size, const std::vector< FF > &challenges)
Batch prover polynomials. Batching happens in place into the first polynomial in the RefArray supplie...
std::shared_ptr< Transcript > transcript
HonkProof export_proof()
Export the proof contained in the transcript.
std::vector< Accumulator > cached_claims
HonkProof accumulate_instance(const std::shared_ptr< ProverInstance_< InstanceFlavor > > &instance, const std::shared_ptr< typename InstanceFlavor::VerificationKey > &honk_vk=nullptr)
Turn an instance into an accumulator and cache the resulting claim for the final batching.
HypernovaFoldingProver(std::shared_ptr< Transcript > transcript)
Accumulator instance_to_accumulator(const std::shared_ptr< ProverInstance_< InstanceFlavor > > &instance, const std::shared_ptr< typename InstanceFlavor::VerificationKey > &honk_vk=nullptr)
Turn an instance into an accumulator by running Sumcheck.
Accumulator sumcheck_output_to_accumulator(SumcheckOutput< InstanceFlavor > &sumcheck_output, const std::shared_ptr< ProverInstance_< InstanceFlavor > > &instance, const std::shared_ptr< typename InstanceFlavor::VerificationKey > &honk_vk)
Convert the output of the sumcheck run on the incoming instance into an accumulator.
static Commitment batch_mul(std::span< Commitment, N > _points, std::vector< FF > &scalars)
Utility to perform batch mul of commitments.
const std::vector< Accumulator > & get_cached_claims() const
BaseTranscript< Codec, HashFunction > Transcript
Curve::AffineElement Commitment
Public entrypoint for multilinear batching.
HonkProof construct_proof()
ProverClaim compute_new_claim()
Executes the "Oink" phase of the Honk proving protocol: the initial rounds that commit to witness dat...
void prove(bool emit_alpha=true)
Commit to witnesses, compute relation parameters, and prepare for Sumcheck.
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
The implementation of the sumcheck Prover for statements of the form for multilinear polynomials .
SumcheckOutput< Flavor > prove()
Non-ZK version: Compute round univariate, place it in transcript, compute challenge,...
typename VerifierCommitmentEntities< Flavor, Commitment >::Type Commitments
static Commitments construct(const std::shared_ptr< VerificationKey > &verification_key)
MemoryProfile GLOBAL_MEMORY_PROFILE
Entry point for Barretenberg command-line interface.
std::vector< fr > HonkProof
void add_scaled_batch(Polynomial< Fr > &dst, std::span< const PolynomialSpan< const Fr > > sources, std::span< const Fr > scalars)
Fused parallel batched add: dst += sum_i scalars[i] * sources[i].
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Prover's claim for multilinear batching - contains polynomials and their evaluation claims.
std::vector< FF > challenge
Contains the evaluations of multilinear polynomials at the challenge point . These are computed by S...
ClaimedEvaluations claimed_evaluations
std::vector< FF > challenge
void add_checkpoint(const std::string &stage)