|
ecc_op_tuple | queue_ecc_add_accum (const g1::affine_element &point) |
| Add simple point addition operation to the op queue and add corresponding gates.
|
|
ecc_op_tuple | queue_ecc_mul_accum (const g1::affine_element &point, const FF &scalar) |
| Add point mul-then-accumulate operation to the op queue and add corresponding gates.
|
|
ecc_op_tuple | queue_ecc_eq () |
| Add point equality operation to the op queue based on the value of the internal accumulator and add corresponding gates.
|
|
ecc_op_tuple | queue_ecc_no_op () |
| Logic for a no-op operation.
|
|
void | queue_ecc_random_op () |
| Mechanism for populating two rows with randomness. This "operation" doesn't return a tuple representing the indices of the ecc op values because it should never be used in subsequent logic.
|
|
| MegaCircuitBuilder_ (const size_t size_hint=0, std::shared_ptr< ECCOpQueue > op_queue_in=std::make_shared< ECCOpQueue >()) |
|
| MegaCircuitBuilder_ (std::shared_ptr< ECCOpQueue > op_queue_in) |
|
| MegaCircuitBuilder_ (std::shared_ptr< ECCOpQueue > op_queue_in, auto &witness_values, const std::vector< uint32_t > &public_inputs, size_t varnum) |
| Constructor from data generated from ACIR.
|
|
uint32_t | get_ecc_op_idx (const EccOpCode &op_code) |
| Convert op code to the witness index for the corresponding op index in the builder.
|
|
void | finalize_circuit (const bool ensure_nonzero) |
|
void | add_ultra_and_mega_gates_to_ensure_all_polys_are_non_zero () |
| Ensure all polynomials have at least one non-zero coefficient to avoid commiting to the zero-polynomial. This only adds gates for the Goblin polynomials. Most polynomials are handled via the Ultra method, which should be done by a separate call to the Ultra builder's non zero polynomial gates method.
|
|
void | add_mega_gates_to_ensure_all_polys_are_non_zero () |
| Ensure all polynomials have at least one non-zero coefficient to avoid commiting to the zero-polynomial. This only adds gates for the Goblin polynomials. Most polynomials are handled via the Ultra method, which should be done by a separate call to the Ultra builder's non zero polynomial gates method.
|
|
size_t | get_num_constant_gates () const override |
|
size_t | get_estimated_num_finalized_gates () const override |
| Get the final number of gates in a circuit, which consists of the sum of: 1) Current number number of actual gates 2) Number of public inputs, as we'll need to add a gate for each of them 3) Number of Rom array-associated gates 4) Number of range-list associated gates 5) Number of non-native field multiplication gates.
|
|
size_t | get_num_gates_added_to_ensure_nonzero_polynomials () |
| Dynamically compute the number of gates added by the "add_gates_to_ensure_all_polys_are_non_zero" method.
|
|
void | print_num_estimated_finalized_gates () const override |
| Print the number and composition of gates in the circuit.
|
|
void | add_public_calldata (const uint32_t &in) |
| Add a witness variable to the public calldata.
|
|
void | add_public_secondary_calldata (const uint32_t &in) |
| Add a witness variable to secondary_calldata.
|
|
void | add_public_return_data (const uint32_t &in) |
| Add a witness variable to the public return_data.
|
|
uint32_t | read_bus_vector (BusId bus_idx, const uint32_t &read_idx_witness_idx) |
| Read from a databus column.
|
|
uint32_t | read_calldata (const uint32_t &read_idx_witness_idx) |
| Read from calldata and create a corresponding databus read gate.
|
|
uint32_t | read_secondary_calldata (const uint32_t &read_idx_witness_idx) |
| Read from secondary_calldata and create a corresponding databus read gate.
|
|
uint32_t | read_return_data (const uint32_t &read_idx_witness_idx) |
| Read from return_data and create a corresponding databus read gate.
|
|
void | append_to_bus_vector (const BusId bus_idx, const uint32_t &witness_idx) |
|
const BusVector & | get_calldata () const |
|
const BusVector & | get_secondary_calldata () const |
|
const BusVector & | get_return_data () const |
|
void | populate_public_inputs_block () |
| Copy the public input idx data into the public inputs trace block.
|
|
void | process_non_native_field_multiplications () |
| Called in compute_proving_key when finalizing circuit. Iterates over the cached_non_native_field_multiplication objects, removes duplicates, and instantiates the remainder as constraints`.
|
|
| UltraCircuitBuilder_ (const size_t size_hint=0) |
|
| UltraCircuitBuilder_ (const size_t size_hint, auto &witness_values, const std::vector< uint32_t > &public_inputs, size_t varnum, bool recursive=false) |
| Constructor from data generated from ACIR.
|
|
| UltraCircuitBuilder_ (const UltraCircuitBuilder_ &other)=default |
|
| UltraCircuitBuilder_ (UltraCircuitBuilder_ &&other) noexcept |
|
UltraCircuitBuilder_ & | operator= (const UltraCircuitBuilder_ &other)=default |
|
UltraCircuitBuilder_ & | operator= (UltraCircuitBuilder_ &&other) noexcept |
|
| ~UltraCircuitBuilder_ () override=default |
|
bool | operator== (const UltraCircuitBuilder_ &other) const |
|
void | check_selector_length_consistency () |
| Debug helper method for ensuring all selectors have the same size.
|
|
void | finalize_circuit (const bool ensure_nonzero) |
|
void | add_gates_to_ensure_all_polys_are_non_zero () |
| Ensure all polynomials have at least one non-zero coefficient to avoid commiting to the zero-polynomial.
|
|
void | create_add_gate (const add_triple_< FF > &in) override |
| Create an addition gate, where in.a * in.a_scaling + in.b * in.b_scaling + in.c * in.c_scaling + in.const_scaling = 0.
|
|
void | create_big_mul_add_gate (const mul_quad_< FF > &in, const bool use_next_gate_w_4=false) |
| Create a big multiplication-addition gate, where in.a * in.b * in.mul_scaling + in.a * in.a_scaling + in.b * in.b_scaling + in.c * in.c_scaling + in.d * in.d_scaling + in.const_scaling = 0. If include_next_gate_w_4 is enabled, then this sum also adds the value of the 4-th witness at the next index.
|
|
void | create_big_add_gate (const add_quad_< FF > &in, const bool use_next_gate_w_4=false) |
| Create a big addition gate, where in.a * in.a_scaling + in.b * in.b_scaling + in.c * in.c_scaling + in.d * in.d_scaling + in.const_scaling = 0. If include_next_gate_w_4 is enabled, then the sum also adds the value of the 4-th witness at the next index.
|
|
void | create_big_add_gate_with_bit_extraction (const add_quad_< FF > &in) |
| A legacy method that was used to extract a bit from c-4d by using gate selectors in the Turboplonk, but is simulated here for ultraplonk.
|
|
void | create_big_mul_gate (const mul_quad_< FF > &in) |
| Create a basic multiplication gate q_m * a * b + q_1 * a + q_2 * b + q_3 * c + q_4 * d + q_c = 0 (q_arith = 1)
|
|
void | create_balanced_add_gate (const add_quad_< FF > &in) |
|
void | create_mul_gate (const mul_triple_< FF > &in) override |
| Create a multiplication gate with q_m * a * b + q_3 * c + q_const = 0.
|
|
void | create_bool_gate (const uint32_t a) override |
| Generate an arithmetic gate equivalent to x^2 - x = 0, which forces x to be 0 or 1.
|
|
void | create_poly_gate (const poly_triple_< FF > &in) override |
| A plonk gate with disabled (set to zero) fourth wire. q_m * a * b + q_1 * a + q_2 * b + q_3.
|
|
void | create_ecc_add_gate (const ecc_add_gate_< FF > &in) |
| Create an elliptic curve addition gate.
|
|
void | create_ecc_dbl_gate (const ecc_dbl_gate_< FF > &in) |
| Create an elliptic curve doubling gate.
|
|
void | fix_witness (const uint32_t witness_index, const FF &witness_value) |
| Add a gate equating a particular witness to a constant, fixing its value.
|
|
void | create_new_range_constraint (const uint32_t variable_index, const uint64_t target_range, std::string const msg="create_new_range_constraint") |
| Constrain a variable to a range.
|
|
void | create_range_constraint (const uint32_t variable_index, const size_t num_bits, std::string const &msg) |
|
uint32_t | put_constant_variable (const FF &variable) |
|
size_t | get_num_constant_gates () const override |
|
void | get_num_estimated_gates_split_into_components (size_t &count, size_t &rangecount, size_t &romcount, size_t &ramcount, size_t &nnfcount) const |
| Get the final number of gates in a circuit, which consists of the sum of: 1) Current number number of actual gates 2) Number of public inputs, as we'll need to add a gate for each of them 3) Number of Rom array-associated gates 4) Number of range-list associated gates 5) Number of non-native field multiplication gates.
|
|
size_t | get_num_finalized_gates () const override |
| Get the number of gates in a finalized circuit.
|
|
size_t | get_estimated_num_finalized_gates () const override |
| Get the final number of gates in a circuit, which consists of the sum of: 1) Current number number of actual gates 2) Number of public inputs, as we'll need to add a gate for each of them 3) Number of Rom array-associated gates 4) Number of range-list associated gates 5) Number of non-native field multiplication gates. !!! WARNING: This function is predictive and might report an incorrect number. Make sure to finalize the circuit and then check the number of gates for a precise result. Kesha: it's basically voodoo.
|
|
size_t | get_num_gates_added_to_ensure_nonzero_polynomials () |
| Dynamically compute the number of gates added by the "add_gates_to_ensure_all_polys_are_non_zero" method.
|
|
size_t | get_tables_size () const |
| Get combined size of all tables used in circuit.
|
|
size_t | get_lookups_size () const |
| Get total number of lookups used in circuit.
|
|
size_t | get_finalized_total_circuit_size () const |
| Get the actual finalized size of a circuit. Assumes the circuit is finalized already.
|
|
size_t | get_estimated_total_circuit_size () const |
| Get the estimated size of the circuit if it was finalized now.
|
|
std::vector< uint32_t > | get_used_witnesses () const |
|
void | update_used_witnesses (uint32_t var_idx) |
|
void | print_num_estimated_finalized_gates () const override |
| Print the number and composition of gates in the circuit.
|
|
void | assert_equal_constant (const uint32_t a_idx, const FF &b, std::string const &msg="assert equal constant") |
|
void | initialize_precomputed_table (const plookup::BasicTableId id, bool(*generator)(std::vector< FF > &, std::vector< FF > &, std::vector< FF > &), std::array< FF, 2 >(*get_values_from_key)(const std::array< uint64_t, 2 >)) |
|
plookup::BasicTable & | get_table (const plookup::BasicTableId id) |
| Get the basic table with provided ID from the set of tables for the present circuit; create it if it doesnt yet exist.
|
|
plookup::MultiTable & | get_multitable (const plookup::MultiTableId id) |
|
plookup::ReadData< uint32_t > | create_gates_from_plookup_accumulators (const plookup::MultiTableId &id, const plookup::ReadData< FF > &read_values, const uint32_t key_a_index, std::optional< uint32_t > key_b_index=std::nullopt) |
| Perform a series of lookups, one for each 'row' in read_values.
|
|
std::vector< uint32_t > | decompose_into_default_range (const uint32_t variable_index, const uint64_t num_bits, const uint64_t target_range_bitnum=DEFAULT_PLOOKUP_RANGE_BITNUM, std::string const &msg="decompose_into_default_range") |
|
std::vector< uint32_t > | decompose_into_default_range_better_for_oddlimbnum (const uint32_t variable_index, const size_t num_bits, std::string const &msg="decompose_into_default_range_better_for_oddlimbnum") |
|
void | create_dummy_gate (auto &block, const uint32_t &idx_1, const uint32_t &idx_2, const uint32_t &idx_3, const uint32_t &idx_4) |
| Create a gate with no constraints but with possibly non-trivial wire values.
|
|
void | create_dummy_constraints (const std::vector< uint32_t > &variable_index) |
|
void | create_sort_constraint (const std::vector< uint32_t > &variable_index) |
|
void | create_sort_constraint_with_edges (const std::vector< uint32_t > &variable_index, const FF &, const FF &) |
|
void | assign_tag (const uint32_t variable_index, const uint32_t tag) |
|
uint32_t | create_tag (const uint32_t tag_index, const uint32_t tau_index) |
|
uint32_t | get_new_tag () |
|
RangeList | create_range_list (const uint64_t target_range) |
|
void | process_range_list (RangeList &list) |
|
void | process_range_lists () |
|
void | apply_memory_selectors (const MEMORY_SELECTORS type) |
| Enable the memory gate of particular type.
|
|
void | apply_nnf_selectors (const NNF_SELECTORS type) |
| Enable the nnf gate of particular type.
|
|
void | range_constrain_two_limbs (const uint32_t lo_idx, const uint32_t hi_idx, const size_t lo_limb_bits=DEFAULT_NON_NATIVE_FIELD_LIMB_BITS, const size_t hi_limb_bits=DEFAULT_NON_NATIVE_FIELD_LIMB_BITS) |
|
std::array< uint32_t, 2 > | decompose_non_native_field_double_width_limb (const uint32_t limb_idx, const size_t num_limb_bits=(2 *DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)) |
| Decompose a single witness into two, where the lowest is DEFAULT_NON_NATIVE_FIELD_LIMB_BITS (68) range constrained and the lowst is num_limb_bits - DEFAULT.. range constrained.
|
|
std::array< uint32_t, 2 > | evaluate_non_native_field_multiplication (const non_native_multiplication_witnesses< FF > &input) |
| Queue up non-native field multiplication data.
|
|
std::array< uint32_t, 2 > | queue_partial_non_native_field_multiplication (const non_native_partial_multiplication_witnesses< FF > &input) |
|
std::array< uint32_t, 5 > | evaluate_non_native_field_subtraction (add_simple limb0, add_simple limb1, add_simple limb2, add_simple limb3, std::tuple< uint32_t, uint32_t, FF > limbp) |
|
std::array< uint32_t, 5 > | evaluate_non_native_field_addition (add_simple limb0, add_simple limb1, add_simple limb2, add_simple limb3, std::tuple< uint32_t, uint32_t, FF > limbp) |
|
size_t | create_ROM_array (const size_t array_size) |
| Create a new read-only memory region.
|
|
void | set_ROM_element (const size_t rom_id, const size_t index_value, const uint32_t value_witness) |
| Initialize a rom cell to equal value_witness
|
|
void | set_ROM_element_pair (const size_t rom_id, const size_t index_value, const std::array< uint32_t, 2 > &value_witnesses) |
| Initialize a ROM array element with a pair of witness values.
|
|
uint32_t | read_ROM_array (const size_t rom_id, const uint32_t index_witness) |
| Read a single element from ROM.
|
|
std::array< uint32_t, 2 > | read_ROM_array_pair (const size_t rom_id, const uint32_t index_witness) |
| Read a pair of elements from ROM.
|
|
size_t | create_RAM_array (const size_t array_size) |
| Create a new updatable memory region.
|
|
void | init_RAM_element (const size_t ram_id, const size_t index_value, const uint32_t value_witness) |
| Initialize a RAM cell to equal value_witness
|
|
uint32_t | read_RAM_array (const size_t ram_id, const uint32_t index_witness) |
|
void | write_RAM_array (const size_t ram_id, const uint32_t index_witness, const uint32_t value_witness) |
|
void | create_poseidon2_external_gate (const poseidon2_external_gate_< FF > &in) |
| Poseidon2 external round gate, activates the q_poseidon2_external selector and relation.
|
|
void | create_poseidon2_internal_gate (const poseidon2_internal_gate_< FF > &in) |
| Poseidon2 internal round gate, activates the q_poseidon2_internal selector and relation.
|
|
msgpack::sbuffer | export_circuit () override |
|
| 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 | operator== (const CircuitBuilderBase &other) const=default |
|
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_poly_gate (const poly_triple_< FF > &in)=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 void | update_variable_names (uint32_t index) |
|
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 | set_err (std::string msg) |
|
void | failure (std::string msg) |
|