|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <circuit_builder_base.hpp>
Public Types | |
| using | FF = FF_ |
| using | EmbeddedCurve = curve::Grumpkin |
Public Member Functions | |
| CircuitBuilderBase (size_t size_hint=0, bool has_dummy_witnesses=false) | |
| CircuitBuilderBase (const CircuitBuilderBase &other)=default | |
| CircuitBuilderBase (CircuitBuilderBase &&other) noexcept=default | |
| CircuitBuilderBase & | operator= (const CircuitBuilderBase &other)=default |
| CircuitBuilderBase & | operator= (CircuitBuilderBase &&other) noexcept=default |
| virtual | ~CircuitBuilderBase ()=default |
| bool | has_dummy_witnesses () const |
| bool | operator== (const CircuitBuilderBase &other) const =default |
| virtual size_t | get_num_finalized_gates () const |
| virtual size_t | get_estimated_num_finalized_gates () const |
| virtual void | print_num_estimated_finalized_gates () const |
| virtual size_t | get_num_variables () const |
| uint32_t | zero_idx () const |
| virtual void | create_add_gate (const add_triple_< FF > &in)=0 |
| virtual void | create_mul_gate (const mul_triple_< FF > &in)=0 |
| virtual void | create_bool_gate (const uint32_t a)=0 |
| virtual void | create_poly_gate (const poly_triple_< FF > &in)=0 |
| virtual size_t | get_num_constant_gates () const =0 |
| const std::vector< FF > & | get_variables () const |
| uint32_t | get_first_variable_in_class (uint32_t index) const |
| void | update_real_variable_indices (uint32_t index, uint32_t new_real_index) |
| FF | get_variable (const uint32_t index) const |
| Get the value of the variable v_{index}. | |
| void | set_variable (const uint32_t index, const FF &value) |
| Set the value of the variable pointed to by a witness index. | |
| const FF & | get_variable_reference (const uint32_t index) const |
| uint32_t | get_public_input_index (const uint32_t witness_index) const |
| FF | get_public_input (const uint32_t index) const |
| const std::vector< uint32_t > & | public_inputs () const |
| void | finalize_public_inputs () |
| Set the public_inputs_finalized_ to true to prevent any new public inputs from being added. | |
| void | initialize_public_inputs (const std::vector< uint32_t > &public_inputs) |
| Directly initialize the public inputs vector. | |
| virtual uint32_t | add_variable (const FF &in) |
| virtual void | set_variable_name (uint32_t index, const std::string &name) |
| virtual msgpack::sbuffer | export_circuit () |
| virtual uint32_t | add_public_variable (const FF &in) |
| virtual uint32_t | set_public_input (uint32_t witness_index) |
| Make a witness variable public. | |
| virtual void | assert_equal (uint32_t a_idx, uint32_t b_idx, std::string const &msg="assert_equal") |
| size_t | get_circuit_subgroup_size (size_t num_gates) const |
| size_t | num_public_inputs () const |
| void | assert_valid_variables (const std::vector< uint32_t > &variable_indices) |
| bool | failed () const |
| const std::string & | err () const |
| void | failure (std::string msg) |
Public Attributes | |
| size_t | num_gates = 0 |
| std::map< uint32_t, uint32_t > | tau |
| std::vector< uint32_t > | real_variable_index |
| std::vector< uint32_t > | real_variable_tags |
| uint32_t | current_tag = DUMMY_TAG |
Protected Member Functions | |
| void | set_zero_idx (uint32_t value) |
Protected Attributes | |
| std::unordered_map< uint32_t, std::string > | variable_names |
Private Attributes | |
| std::vector< FF > | variables |
| std::vector< uint32_t > | public_inputs_ |
| bool | public_inputs_finalized_ = false |
| bool | has_dummy_witnesses_ = false |
| std::vector< uint32_t > | next_var_index |
| std::vector< uint32_t > | prev_var_index |
| bool | _failed = false |
| std::string | _err |
| uint32_t | _zero_idx = 0 |
Static Private Attributes | |
| static constexpr uint32_t | REAL_VARIABLE = UINT32_MAX - 1 |
| static constexpr uint32_t | FIRST_VARIABLE_IN_CLASS = UINT32_MAX - 2 |
Definition at line 22 of file circuit_builder_base.hpp.
| using bb::CircuitBuilderBase< FF_ >::EmbeddedCurve = curve::Grumpkin |
Definition at line 25 of file circuit_builder_base.hpp.
| using bb::CircuitBuilderBase< FF_ >::FF = FF_ |
Definition at line 24 of file circuit_builder_base.hpp.
| bb::CircuitBuilderBase< FF_ >::CircuitBuilderBase | ( | size_t | size_hint = 0, |
| bool | has_dummy_witnesses = false |
||
| ) |
Definition at line 14 of file circuit_builder_base_impl.hpp.
|
default |
|
defaultnoexcept |
|
virtualdefault |
|
virtual |
Add a public variable to variables
The only difference between this and add_variable is that here it is also added to the public_inputs vector
| in | The value of the variable |
Definition at line 122 of file circuit_builder_base_impl.hpp.
|
virtual |
Add a variable to variables
| in | The value of the variable |
Definition at line 83 of file circuit_builder_base_impl.hpp.
|
virtual |
Join variable class b to variable class a.
| a_variable_idx | Index of a variable in class a. |
| b_variable_idx | Index of a variable in class b. |
| msg | Class tag. |
Definition at line 155 of file circuit_builder_base_impl.hpp.
| void bb::CircuitBuilderBase< FF_ >::assert_valid_variables | ( | const std::vector< uint32_t > & | variable_indices | ) |
Definition at line 189 of file circuit_builder_base_impl.hpp.
|
pure virtual |
Implemented in bb::TranslatorCircuitBuilder.
|
pure virtual |
|
pure virtual |
Implemented in bb::TranslatorCircuitBuilder.
|
pure virtual |
Implemented in bb::TranslatorCircuitBuilder.
| const std::string & bb::CircuitBuilderBase< FF_ >::err | ( | ) | const |
Definition at line 203 of file circuit_builder_base_impl.hpp.
|
virtual |
Export the existing circuit as msgpack compatible buffer.
Reimplemented in bb::UltraCircuitBuilder_< ExecutionTrace_ >, and bb::UltraCircuitBuilder_< MegaExecutionTraceBlocks >.
Definition at line 116 of file circuit_builder_base_impl.hpp.
| bool bb::CircuitBuilderBase< FF_ >::failed | ( | ) | const |
Definition at line 198 of file circuit_builder_base_impl.hpp.
| void bb::CircuitBuilderBase< FF_ >::failure | ( | std::string | msg | ) |
Definition at line 208 of file circuit_builder_base_impl.hpp.
|
inline |
Set the public_inputs_finalized_ to true to prevent any new public inputs from being added.
This is used, for example, for special internal public inputs (like pairing inputs) which we want to ensure are placed at the end of the public inputs vector.
Definition at line 172 of file circuit_builder_base.hpp.
| size_t bb::CircuitBuilderBase< FF_ >::get_circuit_subgroup_size | ( | size_t | num_gates | ) | const |
Definition at line 107 of file circuit_builder_base_impl.hpp.
|
virtual |
Reimplemented in bb::MegaCircuitBuilder_< FF >, bb::UltraCircuitBuilder_< ExecutionTrace_ >, and bb::UltraCircuitBuilder_< MegaExecutionTraceBlocks >.
Definition at line 30 of file circuit_builder_base_impl.hpp.
| uint32_t bb::CircuitBuilderBase< FF_ >::get_first_variable_in_class | ( | uint32_t | index | ) | const |
Get the index of the first variable in class.
| index | The index of the variable you want to look up. |
Definition at line 45 of file circuit_builder_base_impl.hpp.
|
pure virtual |
|
virtual |
Reimplemented in bb::UltraCircuitBuilder_< ExecutionTrace_ >, and bb::UltraCircuitBuilder_< MegaExecutionTraceBlocks >.
Definition at line 25 of file circuit_builder_base_impl.hpp.
|
virtual |
Definition at line 40 of file circuit_builder_base_impl.hpp.
| CircuitBuilderBase< FF_ >::FF bb::CircuitBuilderBase< FF_ >::get_public_input | ( | const uint32_t | index | ) | const |
Definition at line 77 of file circuit_builder_base_impl.hpp.
| uint32_t bb::CircuitBuilderBase< FF_ >::get_public_input_index | ( | const uint32_t | witness_index | ) | const |
Definition at line 63 of file circuit_builder_base_impl.hpp.
|
inline |
Get the value of the variable v_{index}.
| index | The index of the variable. |
Definition at line 124 of file circuit_builder_base.hpp.
|
inline |
Get a reference to the variable v_{index}.
We need this function for check_circuit functions.
| index | The index of the variable. |
Definition at line 155 of file circuit_builder_base.hpp.
|
inline |
Definition at line 100 of file circuit_builder_base.hpp.
|
inline |
Definition at line 83 of file circuit_builder_base.hpp.
|
inline |
Directly initialize the public inputs vector.
Used e.g. in the case of a circuit generated from ACIR where some public input indices are known at the time of circuit construction.
Definition at line 180 of file circuit_builder_base.hpp.
|
inline |
Definition at line 228 of file circuit_builder_base.hpp.
|
defaultnoexcept |
|
default |
|
default |
|
virtual |
Reimplemented in bb::MegaCircuitBuilder_< FF >, bb::UltraCircuitBuilder_< ExecutionTrace_ >, and bb::UltraCircuitBuilder_< MegaExecutionTraceBlocks >.
Definition at line 35 of file circuit_builder_base_impl.hpp.
|
inline |
Definition at line 165 of file circuit_builder_base.hpp.
|
virtual |
Make a witness variable public.
| witness_index | The index of the witness. |
Definition at line 130 of file circuit_builder_base_impl.hpp.
|
inline |
Set the value of the variable pointed to by a witness index.
The witness value pointed to by a witness index is determined by the mapping of the input witness index to the corresponding "real variable index" which may agree with the input index or it may point to a different location within the variables array due to copy contraints that have been imposed, e.g. by assert_equal.
| index | |
| value |
Definition at line 141 of file circuit_builder_base.hpp.
|
virtual |
Assign a name to a variable(equivalence class). Should be one name per equivalence class.
| index | Index of the variable you want to name. |
| name | Name of the variable. |
Definition at line 95 of file circuit_builder_base_impl.hpp.
|
inlineprotected |
Definition at line 55 of file circuit_builder_base.hpp.
| void bb::CircuitBuilderBase< FF_ >::update_real_variable_indices | ( | uint32_t | index, |
| uint32_t | new_real_index | ||
| ) |
Update all variables from index in equivalence class to have real variable new_real_index.
| index | The index of a variable in the class we're updating. |
| new_real_index | The index of the real variable to update to. |
Definition at line 54 of file circuit_builder_base_impl.hpp.
|
inline |
Definition at line 92 of file circuit_builder_base.hpp.
|
private |
Definition at line 44 of file circuit_builder_base.hpp.
|
private |
Definition at line 43 of file circuit_builder_base.hpp.
|
private |
Definition at line 50 of file circuit_builder_base.hpp.
| uint32_t bb::CircuitBuilderBase< FF_ >::current_tag = DUMMY_TAG |
Definition at line 72 of file circuit_builder_base.hpp.
|
staticconstexprprivate |
Definition at line 47 of file circuit_builder_base.hpp.
|
private |
Definition at line 36 of file circuit_builder_base.hpp.
|
private |
Definition at line 39 of file circuit_builder_base.hpp.
| size_t bb::CircuitBuilderBase< FF_ >::num_gates = 0 |
Definition at line 58 of file circuit_builder_base.hpp.
|
private |
Definition at line 41 of file circuit_builder_base.hpp.
|
private |
Definition at line 31 of file circuit_builder_base.hpp.
|
private |
Definition at line 33 of file circuit_builder_base.hpp.
|
staticconstexprprivate |
Definition at line 46 of file circuit_builder_base.hpp.
| std::vector<uint32_t> bb::CircuitBuilderBase< FF_ >::real_variable_index |
Definition at line 70 of file circuit_builder_base.hpp.
| std::vector<uint32_t> bb::CircuitBuilderBase< FF_ >::real_variable_tags |
Definition at line 71 of file circuit_builder_base.hpp.
| std::map<uint32_t, uint32_t> bb::CircuitBuilderBase< FF_ >::tau |
Definition at line 63 of file circuit_builder_base.hpp.
|
protected |
Definition at line 53 of file circuit_builder_base.hpp.
|
private |
Definition at line 29 of file circuit_builder_base.hpp.