Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_execution_trace.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
8
14
15namespace bb {
16
17class UltraTraceBlock : public ExecutionTraceBlock<fr, 4> {
18 public:
19 virtual Selector<fr>& q_lookup_type() { return zero_selectors[0]; };
20 virtual Selector<fr>& q_arith() { return zero_selectors[1]; }
21 virtual Selector<fr>& q_delta_range() { return zero_selectors[2]; }
22 virtual Selector<fr>& q_elliptic() { return zero_selectors[3]; }
23 virtual Selector<fr>& q_memory() { return zero_selectors[4]; }
24 virtual Selector<fr>& q_nnf() { return zero_selectors[5]; }
27
29 {
30 return RefVector{ q_m(),
31 q_c(),
32 q_1(),
33 q_2(),
34 q_3(),
35 q_4(),
37 q_arith(),
39 q_elliptic(),
40 q_memory(),
41 q_nnf(),
44 }
45
46 private:
48};
49
51
53 public:
55
56 private:
58};
59
61 public:
62 SelectorType& q_arith() override { return gate_selector; }
63
64 private:
66};
67
75
77 public:
78 SelectorType& q_elliptic() override { return gate_selector; }
79
80 private:
82};
83
85 public:
86 SelectorType& q_memory() override { return gate_selector; }
87
88 private:
90};
91
93 public:
94 SelectorType& q_nnf() override { return gate_selector; }
95
96 private:
98};
99
107
115
117 public:
118 SelectorType& q_lookup_type() override { return gate_selectors[0]; };
119 SelectorType& q_arith() override { return gate_selectors[1]; }
120 SelectorType& q_delta_range() override { return gate_selectors[2]; }
121 SelectorType& q_elliptic() override { return gate_selectors[3]; }
122 SelectorType& q_memory() override { return gate_selectors[4]; }
123 SelectorType& q_nnf() override { return gate_selectors[5]; }
126
127 private:
129};
130
190
192
193 public:
194 static constexpr size_t NUM_WIRES = UltraTraceBlock::NUM_WIRES;
195 using FF = fr;
196
197 bool has_overflow = false;
198
200
201 void compute_offsets(bool is_structured)
202 {
203 if (is_structured) {
204 throw_or_abort("Trace is structuring not implemented for UltraHonk");
205 }
206 uint32_t offset = 1; // start at 1 because the 0th row is unused for selectors for Honk
207 for (auto& block : this->get()) {
208 block.trace_offset_ = offset;
209 offset += block.get_fixed_size(is_structured);
210 }
211 }
212
213 void summarize() const
214 {
215 info("Gate blocks summary:");
216 info("pub inputs :\t", this->pub_inputs.size());
217 info("lookups :\t", this->lookup.size());
218 info("arithmetic :\t", this->arithmetic.size());
219 info("delta range:\t", this->delta_range.size());
220 info("elliptic :\t", this->elliptic.size());
221 info("memory :\t", this->memory.size());
222 info("nnf :\t", this->nnf.size());
223 info("poseidon ext :\t", this->poseidon2_external.size());
224 info("poseidon int :\t", this->poseidon2_internal.size());
225 info("overflow :\t", this->overflow.size());
226 }
227
228 // Get cumulative size of all blocks
230 {
231 size_t total_size(0);
232 for (const auto& block : this->get()) {
233 total_size += block.size();
234 }
235 return total_size;
236 }
237
239 {
240 size_t total_size = 1; // start at 1 because the 0th row is unused for selectors for Honk
241 for (auto& block : this->get()) {
242 total_size += block.get_fixed_size();
243 }
244
245 auto log2_n = static_cast<size_t>(numeric::get_msb(total_size));
246 if ((1UL << log2_n) != (total_size)) {
247 ++log2_n;
248 }
249 return 1UL << log2_n;
250 }
251
252 bool operator==(const UltraExecutionTraceBlocks& other) const = default;
253};
254
255} // namespace bb
Basic structure for storing gate data in a builder.
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:22
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
Abstract interface for a generic selector.
Selector backed by a slab allocator vector.
bool operator==(const UltraExecutionTraceBlocks &other) const =default
void compute_offsets(bool is_structured)
SlabVectorSelector< fr > gate_selector
SelectorType & q_arith() override
virtual Selector< fr > & q_poseidon2_internal()
virtual Selector< fr > & q_elliptic()
RefVector< Selector< fr > > get_selectors() override
virtual Selector< fr > & q_arith()
virtual Selector< fr > & q_poseidon2_external()
virtual Selector< fr > & q_lookup_type()
virtual Selector< fr > & q_nnf()
virtual Selector< fr > & q_delta_range()
std::array< ZeroSelector< fr >, 8 > zero_selectors
virtual Selector< fr > & q_memory()
SlabVectorSelector< fr > gate_selector
SelectorType & q_delta_range() override
SlabVectorSelector< fr > gate_selector
SelectorType & q_elliptic() override
SlabVectorSelector< fr > gate_selector
SelectorType & q_lookup_type() override
SelectorType & q_memory() override
SlabVectorSelector< fr > gate_selector
SelectorType & q_lookup_type() override
SelectorType & q_arith() override
SelectorType & q_nnf() override
SelectorType & q_elliptic() override
SelectorType & q_delta_range() override
SelectorType & q_poseidon2_external() override
std::array< SlabVectorSelector< fr >, 8 > gate_selectors
SelectorType & q_memory() override
SelectorType & q_poseidon2_internal() override
void info(Args... args)
Definition log.hpp:70
ssize_t offset
Definition engine.cpp:36
constexpr T get_msb(const T in)
Definition get_msb.hpp:47
Entry point for Barretenberg command-line interface.
field< Bn254FrParams > fr
Definition fr.hpp:174
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Defines the circuit block types for the Ultra arithmetization.
UltraTracePublicInputBlock pub_inputs
UltraTraceDeltaRangeBlock delta_range
UltraTraceArithmeticBlock arithmetic
UltraTraceNonNativeFieldBlock nnf
UltraTraceOverflowBlock overflow
UltraTraceEllipticBlock elliptic
UltraTracePoseidon2ExternalBlock poseidon2_external
bool operator==(const UltraTraceBlockData &other) const =default
UltraTracePoseidon2InternalBlock poseidon2_internal
void throw_or_abort(std::string const &err)