Struct plonk_pallet::TurboComposer[][src]

pub struct TurboComposer { /* fields omitted */ }
Expand description

The TurboComposer is the circuit-builder tool that the dusk-plonk repository provides so that circuit descriptions can be written, stored and transformed into a Proof at some point.

A TurboComposer stores all of the circuit information, being this one all of the witness and circuit descriptors info (values, positions in the circuits, gates and Wires that occupy..), the public inputs, the connection relationships between the witnesses and how they’re repesented as Wires (so basically the Permutation argument etc..).

The TurboComposer also grants us a way to introduce our secret witnesses in a for of a Witness into the circuit description as well as the public inputs. We can do this with methods like TurboComposer::append_witness.

The TurboComposer also contains as associated functions all the neccessary tools to be able to istrument the circuits that the user needs through the addition of gates. There are functions that may add a single gate to the circuit as for example TurboComposer::gate_add and others that can add several gates to the circuit description such as TurboComposer::component_select.

Each gate or group of gates adds an specific functionallity or operation to de circuit description, and so, that’s why we can understand the TurboComposer as a builder.

Implementations

Returns a Witness representation of zero.

Every TurboComposer is initialized with a circuit description containing a representation of zero. This function will return the index of that representation.

Return the number of gates in the circuit

Evaluate the runtime value of a witness

Safety

Witness evaluation inside a gadget isn’t expected and could produce an unsound circuit (different circuit representation for the same code).

Calling this function performs operations outside the circuit.

Returns the positions that the Public Inputs occupy in this Composer instance.

Constrain a scalar into the circuit description and return an allocated Witness with its value

Allocate a witness value into the composer and return its index.

Adds a width-4 poly gate.

The final constraint added will enforce the following: q_m · a · b + q_l · a + q_r · b + q_o · o + q_4 · d + q_c + PI = 0.

Constrain a to be equal to constant + pi.

constant will be defined as part of the public circuit description.

Asserts a == b by appending a gate

Conditionally selects a Witness based on an input bit.

bit == 1 => a, bit == 0 => b,

bit is expected to be constrained by TurboComposer::component_boolean

Conditionally selects a Witness based on an input bit.

bit == 1 => value, bit == 0 => 0,

bit is expected to be constrained by TurboComposer::component_boolean

Conditionally selects a Witness based on an input bit.

bit == 1 => value, bit == 0 => 1,

bit is expected to be constrained by TurboComposer::component_boolean

Decomposes scalar into an array truncated to N bits (max 256).

Asserts the reconstruction of the bits to be equal to scalar.

Consume 2 · N + 1 gates

This function is used to add a blinding factor to the witness polynomials. It essentially adds two dummy gates to the circuit description which are guaranteed to always satisfy the gate equation.

Adds a plonkup gate to the circuit with its corresponding gates.

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.

When TurboComposer is initialised, it spawns a dummy table with 3 entries that should not be removed. This function appends its input table to the composer’s dummy table

Adds two curve points by consuming 2 gates.

Evaluate jubjub · Generator as a WitnessPoint

generator will be appended to the circuit description as constant

Evaluate jubjub · point as a WitnessPoint

Appends a point in affine form as WitnessPoint

Appends a point in affine form as WitnessPoint

Creates two public inputs as (x, y)

Constrain a point into the circuit description and return an allocated WitnessPoint with its coordinates

Create an identity WitnessPoint constrained by the circuit description

Asserts point == public.

Will add public affine coordinates (x,y) as public inputs

Asserts a == b by appending two gates

Conditionally selects a WitnessPoint based on an input bit.

bit == 1 => a, bit == 0 => b,

bit is expected to be constrained by TurboComposer::component_boolean

Conditionally selects identity as WitnessPoint based on an input bit.

bit == 1 => a, bit == 0 => identity,

bit is expected to be constrained by TurboComposer::component_boolean

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

Panics

If the num_bits specified in the fn params is odd.

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

Panics

If the num_bits specified in the fn params is odd.

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

This function adds num_bits/4 gates to the circuit description in order to add the range constraint.

Panics

This function will panic if the num_bits specified is not even, ie. num_bits % 2 != 0.

Evaluate and return o by appending a new constraint into the circuit.

The output of the constraint will be overwritten with o := q_l · a + q_r · b + q_4 · d + q_c + PI

Evaluate and return o by appending a new constraint into the circuit.

The output of the constraint will be overwritten with o := q_m · a · b + q_4 · d + q_c + PI

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

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

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more