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
27{
28 BB_BENCH_NAME("ChonkVerifier::reduce_to_ipa_claim");
29
30 // Step 1: Verify MegaZK Oink on the shared transcript
31 BatchedHonkTranslatorVerifier batched_verifier(vk_and_hash, transcript);
32 auto oink_result = batched_verifier.verify_mega_zk_oink(proof.hiding_oink_proof);
33
34 // Extract public inputs and kernel data
35 HidingKernelIO kernel_io;
36 kernel_io.reconstruct_from_public(oink_result.public_inputs);
37
38 // Check accumulated pairing points from the IVC chain (inner recursive verifications)
39 if (!kernel_io.pairing_inputs.check()) {
40 info("ChonkVerifier: verification failed at PI pairing points check");
41 return { {}, {}, false };
42 }
43
44 // Step 2: Databus consistency check
45 const Commitment kernel_calldata_commitment = oink_result.kernel_calldata_commitment;
46 const Commitment return_data_commitment = kernel_io.kernel_return_data;
47 bool databus_consistency_verified = (kernel_calldata_commitment == return_data_commitment);
48 vinfo("ChonkVerifier: databus consistency verified: ", databus_consistency_verified);
49 if (!databus_consistency_verified) {
50 info("ChonkVerifier: verification failed at databus consistency check");
51 return { {}, {}, false };
52 }
53
54 // Step 3: Merge verification
55 MergeCommitments merge_commitments{ .t_commitments = oink_result.ecc_op_wires,
56 .T_prev_commitments = kernel_io.ecc_op_tables };
57 GoblinVerifier::MergeVerifier merge_verifier{ transcript };
58 auto merge_result = merge_verifier.reduce_to_pairing_check(proof.merge_proof, merge_commitments);
59 vinfo("ChonkVerifier: Merge reduced to pairing check: ", merge_result.reduction_succeeded ? "true" : "false");
60
61 if (!merge_result.reduction_succeeded) {
62 info("ChonkVerifier: verification failed at Merge reduction");
63 return { {}, {}, false };
64 }
65 if (!merge_result.pairing_points.check()) {
66 info("ChonkVerifier: verification failed at Merge pairing check");
67 return { {}, {}, false };
68 }
69
70 // Step 4: ECCVM verification
71 ECCVMVerifier_<ECCVMFlavor> eccvm_verifier{ transcript, proof.eccvm_proof };
72 auto eccvm_result = eccvm_verifier.reduce_to_ipa_opening();
73 vinfo("ChonkVerifier: ECCVM reduced to IPA opening: ", eccvm_result.reduction_succeeded ? "true" : "false");
74
75 if (!eccvm_result.reduction_succeeded) {
76 info("ChonkVerifier: verification failed at ECCVM step");
77 return { {}, {}, false };
78 }
79 auto translator_input = eccvm_verifier.get_translator_input_data();
80
81 // Step 5: Translator Oink + Joint sumcheck + Joint PCS
82 auto batched_result = batched_verifier.verify(proof.joint_proof,
83 translator_input.evaluation_challenge_x,
84 translator_input.batching_challenge_v,
85 translator_input.accumulated_result,
86 merge_result.merged_commitments);
87 vinfo("ChonkVerifier: Batched translator+joint reduction: ", batched_result.reduction_succeeded ? "true" : "false");
88
89 if (!batched_result.reduction_succeeded) {
90 info("ChonkVerifier: verification failed at batched translator+joint reduction");
91 return { {}, {}, false };
92 }
93 if (!batched_result.pairing_points.check()) {
94 info("ChonkVerifier: verification failed at batched translator+joint pairing check");
95 return { {}, {}, false };
96 }
97
98 return { std::move(eccvm_result.ipa_claim), proof.ipa_proof, true };
99}
100
105{
106 BB_BENCH_NAME("ChonkVerifier::verify");
107 auto result = reduce_to_ipa_claim(proof);
108 if (!result.all_checks_passed) {
109 return false;
110 }
111
112 // Step 6: Verify IPA opening
113 auto ipa_transcript = std::make_shared<Goblin::Transcript>(result.ipa_proof);
115 bool ipa_verified = IPA<curve::Grumpkin>::reduce_verify(ipa_vk, result.ipa_claim, ipa_transcript);
116 vinfo("ChonkVerifier: Goblin IPA verified: ", ipa_verified);
117 if (!ipa_verified) {
118 info("ChonkVerifier: Chonk verification failed at IPA check");
119 return false;
120 }
121
122 return true;
123}
124
139{
140 // Step 1: Verify MegaZK Oink on the shared transcript
141 BatchedHonkTranslatorRecursiveVerifier batched_verifier(vk_and_hash, transcript);
142 auto oink_result = batched_verifier.verify_mega_zk_oink(proof.hiding_oink_proof);
143
144 // Extract public inputs and kernel data
145 HidingKernelIO kernel_io;
146 kernel_io.reconstruct_from_public(oink_result.public_inputs);
147
148 // Step 2: Databus consistency check (in-circuit)
149 const Commitment kernel_calldata_commitment = oink_result.kernel_calldata_commitment;
150 if (kernel_io.kernel_return_data.get_value() != kernel_calldata_commitment.get_value()) {
151 info("ChonkRecursiveVerifier: Databus Consistency check failure");
152 }
153 kernel_io.kernel_return_data.incomplete_assert_equal(kernel_calldata_commitment);
154
155 // Step 3: Merge verification
156 MergeCommitments merge_commitments{ .t_commitments = oink_result.ecc_op_wires,
157 .T_prev_commitments = kernel_io.ecc_op_tables };
158 typename GoblinVerifier::MergeVerifier merge_verifier{ transcript };
159 auto merge_result = merge_verifier.reduce_to_pairing_check(proof.merge_proof, merge_commitments);
160 vinfo("ChonkRecursiveVerifier: Merge reduced to pairing check: ",
161 merge_result.reduction_succeeded ? "true" : "false");
162
163 // Step 4: ECCVM verification
164 typename GoblinVerifier::ECCVMVerifier eccvm_verifier{ transcript, proof.eccvm_proof };
165 auto eccvm_result = eccvm_verifier.reduce_to_ipa_opening();
166 vinfo("ChonkRecursiveVerifier: ECCVM reduced to IPA opening: ",
167 eccvm_result.reduction_succeeded ? "true" : "false");
168 auto translator_input = eccvm_verifier.get_translator_input_data();
169
170 // Step 5: Translator Oink + Joint sumcheck + Joint PCS
171 auto batched_result = batched_verifier.verify(proof.joint_proof,
172 translator_input.evaluation_challenge_x,
173 translator_input.batching_challenge_v,
174 translator_input.accumulated_result,
175 merge_result.merged_commitments);
176 vinfo("ChonkRecursiveVerifier: Batched translator+joint reduction: ",
177 batched_result.reduction_succeeded ? "true" : "false");
178
179 // Step 6: Aggregate all pairing points (PI, Merge, Batched PCS)
180 std::vector<PairingPoints> pairing_points_to_aggregate;
181 pairing_points_to_aggregate.reserve(NUM_PAIRING_POINTS);
182
183 pairing_points_to_aggregate.push_back(kernel_io.pairing_inputs);
184 pairing_points_to_aggregate.push_back(std::move(merge_result.pairing_points));
185 pairing_points_to_aggregate.push_back(std::move(batched_result.pairing_points));
186
187 // Edge case handling disabled: Safe because:
188 // 1. Verifier-computed points (Merge, Batched PCS) are deterministic and won't collide
189 // 2. PI points are added to the result of batching the above points; biggroup addition
190 // gracefully handles edge cases.
191 constexpr bool handle_edge_cases = false;
192 PairingPoints aggregated_pairing_points =
193 PairingPoints::aggregate_multiple(pairing_points_to_aggregate, handle_edge_cases);
194
195 bool all_checks_passed =
196 merge_result.reduction_succeeded && eccvm_result.reduction_succeeded && batched_result.reduction_succeeded;
197
198 return ReductionResult{ .pairing_points = std::move(aggregated_pairing_points),
199 .ipa_claim = std::move(eccvm_result.ipa_claim),
200 .ipa_proof = proof.ipa_proof,
201 .all_checks_passed = all_checks_passed };
202}
203
207template <>
209{
210 throw_or_abort("reduce_to_ipa_claim is only available for native (non-recursive) ChonkVerifier");
211}
212
213// Template instantiations
214template class ChonkVerifier<false>; // Native verifier
215template class ChonkVerifier<true>; // Recursive verifier
216
217} // 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
IPAReductionResult reduce_to_ipa_claim(const Proof &proof)
Run Chonk verification up to but not including IPA, returning the IPA claim for deferred 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
static constexpr size_t ECCVM_FIXED_SIZE
Unified ECCVM verifier class for both native and recursive verification.
ReductionResult reduce_to_ipa_opening()
Reduce the ECCVM proof to an IPA opening claim.
IPA (inner product argument) commitment scheme class.
Definition ipa.hpp:86
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.
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
#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 reducing Chonk verification to an IPA opening claim (native mode only).
Result of Chonk verification reduction (recursive mode only)
void throw_or_abort(std::string const &err)