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"
11
12namespace bb {
13
18{
19 BB_BENCH_NAME("ChonkVerifier::reduce_to_ipa_claim");
20 // Step 1: Verify the Hiding kernel proof (includes pairing check)
21 HidingKernelVerifier verifier{ vk_and_hash, transcript };
22 auto verifier_output = verifier.verify_proof(proof.mega_proof);
23 if (!verifier_output.result) {
24 info("ChonkVerifier: verification failed at MegaZK verification step");
25 return { {}, {}, false };
26 }
27
28 // Extract public inputs and kernel data
29 HidingKernelIO kernel_io;
30 kernel_io.reconstruct_from_public(verifier.get_public_inputs());
31
32 // Step 2: Perform databus consistency check
33 const Commitment calldata_commitment = verifier.get_calldata_commitment();
34 const Commitment return_data_commitment = kernel_io.kernel_return_data;
35 bool databus_consistency_verified = (calldata_commitment == return_data_commitment);
36 vinfo("ChonkVerifier: databus consistency verified: ", databus_consistency_verified);
37 if (!databus_consistency_verified) {
38 info("Chonk Verifier: verification failed at databus consistency check");
39 return { {}, {}, false };
40 }
41
42 // Step 3: Goblin verification (merge, eccvm, translator)
43 MergeCommitments merge_commitments{ .t_commitments = verifier.get_ecc_op_wires(),
44 .T_prev_commitments = kernel_io.ecc_op_tables };
45 GoblinVerifier goblin_verifier{ transcript, proof.goblin_proof, merge_commitments, MergeSettings::APPEND };
46 GoblinReductionResult goblin_output = goblin_verifier.reduce_to_pairing_check_and_ipa_opening();
47
48 if (!goblin_output.all_checks_passed) {
49 info("ChonkVerifier: chonk verification failed at Goblin checks (merge/eccvm/translator reduction + pairing)");
50 return { {}, {}, false };
51 }
52
53 return { std::move(goblin_output.ipa_claim), std::move(goblin_output.ipa_proof), true };
54}
55
60{
61 BB_BENCH_NAME("ChonkVerifier::verify");
62 auto result = reduce_to_ipa_claim(proof);
63 if (!result.all_checks_passed) {
64 return false;
65 }
66
67 // Step 4: Verify IPA opening
68 auto ipa_transcript = std::make_shared<Goblin::Transcript>(result.ipa_proof);
70 bool ipa_verified = IPA<curve::Grumpkin>::reduce_verify(ipa_vk, result.ipa_claim, ipa_transcript);
71 vinfo("ChonkVerifier: Goblin IPA verified: ", ipa_verified);
72 if (!ipa_verified) {
73 info("ChonkVerifier: Chonk verification failed at IPA check");
74 return false;
75 }
76
77 return true;
78}
79
84{
85 // Step 1: Reduce the Hiding kernel proof to pairing check
86 HidingKernelVerifier verifier{ vk_and_hash, transcript };
87 auto [mega_pcs_pairing_points, mega_reduction_succeeded] = verifier.reduce_to_pairing_check(proof.mega_proof);
88 vinfo("ChonkRecursiveVerifier: MegaZK reduced to pairing check: ", mega_reduction_succeeded ? "true" : "false");
89
90 // Extract public inputs and kernel data
91 HidingKernelIO kernel_io;
92 kernel_io.reconstruct_from_public(verifier.get_public_inputs());
93
94 // Step 2: Perform databus consistency check (in-circuit)
95 const Commitment calldata_commitment = verifier.get_calldata_commitment();
96 if (kernel_io.kernel_return_data.get_value() != calldata_commitment.get_value()) {
97 info("ChonkRecursiveVerifier: Databus Consistency check failure");
98 }
99 kernel_io.kernel_return_data.incomplete_assert_equal(calldata_commitment);
100
101 // Step 3: Goblin verification (merge, eccvm, translator)
102 MergeCommitments merge_commitments{ .t_commitments = verifier.get_ecc_op_wires(),
103 .T_prev_commitments = kernel_io.ecc_op_tables };
104 GoblinVerifier goblin_verifier{ transcript, proof.goblin_proof, merge_commitments, MergeSettings::APPEND };
105 GoblinReductionResult goblin_output = goblin_verifier.reduce_to_pairing_check_and_ipa_opening();
106
107 // Step 4: Batch aggregate all pairing points
108 std::vector<PairingPoints> pairing_points_to_aggregate;
109 pairing_points_to_aggregate.reserve(NUM_PAIRING_POINTS);
110
111 // Collect all pairing points: PI, PCS, Merge, Translator
112 pairing_points_to_aggregate.push_back(kernel_io.pairing_inputs);
113 pairing_points_to_aggregate.push_back(std::move(mega_pcs_pairing_points));
114 pairing_points_to_aggregate.push_back(std::move(goblin_output.merge_pairing_points));
115 pairing_points_to_aggregate.push_back(std::move(goblin_output.translator_pairing_points));
116
117 // Edge case handling disabled: Safe because:
118 // 1. Verifier-computed points (PCS, Merge, Translator) are deterministic and won't collide
119 // 2. PI points are added to to the result of batching of the above points, biggroup point addition gracefully
120 // handles edge cases.
121 constexpr bool handle_edge_cases = false;
122 PairingPoints aggregated_pairing_points =
123 PairingPoints::aggregate_multiple(pairing_points_to_aggregate, handle_edge_cases);
124
125 // Return reduction result with aggregated pairing points
126 return ReductionResult{ .pairing_points = std::move(aggregated_pairing_points),
127 .ipa_claim = std::move(goblin_output.ipa_claim),
128 .ipa_proof = std::move(goblin_output.ipa_proof),
129 .all_checks_passed = mega_reduction_succeeded && goblin_output.all_checks_passed };
130}
131
135template <>
137{
138 throw_or_abort("reduce_to_ipa_claim is only available for native (non-recursive) ChonkVerifier");
139}
140
141// Template instantiations
142template class ChonkVerifier<false>; // Native verifier
143template class ChonkVerifier<true>; // Recursive verifier
144
145} // namespace bb
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:225
Verifier for Chonk IVC proofs (both native and recursive).
std::conditional_t< IsRecursive, ReductionResult, bool > Output
std::conditional_t< IsRecursive, bb::MegaZKRecursiveVerifier, bb::MegaZKVerifier > HidingKernelVerifier
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 GoblinVerifier::ReductionResult GoblinReductionResult
std::conditional_t< IsRecursive, bb::GoblinRecursiveVerifier, bb::GoblinVerifier > GoblinVerifier
typename HidingKernelVerifier::Commitment Commitment
std::conditional_t< IsRecursive, ChonkStdlibProof, ChonkProof > Proof
static constexpr size_t ECCVM_FIXED_SIZE
IPA (inner product argument) commitment scheme class.
Definition ipa.hpp:86
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)