|
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 is_write_vk_mode=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 | operator== (const CircuitBuilderBase &other) const =default |
| virtual size_t | get_num_finalized_gates () const |
| virtual size_t | get_num_variables () const |
| size_t | num_gates () const |
| void | increment_num_gates (size_t count=1) |
| const std::unordered_map< uint32_t, uint32_t > & | tau () const |
| uint32_t | zero_idx () const |
| virtual size_t | get_num_constant_gates () const =0 |
| const std::vector< FF > & | get_variables () const |
| 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 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) |
| Add a variable to variables. | |
| template<typename OT > | |
| uint32_t | add_variable (const OT &in)=delete |
| virtual uint32_t | add_public_variable (const FF &in) |
| Add a public variable to variables. | |
| template<typename OT > | |
| uint32_t | add_public_variable (const OT &in)=delete |
| 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 |
| virtual void | set_variable_name (uint32_t index, const std::string &name) |
| Assign a name to a variable (equivalence class) | |
| virtual msgpack::sbuffer | export_circuit () |
| Export the existing circuit as msgpack compatible buffer. | |
| bool | failed () const |
| const std::string & | err () const |
| void | failure (std::string msg) |
| bool | is_write_vk_mode () const |
Public Attributes | |
| std::vector< uint32_t > | real_variable_index |
| Map from witness index to real variable index. | |
| std::vector< uint32_t > | real_variable_tags |
real_variable_tags is the tagging mechanism for the the multiset-equality check. | |
| uint32_t | current_tag = DUMMY_TAG |
| PairingPointsTagging | pairing_points_tagging |
| PairingPoints tagging tool, used to ensure that all pairing points created in this circuit are aggregated together. This is not related to circuit logic. | |
Protected Member Functions | |
| void | set_zero_idx (uint32_t value) |
| uint32_t | get_first_variable_in_class (uint32_t index) const |
| Get the index of the first variable in class. | |
| void | assert_valid_variables (const std::vector< uint32_t > &variable_indices) |
| Check whether each variable index points to a witness value in the variables array. | |
Protected Attributes | |
| std::unordered_map< uint32_t, uint32_t > | _tau |
| The permutation on variable tags, as a constituent of the generalized permutation argument. | |
| std::unordered_map< uint32_t, std::string > | variable_names |
Private Member Functions | |
| void | 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. | |
Private Attributes | |
| std::vector< FF > | variables |
| std::vector< uint32_t > | _public_inputs |
| bool | _public_inputs_finalized = false |
| std::vector< uint32_t > | next_var_index |
| std::vector< uint32_t > | prev_var_index |
| uint32_t | _zero_idx = 0 |
| size_t | _num_gates = 0 |
| bool | _failed = false |
| std::string | _err |
| bool | _is_write_vk_mode = false |
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 24 of file circuit_builder_base.hpp.
| using bb::CircuitBuilderBase< FF_ >::EmbeddedCurve = curve::Grumpkin |
Definition at line 27 of file circuit_builder_base.hpp.
| using bb::CircuitBuilderBase< FF_ >::FF = FF_ |
Definition at line 26 of file circuit_builder_base.hpp.
| bb::CircuitBuilderBase< FF_ >::CircuitBuilderBase | ( | size_t | size_hint = 0, |
| bool | is_write_vk_mode = 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 92 of file circuit_builder_base_impl.hpp.
|
delete |
|
virtual |
Add a variable to variables.
| in | The value of the variable |
Definition at line 53 of file circuit_builder_base_impl.hpp.
|
delete |
|
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 125 of file circuit_builder_base_impl.hpp.
|
protected |
Check whether each variable index points to a witness value in the variables array.
Any variable whose index does not point to witness value is deemed invalid. This implicitly checks whether a variable index is equal to IS_CONSTANT; assuming that we will never have uint32::MAX number of variables
| variable_indices | The indices to validate |
Definition at line 159 of file circuit_builder_base_impl.hpp.
| const std::string & bb::CircuitBuilderBase< FF_ >::err | ( | ) | const |
Definition at line 173 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 86 of file circuit_builder_base_impl.hpp.
| bool bb::CircuitBuilderBase< FF_ >::failed | ( | ) | const |
Definition at line 168 of file circuit_builder_base_impl.hpp.
| void bb::CircuitBuilderBase< FF_ >::failure | ( | std::string | msg | ) |
Definition at line 178 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 183 of file circuit_builder_base.hpp.
| size_t bb::CircuitBuilderBase< FF_ >::get_circuit_subgroup_size | ( | size_t | num_gates | ) | const |
Definition at line 77 of file circuit_builder_base_impl.hpp.
|
protected |
Get the index of the first variable in class.
| index | The index of the variable you want to look up |
Definition at line 35 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 30 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 151 of file circuit_builder_base.hpp.
|
inline |
Definition at line 144 of file circuit_builder_base.hpp.
|
inline |
Definition at line 134 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
| public_inputs | The public inputs vector to initialize with |
Definition at line 191 of file circuit_builder_base.hpp.
|
inline |
Definition at line 269 of file circuit_builder_base.hpp.
|
inline |
Definition at line 131 of file circuit_builder_base.hpp.
|
inline |
Definition at line 227 of file circuit_builder_base.hpp.
|
defaultnoexcept |
|
default |
|
default |
|
inline |
Definition at line 176 of file circuit_builder_base.hpp.
|
virtual |
Make a witness variable public.
| witness_index | The index of the witness |
Definition at line 100 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 | The witness index |
| value | The value to set |
Definition at line 168 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 65 of file circuit_builder_base_impl.hpp.
|
inlineprotected |
Definition at line 63 of file circuit_builder_base.hpp.
|
inline |
Definition at line 137 of file circuit_builder_base.hpp.
|
private |
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 44 of file circuit_builder_base_impl.hpp.
|
inline |
Definition at line 140 of file circuit_builder_base.hpp.
|
private |
Definition at line 235 of file circuit_builder_base.hpp.
|
private |
Definition at line 234 of file circuit_builder_base.hpp.
|
private |
Definition at line 238 of file circuit_builder_base.hpp.
|
private |
Definition at line 53 of file circuit_builder_base.hpp.
|
private |
Definition at line 33 of file circuit_builder_base.hpp.
|
private |
Definition at line 35 of file circuit_builder_base.hpp.
|
protected |
The permutation on variable tags, as a constituent of the generalized permutation argument.
See S6 of https://github.com/AztecProtocol/plonk-with-lookups-private/blob/new-stuff/GenPermuations.pdf See also relations/PERMUTATION_ARGUMENT_README.md
_tau are real variable indicies. Definition at line 89 of file circuit_builder_base.hpp.
|
private |
Definition at line 51 of file circuit_builder_base.hpp.
| uint32_t bb::CircuitBuilderBase< FF_ >::current_tag = DUMMY_TAG |
Definition at line 115 of file circuit_builder_base.hpp.
|
staticconstexprprivate |
Definition at line 48 of file circuit_builder_base.hpp.
|
private |
Definition at line 41 of file circuit_builder_base.hpp.
|
mutable |
PairingPoints tagging tool, used to ensure that all pairing points created in this circuit are aggregated together. This is not related to circuit logic.
Definition at line 267 of file circuit_builder_base.hpp.
|
private |
Definition at line 45 of file circuit_builder_base.hpp.
|
staticconstexprprivate |
Definition at line 47 of file circuit_builder_base.hpp.
| std::vector<uint32_t> bb::CircuitBuilderBase< FF_ >::real_variable_index |
Map from witness index to real variable index.
The "real_variable_index" acts as a map from a "witness index" (e.g. the one stored by a stdlib object) to an index into the variables array. This extra layer of indirection is used to support copy constraints by allowing, for example, two witnesses with differing witness indices to have the same "real variable index" and thus the same witness value. If the witness is not involved in any copy constraints, then real_variable_index[index] == index, i.e., it is the identity map.
Definition at line 105 of file circuit_builder_base.hpp.
| std::vector<uint32_t> bb::CircuitBuilderBase< FF_ >::real_variable_tags |
real_variable_tags is the tagging mechanism for the the multiset-equality check.
The generalized permutation argument checks both copy constraints and multiset equalities. This is mediated by a tag; each real variable has a tag. (By default, the tags are set to DUMMY_TAG == 0. We assume that these are not involved in any non-trivial multiset-equality checks.)
Definition at line 114 of file circuit_builder_base.hpp.
|
protected |
Definition at line 241 of file circuit_builder_base.hpp.
|
private |
Definition at line 31 of file circuit_builder_base.hpp.