Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
plookup.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Luke, Raju], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6//
7// === CODE ROLE: Stdlib interface (conditionally modifies builder) ===
8// This file provides the stdlib (circuit) interface for plookup operations. The key function is
9// get_lookup_accumulators(), which has two code paths:
10//
11// 1. CONSTANT PATH (builder-agnostic): If all inputs are constants, wraps native values as
12// field_t<Builder> constants. No witnesses or gates are created.
13//
14// 2. VARIABLE PATH (builder-modifying): If any input is a witness, calls
15// builder->create_gates_from_plookup_accumulators() to create actual lookup gates.
16//
17// This is the main entry point for stdlib code that needs table lookups. It bridges the native
18// plookup_tables.cpp computation to circuit gate creation in ultra_circuit_builder.cpp.
19// =====================
20
21#pragma once
26#include <array>
27#include <vector>
28
29namespace bb::stdlib {
30
31template <typename Builder> class plookup_read {
33
34 public:
36
38 const field_pt& key_a,
39 const field_pt& key_b);
41
43 const field_pt& key_a,
44 const field_pt& key_b = 0,
45 const bool is_2_to_1_lookup = false);
46};
47} // namespace bb::stdlib
Container for lookup accumulator values and table reads.
Definition types.hpp:357
field_t< Builder > field_pt
Definition plookup.hpp:32
static plookup::ReadData< field_pt > get_lookup_accumulators(const plookup::MultiTableId id, const field_pt &key_a, const field_pt &key_b=0, const bool is_2_to_1_lookup=false)
Definition plookup.cpp:19
static field_pt read_from_2_to_1_table(const plookup::MultiTableId id, const field_pt &key_a, const field_pt &key_b)
Definition plookup.cpp:79
static field_pt read_from_1_to_2_table(const plookup::MultiTableId id, const field_pt &key_a)
Definition plookup.cpp:89
static std::pair< field_pt, field_pt > read_pair_from_table(const plookup::MultiTableId id, const field_pt &key)
Definition plookup.cpp:70
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13