Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
oink_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
17
18namespace bb {
19
28template <IsUltraOrMegaHonk Flavor> void OinkVerifier<Flavor>::verify()
29{
30 // Execute the Verifier rounds
31 execute_preamble_round();
32 execute_wire_commitments_round();
33 execute_sorted_list_accumulator_round();
34 execute_log_derivative_inverse_round();
35 execute_grand_product_computation_round();
36
37 verification_key->witness_commitments = witness_comms;
38 verification_key->relation_parameters = relation_parameters;
39 verification_key->alphas = generate_alphas_round();
40 verification_key->is_complete = true; // instance has been completely populated
41}
42
47template <IsUltraOrMegaHonk Flavor> void OinkVerifier<Flavor>::execute_preamble_round()
48{
49 FF vk_hash = verification_key->vk->hash_through_transcript(domain_separator, *transcript);
50 transcript->add_to_hash_buffer(domain_separator + "vk_hash", vk_hash);
51 vinfo("vk hash in Oink verifier: ", vk_hash);
52
53 std::vector<FF> public_inputs;
54 for (size_t i = 0; i < verification_key->vk->num_public_inputs; ++i) {
55 auto public_input_i =
56 transcript->template receive_from_prover<FF>(domain_separator + "public_input_" + std::to_string(i));
57 public_inputs.emplace_back(public_input_i);
58 }
59 verification_key->public_inputs = std::move(public_inputs);
60}
61
67template <IsUltraOrMegaHonk Flavor> void OinkVerifier<Flavor>::execute_wire_commitments_round()
68{
69 // Get commitments to first three wire polynomials
70 witness_comms.w_l = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_l);
71 witness_comms.w_r = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_r);
72 witness_comms.w_o = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_o);
73
74 // If Goblin, get commitments to ECC op wire polynomials and DataBus columns
75 if constexpr (IsMegaFlavor<Flavor>) {
76 // Receive ECC op wire commitments
77 for (auto [commitment, label] : zip_view(witness_comms.get_ecc_op_wires(), comm_labels.get_ecc_op_wires())) {
78 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
79 }
80
81 // Receive DataBus related polynomial commitments
82 for (auto [commitment, label] :
83 zip_view(witness_comms.get_databus_entities(), comm_labels.get_databus_entities())) {
84 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
85 }
86 }
87}
88
93template <IsUltraOrMegaHonk Flavor> void OinkVerifier<Flavor>::execute_sorted_list_accumulator_round()
94{
95 // Get eta challenges
96 auto [eta, eta_two, eta_three] = transcript->template get_challenges<FF>(
97 domain_separator + "eta", domain_separator + "eta_two", domain_separator + "eta_three");
98 relation_parameters.eta = eta;
99 relation_parameters.eta_two = eta_two;
100 relation_parameters.eta_three = eta_three;
101
102 // Get commitments to lookup argument polynomials and fourth wire
103 witness_comms.lookup_read_counts =
104 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_read_counts);
105 witness_comms.lookup_read_tags =
106 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_read_tags);
107 witness_comms.w_4 = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_4);
108}
109
114template <IsUltraOrMegaHonk Flavor> void OinkVerifier<Flavor>::execute_log_derivative_inverse_round()
115{
116 // Get permutation challenges
117 auto [beta, gamma] = transcript->template get_challenges<FF>(domain_separator + "beta", domain_separator + "gamma");
118 relation_parameters.beta = beta;
119 relation_parameters.gamma = gamma;
120
121 witness_comms.lookup_inverses =
122 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_inverses);
123
124 // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomials
125 if constexpr (IsMegaFlavor<Flavor>) {
126 for (auto [commitment, label] :
127 zip_view(witness_comms.get_databus_inverses(), comm_labels.get_databus_inverses())) {
128 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
129 }
130 }
131}
132
138{
139 const FF public_input_delta = compute_public_input_delta<Flavor>(verification_key->public_inputs,
140 relation_parameters.beta,
141 relation_parameters.gamma,
142 verification_key->vk->pub_inputs_offset);
143
144 relation_parameters.public_input_delta = public_input_delta;
145
146 // Get commitment to permutation and lookup grand products
147 witness_comms.z_perm = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.z_perm);
148}
149
151{
152 // Get the relation separation challenges for sumcheck/combiner computation
153 std::array<std::string, Flavor::NUM_SUBRELATIONS - 1> challenge_labels;
154
155 for (size_t idx = 0; idx < Flavor::NUM_SUBRELATIONS - 1; ++idx) {
156 challenge_labels[idx] = domain_separator + "alpha_" + std::to_string(idx);
157 }
158 // It is more efficient to generate an array of challenges than to generate them individually.
159 SubrelationSeparators alphas = transcript->template get_challenges<FF>(challenge_labels);
160
161 return alphas;
162}
163
164template class OinkVerifier<UltraFlavor>;
165template class OinkVerifier<UltraZKFlavor>;
167#ifdef STARKNET_GARAGA_FLAVORS
170#endif
173template class OinkVerifier<MegaFlavor>;
174template class OinkVerifier<MegaZKFlavor>;
175
176} // namespace bb
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
static constexpr size_t NUM_SUBRELATIONS
Verifier class for all the presumcheck rounds, which are shared between the folding verifier and ultr...
void execute_wire_commitments_round()
Get the wire polynomials (part of the witness), with the exception of the fourth wire,...
typename Flavor::FF FF
void execute_preamble_round()
Get circuit size, public input size, and public inputs from transcript.
void verify()
Oink Verifier function that runs all the rounds of the verifier.
SubrelationSeparators generate_alphas_round()
void execute_log_derivative_inverse_round()
Get log derivative inverse polynomial and its commitment, if MegaFlavor.
typename Flavor::SubrelationSeparators SubrelationSeparators
void execute_grand_product_computation_round()
Compute lookup grand product delta and get permutation and lookup grand product commitments.
void execute_sorted_list_accumulator_round()
Get sorted witness-table accumulator and fourth wire commitments.
void vinfo(Args... args)
Definition log.hpp:76
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)