Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
interaction_builder.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
6
7namespace bb::avm2::tracegen {
8
10 public:
11 virtual ~InteractionBuilderInterface() = default;
12 virtual void process(TraceContainer& trace) = 0;
13};
14
15// A concatenate that works with movable objects.
16template <typename T> std::vector<T> concatenate_jobs(std::vector<T>&& first, auto&&... rest)
17{
18 std::vector<T> result = std::move(first);
19 result.reserve(first.size() + (rest.size() + ...));
20 (std::move(rest.begin(), rest.end(), std::back_inserter(result)), ...);
21 return result;
22}
23
24// We set a dummy value in the inverse column so that the size of the column is right.
25// The correct value will be set by the prover.
26template <typename LookupSettings> void SetDummyInverses(TraceContainer& trace)
27{
28 trace.visit_column(LookupSettings::SRC_SELECTOR,
29 [&](uint32_t row, const FF&) { trace.set(LookupSettings::INVERSES, row, 0xdeadbeef); });
30 trace.visit_column(LookupSettings::DST_SELECTOR,
31 [&](uint32_t row, const FF&) { trace.set(LookupSettings::INVERSES, row, 0xdeadbeef); });
32}
33
34} // namespace bb::avm2::tracegen
35
36// Define a hash function for std::array so that it can be used as a key in a std::unordered_map.
37template <typename T, size_t SIZE> struct std::hash<std::array<T, SIZE>> {
38 inline std::size_t operator()(const std::array<T, SIZE>& arr) const noexcept
39 {
40 return [&arr]<size_t... Is>(std::index_sequence<Is...>) {
41 return bb::utils::hash_as_tuple(arr[Is]...);
43 }
44};
virtual void process(TraceContainer &trace)=0
void visit_column(Column col, const std::function< void(uint32_t, const FF &)> &visitor) const
void set(Column col, uint32_t row, const FF &value)
TestTraceContainer trace
void SetDummyInverses(TraceContainer &trace)
std::vector< T > concatenate_jobs(std::vector< T > &&first, auto &&... rest)
AvmFlavorSettings::FF FF
Definition field.hpp:10
size_t hash_as_tuple(const Ts &... ts)
Definition utils.hpp:22
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::size_t operator()(const std::array< T, SIZE > &arr) const noexcept