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 <typename 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 verifier_instance->witness_commitments = witness_comms;
38 verifier_instance->relation_parameters = relation_parameters;
39 verifier_instance->alphas = generate_alphas_round();
40 verifier_instance->is_complete = true; // instance has been completely populated
41}
42
47template <typename Flavor> void OinkVerifier<Flavor>::execute_preamble_round()
48{
49 auto vk = verifier_instance->get_vk();
50
51 FF vk_hash = vk->hash_through_transcript(domain_separator, *transcript);
52 transcript->add_to_hash_buffer(domain_separator + "vk_hash", vk_hash);
53 vinfo("vk hash in Oink verifier: ", vk_hash);
54
55 // For recursive flavors, assert that the VK hash matches
56 if constexpr (IsRecursiveFlavor<Flavor>) {
57 vinfo("expected vk hash: ", verifier_instance->vk_and_hash->hash);
58 verifier_instance->vk_and_hash->hash.assert_equal(vk_hash);
59 }
60
61 size_t num_public_inputs = get_num_public_inputs();
62
63 std::vector<FF> public_inputs;
64 for (size_t i = 0; i < num_public_inputs; ++i) {
65 auto public_input_i =
66 transcript->template receive_from_prover<FF>(domain_separator + "public_input_" + std::to_string(i));
67 public_inputs.emplace_back(public_input_i);
68 }
69 verifier_instance->public_inputs = std::move(public_inputs);
70}
71
78{
79 // Get commitments to first three wire polynomials
80 witness_comms.w_l = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_l);
81 witness_comms.w_r = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_r);
82 witness_comms.w_o = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_o);
83
84 // If Goblin, get commitments to ECC op wire polynomials and DataBus columns
85 if constexpr (IsMegaFlavor<Flavor>) {
86 // Receive ECC op wire commitments
87 for (auto [commitment, label] : zip_view(witness_comms.get_ecc_op_wires(), comm_labels.get_ecc_op_wires())) {
88 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
89 }
90
91 // Receive DataBus related polynomial commitments
92 for (auto [commitment, label] :
93 zip_view(witness_comms.get_databus_entities(), comm_labels.get_databus_entities())) {
94 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
95 }
96 }
97}
98
104{
105 // Get eta challenges
106 auto [eta, eta_two, eta_three] = transcript->template get_challenges<FF>(
107 domain_separator + "eta", domain_separator + "eta_two", domain_separator + "eta_three");
108 relation_parameters.eta = eta;
109 relation_parameters.eta_two = eta_two;
110 relation_parameters.eta_three = eta_three;
111
112 // Get commitments to lookup argument polynomials and fourth wire
113 witness_comms.lookup_read_counts =
114 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_read_counts);
115 witness_comms.lookup_read_tags =
116 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_read_tags);
117 witness_comms.w_4 = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_4);
118}
119
125{
126 // Get permutation challenges
127 auto [beta, gamma] = transcript->template get_challenges<FF>(domain_separator + "beta", domain_separator + "gamma");
128 relation_parameters.beta = beta;
129 relation_parameters.gamma = gamma;
130
131 witness_comms.lookup_inverses =
132 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_inverses);
133
134 // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomials
135 if constexpr (IsMegaFlavor<Flavor>) {
136 for (auto [commitment, label] :
137 zip_view(witness_comms.get_databus_inverses(), comm_labels.get_databus_inverses())) {
138 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
139 }
140 }
141}
142
148{
149 auto vk = verifier_instance->get_vk();
150
151 const FF public_input_delta = compute_public_input_delta<Flavor>(
152 verifier_instance->public_inputs, relation_parameters.beta, relation_parameters.gamma, vk->pub_inputs_offset);
153
154 relation_parameters.public_input_delta = public_input_delta;
155
156 // Get commitment to permutation and lookup grand products
157 witness_comms.z_perm = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.z_perm);
158}
159
161{
162 // Get the relation separation challenges for sumcheck/combiner computation
163 std::array<std::string, Flavor::NUM_SUBRELATIONS - 1> challenge_labels;
164
165 for (size_t idx = 0; idx < Flavor::NUM_SUBRELATIONS - 1; ++idx) {
166 challenge_labels[idx] = domain_separator + "alpha_" + std::to_string(idx);
167 }
168 // It is more efficient to generate an array of challenges than to generate them individually.
169 SubrelationSeparators alphas = transcript->template get_challenges<FF>(challenge_labels);
170
171 return alphas;
172}
173
174// Native flavor instantiations
175template class OinkVerifier<UltraFlavor>;
176template class OinkVerifier<UltraZKFlavor>;
178#ifdef STARKNET_GARAGA_FLAVORS
181#endif
184template class OinkVerifier<MegaFlavor>;
185template class OinkVerifier<MegaZKFlavor>;
186
187// Recursive flavor instantiations
197
198} // 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.
#define vinfo(...)
Definition log.hpp:79
Entry point for Barretenberg command-line interface.
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)