Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_recursive_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
18
19namespace bb {
20
23 const std::shared_ptr<NativeVerificationKey>& native_verifier_key,
24 const std::shared_ptr<Transcript>& transcript)
25 : key(std::make_shared<VerificationKey>(builder, native_verifier_key))
26 , vk_hash(stdlib::witness_t<Builder>(builder, native_verifier_key->hash()))
27 , transcript(transcript)
29{
30 key->fix_witness(); // fixed to a constant
31 vk_hash.fix_witness(); // fixed to a constant
32}
33
34// Relation params used in sumcheck which is done over FF but the received data is from BF
36 const BF& batching_challenge_v,
37 const BF& accumulated_result)
38{
39
40 const auto compute_four_limbs = [](const BF& in) {
41 return std::array<FF, 4>{ FF(in.binary_basis_limbs[0].element),
42 FF(in.binary_basis_limbs[1].element),
43 FF(in.binary_basis_limbs[2].element),
44 FF(in.binary_basis_limbs[3].element) };
45 };
46
47 const auto compute_five_limbs = [](const BF& in) {
48 return std::array<FF, 5>{ FF(in.binary_basis_limbs[0].element),
49 FF(in.binary_basis_limbs[1].element),
50 FF(in.binary_basis_limbs[2].element),
51 FF(in.binary_basis_limbs[3].element),
52 FF(in.prime_basis_limb) };
53 };
54
55 relation_parameters.evaluation_input_x = compute_five_limbs(evaluation_input_x);
56
57 BF batching_challenge_v_power = batching_challenge_v;
58 for (size_t i = 0; i < 4; i++) {
59 relation_parameters.batching_challenge_v[i] = compute_five_limbs(batching_challenge_v_power);
60 batching_challenge_v_power = batching_challenge_v_power * batching_challenge_v;
61 }
62
63 relation_parameters.accumulated_result = compute_four_limbs(accumulated_result);
64
65 // OriginTag false positive: The accumulated result limbs are evaluation claims that will be checked by
66 // `TranslatorAccumulatorTransferRelationImpl`.
67 for (auto& limb : relation_parameters.accumulated_result) {
68 limb.clear_round_provenance();
69 }
70};
71
82 const StdlibProof& proof,
83 const BF& evaluation_input_x,
84 const BF& batching_challenge_v,
85 const BF& accumulated_result,
87{
88 using Sumcheck = ::bb::SumcheckVerifier<Flavor>;
89 using PCS = Flavor::PCS;
90 using Curve = Flavor::Curve;
91 using Shplemini = ::bb::ShpleminiVerifier_<Curve>;
92 using VerifierCommitments = Flavor::VerifierCommitments;
93 using CommitmentLabels = Flavor::CommitmentLabels;
94 using ClaimBatcher = ClaimBatcher_<Curve>;
95 using ClaimBatch = ClaimBatcher::Batch;
96 using InterleavedBatch = ClaimBatcher::InterleavedBatch;
97
98 transcript->load_proof(proof);
99
100 // Fiat-Shamir the vk hash
101 // We do not need to hash the vk in-circuit because both the vk and vk hash are hardcoded as constants.
102 transcript->add_to_hash_buffer("vk_hash", vk_hash);
103 vinfo("Translator vk hash in recursive verifier: ", vk_hash);
104
105 VerifierCommitments commitments{ key };
106 CommitmentLabels commitment_labels;
107
108 // Use accumulated_result from ECCVM verifier instead of receiving from transcript
109 // The point is prime basis limb of accumulated result can be easily recovered from binary basis limbs, so
110 // there's no meaning to use it at the circuit next and we can put it in used_witnesses
111 mark_witness_as_used(accumulated_result.prime_basis_limb);
112
113 put_translation_data_in_relation_parameters(evaluation_input_x, batching_challenge_v, accumulated_result);
114
115 // Receive Gemini masking polynomial commitment (for ZK-PCS)
116 commitments.gemini_masking_poly = transcript->template receive_from_prover<Commitment>("Gemini:masking_poly_comm");
117
118 // Set op queue wire commitments (provided by merge protocol, not from translator proof)
119 commitments.op = op_queue_wire_commitments[0];
120 commitments.x_lo_y_hi = op_queue_wire_commitments[1];
121 commitments.x_hi_z_1 = op_queue_wire_commitments[2];
122 commitments.y_lo_z_2 = op_queue_wire_commitments[3];
123
124 // Receive commitments to non-op-queue wires and ordered range constraints
125 for (auto [comm, label] : zip_view(commitments.get_non_opqueue_wires_and_ordered_range_constraints(),
126 commitment_labels.get_non_opqueue_wires_and_ordered_range_constraints())) {
127 comm = transcript->template receive_from_prover<Commitment>(label);
128 }
129
130 // Get permutation challenges
131 FF beta = transcript->template get_challenge<FF>("beta");
132 FF gamma = transcript->template get_challenge<FF>("gamma");
133
136
137 // Get commitment to permutation and lookup grand products
138 commitments.z_perm = transcript->template receive_from_prover<Commitment>(commitment_labels.z_perm);
139
140 // Execute Sumcheck Verifier
141 // Each linearly independent subrelation contribution is multiplied by `alpha^i`, where
142 // i = 0, ..., NUM_SUBRELATIONS- 1.
143 const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
144
145 Sumcheck sumcheck(transcript, alpha, TranslatorFlavor::CONST_TRANSLATOR_LOG_N);
146
147 std::vector<FF> gate_challenges(TranslatorFlavor::CONST_TRANSLATOR_LOG_N);
148 for (size_t idx = 0; idx < gate_challenges.size(); idx++) {
149 gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
150 }
151
153 libra_commitments[0] = transcript->template receive_from_prover<Commitment>("Libra:concatenation_commitment");
154
155 FF one{ 1 };
157
158 std::vector<FF> padding_indicator_array(TranslatorFlavor::CONST_TRANSLATOR_LOG_N);
159 std::ranges::fill(padding_indicator_array, one);
160
161 auto sumcheck_output = sumcheck.verify(relation_parameters, gate_challenges, padding_indicator_array);
162
163 libra_commitments[1] = transcript->template receive_from_prover<Commitment>("Libra:grand_sum_commitment");
164 libra_commitments[2] = transcript->template receive_from_prover<Commitment>("Libra:quotient_commitment");
165
166 // Execute Shplemini
167 bool consistency_checked = true;
168 ClaimBatcher claim_batcher{
169 .unshifted = ClaimBatch{ commitments.get_unshifted_without_interleaved(),
170 sumcheck_output.claimed_evaluations.get_unshifted_without_interleaved() },
171 .shifted = ClaimBatch{ commitments.get_to_be_shifted(), sumcheck_output.claimed_evaluations.get_shifted() },
172 .interleaved = InterleavedBatch{ .commitments_groups = commitments.get_groups_to_be_interleaved(),
173 .evaluations = sumcheck_output.claimed_evaluations.get_interleaved() }
174 };
175 auto opening_claim = Shplemini::compute_batch_opening_claim(padding_indicator_array,
176 claim_batcher,
177 sumcheck_output.challenge,
178 Commitment::one(builder),
182 &consistency_checked,
183 libra_commitments,
184 sumcheck_output.claimed_libra_evaluation);
185
186 PairingPoints pairing_points(PCS::reduce_verify_batch_opening_claim(std::move(opening_claim), transcript));
187
188 return pairing_points;
189}
190
191} // namespace bb
An efficient verifier for the evaluation proofs of multilinear polynomials and their shifts.
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
Definition sumcheck.hpp:786
static constexpr size_t CONST_TRANSLATOR_LOG_N
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
stdlib::bn254< CircuitBuilder > Curve
TranslatorFlavor::CommitmentLabels CommitmentLabels
TranslatorFlavor::VerifierCommitments_< Commitment, VerificationKey > VerifierCommitments
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
std::shared_ptr< VerificationKey > key
void put_translation_data_in_relation_parameters(const BF &evaluation_input_x, const BF &batching_challenge_v, const BF &accumulated_result)
PairingPoints verify_proof(const StdlibProof &proof, const BF &evaluation_input_x, const BF &batching_challenge_v, const BF &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
Creates a circuit that executes the Translator verifier algorithm up to the final pairing check.
TranslatorRecursiveVerifier(Builder *builder, const std::shared_ptr< NativeVerificationKey > &native_verifier_key, const std::shared_ptr< Transcript > &transcript)
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:19
void convert_constant_to_fixed_witness(Builder *ctx)
Definition field.hpp:444
#define vinfo(...)
Definition log.hpp:80
AluTraceBuilder builder
Definition alu.test.cpp:124
void hash(State &state) noexcept
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...
Logic to support batching opening claims for unshifted and shifted polynomials in Shplemini.
std::array< std::array< T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR+NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR >, NUM_CHALLENGE_POWERS_IN_GOBLIN_TRANSLATOR > batching_challenge_v
std::array< T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR > accumulated_result
std::array< T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR+NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR > evaluation_input_x
An object storing two EC points that represent the inputs to a pairing check.