barretenberg
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
proof_system::CircuitBuilderBase< FF_ > Class Template Referenceabstract

Public Types

using FF = FF_
 
using EmbeddedCurve = std::conditional_t< std::same_as< FF, barretenberg::g1::coordinate_field >, curve::BN254, curve::Grumpkin >
 

Public Member Functions

 CircuitBuilderBase (size_t size_hint=0)
 
 CircuitBuilderBase (const CircuitBuilderBase &other)=default
 
 CircuitBuilderBase (CircuitBuilderBase &&other) noexcept=default
 
CircuitBuilderBaseoperator= (const CircuitBuilderBase &other)=default
 
CircuitBuilderBaseoperator= (CircuitBuilderBase &&other) noexcept=default
 
virtual size_t get_num_gates () const
 
virtual void print_num_gates () const
 
virtual size_t get_num_variables () 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
 
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
 
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
 
std::vector< FF > get_public_inputs () const
 
virtual uint32_t add_variable (const FF &in)
 
virtual void set_variable_name (uint32_t index, const std::string &name)
 
virtual void update_variable_names (uint32_t index)
 
virtual void finalize_variable_names ()
 
virtual msgpack::sbuffer export_circuit ()
 
virtual uint32_t add_public_variable (const FF &in)
 
virtual void set_public_input (const uint32_t witness_index)
 
virtual void assert_equal (const uint32_t a_idx, const uint32_t b_idx, std::string const &msg="assert_equal")
 
size_t get_circuit_subgroup_size (const size_t num_gates) const
 
size_t get_num_public_inputs () const
 
void assert_valid_variables (const std::vector< uint32_t > &variable_indices)
 
bool is_valid_variable (uint32_t variable_index)
 
void add_recursive_proof (const std::vector< uint32_t > &proof_output_witness_indices)
 Add information about which witnesses contain the recursive proof computation information.
 
void set_recursive_proof (const std::vector< uint32_t > &proof_output_witness_indices)
 Update recursive_proof_public_input_indices with existing public inputs that represent a recursive proof.
 
bool failed () const
 
const std::string & err () const
 
void set_err (std::string msg)
 
void failure (std::string msg)
 

Public Attributes

size_t num_gates = 0
 
std::vector< uint32_t > public_inputs
 
std::vector< FF > variables
 
std::unordered_map< uint32_t, std::string > variable_names
 
std::vector< uint32_t > next_var_index
 
std::vector< uint32_t > prev_var_index
 
std::vector< uint32_t > real_variable_index
 
std::vector< uint32_t > real_variable_tags
 
uint32_t current_tag = DUMMY_TAG
 
std::map< uint32_t, uint32_t > tau
 
std::vector< uint32_t > recursive_proof_public_input_indices
 
bool contains_recursive_proof = false
 
bool _failed = false
 
std::string _err
 
uint32_t zero_idx = 0
 
uint32_t one_idx = 1
 

Static Public Attributes

static constexpr uint32_t REAL_VARIABLE = UINT32_MAX - 1
 
static constexpr uint32_t FIRST_VARIABLE_IN_CLASS = UINT32_MAX - 2
 

Member Function Documentation

◆ add_public_variable()

template<typename FF_ >
virtual uint32_t proof_system::CircuitBuilderBase< FF_ >::add_public_variable ( const FF &  in)
inlinevirtual

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

Parameters
inThe value of the variable
Returns
The index of the new variable in the variables vector

◆ add_recursive_proof()

template<typename FF_ >
void proof_system::CircuitBuilderBase< FF_ >::add_recursive_proof ( const std::vector< uint32_t > &  proof_output_witness_indices)
inline

Add information about which witnesses contain the recursive proof computation information.

Parameters
circuit_constructorObject with the circuit
proof_output_witness_indicesWitness indices that need to become public and stored as recurisve proof specific

◆ add_variable()

template<typename FF_ >
virtual uint32_t proof_system::CircuitBuilderBase< FF_ >::add_variable ( const FF &  in)
inlinevirtual

Add a variable to variables

Parameters
inThe value of the variable
Returns
The index of the new variable in the variables vector

◆ assert_equal()

template<typename FF >
void proof_system::CircuitBuilderBase< FF >::assert_equal ( const uint32_t  a_variable_idx,
const uint32_t  b_variable_idx,
std::string const &  msg = "assert_equal" 
)
virtual

Join variable class b to variable class a.

Parameters
a_variable_idxIndex of a variable in class a.
b_variable_idxIndex of a variable in class b.
msgClass tag.

◆ create_add_gate()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::create_add_gate ( const add_triple_< FF > &  in)
pure virtual

◆ create_bool_gate()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::create_bool_gate ( const uint32_t  a)
pure virtual

◆ create_mul_gate()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::create_mul_gate ( const mul_triple_< FF > &  in)
pure virtual

◆ create_poly_gate()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::create_poly_gate ( const poly_triple_< FF > &  in)
pure virtual

◆ export_circuit()

template<typename FF_ >
virtual msgpack::sbuffer proof_system::CircuitBuilderBase< FF_ >::export_circuit ( )
inlinevirtual

Export the existing circuit as msgpack compatible buffer.

Returns
msgpack compatible buffer

Reimplemented in proof_system::StandardCircuitBuilder_< FF >.

◆ finalize_variable_names()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::finalize_variable_names ( )
inlinevirtual

After finishing the circuit can be called for automatic merging all existing collisions.

◆ get_first_variable_in_class()

template<typename FF_ >
uint32_t proof_system::CircuitBuilderBase< FF_ >::get_first_variable_in_class ( uint32_t  index) const
inline

Get the index of the first variable in class.

Parameters
indexThe index of the variable you want to look up.
Returns
The index of the first variable in the same class as the submitted index.

◆ get_num_gates()

template<typename FF_ >
virtual size_t proof_system::CircuitBuilderBase< FF_ >::get_num_gates ( ) const
inlinevirtual

◆ get_variable()

template<typename FF_ >
FF proof_system::CircuitBuilderBase< FF_ >::get_variable ( const uint32_t  index) const
inline

Get the value of the variable v_{index}. N.B. We should probably inline this.

Parameters
indexThe index of the variable.
Returns
The value of the variable.

◆ get_variable_reference()

template<typename FF_ >
const FF & proof_system::CircuitBuilderBase< FF_ >::get_variable_reference ( const uint32_t  index) const
inline

Get a reference to the variable v_{index}.

We need this function for check_circuit functions.

Parameters
indexThe index of the variable.
Returns
The value of the variable.

◆ print_num_gates()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::print_num_gates ( ) const
inlinevirtual

◆ set_public_input()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::set_public_input ( const uint32_t  witness_index)
inlinevirtual

Make a witness variable public.

Parameters
witness_indexThe index of the witness.

◆ set_recursive_proof()

template<typename FF_ >
void proof_system::CircuitBuilderBase< FF_ >::set_recursive_proof ( const std::vector< uint32_t > &  proof_output_witness_indices)
inline

Update recursive_proof_public_input_indices with existing public inputs that represent a recursive proof.

TODO: We can remove this and use add_recursive_proof once my question has been addressed TODO: using add_recursive_proof also means that we will need to remove the cde which is TODO: adding the public_inputs

Parameters
proof_output_witness_indices

◆ set_variable_name()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::set_variable_name ( uint32_t  index,
const std::string &  name 
)
inlinevirtual

Assign a name to a variable(equivalence class). Should be one name per equivalence class.

Parameters
indexIndex of the variable you want to name.
nameName of the variable.

◆ update_real_variable_indices()

template<typename FF_ >
void proof_system::CircuitBuilderBase< FF_ >::update_real_variable_indices ( uint32_t  index,
uint32_t  new_real_index 
)
inline

Update all variables from index in equivalence class to have real variable new_real_index.

Parameters
indexThe index of a variable in the class we're updating.
new_real_indexThe index of the real variable to update to.

◆ update_variable_names()

template<typename FF_ >
virtual void proof_system::CircuitBuilderBase< FF_ >::update_variable_names ( uint32_t  index)
inlinevirtual

After assert_equal() merge two class names if present. Preserves the first name in class.

Parameters
indexIndex of the variable you have previously named and used in assert_equal.

The documentation for this class was generated from the following files: