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: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
15
16namespace bb {
17
21 const std::shared_ptr<Transcript>& transcript)
22 : transcript(transcript)
23{
24 BB_BENCH();
25 ProverPolynomials polynomials;
26 size_t virtual_circuit_size = 1 << Flavor::VIRTUAL_LOG_N;
27 size_t max_dyadic_size = std::max(accumulator_claim->dyadic_size, instance_claim->dyadic_size);
28 polynomials.w_non_shifted_accumulator = accumulator_claim->non_shifted_polynomial;
29 polynomials.w_shifted_accumulator = accumulator_claim->shifted_polynomial.shifted();
30 polynomials.w_non_shifted_instance = instance_claim->non_shifted_polynomial;
31 polynomials.w_shifted_instance = instance_claim->shifted_polynomial.shifted();
32 polynomials.w_evaluations_accumulator =
33 ProverEqPolynomial<FF>::construct(accumulator_claim->challenge, bb::numeric::get_msb(max_dyadic_size));
34 polynomials.w_evaluations_instance =
35 ProverEqPolynomial<FF>::construct(instance_claim->challenge, bb::numeric::get_msb(max_dyadic_size));
36
37 polynomials.increase_polynomials_virtual_size(virtual_circuit_size);
38 std::vector<FF> accumulator_evaluations = { accumulator_claim->non_shifted_evaluation,
39 accumulator_claim->shifted_evaluation };
40 std::vector<FF> instance_evaluations = { instance_claim->non_shifted_evaluation,
41 instance_claim->shifted_evaluation };
43 accumulator_claim->challenge,
44 instance_claim->challenge,
45 accumulator_evaluations,
46 instance_evaluations,
47 accumulator_claim->non_shifted_commitment,
48 accumulator_claim->shifted_commitment,
49 instance_claim->non_shifted_commitment,
50 instance_claim->shifted_commitment,
51 accumulator_claim->shifted_polynomial,
52 instance_claim->shifted_polynomial);
53 key->proving_key->circuit_size = max_dyadic_size;
54}
55
57{
58 BB_BENCH();
59 transcript->send_to_verifier("non_shifted_accumulator_commitment", key->non_shifted_accumulator_commitment);
60 transcript->send_to_verifier("shifted_accumulator_commitment", key->shifted_accumulator_commitment);
61}
63{
64 BB_BENCH();
65 for (size_t i = 0; i < Flavor::VIRTUAL_LOG_N; i++) {
66 transcript->send_to_verifier("accumulator_challenge_" + std::to_string(i),
67 key->proving_key->accumulator_challenge[i]);
68 }
69 for (size_t i = 0; i < 2; i++) {
70 transcript->send_to_verifier("accumulator_evaluation_" + std::to_string(i),
71 key->proving_key->accumulator_evaluations[i]);
72 }
73}
74
80{
81 BB_BENCH();
82 using Sumcheck = SumcheckProver<Flavor>;
83
84 // Each linearly independent subrelation contribution is multiplied by `alpha^i`, where
85 // i = 0, ..., NUM_SUBRELATIONS- 1.
86 const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
87
88 const size_t circuit_size = key->proving_key->circuit_size;
89
90 Sumcheck sumcheck(circuit_size,
91 key->proving_key->polynomials,
93 alpha,
95 key->proving_key->accumulator_challenge,
96 key->proving_key->instance_challenge);
97
98 sumcheck_output = sumcheck.prove();
99}
100
102{
103 BB_BENCH();
104
105 // Batching challenge: the new claim is computed as instance + challenge * accumulator
106 auto claim_batching_challenge = transcript->get_challenge<FF>("claim_batching_challenge");
107
108 // New polynomials
109 auto new_non_shifted_polynomial = Polynomial(key->proving_key->circuit_size);
110 new_non_shifted_polynomial += key->proving_key->polynomials.w_non_shifted_instance;
111 new_non_shifted_polynomial.add_scaled(key->proving_key->polynomials.w_non_shifted_accumulator,
112 claim_batching_challenge);
113
114 auto new_shifted_polynomial = Polynomial::shiftable(key->proving_key->circuit_size);
115 new_shifted_polynomial += key->preshifted_instance;
116 new_shifted_polynomial.add_scaled(key->preshifted_accumulator, claim_batching_challenge);
117
118 // New commitments
119 auto new_non_shifted_commitment =
120 key->non_shifted_instance_commitment + key->non_shifted_accumulator_commitment * claim_batching_challenge;
121 auto new_shifted_commitment =
122 key->shifted_instance_commitment + key->shifted_accumulator_commitment * claim_batching_challenge;
123
124 // New evaluations
125 FF new_non_shifted_evaluation =
126 sumcheck_output.claimed_evaluations.w_non_shifted_instance +
127 sumcheck_output.claimed_evaluations.w_non_shifted_accumulator * claim_batching_challenge;
128 FF new_shifted_evaluation = sumcheck_output.claimed_evaluations.w_shifted_instance +
129 sumcheck_output.claimed_evaluations.w_shifted_accumulator * claim_batching_challenge;
130
132 .non_shifted_evaluation = new_non_shifted_evaluation,
133 .shifted_evaluation = new_shifted_evaluation,
134 .non_shifted_polynomial = new_non_shifted_polynomial,
135 .shifted_polynomial = new_shifted_polynomial,
136 .non_shifted_commitment = new_non_shifted_commitment,
137 .shifted_commitment = new_shifted_commitment,
138 .dyadic_size = key->proving_key->circuit_size
139
140 };
141}
142
144{
145 return transcript->export_proof();
146}
147
149{
150 BB_BENCH_NAME("MultilinearBatchingProver::construct_proof");
151
152 // Add circuit size public input size and public inputs to transcript.
154
155 // Fiat-Shamir: challenges and evaluations
157 // Fiat-Shamir: alpha
158 // Run sumcheck subprotocol.
160
161 vinfo("MultilinearBatchingProver:: Computed batching proof");
162 return export_proof();
163}
164
165} // namespace bb
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:219
#define BB_BENCH()
Definition bb_bench.hpp:223
MultilinearBatchingProver(const std::shared_ptr< MultilinearBatchingProverClaim > &accumulator_claim, const std::shared_ptr< MultilinearBatchingProverClaim > &instance_claim, const std::shared_ptr< Transcript > &transcript)
BB_PROFILE void execute_relation_check_rounds()
Run Sumcheck resulting in u = (u_1,...,u_d) challenges and all evaluations at u being calculated.
typename Flavor::ProverPolynomials ProverPolynomials
std::shared_ptr< MultilinearBatchingProvingKey > key
BB_PROFILE MultilinearBatchingProverClaim compute_new_claim()
std::shared_ptr< Transcript > transcript
static Polynomial shiftable(size_t virtual_size)
Utility to create a shiftable polynomial of given virtual size.
static Polynomial< FF > construct(std::span< const FF > challenges, size_t log_num_monomials)
Construct eq(X, r) coefficient table over Boolean hypercube {0,1}^d.
The implementation of the sumcheck Prover for statements of the form for multilinear polynomials .
Definition sumcheck.hpp:289
#define vinfo(...)
Definition log.hpp:80
constexpr T get_msb(const T in)
Definition get_msb.hpp:47
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::vector< fr > HonkProof
Definition proof.hpp:15
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)