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: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
18
19namespace bb {
20
29template <typename Flavor> void OinkVerifier<Flavor>::verify()
30{
31 // Execute the Verifier rounds
32 execute_preamble_round();
33 // For ZK flavors: receive Gemini masking polynomial commitment
34 if constexpr (Flavor::HasZK) {
35 verifier_instance->gemini_masking_commitment =
36 transcript->template receive_from_prover<Commitment>("Gemini:masking_poly_comm");
37 }
38 execute_wire_commitments_round();
39 execute_sorted_list_accumulator_round();
40 execute_log_derivative_inverse_round();
41 execute_grand_product_computation_round();
42
43 verifier_instance->witness_commitments = witness_comms;
44 verifier_instance->relation_parameters = relation_parameters;
45 verifier_instance->alpha = generate_alpha_round();
46}
47
52template <typename Flavor> void OinkVerifier<Flavor>::execute_preamble_round()
53{
54 auto vk = verifier_instance->get_vk();
55
56 FF vk_hash = vk->hash_with_origin_tagging(*transcript);
57 transcript->add_to_hash_buffer(domain_separator + "vk_hash", vk_hash);
58 vinfo("vk hash in Oink verifier: ", vk_hash);
59
60 // For recursive flavors, assert that the VK hash matches the expected hash provided in the VK
61 if constexpr (IsRecursiveFlavor<Flavor>) {
62 const bool vk_hash_consistency = verifier_instance->vk_and_hash->hash.get_value() == vk_hash.get_value();
63 if (!vk_hash_consistency) {
64 info("Recursive Ultra Verifier: VK Hash Mismatch");
65 }
66 verifier_instance->vk_and_hash->hash.assert_equal(vk_hash);
67 } else {
68 BB_ASSERT_EQ(verifier_instance->vk_and_hash->hash, vk_hash, "Native Ultra Verifier: VK Hash Mismatch");
69 };
70
71 size_t num_public_inputs = get_num_public_inputs();
72
73 std::vector<FF> public_inputs;
74 for (size_t i = 0; i < num_public_inputs; ++i) {
75 auto public_input_i =
76 transcript->template receive_from_prover<FF>(domain_separator + "public_input_" + std::to_string(i));
77 public_inputs.emplace_back(public_input_i);
78 }
79 verifier_instance->public_inputs = std::move(public_inputs);
80}
81
88{
89 // Get commitments to first three wire polynomials
90 witness_comms.w_l = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_l);
91 witness_comms.w_r = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_r);
92 witness_comms.w_o = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_o);
93
94 // If Goblin, get commitments to ECC op wire polynomials and DataBus columns
95 if constexpr (IsMegaFlavor<Flavor>) {
96 // Receive ECC op wire commitments
97 for (auto [commitment, label] : zip_view(witness_comms.get_ecc_op_wires(), comm_labels.get_ecc_op_wires())) {
98 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
99 }
100
101 // Receive DataBus related polynomial commitments
102 for (auto [commitment, label] :
103 zip_view(witness_comms.get_databus_entities(), comm_labels.get_databus_entities())) {
104 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
105 }
106 }
107}
108
114{
115 // Get eta challenges
116 auto [eta, eta_two, eta_three] = transcript->template get_challenges<FF>(std::array<std::string, 3>{
117 domain_separator + "eta", domain_separator + "eta_two", domain_separator + "eta_three" });
118 relation_parameters.eta = eta;
119 relation_parameters.eta_two = eta_two;
120 relation_parameters.eta_three = eta_three;
121
122 // Get commitments to lookup argument polynomials and fourth wire
123 witness_comms.lookup_read_counts =
124 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_read_counts);
125 witness_comms.lookup_read_tags =
126 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_read_tags);
127 witness_comms.w_4 = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.w_4);
128}
129
135{
136 // Get permutation challenges
137 auto [beta, gamma] = transcript->template get_challenges<FF>(
138 std::array<std::string, 2>{ domain_separator + "beta", domain_separator + "gamma" });
139 relation_parameters.beta = beta;
140 relation_parameters.gamma = gamma;
141
142 witness_comms.lookup_inverses =
143 transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.lookup_inverses);
144
145 // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomials
146 if constexpr (IsMegaFlavor<Flavor>) {
147 for (auto [commitment, label] :
148 zip_view(witness_comms.get_databus_inverses(), comm_labels.get_databus_inverses())) {
149 commitment = transcript->template receive_from_prover<Commitment>(domain_separator + label);
150 }
151 }
152}
153
159{
160 auto vk = verifier_instance->get_vk();
161
162 const FF public_input_delta = compute_public_input_delta<Flavor>(
163 verifier_instance->public_inputs, relation_parameters.beta, relation_parameters.gamma, vk->pub_inputs_offset);
164
165 relation_parameters.public_input_delta = public_input_delta;
166
167 // Get commitment to permutation and lookup grand products
168 witness_comms.z_perm = transcript->template receive_from_prover<Commitment>(domain_separator + comm_labels.z_perm);
169}
170
171template <typename Flavor> typename Flavor::SubrelationSeparator OinkVerifier<Flavor>::generate_alpha_round()
172{
173 // Get the single alpha challenge for sumcheck computation
174 // Powers of this challenge will be used to batch subrelations
175 return transcript->template get_challenge<FF>(domain_separator + "alpha");
176}
177
178// Native flavor instantiations
179template class OinkVerifier<UltraFlavor>;
180template class OinkVerifier<UltraZKFlavor>;
182#ifdef STARKNET_GARAGA_FLAVORS
185#endif
188template class OinkVerifier<MegaFlavor>;
189template class OinkVerifier<MegaZKFlavor>;
190
191// Recursive flavor instantiations
202
203} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:93
static constexpr bool HasZK
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.
SubrelationSeparator generate_alpha_round()
void execute_log_derivative_inverse_round()
Get log derivative inverse polynomial and its commitment, if MegaFlavor.
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:94
void info(Args... args)
Definition log.hpp:89
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)