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"
10
11namespace bb {
12
17{
18 // Step 1: Verify the Hiding kernel proof (includes pairing check)
19 HidingKernelVerifier verifier{ vk_and_hash, transcript };
20 auto verifier_output = verifier.verify_proof(proof.mega_proof);
21 if (!verifier_output.result) {
22 info("ChonkVerifier: verification failed at MegaZK verification step");
23 return false;
24 }
25
26 // Extract public inputs and kernel data
27 HidingKernelIO kernel_io;
28 kernel_io.reconstruct_from_public(verifier.get_public_inputs());
29
30 // Step 2: Perform databus consistency check
31 const Commitment calldata_commitment = verifier.get_calldata_commitment();
32 const Commitment return_data_commitment = kernel_io.kernel_return_data;
33 bool databus_consistency_verified = (calldata_commitment == return_data_commitment);
34 vinfo("ChonkVerifier: databus consistency verified: ", databus_consistency_verified);
35 if (!databus_consistency_verified) {
36 info("Chonk Verifier: verification failed at databus consistency check");
37 return false;
38 }
39
40 // Step 3: Goblin verification (merge, eccvm, translator)
41 MergeCommitments merge_commitments{ .t_commitments = verifier.get_ecc_op_wires(),
42 .T_prev_commitments = kernel_io.ecc_op_tables };
43 GoblinVerifier goblin_verifier{ transcript, proof.goblin_proof, merge_commitments, MergeSettings::APPEND };
44 GoblinReductionResult goblin_output = goblin_verifier.reduce_to_pairing_check_and_ipa_opening();
45
46 if (!goblin_output.all_checks_passed) {
47 info("ChonkVerifier: chonk verification failed at Goblin checks (merge/eccvm/translator reduction + pairing)");
48 return false;
49 }
50
51 // Step 4: Verify IPA opening
52 auto ipa_transcript = std::make_shared<Goblin::Transcript>(goblin_output.ipa_proof);
54 bool ipa_verified = IPA<curve::Grumpkin>::reduce_verify(ipa_vk, goblin_output.ipa_claim, ipa_transcript);
55 vinfo("ChonkVerifier: Goblin IPA verified: ", ipa_verified);
56 if (!ipa_verified) {
57 info("ChonkVerifier: Chonk verification failed at IPA check");
58 return false;
59 }
60
61 return true;
62}
63
68{
69 // Step 1: Reduce the Hiding kernel proof to pairing check
70 HidingKernelVerifier verifier{ vk_and_hash, transcript };
71 auto [mega_pcs_pairing_points, mega_reduction_succeeded] = verifier.reduce_to_pairing_check(proof.mega_proof);
72 vinfo("ChonkRecursiveVerifier: MegaZK reduced to pairing check: ", mega_reduction_succeeded ? "true" : "false");
73
74 // Extract public inputs and kernel data
75 HidingKernelIO kernel_io;
76 kernel_io.reconstruct_from_public(verifier.get_public_inputs());
77
78 // Step 2: Perform databus consistency check (in-circuit)
79 const Commitment calldata_commitment = verifier.get_calldata_commitment();
80 if (kernel_io.kernel_return_data.get_value() != calldata_commitment.get_value()) {
81 info("ChonkRecursiveVerifier: Databus Consistency check failure");
82 }
83 kernel_io.kernel_return_data.incomplete_assert_equal(calldata_commitment);
84
85 // Step 3: Goblin verification (merge, eccvm, translator)
86 MergeCommitments merge_commitments{ .t_commitments = verifier.get_ecc_op_wires(),
87 .T_prev_commitments = kernel_io.ecc_op_tables };
88 GoblinVerifier goblin_verifier{ transcript, proof.goblin_proof, merge_commitments, MergeSettings::APPEND };
89 GoblinReductionResult goblin_output = goblin_verifier.reduce_to_pairing_check_and_ipa_opening();
90
91 // Step 4: Batch aggregate all pairing points
92 std::vector<PairingPoints> pairing_points_to_aggregate;
93 pairing_points_to_aggregate.reserve(NUM_PAIRING_POINTS);
94
95 // Collect all pairing points: PI, PCS, Merge, Translator
96 pairing_points_to_aggregate.push_back(kernel_io.pairing_inputs);
97 pairing_points_to_aggregate.push_back(std::move(mega_pcs_pairing_points));
98 pairing_points_to_aggregate.push_back(std::move(goblin_output.merge_pairing_points));
99 pairing_points_to_aggregate.push_back(std::move(goblin_output.translator_pairing_points));
100
101 // Edge case handling disabled: Safe because:
102 // 1. Verifier-computed points (PCS, Merge, Translator) are deterministic and won't collide
103 // 2. PI points are added to to the result of batching of the above points, biggroup point addition gracefully
104 // handles edge cases.
105 constexpr bool handle_edge_cases = false;
106 PairingPoints aggregated_pairing_points =
107 PairingPoints::aggregate_multiple(pairing_points_to_aggregate, handle_edge_cases);
108
109 // Return reduction result with aggregated pairing points
110 return ReductionResult{ .pairing_points = std::move(aggregated_pairing_points),
111 .ipa_claim = std::move(goblin_output.ipa_claim),
112 .ipa_proof = std::move(goblin_output.ipa_proof),
113 .all_checks_passed = mega_reduction_succeeded && goblin_output.all_checks_passed };
114}
115
116// Template instantiations
117template class ChonkVerifier<false>; // Native verifier
118template class ChonkVerifier<true>; // Recursive verifier
119
120} // namespace bb
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
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:93
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
#define vinfo(...)
Definition log.hpp:94
void info(Args... args)
Definition log.hpp:89
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)