Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
eccvm_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
19{
20 using Curve = typename Flavor::Curve;
21 using Shplemini = ShpleminiVerifier_<Curve>;
22 using Shplonk = ShplonkVerifier_<Curve>;
24 using ClaimBatcher = ClaimBatcher_<Curve>;
25 using ClaimBatch = ClaimBatcher::Batch;
26
27 RelationParameters<FF> relation_parameters;
28
29 ipa_transcript->load_proof(proof.ipa_proof);
30 transcript->load_proof(proof.pre_ipa_proof);
31
32 // Fiat-Shamir the vk hash
33 typename Flavor::BF vk_hash = key->hash();
34 transcript->add_to_hash_buffer("vk_hash", vk_hash);
35 vinfo("ECCVM vk hash in verifier: ", vk_hash);
36
38 CommitmentLabels commitment_labels;
39
40 for (auto [comm, label] : zip_view(commitments.get_wires(), commitment_labels.get_wires())) {
41 comm = transcript->template receive_from_prover<Commitment>(label);
42 }
43
44 // Get challenge for sorted list batching and wire four memory records
45 auto [beta, gamma] = transcript->template get_challenges<FF>("beta", "gamma");
46
47 auto beta_sqr = beta * beta;
48 relation_parameters.gamma = gamma;
49 relation_parameters.beta = beta;
50 relation_parameters.beta_sqr = beta * beta;
51 relation_parameters.beta_cube = beta_sqr * beta;
52 relation_parameters.eccvm_set_permutation_delta =
53 gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr);
54 relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert();
55
56 // Get commitment to permutation and lookup grand products
57 commitments.lookup_inverses =
58 transcript->template receive_from_prover<Commitment>(commitment_labels.lookup_inverses);
59 commitments.z_perm = transcript->template receive_from_prover<Commitment>(commitment_labels.z_perm);
60
61 // Each linearly independent subrelation contribution is multiplied by `alpha^i`, where
62 // i = 0, ..., NUM_SUBRELATIONS- 1.
63 const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
64
65 // Execute Sumcheck Verifier
66 SumcheckVerifier<Flavor> sumcheck(transcript, alpha, CONST_ECCVM_LOG_N);
67
68 std::vector<FF> gate_challenges(CONST_ECCVM_LOG_N);
69 for (size_t idx = 0; idx < gate_challenges.size(); idx++) {
70 gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
71 }
72
73 // Receive commitments to Libra masking polynomials
75
76 libra_commitments[0] = transcript->template receive_from_prover<Commitment>("Libra:concatenation_commitment");
77
78 auto sumcheck_output = sumcheck.verify(relation_parameters, gate_challenges);
79
80 libra_commitments[1] = transcript->template receive_from_prover<Commitment>("Libra:grand_sum_commitment");
81 libra_commitments[2] = transcript->template receive_from_prover<Commitment>("Libra:quotient_commitment");
82
83 // Compute the Shplemini accumulator consisting of the Shplonk evaluation and the commitments and scalars vector
84 // produced by the unified protocol
85 bool consistency_checked = true;
86 ClaimBatcher claim_batcher{
87 .unshifted = ClaimBatch{ commitments.get_unshifted(), sumcheck_output.claimed_evaluations.get_unshifted() },
88 .shifted = ClaimBatch{ commitments.get_to_be_shifted(), sumcheck_output.claimed_evaluations.get_shifted() }
89 };
90
91 std::array<FF, CONST_ECCVM_LOG_N> padding_indicator_array;
92 std::ranges::fill(padding_indicator_array, FF{ 1 });
93
94 BatchOpeningClaim<Curve> sumcheck_batch_opening_claims =
95 Shplemini::compute_batch_opening_claim(padding_indicator_array,
96 claim_batcher,
97 sumcheck_output.challenge,
98 key->pcs_verification_key.get_g1_identity(),
102 &consistency_checked,
103 libra_commitments,
104 sumcheck_output.claimed_libra_evaluation,
105 sumcheck_output.round_univariate_commitments,
106 sumcheck_output.round_univariate_evaluations);
107
108 // Reduce the accumulator to a single opening claim
109 OpeningClaim multivariate_to_univariate_opening_claim =
110 PCS::reduce_batch_opening_claim(sumcheck_batch_opening_claims);
111
112 // Produce the opening claim for batch opening of `op`, `Px`, `Py`, `z1`, and `z2` wires as univariate polynomials
113 std::array<Commitment, NUM_TRANSLATION_EVALUATIONS> translation_commitments = { commitments.transcript_op,
114 commitments.transcript_Px,
115 commitments.transcript_Py,
116 commitments.transcript_z1,
117 commitments.transcript_z2 };
118
119 compute_translation_opening_claims(translation_commitments);
120
121 opening_claims.back() = multivariate_to_univariate_opening_claim;
122
123 // Construct and verify the combined opening claim
124 const OpeningClaim batch_opening_claim =
125 Shplonk::reduce_verification(key->pcs_verification_key.get_g1_identity(), opening_claims, transcript);
126
127 const bool batched_opening_verified =
128 PCS::reduce_verify(key->pcs_verification_key, batch_opening_claim, ipa_transcript);
129 vinfo("eccvm sumcheck verified?: ", sumcheck_output.verified);
130 vinfo("batch opening verified?: ", batched_opening_verified);
131 vinfo("eccvm consistency check verified?: ", consistency_checked);
132 vinfo("translation masking consistency checked?: ", translation_masking_consistency_checked);
133 return sumcheck_output.verified && batched_opening_verified && consistency_checked &&
135}
136
147 const std::array<Commitment, NUM_TRANSLATION_EVALUATIONS>& translation_commitments)
148{
149 // Used to capture the batched evaluation of unmasked `translation_polynomials` while preserving ZK
151
152 // Initialize SmallSubgroupIPA structures
153 SmallSubgroupIPACommitments<Commitment> small_ipa_commitments;
154 std::array<FF, NUM_SMALL_IPA_EVALUATIONS> small_ipa_evaluations;
155 const std::array<std::string, NUM_SMALL_IPA_EVALUATIONS> labels = SmallIPA::evaluation_labels("Translation:");
156
157 // Get a commitment to M + Z_H * R, where M is a concatenation of the masking terms of `translation_polynomials`,
158 // Z_H = X^{|H|} - 1, and R is a random degree 2 polynomial
159 small_ipa_commitments.concatenated =
160 transcript->template receive_from_prover<Commitment>("Translation:concatenated_masking_term_commitment");
161
162 // Get a challenge to evaluate `translation_polynomials` as univariates
163 evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");
164
165 // Populate the translation evaluations {`op(x)`, `Px(x)`, `Py(x)`, `z1(x)`, `z2(x)`} to be batched
167 eval = transcript->template receive_from_prover<FF>(label);
168 }
169
170 // Get the batching challenge for commitments and evaluations
171 batching_challenge_v = transcript->template get_challenge<FF>("Translation:batching_challenge_v");
172
173 // Get the value ∑ mᵢ(x) ⋅ vⁱ
174 translation_masking_term_eval = transcript->template receive_from_prover<FF>("Translation:masking_term_eval");
175
176 // Receive commitments to the SmallSubgroupIPA witnesses that are computed once x and v are available
177 small_ipa_commitments.grand_sum =
178 transcript->template receive_from_prover<Commitment>("Translation:grand_sum_commitment");
179 small_ipa_commitments.quotient =
180 transcript->template receive_from_prover<Commitment>("Translation:quotient_commitment");
181
182 // Get a challenge for the evaluations of the concatenated masking term G, grand sum A, its shift, and grand sum
183 // identity quotient Q
184 const FF small_ipa_evaluation_challenge =
185 transcript->template get_challenge<FF>("Translation:small_ipa_evaluation_challenge");
186
187 // Compute {r, r * g, r, r}, where r = `small_ipa_evaluation_challenge`
189 SmallIPA::evaluation_points(small_ipa_evaluation_challenge);
190
191 // Get the evaluations G(r), A(g * r), A(r), Q(r)
192 for (size_t idx = 0; idx < NUM_SMALL_IPA_EVALUATIONS; idx++) {
193 small_ipa_evaluations[idx] = transcript->template receive_from_prover<FF>(labels[idx]);
194 opening_claims[idx] = { { evaluation_points[idx], small_ipa_evaluations[idx] },
195 small_ipa_commitments.get_all()[idx] };
196 }
197
198 // Check Grand Sum Identity at r
200 SmallIPA::check_eccvm_evaluations_consistency(small_ipa_evaluations,
201 small_ipa_evaluation_challenge,
205
206 // Compute the batched commitment and batched evaluation for the univariate opening claim
207 Commitment batched_commitment = translation_commitments[0];
208 FF batched_translation_evaluation = translation_evaluations.get_all()[0];
209 FF batching_scalar = batching_challenge_v;
210 for (size_t idx = 1; idx < NUM_TRANSLATION_EVALUATIONS; ++idx) {
211 batched_commitment = batched_commitment + translation_commitments[idx] * batching_scalar;
212 batched_translation_evaluation += batching_scalar * translation_evaluations.get_all()[idx];
213 batching_scalar *= batching_challenge_v;
214 }
215
216 // Place the claim to the array containing the SmallSubgroupIPA opening claims
217 opening_claims[NUM_SMALL_IPA_EVALUATIONS] = { { evaluation_challenge_x, batched_translation_evaluation },
218 batched_commitment };
219
220 // Compute `translation_masking_term_eval` * `evaluation_challenge_x`^{circuit_size - NUM_DISABLED_ROWS_IN_SUMCHECK}
221 shift_translation_masking_term_eval(evaluation_challenge_x, translation_masking_term_eval);
222};
223
224} // namespace bb
A container for commitment labels.
static constexpr bool HasZK
typename Curve::BaseField BF
curve::Grumpkin Curve
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
bool verify_proof(const ECCVMProof &proof)
This function verifies an ECCVM Honk proof for given program settings.
std::map< std::string, Commitment > commitments
std::array< OpeningClaim< Curve >, NUM_OPENING_CLAIMS > opening_claims
std::shared_ptr< Transcript > ipa_transcript
TranslationEvaluations_< FF > translation_evaluations
std::shared_ptr< VerificationKey > key
std::shared_ptr< Transcript > transcript
Flavor::Commitment Commitment
bool translation_masking_consistency_checked
void compute_translation_opening_claims(const std::array< Commitment, NUM_TRANSLATION_EVALUATIONS > &translation_commitments)
To link the ECCVM Transcript wires op, Px, Py, z1, and z2 to the accumulator computed by the translat...
Unverified claim (C,r,v) for some witness polynomial p(X) such that.
Definition claim.hpp:53
An efficient verifier for the evaluation proofs of multilinear polynomials and their shifts.
Shplonk Verifier.
Definition shplonk.hpp:343
Verifies the consistency of polynomial evaluations provided by the the prover.
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
Definition sumcheck.hpp:645
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, std::vector< FF > &gate_challenges, const std::vector< FF > &padding_indicator_array)
Extract round univariate, check sum, generate challenge, compute next target sum.....
Definition sumcheck.hpp:718
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)
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:169
Logic to support batching opening claims for unshifted and shifted polynomials in Shplemini.
HonkProof pre_ipa_proof
Definition proof.hpp:24
HonkProof ipa_proof
Definition proof.hpp:25
Container for parameters used by the grand product (permutation, lookup) Honk relations.
Contains commitments to polynomials [G], [A], and [Q]. See SmallSubgroupIPAProver docs.
RefArray< Commitment, NUM_SMALL_IPA_EVALUATIONS > get_all()
RefArray< BF, NUM_TRANSLATION_EVALUATIONS > get_all()
std::array< std::string, NUM_TRANSLATION_EVALUATIONS > labels