Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
chonk_verifier.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Sergei], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#include "chonk_verifier.hpp"
13
14namespace bb {
15
26template <>
28{
29 BB_BENCH_NAME("ChonkVerifier::reduce_to_triple_ipa_opening");
30
31 // Step 1: Verify MegaZK Oink on the shared transcript
32 BatchedHonkTranslatorVerifier batched_verifier(vk_and_hash, transcript);
33 auto oink_result = batched_verifier.verify_mega_zk_oink(proof.hiding_oink_proof);
34
35 // Extract public inputs and kernel data
36 HidingKernelIO kernel_io;
37 kernel_io.reconstruct_from_public(oink_result.public_inputs);
38
39 // Check accumulated pairing points from the IVC chain (inner recursive verifications)
40 if (!kernel_io.pairing_inputs.check()) {
41 info("ChonkVerifier: verification failed at PI pairing points check");
42 return { false };
43 }
44
45 // Step 2: Databus consistency check
46 const Commitment kernel_calldata_commitment = oink_result.kernel_calldata_commitment;
47 const Commitment return_data_commitment = kernel_io.kernel_return_data;
48 bool databus_consistency_verified = (kernel_calldata_commitment == return_data_commitment);
49 vinfo("ChonkVerifier: databus consistency verified: ", databus_consistency_verified);
50 if (!databus_consistency_verified) {
51 info("ChonkVerifier: verification failed at databus consistency check");
52 return { false };
53 }
54
55 // Step 3: Merge verification
56 // These commitments are already in the shared Fiat-Shamir transcript: Oink read the ecc-op wire commitments
57 // directly, and it read the public inputs from which HidingKernelIO reconstructs the prior table commitments.
58 MergeCommitments merge_commitments{ .t_commitments = oink_result.ecc_op_wires,
59 .T_prev_commitments = kernel_io.ecc_op_tables };
60 GoblinVerifier::MergeVerifier merge_verifier{ transcript };
61 auto merge_result = merge_verifier.reduce_to_pairing_check(proof.merge_proof, merge_commitments);
62 vinfo("ChonkVerifier: Merge reduced to pairing check: ", merge_result.reduction_succeeded ? "true" : "false");
63
64 if (!merge_result.reduction_succeeded) {
65 info("ChonkVerifier: verification failed at Merge reduction");
66 return { false };
67 }
68 if (!merge_result.pairing_points.check()) {
69 info("ChonkVerifier: verification failed at Merge pairing check");
70 return { false };
71 }
72
73 // Step 4: ECCVM verification (reconstruct TripleIPA claim; proof is carried separately)
74 ECCVMVerifier_<ECCVMFlavor> eccvm_verifier{ transcript, proof.eccvm_proof };
75 auto eccvm_result = eccvm_verifier.reduce_to_triple_ipa_claim();
76 vinfo("ChonkVerifier: ECCVM reduced to TripleIPA claim: ", eccvm_result.reduction_succeeded ? "true" : "false");
77
78 if (!eccvm_result.reduction_succeeded) {
79 info("ChonkVerifier: verification failed at ECCVM step");
80 return { false };
81 }
82 auto translator_input = eccvm_verifier.get_translator_input_data();
83
84 // Step 5: Translator Oink + Joint sumcheck + Joint PCS
85 auto batched_result = batched_verifier.verify(proof.joint_proof,
86 translator_input.evaluation_challenge_x,
87 translator_input.batching_challenge_v,
88 translator_input.accumulated_result,
89 merge_result.merged_commitments);
90 vinfo("ChonkVerifier: Batched translator+joint reduction: ", batched_result.reduction_succeeded ? "true" : "false");
91
92 if (!batched_result.reduction_succeeded) {
93 info("ChonkVerifier: verification failed at batched translator+joint reduction");
94 return { false };
95 }
96 if (!batched_result.pairing_points.check()) {
97 info("ChonkVerifier: verification failed at batched translator+joint pairing check");
98 return { false };
99 }
100
101 return { .all_checks_passed = true,
102 .triple_ipa_opening = { .claim = std::move(eccvm_result.triple_ipa_claim), .proof = proof.ipa_proof } };
103}
104
109{
110 BB_BENCH_NAME("ChonkVerifier::verify");
111 auto result = reduce_to_triple_ipa_opening(proof);
112 if (!result.all_checks_passed) {
113 return false;
114 }
115 return ECCVMVerifier::verify_accumulator(result.triple_ipa_opening.reduce_to_accumulator());
116}
117
132{
133 // Step 1: Verify MegaZK Oink on the shared transcript
134 BatchedHonkTranslatorRecursiveVerifier batched_verifier(vk_and_hash, transcript);
135 auto oink_result = batched_verifier.verify_mega_zk_oink(proof.hiding_oink_proof);
136
137 // Extract public inputs and kernel data
138 HidingKernelIO kernel_io;
139 kernel_io.reconstruct_from_public(oink_result.public_inputs);
140
141 // Step 2: Databus consistency check (in-circuit)
142 const Commitment kernel_calldata_commitment = oink_result.kernel_calldata_commitment;
143 if (kernel_io.kernel_return_data.get_value() != kernel_calldata_commitment.get_value()) {
144 info("ChonkRecursiveVerifier: Databus Consistency check failure");
145 }
146 kernel_io.kernel_return_data.incomplete_assert_equal(kernel_calldata_commitment);
147
148 // Step 3: Merge verification
149 // These commitments are already in the shared Fiat-Shamir transcript: Oink read the ecc-op wire commitments
150 // directly, and it read the public inputs from which HidingKernelIO reconstructs the prior table commitments.
151 MergeCommitments merge_commitments{ .t_commitments = oink_result.ecc_op_wires,
152 .T_prev_commitments = kernel_io.ecc_op_tables };
153 typename GoblinVerifier::MergeVerifier merge_verifier{ transcript };
154 auto merge_result = merge_verifier.reduce_to_pairing_check(proof.merge_proof, merge_commitments);
155 vinfo("ChonkRecursiveVerifier: Merge reduced to pairing check: ",
156 merge_result.reduction_succeeded ? "true" : "false");
157
158 // Step 4: ECCVM verification
159 typename GoblinVerifier::ECCVMVerifier eccvm_verifier{ transcript, proof.eccvm_proof };
160 auto eccvm_result = eccvm_verifier.reduce_to_triple_ipa_claim();
161 vinfo("ChonkRecursiveVerifier: ECCVM reduced to TripleIPA claim: ",
162 eccvm_result.reduction_succeeded ? "true" : "false");
163 auto translator_input = eccvm_verifier.get_translator_input_data();
164
165 // Step 5: Translator Oink + Joint sumcheck + Joint PCS
166 auto batched_result = batched_verifier.verify(proof.joint_proof,
167 translator_input.evaluation_challenge_x,
168 translator_input.batching_challenge_v,
169 translator_input.accumulated_result,
170 merge_result.merged_commitments);
171 vinfo("ChonkRecursiveVerifier: Batched translator+joint reduction: ",
172 batched_result.reduction_succeeded ? "true" : "false");
173
174 // Step 6: Aggregate all pairing points (PI, Merge, Batched PCS)
175 std::vector<PairingPoints> pairing_points_to_aggregate;
176 pairing_points_to_aggregate.reserve(NUM_PAIRING_POINTS);
177
178 pairing_points_to_aggregate.push_back(kernel_io.pairing_inputs);
179 pairing_points_to_aggregate.push_back(std::move(merge_result.pairing_points));
180 pairing_points_to_aggregate.push_back(std::move(batched_result.pairing_points));
181
182 // Edge case handling disabled: Safe because:
183 // 1. Verifier-computed points (Merge, Batched PCS) are deterministic and won't collide
184 // 2. PI points are added to the result of batching the above points; biggroup addition
185 // gracefully handles edge cases.
186 constexpr bool handle_edge_cases = false;
187 PairingPoints aggregated_pairing_points =
188 PairingPoints::aggregate_multiple(pairing_points_to_aggregate, handle_edge_cases);
189
190 bool all_checks_passed =
191 merge_result.reduction_succeeded && eccvm_result.reduction_succeeded && batched_result.reduction_succeeded;
192
193 return ReductionResult{
194 .pairing_points = std::move(aggregated_pairing_points),
195 .triple_ipa_opening = { .claim = std::move(eccvm_result.triple_ipa_claim), .proof = proof.ipa_proof },
196 .all_checks_passed = all_checks_passed,
197 };
198}
199
204template <>
206 [[maybe_unused]] const Proof& proof)
207{
208 throw_or_abort("reduce_to_triple_ipa_opening is only available for native (non-recursive) ChonkVerifier");
209}
210
211// Template instantiations
212template class ChonkVerifier<false>; // Native verifier
213template class ChonkVerifier<true>; // Recursive verifier
214
215} // namespace bb
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:264
Verifier for the batched MegaZK circuit + translator sumcheck and PCS.
ReductionResult verify(const Proof &joint_proof, const TransBF &evaluation_input_x, const TransBF &batching_challenge_v, const TransBF &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
Phase 2: Verify translator Oink + joint sumcheck + joint PCS.
OinkResult verify_mega_zk_oink(const Proof &mega_zk_proof)
Phase 1: Verify the MegaZK Oink phase on the shared transcript.
Verifier for Chonk IVC proofs (both native and recursive).
std::conditional_t< IsRecursive, ReductionResult, bool > Output
TripleIpaReductionResult reduce_to_triple_ipa_opening(const Proof &proof)
Run Chonk verification up to but not including TripleIPA verification.
typename GoblinVerifier::ReductionResult::PairingPoints PairingPoints
typename GoblinVerifier::MergeVerifier::InputCommitments MergeCommitments
Output verify(const Proof &proof)
Verify a Chonk proof.
std::conditional_t< IsRecursive, stdlib::recursion::honk::HidingKernelIO< Builder >, bb::HidingKernelIO > HidingKernelIO
typename HidingKernelVerifier::Commitment Commitment
std::conditional_t< IsRecursive, ChonkStdlibProof, ChonkProof > Proof
Unified ECCVM verifier class for both native and recursive verification.
ReductionResult reduce_to_triple_ipa_claim()
Reduce the ECCVM proof to a compact TripleIPA verifier claim.
static bool verify_accumulator(const TripleIpaAccumulator &accumulator)
Verifier for the single-step Goblin ECC op queue merge protocol.
ReductionResult reduce_to_pairing_check(const Proof &proof, const InputCommitments &input_commitments)
Reduce the merge proof to a pairing check.
#define info(...)
Definition log.hpp:93
#define vinfo(...)
Definition log.hpp:94
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Result of Chonk verification reduction (recursive mode only)
Result of reducing Chonk verification to a deferred TripleIPA opening (native mode only).
void throw_or_abort(std::string const &err)
VectorField result