Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
recursive_decider_verification_keys.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
12
14template <IsRecursiveFlavor Flavor_, size_t NUM_> struct RecursiveDeciderVerificationKeys_ {
15 using Flavor = Flavor_;
18 using VKAndHash = typename Flavor::VKAndHash;
21 using FF = typename Flavor::FF;
22
23 public:
24 static constexpr size_t NUM = NUM_;
25 static constexpr size_t BATCHED_EXTENDED_LENGTH = (Flavor::MAX_TOTAL_RELATION_LENGTH - 1 + NUM - 1) * (NUM - 1) + 1;
27 std::shared_ptr<DeciderVK> const& operator[](size_t idx) const { return _data[idx]; }
28 typename ArrayType::iterator begin() { return _data.begin(); };
29 typename ArrayType::iterator end() { return _data.end(); };
31
33 const std::shared_ptr<DeciderVK>& accumulator,
34 const std::vector<std::shared_ptr<VKAndHash>>& vk_and_hashs)
36 {
37 BB_ASSERT_EQ(vk_and_hashs.size(), NUM - 1);
38
39 _data[0] = accumulator;
40
41 size_t idx = 1;
42 for (auto& vk_and_hash : vk_and_hashs) {
43 _data[idx] = std::make_shared<DeciderVK>(builder, vk_and_hash);
44 idx++;
45 }
46 }
47
49 const std::shared_ptr<DeciderVK>& accumulator,
50 const std::shared_ptr<DeciderVK>& incoming_instance)
52 {
53 _data[0] = accumulator;
54 _data[1] = incoming_instance;
55 }
56
70 {
71 const size_t num_commitments_to_fold = _data[0]->vk_and_hash->vk->get_all().size();
72 std::vector<std::vector<typename Flavor::Commitment>> result(num_commitments_to_fold,
73 std::vector<typename Flavor::Commitment>(NUM));
74 for (size_t idx = 0; auto& commitment_at_idx : result) {
75 for (auto [elt, key] : zip_view(commitment_at_idx, _data)) {
76 elt = key->vk_and_hash->vk->get_all()[idx];
77 }
78 idx++;
79 }
80 return result;
81 }
82
88 {
89 const size_t num_commitments_to_fold = _data[0]->witness_commitments.get_all().size();
90 std::vector<std::vector<typename Flavor::Commitment>> result(num_commitments_to_fold,
91 std::vector<typename Flavor::Commitment>(NUM));
92 for (size_t idx = 0; auto& commitment_at_idx : result) {
93 for (auto [elt, key] : zip_view(commitment_at_idx, _data)) {
94 elt = key->witness_commitments.get_all()[idx];
95 }
96 idx++;
97 }
98 return result;
99 }
100
106 {
107 const size_t num_alphas_to_fold = _data[0]->alphas.size();
109 for (size_t idx = 0; auto& alpha_at_idx : result) {
110 for (auto [elt, key] : zip_view(alpha_at_idx, _data)) {
111 elt = key->alphas[idx];
112 }
113 idx++;
114 }
115 return result;
116 }
117
123 {
124 const size_t num_params_to_fold = _data[0]->relation_parameters.get_to_fold().size();
126 for (size_t idx = 0; auto& params_at_idx : result) {
127 for (auto [elt, key] : zip_view(params_at_idx, _data)) {
128 elt = key->relation_parameters.get_to_fold()[idx];
129 }
130 idx++;
131 }
132 return result;
133 }
134};
135} // namespace bb::stdlib::recursion::honk
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:59
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
Curve::ScalarField FF
static constexpr size_t MAX_TOTAL_RELATION_LENGTH
MegaCircuitBuilder CircuitBuilder
The stdlib counterpart of DeciderVerificationKey, used in recursive folding verification.
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
std::vector< std::vector< typename Flavor::FF > > get_alphas() const
Get the alphas grouped by commitment index.
RecursiveDeciderVerificationKeys_(Builder *builder, const std::shared_ptr< DeciderVK > &accumulator, const std::shared_ptr< DeciderVK > &incoming_instance)
std::vector< std::vector< typename Flavor::Commitment > > get_witness_commitments() const
Get the witness commitments grouped by commitment index.
std::vector< std::vector< typename Flavor::Commitment > > get_precomputed_commitments() const
std::vector< std::vector< typename Flavor::FF > > get_relation_parameters() const
Get the relation parameters grouped by commitment index.
RecursiveDeciderVerificationKeys_(Builder *builder, const std::shared_ptr< DeciderVK > &accumulator, const std::vector< std::shared_ptr< VKAndHash > > &vk_and_hashs)