jf_relation::constraint_system

Trait Circuit

Source
pub trait Circuit<F: Field> {
Show 28 methods // Required methods fn num_gates(&self) -> usize; fn num_vars(&self) -> usize; fn num_inputs(&self) -> usize; fn num_wire_types(&self) -> usize; fn public_input(&self) -> Result<Vec<F>, CircuitError>; fn check_circuit_satisfiability( &self, pub_input: &[F], ) -> Result<(), CircuitError>; fn create_constant_variable( &mut self, val: F, ) -> Result<Variable, CircuitError>; fn create_variable(&mut self, val: F) -> Result<Variable, CircuitError>; fn create_public_variable( &mut self, val: F, ) -> Result<Variable, CircuitError>; fn set_variable_public(&mut self, var: Variable) -> Result<(), CircuitError>; fn zero(&self) -> Variable; fn one(&self) -> Variable; fn witness(&self, idx: Variable) -> Result<F, CircuitError>; fn enforce_constant( &mut self, var: Variable, constant: F, ) -> Result<(), CircuitError>; fn add_gate( &mut self, a: Variable, b: Variable, c: Variable, ) -> Result<(), CircuitError>; fn add( &mut self, a: Variable, b: Variable, ) -> Result<Variable, CircuitError>; fn sub_gate( &mut self, a: Variable, b: Variable, c: Variable, ) -> Result<(), CircuitError>; fn sub( &mut self, a: Variable, b: Variable, ) -> Result<Variable, CircuitError>; fn mul_gate( &mut self, a: Variable, b: Variable, c: Variable, ) -> Result<(), CircuitError>; fn mul( &mut self, a: Variable, b: Variable, ) -> Result<Variable, CircuitError>; fn enforce_bool(&mut self, a: Variable) -> Result<(), CircuitError>; fn enforce_equal( &mut self, a: Variable, b: Variable, ) -> Result<(), CircuitError>; fn pad_gates(&mut self, n: usize); fn support_lookup(&self) -> bool; // Provided methods fn create_boolean_variable( &mut self, val: bool, ) -> Result<BoolVar, CircuitError> { ... } fn create_public_boolean_variable( &mut self, val: bool, ) -> Result<BoolVar, CircuitError> { ... } fn false_var(&self) -> BoolVar { ... } fn true_var(&self) -> BoolVar { ... }
}
Expand description

An interface for Plonk constraint systems.

Required Methods§

Source

fn num_gates(&self) -> usize

The number of constraints.

Source

fn num_vars(&self) -> usize

The number of variables.

Source

fn num_inputs(&self) -> usize

The number of public input variables.

Source

fn num_wire_types(&self) -> usize

The number of wire types of the circuit. E.g., UltraPlonk has 4 different types of input wires, 1 type of output wires, and 1 type of lookup wires.

Source

fn public_input(&self) -> Result<Vec<F>, CircuitError>

The list of public input values.

Source

fn check_circuit_satisfiability( &self, pub_input: &[F], ) -> Result<(), CircuitError>

Check circuit satisfiability against a public input.

Source

fn create_constant_variable(&mut self, val: F) -> Result<Variable, CircuitError>

Add a constant variable to the circuit; return the index of the variable.

Source

fn create_variable(&mut self, val: F) -> Result<Variable, CircuitError>

Add a variable to the circuit; return the index of the variable.

Source

fn create_public_variable(&mut self, val: F) -> Result<Variable, CircuitError>

Add a public input variable; return the index of the variable.

Source

fn set_variable_public(&mut self, var: Variable) -> Result<(), CircuitError>

Set a variable to a public variable

Source

fn zero(&self) -> Variable

Return a default variable with value zero.

Source

fn one(&self) -> Variable

Return a default variable with value one.

Source

fn witness(&self, idx: Variable) -> Result<F, CircuitError>

Return the witness value of variable idx. Return error if the input variable is invalid.

Source

fn enforce_constant( &mut self, var: Variable, constant: F, ) -> Result<(), CircuitError>

Common gates that should be implemented in any constraint systems.

Constrain a variable to a constant. Return error if var is an invalid variable.

Source

fn add_gate( &mut self, a: Variable, b: Variable, c: Variable, ) -> Result<(), CircuitError>

Constrain variable c to the addition of a and b. Return error if the input variables are invalid.

Source

fn add(&mut self, a: Variable, b: Variable) -> Result<Variable, CircuitError>

Obtain a variable representing an addition. Return the index of the variable. Return error if the input variables are invalid.

Source

fn sub_gate( &mut self, a: Variable, b: Variable, c: Variable, ) -> Result<(), CircuitError>

Constrain variable c to the subtraction of a and b. Return error if the input variables are invalid.

Source

fn sub(&mut self, a: Variable, b: Variable) -> Result<Variable, CircuitError>

Obtain a variable representing a subtraction. Return the index of the variable. Return error if the input variables are invalid.

Source

fn mul_gate( &mut self, a: Variable, b: Variable, c: Variable, ) -> Result<(), CircuitError>

Constrain variable c to the multiplication of a and b. Return error if the input variables are invalid.

Source

fn mul(&mut self, a: Variable, b: Variable) -> Result<Variable, CircuitError>

Obtain a variable representing a multiplication. Return the index of the variable. Return error if the input variables are invalid.

Source

fn enforce_bool(&mut self, a: Variable) -> Result<(), CircuitError>

Constrain a variable to a bool. Return error if the input is invalid.

Source

fn enforce_equal( &mut self, a: Variable, b: Variable, ) -> Result<(), CircuitError>

Constrain two variables to have the same value. Return error if the input variables are invalid.

Source

fn pad_gates(&mut self, n: usize)

Pad the circuit with n dummy gates

Source

fn support_lookup(&self) -> bool

Plookup-related methods. Return true if the circuit support lookup gates.

Provided Methods§

Source

fn create_boolean_variable( &mut self, val: bool, ) -> Result<BoolVar, CircuitError>

Add a bool variable to the circuit; return the index of the variable.

Source

fn create_public_boolean_variable( &mut self, val: bool, ) -> Result<BoolVar, CircuitError>

Add a public bool variable to the circuit; return the index of the variable.

Source

fn false_var(&self) -> BoolVar

Return a default variable with value false (namely zero).

Source

fn true_var(&self) -> BoolVar

Return a default variable with value true (namely one).

Implementors§

Source§

impl<F: FftField> Circuit<F> for PlonkCircuit<F>