Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_recursive_flavor.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
11#include <array>
12#include <concepts>
13#include <span>
14#include <string>
15#include <type_traits>
16#include <vector>
17
20
21namespace bb {
22
37template <typename BuilderType> class UltraRecursiveFlavor_ {
38 public:
39 using CircuitBuilder = BuilderType; // Determines arithmetization of circuit instantiated with this flavor
41 using PCS = KZG<Curve>;
42 using GroupElement = typename Curve::Element;
43 using Commitment = typename Curve::Element;
44 using FF = typename Curve::ScalarField;
48
49 static constexpr size_t VIRTUAL_LOG_N = UltraFlavor::VIRTUAL_LOG_N;
50 // indicates when evaluating sumcheck, edges can be left as degree-1 monomials
52
53 // Note(luke): Eventually this may not be needed at all
55 // Indicates that this flavor runs with non-ZK Sumcheck.
56 static constexpr bool HasZK = false;
57 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
58 // and Shplemini
59 static constexpr bool USE_PADDING = UltraFlavor::USE_PADDING;
60 static constexpr size_t NUM_WIRES = UltraFlavor::NUM_WIRES;
61 // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often
62 // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`.
63 // Note: this number does not include the individual sorted list polynomials.
65 // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying
66 // assignment of witnesses. We again choose a neutral name.
68 // The total number of witness entities not including shifts.
70
72
73 // define the tuple of Relations that comprise the Sumcheck relation
75
76 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
77 // static_assert(MAX_PARTIAL_RELATION_LENGTH == 7);
78 static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length<Relations>();
79 // static_assert(MAX_TOTAL_RELATION_LENGTH == 11);
80
81 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
82 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
83 // length = 3
85 static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;
86
87 // For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each
88 // subrelation to avoid increasing the degree of Protogalaxy polynomial $G$ (the
89 // combiner) too much.
91 using SubrelationSeparators = std::array<FF, NUM_SUBRELATIONS - 1>;
92
101 class VerificationKey : public StdlibVerificationKey_<BuilderType, UltraFlavor::PrecomputedEntities<Commitment>> {
102 public:
104
112 {
113 this->log_circuit_size = FF::from_witness(builder, native_key->log_circuit_size);
114 this->num_public_inputs = FF::from_witness(builder, native_key->num_public_inputs);
115 this->pub_inputs_offset = FF::from_witness(builder, native_key->pub_inputs_offset);
116
117 // Generate stdlib commitments (biggroup) from the native counterparts
118 for (auto [commitment, native_commitment] : zip_view(this->get_all(), native_key->get_all())) {
119 commitment = Commitment::from_witness(builder, native_commitment);
120 }
121 };
122
130 {
131 using Codec = stdlib::StdlibCodec<FF>;
132
133 size_t num_frs_read = 0;
134
135 this->log_circuit_size = Codec::template deserialize_from_frs<FF>(elements, num_frs_read);
136 this->num_public_inputs = Codec::template deserialize_from_frs<FF>(elements, num_frs_read);
137 this->pub_inputs_offset = Codec::template deserialize_from_frs<FF>(elements, num_frs_read);
138
139 for (Commitment& commitment : this->get_all()) {
140 commitment = Codec::template deserialize_from_frs<Commitment>(elements, num_frs_read);
141 }
142 }
143
152 const std::span<const uint32_t>& witness_indices)
153 {
154 std::vector<FF> vk_fields;
155 vk_fields.reserve(witness_indices.size());
156 for (const auto& idx : witness_indices) {
157 vk_fields.emplace_back(FF::from_witness_index(&builder, idx));
158 }
159 return VerificationKey(vk_fields);
160 }
161 };
162
168 public:
170 using Base::Base;
171 };
172
174
176
177 // Reuse the VerifierCommitments from Ultra
179
181};
182
183} // namespace bb
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
Base Stdlib verification key class.
Definition flavor.hpp:303
A base class labelling all entities (for instance, all of the polynomials used by the prover during s...
A container for commitment labels.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
A container encapsulating all the commitments that the verifier receives (to precomputed polynomials ...
Container for all witness polynomials used/constructed by the prover.
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
static constexpr bool USE_PADDING
static constexpr size_t NUM_PRECOMPUTED_ENTITIES
static constexpr bool USE_SHORT_MONOMIALS
static constexpr size_t NUM_SUBRELATIONS
static constexpr size_t VIRTUAL_LOG_N
std::tuple< bb::UltraArithmeticRelation< FF >, bb::UltraPermutationRelation< FF >, bb::LogDerivLookupRelation< FF >, bb::DeltaRangeConstraintRelation< FF >, bb::EllipticRelation< FF >, bb::MemoryRelation< FF >, bb::NonNativeFieldRelation< FF >, bb::Poseidon2ExternalRelation< FF >, bb::Poseidon2InternalRelation< FF > > Relations_
static constexpr size_t NUM_ALL_ENTITIES
static constexpr size_t NUM_WIRES
static constexpr size_t NUM_WITNESS_ENTITIES
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
static VerificationKey from_witness_indices(CircuitBuilder &builder, const std::span< const uint32_t > &witness_indices)
Construct a VerificationKey from a set of corresponding witness indices.
VerificationKey(CircuitBuilder *builder, const std::shared_ptr< NativeVerificationKey > &native_key)
Construct a new Verification Key with stdlib types from a provided native verification key.
VerificationKey(std::span< FF > elements)
Deserialize a verification key from a vector of field elements.
The recursive counterpart to the "native" Ultra flavor.
static constexpr size_t NUM_PRECOMPUTED_ENTITIES
static constexpr size_t NUM_ALL_ENTITIES
typename Curve::Element GroupElement
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
static constexpr size_t VIRTUAL_LOG_N
typename Curve::Element Commitment
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
static constexpr bool USE_SHORT_MONOMIALS
static constexpr size_t NUM_WIRES
UltraFlavor::Relations_< FF > Relations
static constexpr size_t NUM_RELATIONS
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
typename Curve::ScalarField FF
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
static constexpr size_t NUM_SUBRELATIONS
static constexpr size_t NUM_WITNESS_ENTITIES
static constexpr size_t MAX_TOTAL_RELATION_LENGTH
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
static field_t from_witness_index(Builder *ctx, uint32_t witness_index)
Definition field.cpp:61
static field_t from_witness(Builder *ctx, const bb::fr &input)
Definition field.hpp:432
AluTraceBuilder builder
Definition alu.test.cpp:123
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
field_t< CircuitBuilder > ScalarField
Definition bn254.hpp:33