[][src]Struct dusk_plonk::prelude::StandardComposer

pub struct StandardComposer { /* fields omitted */ }

A composer is a circuit builder and will dictate how a circuit is built We will have a default Composer called StandardComposer

Implementations

impl StandardComposer[src]

pub fn circuit_size(&self) -> usize[src]

Returns the number of gates in the circuit

impl StandardComposer[src]

pub fn new() -> Self[src]

Generates a new empty StandardComposer with all of it's fields set to hold an initial capacity of 0.

Warning

The usage of this may cause lots of re-allocations since the Composer holds Vec for every polynomial, and these will need to be re-allocated each time the circuit grows considerably.

pub fn add_witness_to_circuit_description(
    &mut self,
    var: Variable,
    value: Scalar
)
[src]

Fixes a variable in the witness to be a part of the circuit description. This method is (currently) only used in the following context: We have gates which only require 3/4 wires, We must assign the fourth value to another value, we then fix this value to be zero. However, the verifier needs to be able to verify that this value is also zero. We therefore must make this zero value a part of the circuit description of every circuit.

pub fn with_expected_size(expected_size: usize) -> Self[src]

Creates a new circuit with an expected circuit size. This will allow for less reallocations when building the circuit since the Vecs will already have an appropriate allocation at the beginning of the composing stage.

pub fn add_input(&mut self, s: Scalar) -> Variable[src]

Add Input first calls the Permutation struct to generate and allocate a new variable var. The composer then links the Variable to the Scalar and returns the Variable for use in the system.

pub fn add_constant_witness(&mut self, s: Scalar) -> Variable[src]

Adds the passed BlsScalar to the Constraint System as a witness value and constraints it to be equal to the value that was sent.

This makes easier to work with Public Inputs, since they can just be used as witnesses constrained to a fixed value.

pub fn poly_gate(
    &mut self,
    a: Variable,
    b: Variable,
    c: Variable,
    q_m: Scalar,
    q_l: Scalar,
    q_r: Scalar,
    q_o: Scalar,
    q_c: Scalar,
    pi: Scalar
) -> (Variable, Variable, Variable)
[src]

Adds a width-3 poly gate. This gate gives total freedom to the end user to implement the corresponding circuits in the most optimized way possible because the under has access to the whole set of variables, as well as selector coefficients that take part in the computation of the gate equation.

The final constraint added will force the following: (a * b) * q_m + a * q_l + b * q_r + q_c + PI + q_o * c = 0.

pub fn constrain_to_constant(
    &mut self,
    a: Variable,
    constant: Scalar,
    pi: Scalar
)
[src]

Adds a gate which is designed to constrain a Variable to have a specific constant value which is sent as a Scalar.

pub fn assert_equal(&mut self, a: Variable, b: Variable)[src]

Asserts that two variables are the same

pub fn add_dummy_constraints(&mut self)[src]

This function is used to add a blinding factor to the witness polynomials XXX: Split this into two separate functions and document XXX: We could add another section to add random witness variables, with selector polynomials all zero

impl StandardComposer[src]

pub fn add_gate(
    &mut self,
    a: Variable,
    b: Variable,
    c: Variable,
    q_l: Scalar,
    q_r: Scalar,
    q_o: Scalar,
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a width-3 add gate to the circuit, linking the addition of the provided inputs, scaled by the selector coefficients with the output provided.

pub fn big_add_gate(
    &mut self,
    a: Variable,
    b: Variable,
    c: Variable,
    d: Option<Variable>,
    q_l: Scalar,
    q_r: Scalar,
    q_o: Scalar,
    q_4: Scalar,
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a width-4 add gate to the circuit and it's corresponding constraint.

This type of gate is usually used when we need to have the largest amount of performance and the minimum circuit-size possible. Since it allows the end-user to set every selector coefficient as scaling value on the gate eq.

pub fn mul_gate(
    &mut self,
    a: Variable,
    b: Variable,
    c: Variable,
    q_m: Scalar,
    q_o: Scalar,
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a width-3 add gate to the circuit linking the product of the provided inputs scaled by the selector coefficient q_m with the output provided scaled by q_o.

Note that this gate requires to provide the actual result of the gate (output wire) since it will just add a mul constraint to the circuit.

pub fn big_mul_gate(
    &mut self,
    a: Variable,
    b: Variable,
    c: Variable,
    d: Option<Variable>,
    q_m: Scalar,
    q_o: Scalar,
    q_c: Scalar,
    q_4: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a width-4 big_mul_gate with the left, right and fourth inputs and it's scaling factors, computing & returning the output (result) Variable and adding the corresponding mul constraint.

This type of gate is usually used when we need to have the largest amount of performance and the minimum circuit-size possible. Since it allows the end-user to setup all of the selector coefficients.

Forces q_l * (w_l + w_r) + w_4 * q_4 + + q_c + PI = q_o * w_o(computed by the gate). XXX: Maybe make these tuples instead of individual field?

pub fn add(
    &mut self,
    q_l_a: (Scalar, Variable),
    q_r_b: (Scalar, Variable),
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a big_addition_gate with the left and right inputs and it's scaling factors, computing & returning the output (result) Variable, and adding the corresponding addition constraint.

This type of gate is usually used when we don't need to have the largest amount of performance as well as the minimum circuit-size possible. Since it defaults some of the selector coeffs = 0 in order to reduce the verbosity and complexity.

Forces q_l * w_l + q_r * w_r + q_c + PI = w_o(computed by the gate).

pub fn big_add(
    &mut self,
    q_l_a: (Scalar, Variable),
    q_r_b: (Scalar, Variable),
    q_4_d: Option<(Scalar, Variable)>,
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a big_addition_gate with the left, right and fourth inputs and it's scaling factors, computing & returning the output (result) Variable and adding the corresponding addition constraint.

This type of gate is usually used when we don't need to have the largest amount of performance and the minimum circuit-size possible. Since it defaults some of the selector coeffs = 0 in order to reduce the verbosity and complexity.

Forces q_l * w_l + q_r * w_r + q_4 * w_4 + q_c + PI = w_o(computed by the gate).

pub fn mul(
    &mut self,
    q_m: Scalar,
    a: Variable,
    b: Variable,
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a simple and basic addition to the circuit between to Variables returning the resulting Variable.

pub fn big_mul(
    &mut self,
    q_m: Scalar,
    a: Variable,
    b: Variable,
    q_4_d: Option<(Scalar, Variable)>,
    q_c: Scalar,
    pi: Scalar
) -> Variable
[src]

Adds a width-4 big_mul_gate with the left, right and fourth inputs and it's scaling factors, computing & returning the output (result) Variable and adding the corresponding mul constraint.

This type of gate is usually used when we don't need to have the largest amount of performance and the minimum circuit-size possible. Since it defaults some of the selector coeffs = 0 in order to reduce the verbosity and complexity.

Forces q_l * (w_l + w_r) + w_4 * q_4 + q_c + PI = w_o(computed by the gate). XXX: This API is not consistent. It should use tuples and not individual fields

impl StandardComposer[src]

pub fn boolean_gate(&mut self, a: Variable) -> Variable[src]

Adds a boolean constraint (also known as binary constraint) where the gate eq. will enforce that the Variable received is either 0 or 1 by adding a constraint in the circuit.

Note that using this constraint with whatever Variable that is not representing a value equalling 0 or 1, will always force the equation to fail.

impl StandardComposer[src]

pub fn assert_equal_public_point(
    &mut self,
    point: Point,
    public_point: AffinePoint
)
[src]

Asserts that a point in the circuit is equal to a known public point

pub fn assert_equal_point(&mut self, point_a: Point, point_b: Point)[src]

Asserts that a point in the circuit is equal to another point in the circuit

impl StandardComposer[src]

pub fn xor_gate(
    &mut self,
    a: Variable,
    b: Variable,
    num_bits: usize
) -> Variable
[src]

Adds a logical XOR gate that performs the XOR between two values for the specified first num_bits returning a Variable holding the result.

Panics

If the num_bits specified in the fn params is odd.

pub fn and_gate(
    &mut self,
    a: Variable,
    b: Variable,
    num_bits: usize
) -> Variable
[src]

Adds a logical AND gate that performs the bitwise AND between two values for the specified first num_bits returning a Variable holding the result.

Panics

If the num_bits specified in the fn params is odd.

impl StandardComposer[src]

pub fn range_gate(&mut self, witness: Variable, num_bits: usize)[src]

Adds a range-constraint gate that checks and constrains a Variable to be inside of the range [0,num_bits].

impl StandardComposer[src]

pub fn preprocess_prover(
    &mut self,
    commit_key: &CommitKey,
    transcript: &mut Transcript
) -> Result<ProverKey, Error>
[src]

These are the parts of preprocessing that the prover must compute Although the prover does not need the verification key, he must compute the commitments in order to seed the transcript, allowing both the prover and verifier to have the same view

pub fn preprocess_verifier(
    &mut self,
    commit_key: &CommitKey,
    transcript: &mut Transcript
) -> Result<VerifierKey, Error>
[src]

The verifier only requires the commitments in order to verify a proof We can therefore speed up preprocessing for the verifier by skipping the FFTs needed to compute the 4n evaluations

Trait Implementations

impl Debug for StandardComposer[src]

impl Default for StandardComposer[src]

Auto Trait Implementations

impl RefUnwindSafe for StandardComposer

impl Send for StandardComposer

impl Sync for StandardComposer

impl Unpin for StandardComposer

impl UnwindSafe for StandardComposer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,