pub trait CircuitBuilder {
type Wire: Copy;
type Field: Field;
// Required methods
fn assert_zero(&mut self, wire: Self::Wire);
fn constant(&mut self, val: Self::Field) -> Self::Wire;
fn add(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire;
fn mul(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire;
fn hint<H: Fn([Self::Field; IN]) -> [Self::Field; OUT], const IN: usize, const OUT: usize>(
&mut self,
inputs: [Self::Wire; IN],
f: H,
) -> [Self::Wire; OUT];
fn hint_varsize<H: FnOnce(&[Self::Field]) -> Vec<Self::Field>>(
&mut self,
inputs: &[Self::Wire],
out_len: usize,
f: H,
) -> Vec<Self::Wire>;
// Provided methods
fn assert_eq(&mut self, lhs: Self::Wire, rhs: Self::Wire) { ... }
fn sub(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire { ... }
}Expand description
Common interface for circuit construction and witness generation.
This trait enables writing circuit logic once that works for both abstract circuit
expression (ConstraintBuilder) and concrete witness generation (WitnessGenerator).
The same function can build constraints symbolically or evaluate them with concrete values.
Required Associated Types§
Required Methods§
fn assert_zero(&mut self, wire: Self::Wire)
fn constant(&mut self, val: Self::Field) -> Self::Wire
fn add(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire
fn mul(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire
fn hint<H: Fn([Self::Field; IN]) -> [Self::Field; OUT], const IN: usize, const OUT: usize>( &mut self, inputs: [Self::Wire; IN], f: H, ) -> [Self::Wire; OUT]
Sourcefn hint_varsize<H: FnOnce(&[Self::Field]) -> Vec<Self::Field>>(
&mut self,
inputs: &[Self::Wire],
out_len: usize,
f: H,
) -> Vec<Self::Wire>
fn hint_varsize<H: FnOnce(&[Self::Field]) -> Vec<Self::Field>>( &mut self, inputs: &[Self::Wire], out_len: usize, f: H, ) -> Vec<Self::Wire>
Runtime-arity variant of hint: takes a slice of input wires and an
out_len, with a closure mapping the input values to out_len output values. Emits no
constraints; the outputs are public-derivable (allocated in the derived segment) iff every
input is, matching hint. The closure is invoked at most once —
value-generating builders run it, the symbolic builder skips it.
Provided Methods§
fn assert_eq(&mut self, lhs: Self::Wire, rhs: Self::Wire)
fn sub(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".