pub struct ConstraintBuilder<F: Field> { /* private fields */ }Expand description
Builds constraint systems symbolically by recording operations as constraints.
Implements CircuitBuilder with ConstraintWire as the wire type. Operations like
add and mul allocate new wires and record constraints without evaluating values.
Implementations§
Source§impl<F: Field> ConstraintBuilder<F>
impl<F: Field> ConstraintBuilder<F>
pub fn new() -> Self
pub const fn alloc_inout(&mut self) -> ConstraintWire
pub const fn alloc_precommit(&mut self) -> ConstraintWire
pub fn build(self) -> ConstraintSystemIR<F>
Trait Implementations§
Source§impl<F: Field> CircuitBuilder for ConstraintBuilder<F>
impl<F: Field> CircuitBuilder for ConstraintBuilder<F>
type Wire = ConstraintWire
type Field = F
fn assert_zero(&mut self, wire: Self::Wire)
fn assert_eq(&mut self, lhs: Self::Wire, rhs: Self::Wire)
fn constant(&mut self, val: F) -> 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([F; IN]) -> [F; OUT], const IN: usize, const OUT: usize>( &mut self, inputs: [Self::Wire; IN], _f: H, ) -> [Self::Wire; OUT]
Source§fn hint_varsize<H: FnOnce(&[F]) -> Vec<F>>(
&mut self,
inputs: &[Self::Wire],
out_len: usize,
_f: H,
) -> Vec<Self::Wire>
fn hint_varsize<H: FnOnce(&[F]) -> Vec<F>>( &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.fn sub(&mut self, lhs: Self::Wire, rhs: Self::Wire) -> Self::Wire
Auto Trait Implementations§
impl<F> Freeze for ConstraintBuilder<F>
impl<F> RefUnwindSafe for ConstraintBuilder<F>where
F: RefUnwindSafe,
impl<F> Send for ConstraintBuilder<F>
impl<F> Sync for ConstraintBuilder<F>
impl<F> Unpin for ConstraintBuilder<F>where
F: Unpin,
impl<F> UnsafeUnpin for ConstraintBuilder<F>
impl<F> UnwindSafe for ConstraintBuilder<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more