17template <
typename Flavor_>
19 const std::shared_ptr<Transcript>& transcript)
20 : transcript(transcript)
23template <
typename Flavor_>
25 Flavor_>::compute_target_sum(
const FF& alpha,
29 FF non_shifted_target(0);
31 for (
size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
32 non_shifted_target += claims[idx].non_shifted_evaluation * scalars[idx];
33 shifted_target += claims[idx].shifted_evaluation * scalars[idx];
35 return non_shifted_target + shifted_target * alpha;
38template <
typename Flavor_>
42 std::vector<FF> scalars)
44 std::vector<Commitment> non_shifted_commitments;
45 std::vector<Commitment> shifted_commitments;
46 non_shifted_commitments.reserve(NUM_CLAIMS);
47 shifted_commitments.reserve(NUM_CLAIMS);
48 for (
size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
49 non_shifted_commitments.emplace_back(claims[idx].non_shifted_commitment);
50 shifted_commitments.emplace_back(claims[idx].shifted_commitment);
53 Commitment non_shifted_commitment = Curve::Element::batch_mul(non_shifted_commitments, scalars);
54 Commitment shifted_commitment = Curve::Element::batch_mul(shifted_commitments, scalars);
56 FF non_shifted_evaluation(0);
57 FF shifted_evaluation(0);
58 for (
size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
59 non_shifted_evaluation += scalars[idx] * sumcheck_result.
claimed_evaluations.non_shifted(idx);
64 .non_shifted_evaluation = non_shifted_evaluation,
65 .shifted_evaluation = shifted_evaluation,
66 .non_shifted_commitment = non_shifted_commitment,
67 .shifted_commitment = shifted_commitment };
70template <
typename Flavor_>
75 for (
size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
78 if constexpr (IsRecursive) {
79 verified &= eq_diff.get_value() == 0;
80 eq_diff.assert_equal(
FF(0),
"MultilinearBatchingVerifier: eq polynomial mismatch");
82 verified &= eq_diff ==
FF(0);
88template <
typename Flavor_>
93 BB_ASSERT_EQ(claims.size(), NUM_CLAIMS,
"MultilinearBatchingVerifier: claim count must equal the width");
100 const FF claim_batching_challenge = transcript->template get_challenge<FF>(
"claim_batching_challenge");
105 const FF alpha = transcript->template get_challenge<FF>(
"Sumcheck:alpha");
108 Sumcheck sumcheck(transcript, alpha, Flavor::VIRTUAL_LOG_N, target_sum);
109 const auto sumcheck_result = sumcheck.
verify(relation_parameters, {});
111 bool eq_consistent = check_eq_consistency(sumcheck_result, claims);
115 const FF claim_merge_challenge = transcript->template get_challenge<FF>(
"claim_merge_challenge");
116 std::vector<FF> merge_scalars(NUM_CLAIMS);
117 merge_scalars[0] =
FF(1);
118 for (
size_t idx = 1; idx < NUM_CLAIMS; ++idx) {
119 merge_scalars[idx] = merge_scalars[idx - 1] * claim_merge_challenge;
123 bool verified = sumcheck_result.verified && eq_consistent;
125 return { verified,
std::move(verifier_claim) };
128template <
bool IsRecursive_>
130 : transcript(transcript)
133template <
bool IsRecursive_>
134template <
size_t NumClaims>
145template <
bool IsRecursive_>
153 constexpr_for<2, CHONK_MAX_CLAIMS_PER_KERNEL + 1, 1>([&]<
size_t Width>() {
154 if (claims.size() == Width) {
155 result = this->template verify_with_width<Width>(claims);
158 if (!
result.has_value()) {
159 throw_or_abort(
"MultilinearBatchingVerifier: unsupported batch width");
#define BB_ASSERT_EQ(actual, expected,...)
bb::field< bb::Bn254FrParams > FF
#define BB_BENCH_NAME(name)
Native flavor for multilinear batching sumcheck with NumClaims polynomials.
Public entrypoint for multilinear batching verification.
MultilinearBatchingVerifier(const std::shared_ptr< Transcript > &transcript)
Internal verifier for multilinear batching sumcheck over a fixed number of claims.
bool check_eq_consistency(const SumcheckOutput< Flavor > &sumcheck_result, const std::vector< VerifierClaim > &claims)
MultilinearBatchingVerifierInternal(const std::shared_ptr< Transcript > &transcript)
typename Flavor::Commitment Commitment
std::pair< bool, VerifierClaim > verify_proof(const std::vector< VerifierClaim > &claims)
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, const std::vector< FF > &gate_challenges)
The Sumcheck verification method. First it extracts round univariate, checks sum (the sumcheck univar...
Entry point for Barretenberg command-line interface.
std::vector< Fr > batching_scalars(const Fr &challenge, const size_t count)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Verifier's claim for multilinear batching - contains commitments and evaluation claims.
std::vector< FF > challenge
Container for parameters used by the grand product (permutation, lookup) Honk relations.
std::array< T, NUM_MULTILINEAR_BATCHING_CHALLENGES > multilinear_batching_challenges
void compute_multilinear_batching_challenges(const T &batching_challenge, const size_t num_claims)
Contains the evaluations of multilinear polynomials at the challenge point . These are computed by S...
ClaimedEvaluations claimed_evaluations
std::vector< FF > challenge
static FF eval(std::span< const FF > r_in, std::span< const FF > u)
void throw_or_abort(std::string const &err)