Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::gate_patterns Namespace Reference

Namespaces

namespace  memory_helpers
 
namespace  nnf_helpers
 

Classes

struct  GatePattern
 Pattern defining which wires are constrained by a gate type. More...
 
struct  Selectors
 Selector values read from a gate. More...
 
struct  WireSpec
 

Typedefs

using Predicate = std::function< bool(const Selectors &)>
 

Enumerations

enum class  Wire : uint8_t {
  W_L , W_R , W_O , W_4 ,
  W_L_SHIFT , W_R_SHIFT , W_O_SHIFT , W_4_SHIFT
}
 

Functions

template<typename Block , typename GateSelectorColumn >
Selectors read_selectors (Block &block, size_t gate_index, const GateSelectorColumn &gate_selector_column)
 
template<typename Block >
uint32_t get_wire (Block &block, size_t gate_index, Wire wire)
 
bool is_shifted (Wire wire)
 
template<typename Block >
std::vector< uint32_t > extract_wires (Block &block, size_t gate_index, const GatePattern &pattern, const Selectors &selectors)
 

Variables

const GatePattern ARITHMETIC
 
const GatePattern ELLIPTIC
 
const GatePattern NON_NATIVE_FIELD
 
const GatePattern MEMORY
 
const GatePattern LOOKUP
 
const GatePattern DELTA_RANGE
 
const GatePattern POSEIDON2_INTERNAL
 
const GatePattern POSEIDON2_EXTERNAL
 
const GatePattern DATABUS
 

Typedef Documentation

◆ Predicate

using bb::gate_patterns::Predicate = typedef std::function<bool(const Selectors&)>

Definition at line 47 of file gate_patterns.hpp.

Enumeration Type Documentation

◆ Wire

enum class bb::gate_patterns::Wire : uint8_t
strong
Enumerator
W_L 
W_R 
W_O 
W_4 
W_L_SHIFT 
W_R_SHIFT 
W_O_SHIFT 
W_4_SHIFT 

Definition at line 16 of file gate_patterns.hpp.

Function Documentation

◆ extract_wires()

template<typename Block >
std::vector< uint32_t > bb::gate_patterns::extract_wires ( Block &  block,
size_t  gate_index,
const GatePattern pattern,
const Selectors selectors 
)

Definition at line 386 of file gate_patterns.hpp.

◆ get_wire()

template<typename Block >
uint32_t bb::gate_patterns::get_wire ( Block &  block,
size_t  gate_index,
Wire  wire 
)

Definition at line 357 of file gate_patterns.hpp.

◆ is_shifted()

bool bb::gate_patterns::is_shifted ( Wire  wire)
inline

Definition at line 380 of file gate_patterns.hpp.

◆ read_selectors()

template<typename Block , typename GateSelectorColumn >
Selectors bb::gate_patterns::read_selectors ( Block &  block,
size_t  gate_index,
const GateSelectorColumn &  gate_selector_column 
)

Definition at line 344 of file gate_patterns.hpp.

Variable Documentation

◆ ARITHMETIC

const GatePattern bb::gate_patterns::ARITHMETIC
inline
Initial value:
= { .name = "arithmetic",
.wires = {
{ Wire::W_L,
[](const Selectors& sel) {
return sel.q_1_nz || (sel.q_m_nz && sel.gate_selector != 3) || sel.gate_selector == 3;
} },
{ Wire::W_R,
[](const Selectors& sel) { return sel.q_2_nz || (sel.q_m_nz && sel.gate_selector != 3); } },
{ Wire::W_O, [](const Selectors& sel) { return sel.q_3_nz; } },
{ Wire::W_4, [](const Selectors& sel) { return sel.q_4_nz || sel.gate_selector == 3; } },
{ Wire::W_4_SHIFT,
[](const Selectors& sel) { return sel.gate_selector == 2 || sel.gate_selector == 3; } },
{ Wire::W_L_SHIFT, [](const Selectors& sel) { return sel.gate_selector == 3; } },
} }

Definition at line 80 of file gate_patterns.hpp.

◆ DATABUS

const GatePattern bb::gate_patterns::DATABUS
inline
Initial value:
= { .name = "databus",
.wires = {
{ Wire::W_L, [](const Selectors&) { return true; } },
{ Wire::W_R, [](const Selectors&) { return true; } },
} }

Definition at line 333 of file gate_patterns.hpp.

◆ DELTA_RANGE

const GatePattern bb::gate_patterns::DELTA_RANGE
inline
Initial value:
= { .name = "delta_range",
.wires = {
{ Wire::W_L, [](const Selectors&) { return true; } },
{ Wire::W_R, [](const Selectors&) { return true; } },
{ Wire::W_O, [](const Selectors&) { return true; } },
{ Wire::W_4, [](const Selectors&) { return true; } },
{ Wire::W_L_SHIFT, [](const Selectors&) { return true; } },
} }

Definition at line 276 of file gate_patterns.hpp.

◆ ELLIPTIC

const GatePattern bb::gate_patterns::ELLIPTIC
inline
Initial value:
= { .name = "elliptic",
.wires = {
{ Wire::W_R, [](const Selectors&) { return true; } },
{ Wire::W_O, [](const Selectors&) { return true; } },
{ Wire::W_R_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_O_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_L_SHIFT, [](const Selectors& sel) { return !sel.q_m_nz; } },
{ Wire::W_4_SHIFT, [](const Selectors& sel) { return !sel.q_m_nz; } },
} }

Definition at line 113 of file gate_patterns.hpp.

◆ LOOKUP

const GatePattern bb::gate_patterns::LOOKUP
inline
Initial value:
= { .name = "lookup",
.wires = {
{ Wire::W_L, [](const Selectors&) { return true; } },
{ Wire::W_R, [](const Selectors&) { return true; } },
{ Wire::W_O, [](const Selectors&) { return true; } },
{ Wire::W_L_SHIFT, [](const Selectors& sel) { return sel.q_2_nz; } },
{ Wire::W_R_SHIFT, [](const Selectors& sel) { return sel.q_m_nz; } },
{ Wire::W_O_SHIFT, [](const Selectors& sel) { return sel.q_c_nz; } },
} }

Definition at line 258 of file gate_patterns.hpp.

◆ MEMORY

const GatePattern bb::gate_patterns::MEMORY
inline

Definition at line 209 of file gate_patterns.hpp.

◆ NON_NATIVE_FIELD

const GatePattern bb::gate_patterns::NON_NATIVE_FIELD
inline
Initial value:
= { .name = "non_native_field",
.wires = {
{ Wire::W_L, [](const Selectors& sel) { return !nnf_helpers::is_limb_accum_2(sel); } },
{ Wire::W_R, [](const Selectors& sel) { return !nnf_helpers::is_limb_accum_2(sel); } },
{ Wire::W_O, [](const Selectors& sel) { return !nnf_helpers::is_product_3(sel); } },
{ Wire::W_4, [](const Selectors&) { return true; } },
{ Wire::W_L_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_R_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_O_SHIFT,
[](const Selectors& sel) { return sel.q_m_nz || (sel.q_2_nz && sel.q_4_nz); } },
{ Wire::W_4_SHIFT,
[](const Selectors& sel) { return sel.q_m_nz || (sel.q_2_nz && sel.q_4_nz); } },
} }

Definition at line 155 of file gate_patterns.hpp.

◆ POSEIDON2_EXTERNAL

const GatePattern bb::gate_patterns::POSEIDON2_EXTERNAL
inline
Initial value:
= { .name = "poseidon2_external",
.wires = {
{ Wire::W_L, [](const Selectors&) { return true; } },
{ Wire::W_R, [](const Selectors&) { return true; } },
{ Wire::W_O, [](const Selectors&) { return true; } },
{ Wire::W_4, [](const Selectors&) { return true; } },
{ Wire::W_L_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_R_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_O_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_4_SHIFT, [](const Selectors&) { return true; } },
} }

Definition at line 313 of file gate_patterns.hpp.

◆ POSEIDON2_INTERNAL

const GatePattern bb::gate_patterns::POSEIDON2_INTERNAL
inline
Initial value:
= { .name = "poseidon2_internal",
.wires = {
{ Wire::W_L, [](const Selectors&) { return true; } },
{ Wire::W_R, [](const Selectors&) { return true; } },
{ Wire::W_O, [](const Selectors&) { return true; } },
{ Wire::W_4, [](const Selectors&) { return true; } },
{ Wire::W_L_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_R_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_O_SHIFT, [](const Selectors&) { return true; } },
{ Wire::W_4_SHIFT, [](const Selectors&) { return true; } },
} }

Definition at line 293 of file gate_patterns.hpp.