Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy_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
14
16template <class VerifierInstance> class ProtogalaxyRecursiveVerifier_ {
17 public:
18 using Flavor = typename VerifierInstance::Flavor;
19 using FF = typename Flavor::FF;
21 using BaseField = typename Commitment::BaseField;
22 using VKAndHash = typename Flavor::VKAndHash;
24
27
28 static constexpr size_t EXTENDED_LENGTH = computed_extended_length<Flavor>();
29 static constexpr size_t BATCHED_EXTENDED_LENGTH = computed_batched_extended_length<Flavor>();
30 static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS;
31
33
35
36 std::shared_ptr<Transcript> transcript = std::make_shared<Transcript>();
37
39 const std::shared_ptr<VerifierInstance>& accumulator,
40 const std::shared_ptr<VKAndHash>& vk_and_hash,
41 const std::shared_ptr<Transcript>& transcript)
44 {
45 insts_to_fold[0] = accumulator;
47 };
48
50 const std::shared_ptr<VerifierInstance>& accumulator,
51 const std::shared_ptr<VerifierInstance>& incoming_instance,
52 const std::shared_ptr<Transcript>& transcript)
55 {
56 insts_to_fold[0] = accumulator;
57 insts_to_fold[1] = incoming_instance;
58 };
59
63 void run_oink_verifier_on_each_incomplete_instance(const std::vector<FF>&);
64
81 std::shared_ptr<VerifierInstance> verify_folding_proof(const stdlib::Proof<Builder>&);
82
83 private:
90
97 template <FOLDING_DATA FoldingData> auto get_data_to_fold() const
98 {
99 using PrecomputedCommDataType = RefArray<Commitment, Flavor::NUM_PRECOMPUTED_ENTITIES>;
100 using WitnessCommitmentsDataType = RefArray<Commitment, Flavor::NUM_WITNESS_ENTITIES>;
101 using AlphasDataType = Flavor::SubrelationSeparators;
102 using RelationParametersDataType = RefArray<FF, RelationParameters<FF>::NUM_TO_FOLD>;
103 using DataType = std::conditional_t<
105 PrecomputedCommDataType,
108 WitnessCommitmentsDataType,
110
112 if constexpr (FoldingData == FOLDING_DATA::PRECOMPUTED_COMMITMENTS) {
113 data[0] = insts_to_fold[0]->vk_and_hash->vk->get_all();
114 data[1] = insts_to_fold[1]->vk_and_hash->vk->get_all();
115 } else if constexpr (FoldingData == FOLDING_DATA::WITNESS_COMMITMENTS) {
116 data[0] = insts_to_fold[0]->witness_commitments.get_all();
117 data[1] = insts_to_fold[1]->witness_commitments.get_all();
118 } else if constexpr (FoldingData == FOLDING_DATA::ALPHAS) {
119 data[0] = insts_to_fold[0]->alphas;
120 data[1] = insts_to_fold[1]->alphas;
121 } else if constexpr (FoldingData == FOLDING_DATA::RELATION_PARAMETERS) {
122 data[0] = insts_to_fold[0]->relation_parameters.get_to_fold();
123 data[1] = insts_to_fold[1]->relation_parameters.get_to_fold();
124 } else {
125 throw_or_abort("Invalid folding data type.");
126 }
127
128 // Extract data type (strip references for storage in std::vector)
129 using ReturnType = decltype(data[0][0]);
130 using ReturnValue = std::remove_reference_t<ReturnType>;
131
132 const size_t num_to_fold = data[0].size();
133 std::vector<std::vector<ReturnValue>> result(num_to_fold, std::vector<ReturnValue>(NUM_INSTANCES));
134 for (size_t idx = 0; auto& data_at_idx : result) {
135 data_at_idx[0] = data[0][idx];
136 data_at_idx[1] = data[1][idx];
137 idx++;
138 }
139 return result;
140 }
141};
142
143} // namespace bb::stdlib::recursion::honk
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
Curve::ScalarField FF
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
static constexpr size_t NUM_SUBRELATIONS
MegaCircuitBuilder CircuitBuilder
Curve::AffineElement Commitment
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:22
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:19
ProtogalaxyRecursiveVerifier_(Builder *builder, const std::shared_ptr< VerifierInstance > &accumulator, const std::shared_ptr< VKAndHash > &vk_and_hash, const std::shared_ptr< Transcript > &transcript)
std::array< std::shared_ptr< VerifierInstance >, NUM_INSTANCES > VerifierInstances
auto get_data_to_fold() const
Get data to be folded grouped by commitment index. Here the "commitment index" is the index of the ro...
void run_oink_verifier_on_each_incomplete_instance(const std::vector< FF > &)
Process the public data for the verification keys to be folded.
std::shared_ptr< VerifierInstance > verify_folding_proof(const stdlib::Proof< Builder > &)
Run the folding protocol on the verifier side to establish whether the public data of the new accumu...
ProtogalaxyRecursiveVerifier_(Builder *builder, const std::shared_ptr< VerifierInstance > &accumulator, const std::shared_ptr< VerifierInstance > &incoming_instance, const std::shared_ptr< Transcript > &transcript)
const std::vector< FF > data
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
void throw_or_abort(std::string const &err)