Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
multilinear_batching_prover.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Sergei], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
9
10namespace bb {
11
13 MultilinearBatchingProverClaim&& instance_claim,
14 std::shared_ptr<Transcript> transcript)
15 : transcript(std::move(transcript))
16 , key(std::move(accumulator_claim), std::move(instance_claim))
17{}
18
20{
21 BB_BENCH();
22 transcript->send_to_verifier("non_shifted_accumulator_commitment", key.non_shifted_accumulator_commitment);
23 transcript->send_to_verifier("shifted_accumulator_commitment", key.shifted_accumulator_commitment);
24}
25
27{
28 BB_BENCH();
29 for (size_t i = 0; i < Flavor::VIRTUAL_LOG_N; i++) {
30 transcript->send_to_verifier("accumulator_challenge_" + std::to_string(i), key.accumulator_challenge[i]);
31 }
32 for (size_t i = 0; i < Flavor::NUM_ACCUMULATOR_EVALUATIONS; i++) {
33 transcript->send_to_verifier("accumulator_evaluation_" + std::to_string(i), key.accumulator_evaluations[i]);
34 }
35}
36
38{
39 BB_BENCH();
40 using Sumcheck = SumcheckProver<Flavor>;
41
42 // Each linearly independent subrelation contribution is multiplied by `alpha^i`, where
43 // i = 0, ..., NUM_SUBRELATIONS- 1.
44 const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
45
46 const size_t circuit_size = key.circuit_size;
47
48 Sumcheck sumcheck(circuit_size,
49 key.polynomials,
51 alpha,
53 key.accumulator_challenge,
54 key.instance_challenge);
55
56 sumcheck_output = sumcheck.prove();
57}
58
60{
61 BB_BENCH();
62
63 // Batching challenge: the new claim is computed as instance + challenge * accumulator
64 auto claim_batching_challenge = transcript->get_challenge<FF>("claim_batching_challenge");
65
66 // New polynomials
67 bb::Polynomial<FF> new_non_shifted_polynomial;
68 if (key.polynomials.batched_unshifted_instance.size() > key.polynomials.batched_unshifted_accumulator.size()) {
69 new_non_shifted_polynomial = std::move(key.polynomials.batched_unshifted_instance);
70 new_non_shifted_polynomial.add_scaled(key.polynomials.batched_unshifted_accumulator, claim_batching_challenge);
71 } else {
72 new_non_shifted_polynomial = std::move(key.polynomials.batched_unshifted_accumulator);
73 new_non_shifted_polynomial *= claim_batching_challenge;
74 new_non_shifted_polynomial += key.polynomials.batched_unshifted_instance;
75 }
76
77 bb::Polynomial<FF> new_shifted_polynomial;
78 if (key.preshifted_instance.size() > key.preshifted_accumulator.size()) {
79 new_shifted_polynomial = std::move(key.preshifted_instance);
80 new_shifted_polynomial.add_scaled(key.preshifted_accumulator, claim_batching_challenge);
81 } else {
82 new_shifted_polynomial = std::move(key.preshifted_accumulator);
83 new_shifted_polynomial *= claim_batching_challenge;
84 new_shifted_polynomial += key.preshifted_instance;
85 }
86
87 // New commitments
88 auto new_non_shifted_commitment =
89 key.non_shifted_instance_commitment + key.non_shifted_accumulator_commitment * claim_batching_challenge;
90 auto new_shifted_commitment =
91 key.shifted_instance_commitment + key.shifted_accumulator_commitment * claim_batching_challenge;
92
93 // New evaluations
94 FF new_non_shifted_evaluation =
95 sumcheck_output.claimed_evaluations.batched_unshifted_instance +
96 sumcheck_output.claimed_evaluations.batched_unshifted_accumulator * claim_batching_challenge;
97 FF new_shifted_evaluation =
98 sumcheck_output.claimed_evaluations.batched_shifted_instance +
99 sumcheck_output.claimed_evaluations.batched_shifted_accumulator * claim_batching_challenge;
100
102 .non_shifted_evaluation = new_non_shifted_evaluation,
103 .shifted_evaluation = new_shifted_evaluation,
104 .non_shifted_polynomial = std::move(new_non_shifted_polynomial),
105 .shifted_polynomial = std::move(new_shifted_polynomial),
106 .non_shifted_commitment = new_non_shifted_commitment,
107 .shifted_commitment = new_shifted_commitment,
108 .dyadic_size = key.circuit_size };
109}
110
112{
113 return transcript->export_proof();
114}
115
117{
118 BB_BENCH_NAME("MultilinearBatchingProver::construct_proof");
119
120 // Add circuit size public input size and public inputs to transcript.
122
123 // Fiat-Shamir: challenges and evaluations
125 // Fiat-Shamir: alpha
126 // Run sumcheck subprotocol.
128
129 vinfo("MultilinearBatchingProver:: Computed batching proof");
130 return export_proof();
131}
132
133} // namespace bb
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:225
#define BB_BENCH()
Definition bb_bench.hpp:229
static constexpr size_t NUM_ACCUMULATOR_EVALUATIONS
BB_PROFILE void execute_relation_check_rounds()
Execute sumcheck to reduce two evaluation claims to one at a random point u.
BB_PROFILE void execute_challenges_and_evaluations_round()
Send accumulator challenge point and evaluations to the verifier.
HonkProof construct_proof()
Construct a multilinear batching proof.
BB_PROFILE void execute_commitments_round()
Send accumulator commitments to the verifier.
MultilinearBatchingProver(MultilinearBatchingProverClaim &&accumulator_claim, MultilinearBatchingProverClaim &&instance_claim, std::shared_ptr< Transcript > transcript)
Construct prover from two claims to be batched.
BB_PROFILE MultilinearBatchingProverClaim compute_new_claim()
Compute the batched output claim after sumcheck.
std::shared_ptr< Transcript > transcript
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
void add_scaled(PolynomialSpan< const Fr > other, const Fr &scaling_factor)
adds the polynomial q(X) 'other', multiplied by a scaling factor.
The implementation of the sumcheck Prover for statements of the form for multilinear polynomials .
Definition sumcheck.hpp:298
#define vinfo(...)
Definition log.hpp:94
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::vector< fr > HonkProof
Definition proof.hpp:15
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
Prover's claim for multilinear batching - contains polynomials and their evaluation claims.