9#include "../circuit_builders/circuit_builders.hpp"
16template <
typename Builder>
21 for (
const auto& entry : table_entries) {
22 if (entry[0].get_context() !=
nullptr) {
23 context = entry[0].get_context();
26 if (entry[1].get_context() !=
nullptr) {
27 context = entry[1].get_context();
31 raw_entries = table_entries;
32 length = raw_entries.size();
41 for (
size_t i = 0; i <
length; ++i) {
42 tags[i] = { raw_entries[i][0].get_origin_tag(), raw_entries[i][1].get_origin_tag() };
55 BB_ASSERT_EQ(
context !=
nullptr,
true,
"twin_rom_table: context must be set before initializing the table");
58 for (
const auto& entry : raw_entries) {
61 if (entry[0].is_constant()) {
66 if (entry[1].is_constant()) {
77 for (
size_t i = 0; i <
length; ++i) {
79 rom_id, i, std::array<uint32_t, 2>{ entries[i][0].get_witness_index(), entries[i][1].get_witness_index() });
84 for (
size_t i = 0; i <
length; ++i) {
85 tags[i] = { raw_entries[i][0].
get_origin_tag(), raw_entries[i][1].get_origin_tag() };
90template <
typename Builder>
92 : raw_entries(other.raw_entries)
93 , entries(other.entries)
96 , rom_id(other.rom_id)
97 , initialized(other.initialized)
101template <
typename Builder>
103 : raw_entries(other.raw_entries)
104 , entries(other.entries)
107 , rom_id(other.rom_id)
108 , initialized(other.initialized)
127 entries = other.entries;
130 rom_id = other.rom_id;
131 initialized = other.initialized;
136template <
typename Builder>
141 context->failure(
"twin_rom_table: ROM array access out of bounds");
144 return entries[index];
147template <
typename Builder>
159 context->failure(
"twin_rom_table: ROM array access out of bounds");
169 const size_t cast_index =
static_cast<size_t>(
static_cast<uint64_t
>(native_index));
171 if (native_index <
length) {
172 pair[0].set_origin_tag(tags[cast_index][0]);
173 pair[1].set_origin_tag(tags[cast_index][1]);
#define BB_ASSERT_EQ(actual, expected,...)
#define ASSERT(expression,...)
static field_t from_witness_index(Builder *ctx, uint32_t witness_index)
Builder * get_context() const
OriginTag get_origin_tag() const
bb::fr get_value() const
Given a := *this, compute its value given by a.v * a.mul + a.add.
field_t normalize() const
Return a new element, where the in-circuit witness contains the actual represented value (multiplicat...
uint32_t get_normalized_witness_index() const
Get the index of a normalized version of this element.
std::vector< field_pair_pt > entries
field_pair_pt operator[](const size_t index) const
std::vector< std::array< OriginTag, 2 > > tags
twin_rom_table & operator=(const twin_rom_table &other)
void initialize_table() const
std::array< field_pt, 2 > field_pair_pt
std::vector< field_pair_pt > raw_entries
Contains all the headers required to adequately compile the types defined in circuit_builders_fwd....
StrictMock< MockContext > context
uint8_t const size_t length
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept