Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
acir_to_constraint_buf.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 "acir_format.hpp"
9#include "serde/index.hpp"
10
11namespace acir_format {
12
14
17
21WitnessOrConstant<bb::fr> parse_input(Acir::FunctionInput input);
22
29
38void update_max_witness_index(uint32_t witness_idx, AcirFormat& af);
39
47void update_max_witness_index_from_expression(Acir::Expression const& expr, AcirFormat& af);
48
55void update_max_witness_index_from_opcode(Acir::Opcode const& opcode, AcirFormat& af);
56
58
76
86template <typename T>
87T deserialize_any_format(std::vector<uint8_t>&& buf,
88 std::function<T(msgpack::object const&)> decode_msgpack,
89 std::function<T(std::vector<uint8_t>)> decode_bincode);
90
94AcirFormat circuit_serde_to_acir_format(Acir::Circuit const& circuit);
95
103
107AcirFormat circuit_buf_to_acir_format(std::vector<uint8_t>&& buf);
108
112WitnessVector witness_buf_to_witness_vector(std::vector<uint8_t>&& buf);
113
115
117
124
131bool is_single_arithmetic_gate(Acir::Expression const& arg, const std::map<uint32_t, bb::fr>& linear_terms);
132
133// clang-format off
177// clang-format on
179 std::map<uint32_t, bb::fr>& linear_terms);
180
190void assert_zero_to_quad_constraints(Acir::Opcode::AssertZero const& arg, AcirFormat& af, size_t opcode_index);
191
193
199BlockConstraint memory_init_to_block_constraint(Acir::Opcode::MemoryInit const& mem_init);
200
205void add_memory_op_to_block_constraint(Acir::Opcode::MemoryOp const& mem_op, BlockConstraint& block);
206
208
227 AcirFormat& af,
228 size_t opcode_index);
229
230} // namespace acir_format
uint8_t const * buf
Definition data_store.hpp:9
void 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.
AcirFormat circuit_serde_to_acir_format(Acir::Circuit const &circuit)
Convert an Acir::Circuit into an AcirFormat by processing all the opcodes.
T deserialize_any_format(std::vector< uint8_t > &&buf, std::function< T(msgpack::object const &)> decode_msgpack, std::function< T(std::vector< uint8_t >)> decode_bincode)
========= BYTES TO BARRETENBERG'S REPRESENTATION ========= ///
void 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.
void update_max_witness_index_from_expression(Acir::Expression const &expr, AcirFormat &af)
Update max_witness_index by processing all witnesses in an Acir::Expression.
WitnessVector witness_buf_to_witness_vector(std::vector< uint8_t > &&buf)
Convert a buffer representing a witness vector into Barretenberg's internal WitnessVector format.
std::vector< mul_quad_< fr > > split_into_mul_quad_gates(Acir::Expression const &arg, std::map< uint32_t, bb::fr > &linear_terms)
========= ACIR OPCODE HANDLERS ========= ///
WitnessVector witness_map_to_witness_vector(Witnesses::WitnessMap const &witness_map)
Convert from the ACIR-native WitnessMap format to Barretenberg's internal WitnessVector format.
uint32_t get_witness_from_function_input(Acir::FunctionInput input)
Extract the witness index from an Acir::FunctionInput representing a witness.
std::vector< bb::fr > WitnessVector
bool 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 ...
WitnessOrConstant< bb::fr > parse_input(Acir::FunctionInput input)
========= HELPERS ========= ///
void update_max_witness_index(uint32_t witness_idx, AcirFormat &af)
Update the max_witness_index.
BlockConstraint memory_init_to_block_constraint(Acir::Opcode::MemoryInit const &mem_init)
========= MEMORY OPERATIONS ========== ///
AcirFormat circuit_buf_to_acir_format(std::vector< uint8_t > &&buf)
Convert a buffer representing a circuit into Barretenberg's internal AcirFormat representation.
void assert_zero_to_quad_constraints(Acir::Opcode::AssertZero const &arg, AcirFormat &af, size_t opcode_index)
Single entrypoint for processing arithmetic (AssertZero) opcodes.
void add_blackbox_func_call_to_acir_format(Acir::Opcode::BlackBoxFuncCall const &arg, AcirFormat &af, size_t opcode_index)
std::map< uint32_t, bb::fr > process_linear_terms(Acir::Expression const &expr)
========= ACIR OPCODE HANDLERS ========= ///
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13