Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy_verifier.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
12
13namespace bb {
14
15template <class VerifierInstance>
17{
18 transcript->load_proof(proof);
19 auto inst = insts_to_fold[0];
20 auto domain_separator = std::to_string(0);
21 if (!inst->is_complete) {
22 OinkVerifier<Flavor> oink_verifier{ inst, transcript, domain_separator + '_' };
23 oink_verifier.verify();
24 inst->target_sum = 0;
25 // Get the gate challenges for sumcheck/combiner computation
26 inst->gate_challenges =
27 transcript->template get_powers_of_challenge<FF>(domain_separator + "_gate_challenge", CONST_PG_LOG_N);
28 }
29
30 inst = insts_to_fold[1];
31 domain_separator = std::to_string(1);
32 OinkVerifier<Flavor> oink_verifier{ inst, transcript, domain_separator + '_' };
33 oink_verifier.verify();
34}
35
36template <typename FF>
38{
39 FF vanishing_polynomial_at_challenge = combiner_challenge * (combiner_challenge - FF(1));
40 std::vector<FF> lagranges = { FF(1) - combiner_challenge, combiner_challenge };
41 return std::make_tuple(vanishing_polynomial_at_challenge, lagranges);
42}
43
44template <class VerifierInstance>
46 const std::vector<FF>& proof)
47{
48 // The degree of the combiner quotient (K in the paper) is equal to deg(G) - deg(Z), where Z is the vanishing
49 // polynomial of the domain 0, .., NUM_INSTANCES-1. Hence, deg(K) = deg(G) - NUM_INSTANCES and we need deg(G) + 1 -
50 // NUM_INSTANCES = BATCHED_EXTENDED_LENGTH - NUM_INSTANCES evaluations to represent it
51 static constexpr size_t COMBINER_QUOTIENT_LENGTH = BATCHED_EXTENDED_LENGTH - NUM_INSTANCES;
52
53 const std::shared_ptr<VerifierInstance>& accumulator = insts_to_fold[0];
54
55 run_oink_verifier_on_each_incomplete_instance(proof);
56
57 // Perturbator round
58 const std::vector<FF> deltas = transcript->template get_powers_of_challenge<FF>("delta", CONST_PG_LOG_N);
59
60 std::vector<FF> perturbator_coeffs(CONST_PG_LOG_N + 1, 0);
61 for (size_t idx = 1; idx <= CONST_PG_LOG_N; idx++) {
62 perturbator_coeffs[idx] = transcript->template receive_from_prover<FF>("perturbator_" + std::to_string(idx));
63 }
64 const FF perturbator_challenge = transcript->template get_challenge<FF>("perturbator_challenge");
65
66 // Combiner quotient round
67 perturbator_coeffs[0] = accumulator->target_sum;
68 const Polynomial<FF> perturbator(perturbator_coeffs);
69 const FF perturbator_evaluation = perturbator.evaluate(perturbator_challenge);
70
71 std::array<FF, COMBINER_QUOTIENT_LENGTH> combiner_quotient_evals;
72 for (size_t idx = NUM_INSTANCES; auto& val : combiner_quotient_evals) {
73 val = transcript->template receive_from_prover<FF>("combiner_quotient_" + std::to_string(idx++));
74 }
75
76 // Folding
77 const FF combiner_challenge = transcript->template get_challenge<FF>("combiner_quotient_challenge");
78 const Univariate<FF, BATCHED_EXTENDED_LENGTH, NUM_INSTANCES> combiner_quotient(combiner_quotient_evals);
79 const FF combiner_quotient_evaluation = combiner_quotient.evaluate(combiner_challenge);
80
81 // Set a constant virtual log circuit size in the accumulator
82 const size_t accumulator_log_circuit_size = CONST_PG_LOG_N;
83 accumulator->vk->log_circuit_size = accumulator_log_circuit_size;
84
85 // Compute next folding parameters
86 const auto [vanishing_polynomial_at_challenge, lagranges] =
87 compute_vanishing_polynomial_and_lagrange_evaluations<FF>(combiner_challenge);
88 accumulator->target_sum =
89 perturbator_evaluation * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_evaluation;
90 accumulator->gate_challenges = // note: known already in previous round
91 update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas);
92
93 // Fold the commitments
94 for (auto [combination, to_combine] :
95 zip_view(accumulator->vk->get_all(), get_data_to_fold<FOLDING_DATA::PRECOMPUTED_COMMITMENTS>())) {
96 combination = batch_mul_native(to_combine, lagranges);
97 }
98 for (auto [combination, to_combine] :
99 zip_view(accumulator->witness_commitments.get_all(), get_data_to_fold<FOLDING_DATA::WITNESS_COMMITMENTS>())) {
100 combination = batch_mul_native(to_combine, lagranges);
101 }
102
103 // Fold the relation parameters
104 for (auto [combination, to_combine] : zip_view(accumulator->alphas, get_data_to_fold<FOLDING_DATA::ALPHAS>())) {
105 combination = to_combine[0] + combiner_challenge * (to_combine[1] - to_combine[0]);
106 }
107 for (auto [combination, to_combine] : zip_view(accumulator->relation_parameters.get_to_fold(),
108 get_data_to_fold<FOLDING_DATA::RELATION_PARAMETERS>())) {
109 combination = to_combine[0] + combiner_challenge * (to_combine[1] - to_combine[0]);
110 }
111
112 return accumulator;
113}
114
116
117} // namespace bb
Verifier class for all the presumcheck rounds, which are shared between the folding verifier and ultr...
void verify()
Oink Verifier function that runs all the rounds of the verifier.
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
Fr evaluate(const Fr &z, size_t target_size) const
void run_oink_verifier_on_each_incomplete_instance(const std::vector< FF > &)
Instatiate the verifier instances and the transcript.
std::shared_ptr< VerifierInstance > verify_folding_proof(const std::vector< FF > &)
Run the folding protocol on the verifier side to establish whether the public data ϕ of the new accum...
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
Fr evaluate(const Fr &u) const
Evaluate a univariate at a point u not known at compile time and assumed not to be in the domain (els...
Entry point for Barretenberg command-line interface.
std::tuple< FF, std::vector< FF > > compute_vanishing_polynomial_and_lagrange_evaluations(const FF &combiner_challenge)
typename Flavor::FF FF
std::vector< FF > update_gate_challenges(const FF &perturbator_challenge, const std::vector< FF > &gate_challenges, const std::vector< FF > &init_challenges)
Compute the gate challenges used in the combiner calculation.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)