Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
chonk_recursive_verifier.hpp
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
7#pragma once
10
13 using Builder = UltraCircuitBuilder; // The circuit will be an Ultra circuit
14 using RecursiveFlavor = MegaZKRecursiveFlavor_<Builder>; // The Hiding kernel verifier algorithm is MegaZK
22
23 public:
28
29 struct StdlibProof {
31
32 static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n = Flavor::VIRTUAL_LOG_N)
33 {
35 }
36
37 static constexpr size_t PROOF_LENGTH(size_t virtual_log_n = Flavor::VIRTUAL_LOG_N)
38 {
39 return bb::Chonk::Proof::PROOF_LENGTH(virtual_log_n);
40 }
41
42 StdlibHonkProof mega_proof; // proof of the hiding circuit
44
49
56 StdlibProof(const std::vector<field_t<Builder>>& proof_indices,
57 size_t public_inputs_size,
58 size_t virtual_log_n = Flavor::VIRTUAL_LOG_N)
59 {
60
61 BB_ASSERT_EQ(proof_indices.size(),
62 PROOF_LENGTH(virtual_log_n) + public_inputs_size,
63 "Number of indices differs from the expected proof size.");
64
65 auto it = proof_indices.begin();
66
67 // Mega proof
68 std::ptrdiff_t start_idx = 0;
69 std::ptrdiff_t end_idx = static_cast<std::ptrdiff_t>(
70 RecursiveFlavor::NativeFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n) +
72 mega_proof.insert(mega_proof.end(), it + start_idx, it + end_idx);
73
74 // Merge proof
75 start_idx = end_idx;
76 end_idx += static_cast<std::ptrdiff_t>(MERGE_PROOF_SIZE);
77 goblin_proof.merge_proof.insert(goblin_proof.merge_proof.end(), it + start_idx, it + end_idx);
78
79 // ECCVM proof (IPA is separate)
80 start_idx = end_idx;
82 goblin_proof.eccvm_proof.insert(goblin_proof.eccvm_proof.end(), it + start_idx, it + end_idx);
83
84 // IPA proof
85 start_idx = end_idx;
86 end_idx += static_cast<std::ptrdiff_t>(IPA_PROOF_LENGTH);
87 goblin_proof.ipa_proof.insert(goblin_proof.ipa_proof.end(), it + start_idx, it + end_idx);
88
89 // Translator proof
90 start_idx = end_idx;
92 goblin_proof.translator_proof.insert(goblin_proof.translator_proof.end(), it + start_idx, it + end_idx);
93
94 BB_ASSERT_EQ(static_cast<uint32_t>(end_idx),
95 PROOF_LENGTH(virtual_log_n) + public_inputs_size,
96 "Reconstructed a Chonk proof of wrong the length from proof indices.");
97 }
98 };
99
100 ChonkRecursiveVerifier(Builder* builder, const std::shared_ptr<VerificationKey>& native_mega_vk)
102 , stdlib_mega_vk_and_hash(std::make_shared<RecursiveVKAndHash>(*builder, native_mega_vk)) {};
103
107
108 [[nodiscard("IPA claim and Pairing points should be accumulated")]] Output verify(const StdlibProof&);
109
110 private:
112 // VK and hash of the hiding kernel
113 std::shared_ptr<RecursiveVKAndHash> stdlib_mega_vk_and_hash;
114};
115} // namespace bb::stdlib::recursion::honk
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:77
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
Child class of MegaFlavor that runs with ZK Sumcheck. See more in Sumcheck Outline.
static constexpr size_t VIRTUAL_LOG_N
The recursive counterpart to the "native" MegaZKFlavor.
typename MegaRecursiveFlavor_< BuilderType >::VerificationKey VerificationKey
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:19
Output verify(const StdlibProof &)
Creates a circuit that executes the Chonk verification algorithm.
ChonkRecursiveVerifier(Builder *builder, const std::shared_ptr< VerificationKey > &native_mega_vk)
ChonkRecursiveVerifier(Builder *builder, const std::shared_ptr< RecursiveVKAndHash > &stdlib_mega_vk_and_hash)
RecursiveVerifierInstance::VerificationKey RecursiveVerificationKey
std::shared_ptr< RecursiveVKAndHash > stdlib_mega_vk_and_hash
Manages the data that is propagated on the public inputs of a hiding kernel circuit.
The stdlib counterpart of VerifierInstance, used in recursive folding verification.
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
A full proof for the IVC scheme containing a Mega proof showing correctness of the Hiding kernel (whi...
Definition chonk.hpp:91
static constexpr size_t PROOF_LENGTH(size_t virtual_log_n=MegaZKFlavor::VIRTUAL_LOG_N)
The size of a Chonk proof with backend-added public inputs: HidingKernelIO.
Definition chonk.hpp:116
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n=MegaZKFlavor::VIRTUAL_LOG_N)
The size of a Chonk proof without backend-added public inputs.
Definition chonk.hpp:101
static constexpr size_t PROOF_LENGTH(size_t virtual_log_n=Flavor::VIRTUAL_LOG_N)
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n=Flavor::VIRTUAL_LOG_N)
StdlibProof(const std::vector< field_t< Builder > > &proof_indices, size_t public_inputs_size, size_t virtual_log_n=Flavor::VIRTUAL_LOG_N)
Construct a new Stdlib Proof object from indices in a builder.