Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
rom_table.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#include "../circuit_builders/circuit_builders_fwd.hpp"
9#include "../field/field.hpp"
11
12namespace bb::stdlib {
13
14// A runtime-defined read-only memory table. Table entries must be initialized in the constructor.
15// N.B. Only works with the UltraBuilder at the moment!
16template <typename Builder> class rom_table {
17 private:
19
20 public:
22 rom_table(const std::vector<field_pt>& table_entries);
23 rom_table(const rom_table& other);
24 rom_table(rom_table&& other);
25
26 void initialize_table() const;
27
28 rom_table& operator=(const rom_table& other);
30
31 // read from table with a constant index value. Does not add any gates
32 field_pt operator[](const size_t index) const;
33
34 // read from table with a witness index value. Adds 2 gates
35 field_pt operator[](const field_pt& index) const;
36
37 size_t size() const { return length; }
38
39 Builder* get_context() const { return context; }
40
41 private:
44 // Origin Tags for detecting problematic interactions of stdlib primitives
46 size_t length = 0;
47 mutable size_t rom_id = 0; // Builder identifier for this ROM table
48 mutable bool initialized = false;
49 mutable Builder* context = nullptr;
50};
51} // namespace bb::stdlib
std::vector< field_pt > entries
Definition rom_table.hpp:43
std::vector< OriginTag > _tags
Definition rom_table.hpp:45
size_t size() const
Definition rom_table.hpp:37
field_t< Builder > field_pt
Definition rom_table.hpp:18
void initialize_table() const
Definition rom_table.cpp:44
rom_table & operator=(const rom_table &other)
Definition rom_table.cpp:98
std::vector< field_pt > raw_entries
Definition rom_table.hpp:42
Builder * get_context() const
Definition rom_table.hpp:39
field_pt operator[](const size_t index) const
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...