Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_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
11
12namespace bb {
13
14TranslatorVerifier::TranslatorVerifier(const std::shared_ptr<Transcript>& transcript)
15 : transcript(transcript)
16{}
17
18TranslatorVerifier::TranslatorVerifier(const std::shared_ptr<VerificationKey>& verifier_key,
19 const std::shared_ptr<Transcript>& transcript)
20 : key(verifier_key)
21 , transcript(transcript)
22{}
23
25 const BF& batching_challenge_v,
26 const uint256_t& accumulated_result)
27{
28
29 const auto compute_four_limbs = [](const auto& in) {
30 constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS;
31 return std::array<FF, 4>{ in.slice(0, NUM_LIMB_BITS),
32 in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2),
33 in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3),
34 in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4) };
35 };
36
37 const auto compute_five_limbs = [](const auto& in) {
38 constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS;
39 return std::array<FF, 5>{ in.slice(0, NUM_LIMB_BITS),
40 in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2),
41 in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3),
42 in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4),
43 in };
44 };
45
47
48 uint256_t batching_challenge_v_power{ batching_challenge_v };
49 for (size_t i = 0; i < 4; i++) {
50 relation_parameters.batching_challenge_v[i] = compute_five_limbs(batching_challenge_v_power);
51 batching_challenge_v_power = BF(batching_challenge_v_power) * batching_challenge_v;
52 }
53
54 relation_parameters.accumulated_result = compute_four_limbs(accumulated_result);
55};
56
61 const HonkProof& proof,
62 const uint256_t& evaluation_input_x,
63 const BF& batching_challenge_v,
64 const uint256_t& accumulated_result,
66{
67 using Curve = Flavor::Curve;
68 using PCS = Flavor::PCS;
69 using Shplemini = ShpleminiVerifier_<Curve>;
70 using ClaimBatcher = ClaimBatcher_<Curve>;
71 using ClaimBatch = ClaimBatcher::Batch;
72 using InterleavedBatch = ClaimBatcher::InterleavedBatch;
73 using Sumcheck = SumcheckVerifier<Flavor>;
75
76 // Load the proof produced by the translator prover
77 transcript->load_proof(proof);
78
79 // Fiat-Shamir the vk hash
80 typename Flavor::FF vk_hash = key->hash();
81 transcript->add_to_hash_buffer("vk_hash", vk_hash);
82 vinfo("Translator vk hash in verifier: ", vk_hash);
83
84 Flavor::VerifierCommitments commitments{ key };
85 Flavor::CommitmentLabels commitment_labels;
86
87 // Use accumulated_result from ECCVM verifier
89
90 // Receive Gemini masking polynomial commitment (for ZK-PCS)
91 commitments.gemini_masking_poly = transcript->template receive_from_prover<Commitment>("Gemini:masking_poly_comm");
92
93 // Set op queue wire commitments (provided by merge protocol, not from translator proof)
94 commitments.op = op_queue_wire_commitments[0];
95 commitments.x_lo_y_hi = op_queue_wire_commitments[1];
96 commitments.x_hi_z_1 = op_queue_wire_commitments[2];
97 commitments.y_lo_z_2 = op_queue_wire_commitments[3];
98
99 // Receive commitments to non-op-queue wires and ordered range constraints
100 for (auto [comm, label] : zip_view(commitments.get_non_opqueue_wires_and_ordered_range_constraints(),
102 comm = transcript->template receive_from_prover<Commitment>(label);
103 }
104
105 // Get permutation challenges
106 FF beta = transcript->template get_challenge<FF>("beta");
107 FF gamma = transcript->template get_challenge<FF>("gamma");
108
111
112 // Get commitment to permutation and lookup grand products
113 commitments.z_perm = transcript->template receive_from_prover<Commitment>(commitment_labels.z_perm);
114
115 // Each linearly independent subrelation contribution is multiplied by `alpha^i`, where
116 // i = 0, ..., NUM_SUBRELATIONS- 1.
117 const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
118
119 // Execute Sumcheck Verifier
120 Sumcheck sumcheck(transcript, alpha, Flavor::CONST_TRANSLATOR_LOG_N);
121
122 std::vector<FF> gate_challenges(Flavor::CONST_TRANSLATOR_LOG_N);
123 for (size_t idx = 0; idx < gate_challenges.size(); idx++) {
124 gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
125 }
126
127 // Receive commitments to Libra masking polynomials
129 libra_commitments[0] = transcript->template receive_from_prover<Commitment>("Libra:concatenation_commitment");
130
131 std::vector<FF> padding_indicator_array(Flavor::CONST_TRANSLATOR_LOG_N);
132 std::ranges::fill(padding_indicator_array, FF{ 1 });
133
134 auto sumcheck_output = sumcheck.verify(relation_parameters, gate_challenges, padding_indicator_array);
135
136 // If Sumcheck did not verify, return false
137 if (!sumcheck_output.verified) {
138 return false;
139 }
140
141 libra_commitments[1] = transcript->template receive_from_prover<Commitment>("Libra:grand_sum_commitment");
142 libra_commitments[2] = transcript->template receive_from_prover<Commitment>("Libra:quotient_commitment");
143
144 // Execute Shplemini
145 bool consistency_checked = false;
146 ClaimBatcher claim_batcher{
147 .unshifted = ClaimBatch{ commitments.get_unshifted_without_interleaved(),
148 sumcheck_output.claimed_evaluations.get_unshifted_without_interleaved() },
149 .shifted = ClaimBatch{ commitments.get_to_be_shifted(), sumcheck_output.claimed_evaluations.get_shifted() },
150 .interleaved = InterleavedBatch{ .commitments_groups = commitments.get_groups_to_be_interleaved(),
151 .evaluations = sumcheck_output.claimed_evaluations.get_interleaved() }
152 };
153 auto opening_claim = Shplemini::compute_batch_opening_claim(padding_indicator_array,
154 claim_batcher,
155 sumcheck_output.challenge,
156 Commitment::one(),
160 &consistency_checked,
161 libra_commitments,
162 sumcheck_output.claimed_libra_evaluation);
163 const auto pairing_points = PCS::reduce_verify_batch_opening_claim(std::move(opening_claim), transcript);
164
165 VerifierCommitmentKey pcs_vkey{};
166 auto verified = pcs_vkey.pairing_check(pairing_points[0], pairing_points[1]);
167 return verified && consistency_checked;
168}
169} // 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
A container for commitment labels.
auto get_non_opqueue_wires_and_ordered_range_constraints()
Non-op-queue wires and ordered range constraints (committed to by translator prover)
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
static constexpr size_t CONST_TRANSLATOR_LOG_N
static constexpr bool HasZK
static constexpr size_t NUM_LIMB_BITS
bb::VerifierCommitmentKey< Curve > VerifierCommitmentKey
void put_translation_data_in_relation_parameters(const uint256_t &evaluation_input_x, const BF &batching_challenge_v, const uint256_t &accumulated_result)
std::shared_ptr< VerificationKey > key
RelationParameters< FF > relation_parameters
TranslatorVerifier(const std::shared_ptr< Transcript > &transcript)
bool verify_proof(const HonkProof &proof, const uint256_t &evaluation_input_x, const BF &batching_challenge_v, const uint256_t &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
This function verifies a TranslatorFlavor Honk proof for given program settings.
std::shared_ptr< Transcript > transcript
#define vinfo(...)
Definition log.hpp:80
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::vector< fr > HonkProof
Definition proof.hpp:15
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
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