Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
acir_to_constraint_buf.hpp File Reference
#include "acir_format.hpp"
#include "serde/index.hpp"

Go to the source code of this file.

Classes

struct  acir_format::BatchedEqEntry
 Linear AssertZero (≤2 witnesses + constant) More...
 

Namespaces

namespace  acir_format
 

Enumerations

enum class  acir_format::AssertZeroGate : uint8_t { acir_format::Bilinear , acir_format::BatchedEq , acir_format::SingleArithmetic , acir_format::MultiArithmetic }
 How an AssertZero opcode is lowered to gates. More...
 

Functions

bb::fr acir_format::from_buffer_with_bound_checks (const std::vector< uint8_t > &buffer)
 ========= HELPERS ========= ///
 
WitnessOrConstant< bb::fracir_format::parse_input (const Acir::FunctionInput &input)
 Parse an Acir::FunctionInput (which can either be a witness or a constant) into a WitnessOrConstant.
 
uint32_t acir_format::get_witness_from_function_input (const Acir::FunctionInput &input)
 Extract the witness index from an Acir::FunctionInput representing a witness.
 
void acir_format::update_max_witness_index (const uint32_t witness_idx, AcirFormat &af)
 Update the max_witness_index.
 
void acir_format::update_max_witness_index_from_expression (Acir::Expression const &expr, AcirFormat &af)
 Update max_witness_index by processing all witnesses in an Acir::Expression.
 
void acir_format::update_max_witness_index_from_opcode (Acir::Opcode const &opcode, AcirFormat &af)
 Update the max witness index by processing all the witness indices contained in the Acir::Opcode.
 
template<typename T >
acir_format::deserialize_msgpack_compact (std::vector< uint8_t > &&buf, std::function< T(msgpack::object const &)> decode_msgpack)
 ========= BYTES TO BARRETENBERG'S REPRESENTATION ========= ///
 
AcirFormat acir_format::circuit_serde_to_acir_format (Acir::Circuit const &circuit, bool is_mega)
 Convert an Acir::Circuit into an AcirFormat by processing all the opcodes.
 
WitnessVector acir_format::witness_map_to_witness_vector (Witnesses::WitnessMap const &witness_map)
 Convert from the ACIR-native WitnessMap format to Barretenberg's internal WitnessVector format.
 
AcirFormat acir_format::circuit_buf_to_acir_format (std::vector< uint8_t > &&buf, bool is_mega)
 Convert a buffer representing a circuit into Barretenberg's internal AcirFormat representation.
 
AcirFormat acir_format::circuit_buf_to_mega_acir_format (std::vector< uint8_t > &&buf)
 Specialization for Mega constructor.
 
WitnessVector acir_format::witness_buf_to_witness_vector (std::vector< uint8_t > &&buf)
 Convert a buffer representing a witness vector into Barretenberg's internal WitnessVector format.
 
std::map< uint32_t, bb::fracir_format::process_linear_terms (Acir::Expression const &expr)
 ========= ACIR OPCODE HANDLERS ========= ///
 
AssertZeroGate acir_format::classify_assert_zero (Acir::Expression const &arg, const std::map< uint32_t, bb::fr > &linear_terms, bool is_mega)
 Classify an Acir::Expression with its processed linear terms into the gate it lowers to.
 
bool acir_format::resolve_shared_wire_products (Acir::Expression const &arg, uint32_t &w_l, uint32_t &w_r, uint32_t &w_o)
 Given an Arithmetic expression with two multiplication terms, determine whether they share a witness and place the witness indices in w_l, w_r, w_o.
 
bool acir_format::is_bilinear (Acir::Expression const &arg, const std::map< uint32_t, bb::fr > &linear_terms)
 Whether an AssertZero fits a single bilinear-gate row.
 
bool acir_format::is_batched_eq (Acir::Expression const &arg, const std::map< uint32_t, bb::fr > &linear_terms)
 Whether an AssertZero is "batched-eq" — a pure linear constraint with 1 or 2 witnesses.
 
bool acir_format::is_single_arithmetic_gate (Acir::Expression const &arg, const std::map< uint32_t, bb::fr > &linear_terms)
 Given an Acir::Expression and its processed linear terms, determine whether it can be represented by a single width-4 arithmetic gate.
 
BilinearConstraint acir_format::build_bilinear_constraint (Acir::Expression const &arg, const std::map< uint32_t, bb::fr > &linear_terms)
 Build the bilinear-gate constraint for an AssertZero already classified as Bilinear.
 
std::vector< mul_quad_< fr > > acir_format::split_into_mul_quad_gates (Acir::Expression const &arg, std::map< uint32_t, bb::fr > &linear_terms)
 ========= ACIR OPCODE HANDLERS ========= ///
 
BatchedEqEntry acir_format::build_batched_eq_entry (Acir::Expression const &arg, const std::map< uint32_t, bb::fr > &linear_terms, size_t opcode_index)
 Build the batched-eq entry for an AssertZero already classified as BatchedEq.
 
BatchedEqCheckConstraint acir_format::build_batched_eq_check_constraint (const BatchedEqEntry &entry1, const std::optional< BatchedEqEntry > &entry2)
 Build a BATCHED_EQ row from batched-eq halves.
 
void acir_format::assert_zero_to_constraints (Acir::Opcode::AssertZero const &arg, AcirFormat &af, size_t opcode_index, std::vector< BatchedEqEntry > &batched_eq_assert_zeros, bool is_mega)
 Single entrypoint for processing arithmetic (AssertZero) opcodes.
 
void acir_format::batched_eq_assert_zeros_into_constraints (AcirFormat &af, std::vector< BatchedEqEntry > &pending)
 Pair buffered batched-eq AssertZeros into BATCHED_EQ rows (and emit any leftover as a single-half row).
 
BlockConstraint acir_format::memory_init_to_block_constraint (Acir::Opcode::MemoryInit const &mem_init)
 ========= MEMORY OPERATIONS ========== ///
 
void acir_format::add_memory_op_to_block_constraint (Acir::Opcode::MemoryOp const &mem_op, BlockConstraint &block)
 Process memory operation, either read or write, and update the BlockConstraint type accordingly.
 
void acir_format::add_blackbox_func_call_to_acir_format (Acir::Opcode::BlackBoxFuncCall const &arg, AcirFormat &af, size_t opcode_index)