Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy_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#include <type_traits>
15
16namespace bb {
17template <class VerifierInstance> class ProtogalaxyVerifier_ {
18 public:
19 using Flavor = typename VerifierInstance::Flavor;
21 using FF = typename Flavor::FF;
28
29 static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS;
30 static constexpr size_t BATCHED_EXTENDED_LENGTH = computed_batched_extended_length<Flavor>();
31
33
34 std::shared_ptr<Transcript> transcript = std::make_shared<Transcript>();
35
36 ProtogalaxyVerifier_(const VerifierInstances& insts, const std::shared_ptr<Transcript>& transcript)
37 : insts_to_fold(insts)
40
46 void run_oink_verifier_on_each_incomplete_instance(const std::vector<FF>&);
47
52 std::shared_ptr<VerifierInstance> verify_folding_proof(const std::vector<FF>&);
53
54 private:
61
68 template <FOLDING_DATA FoldingData> auto get_data_to_fold() const
69 {
70 using PrecomputedCommDataType = RefArray<Commitment, Flavor::NUM_PRECOMPUTED_ENTITIES>;
71 using WitnessCommitmentsDataType = RefArray<Commitment, Flavor::NUM_WITNESS_ENTITIES>;
72 using AlphasDataType = Flavor::SubrelationSeparators;
73 using RelationParametersDataType = RefArray<FF, RelationParameters<FF>::NUM_TO_FOLD>;
74 using DataType = std::conditional_t<
76 PrecomputedCommDataType,
79 WitnessCommitmentsDataType,
81
83 if constexpr (FoldingData == FOLDING_DATA::PRECOMPUTED_COMMITMENTS) {
84 data[0] = insts_to_fold[0]->vk->get_all();
85 data[1] = insts_to_fold[1]->vk->get_all();
86 } else if constexpr (FoldingData == FOLDING_DATA::WITNESS_COMMITMENTS) {
87 data[0] = insts_to_fold[0]->witness_commitments.get_all();
88 data[1] = insts_to_fold[1]->witness_commitments.get_all();
89 } else if constexpr (FoldingData == FOLDING_DATA::ALPHAS) {
90 data[0] = insts_to_fold[0]->alphas;
91 data[1] = insts_to_fold[1]->alphas;
92 } else if constexpr (FoldingData == FOLDING_DATA::RELATION_PARAMETERS) {
93 data[0] = insts_to_fold[0]->relation_parameters.get_to_fold();
94 data[1] = insts_to_fold[1]->relation_parameters.get_to_fold();
95 } else {
96 throw_or_abort("Invalid folding data type.");
97 }
98
99 // Extract data type (strip references for storage in std::vector)
100 using ReturnType = decltype(data[0][0]);
101 using ReturnValue = std::remove_reference_t<ReturnType>;
102
103 const size_t num_to_fold = data[0].size();
104 std::vector<std::vector<ReturnValue>> result(num_to_fold, std::vector<ReturnValue>(NUM_INSTANCES));
105 for (size_t idx = 0; auto& data_at_idx : result) {
106 data_at_idx[0] = data[0][idx];
107 data_at_idx[1] = data[1][idx];
108 idx++;
109 }
110 return result;
111 }
112};
113
114} // namespace bb
A container for commitment labels.
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
WitnessEntities< Commitment > WitnessCommitments
A container for the witness commitments.
Curve::ScalarField FF
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
static constexpr size_t NUM_SUBRELATIONS
NativeTranscript Transcript
Curve::AffineElement Commitment
typename Flavor::VerificationKey VerificationKey
void run_oink_verifier_on_each_incomplete_instance(const std::vector< FF > &)
Instatiate the verifier instances and the transcript.
std::array< std::shared_ptr< VerifierInstance >, NUM_INSTANCES > VerifierInstances
std::shared_ptr< VerifierInstance > verify_folding_proof(const std::vector< FF > &)
Run the folding protocol on the verifier side to establish whether the public data ϕ of the new accum...
typename Flavor::WitnessCommitments WitnessCommitments
static constexpr size_t NUM_SUBRELATIONS
typename VerifierInstance::Flavor Flavor
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...
typename Flavor::CommitmentLabels CommitmentLabels
typename Flavor::SubrelationSeparators SubrelationSeparators
static constexpr size_t BATCHED_EXTENDED_LENGTH
ProtogalaxyVerifier_(const VerifierInstances &insts, const std::shared_ptr< Transcript > &transcript)
std::shared_ptr< Transcript > transcript
typename Flavor::Commitment Commitment
typename Flavor::Transcript Transcript
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:22
const std::vector< FF > data
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
void throw_or_abort(std::string const &err)