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 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1604): Optimize new claim computation
68 bb::Polynomial<FF> new_non_shifted_polynomial(key.circuit_size);
69 new_non_shifted_polynomial += key.polynomials.batched_unshifted_instance;
70 new_non_shifted_polynomial.add_scaled(key.polynomials.batched_unshifted_accumulator, claim_batching_challenge);
71
72 bb::Polynomial<FF> new_shifted_polynomial(bb::Polynomial<FF>::shiftable(key.circuit_size));
73 new_shifted_polynomial += key.preshifted_instance;
74 new_shifted_polynomial.add_scaled(key.preshifted_accumulator, claim_batching_challenge);
75
76 // New commitments
77 auto new_non_shifted_commitment =
78 key.non_shifted_instance_commitment + key.non_shifted_accumulator_commitment * claim_batching_challenge;
79 auto new_shifted_commitment =
80 key.shifted_instance_commitment + key.shifted_accumulator_commitment * claim_batching_challenge;
81
82 // New evaluations
83 FF new_non_shifted_evaluation =
84 sumcheck_output.claimed_evaluations.batched_unshifted_instance +
85 sumcheck_output.claimed_evaluations.batched_unshifted_accumulator * claim_batching_challenge;
86 FF new_shifted_evaluation =
87 sumcheck_output.claimed_evaluations.batched_shifted_instance +
88 sumcheck_output.claimed_evaluations.batched_shifted_accumulator * claim_batching_challenge;
89
91 .non_shifted_evaluation = new_non_shifted_evaluation,
92 .shifted_evaluation = new_shifted_evaluation,
93 .non_shifted_polynomial = std::move(new_non_shifted_polynomial),
94 .shifted_polynomial = std::move(new_shifted_polynomial),
95 .non_shifted_commitment = new_non_shifted_commitment,
96 .shifted_commitment = new_shifted_commitment,
97 .dyadic_size = key.circuit_size };
98}
99
101{
102 return transcript->export_proof();
103}
104
106{
107 BB_BENCH_NAME("MultilinearBatchingProver::construct_proof");
108
109 // Add circuit size public input size and public inputs to transcript.
111
112 // Fiat-Shamir: challenges and evaluations
114 // Fiat-Shamir: alpha
115 // Run sumcheck subprotocol.
117
118 vinfo("MultilinearBatchingProver:: Computed batching proof");
119 return export_proof();
120}
121
122} // namespace bb
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:219
#define BB_BENCH()
Definition bb_bench.hpp:223
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:289
#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.