pub struct InstanceGenerator<F: Field, LayoutRef = Arc<WitnessLayout<F>>> { /* private fields */ }Expand description
Reconstructs the public input vector [constants | inout | derived] on the verifier side by
re-running the circuit function.
Implements CircuitBuilder with PublicWire as the wire type, structurally mirroring
WitnessGenerator, but it only computes the public segment. The verifier lacks the secret
(precommit) values, so private wires carry no value; by the soundness invariant a derived wire
never reads a secret, so every derived value is computable from the real public inputs alone.
Derived wires are allocated in the same order as ConstraintBuilder, keeping their ids
aligned so WitnessLayout::get resolves each to the correct public slot.
LayoutRef is any pointer to a WitnessLayout, chosen by the caller:
&WitnessLayout<F>— a zero-cost borrow, tied to the borrow’s lifetime.Arc<WitnessLayout<F>>— shared and'static(the default).
A 'static generator is what lets a wrapper channel hand its transparent closures to an opener.
Sharing an Arc gives that without cloning the layout, so the wrapper channel uses it.
Implementations§
Source§impl<F: Field, LayoutRef: Deref<Target = WitnessLayout<F>>> InstanceGenerator<F, LayoutRef>
impl<F: Field, LayoutRef: Deref<Target = WitnessLayout<F>>> InstanceGenerator<F, LayoutRef>
pub fn new(layout: LayoutRef) -> Self
Sourcepub fn write_inout(&mut self, wire: ConstraintWire, value: F) -> PublicWire<F>
pub fn write_inout(&mut self, wire: ConstraintWire, value: F) -> PublicWire<F>
Writes a real inout value into its public slot.
Sourcepub fn placeholder_precommit(&mut self, wire: ConstraintWire) -> PublicWire<F>
pub fn placeholder_precommit(&mut self, wire: ConstraintWire) -> PublicWire<F>
Records a precommit wire as private (value unknown to the verifier). Per the soundness invariant a secret never feeds a derived value, so the missing value is inert.
Sourcepub fn public(&self) -> &[F]
pub fn public(&self) -> &[F]
The reconstructed public vector [constants | inout | derived] so far, of length
1 << layout.log_public(). Once every inout and alive-derived wire has been written, this
is the final public vector; reading it by reference (rather than consuming via
Self::build) lets callers keep the generator alive for wires that still reference it.
Trait Implementations§
Source§impl<F: Field, LayoutRef: Deref<Target = WitnessLayout<F>>> CircuitBuilder for InstanceGenerator<F, LayoutRef>
impl<F: Field, LayoutRef: Deref<Target = WitnessLayout<F>>> CircuitBuilder for InstanceGenerator<F, LayoutRef>
type Wire = PublicWire<F>
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>
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, LayoutRef> Freeze for InstanceGenerator<F, LayoutRef>where
LayoutRef: Freeze,
impl<F, LayoutRef> RefUnwindSafe for InstanceGenerator<F, LayoutRef>where
LayoutRef: RefUnwindSafe,
F: RefUnwindSafe,
impl<F, LayoutRef> Send for InstanceGenerator<F, LayoutRef>where
LayoutRef: Send,
impl<F, LayoutRef> Sync for InstanceGenerator<F, LayoutRef>where
LayoutRef: Sync,
impl<F, LayoutRef> Unpin for InstanceGenerator<F, LayoutRef>
impl<F, LayoutRef> UnsafeUnpin for InstanceGenerator<F, LayoutRef>where
LayoutRef: UnsafeUnpin,
impl<F, LayoutRef> UnwindSafe for InstanceGenerator<F, LayoutRef>where
LayoutRef: UnwindSafe,
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
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>
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>
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