pub struct ConstraintSystemM4 {
pub main: EmbeddedConstraintSystem,
pub chips: Vec<(EmbeddedConstraintSystem, usize)>,
}Expand description
An M4 constraint system.
An M4 constraint system is essentially defined by the composition of chips, each of which validates a relation on its local inout values. Chips can delegate subrelation constraints to other chips via chip calls.
Validity invariants:
- all embedded constraint systems in
chipsmust have a chip_id value that indexes intochips - the chip calls must claim each chip’s active instances exactly once between them
The chips are in topological order: a chip calls only chips with a higher ID, and main, which
is not one of them, calls any. Enumerating the chips in ID order therefore reaches every caller
of a chip before the chip itself, which is what lets one pass assign the instances and one pass
generate the witness. Self::validate requires the ordering, which makes the call graph
acyclic as a consequence.
Fields§
§main: EmbeddedConstraintSystemThe entry point of the system. It calls chips, but no chip ID names it, so nothing calls it.
chips: Vec<(EmbeddedConstraintSystem, usize)>The chips, indexed by chip ID, each paired with its number of active instances.
A chip runs once per call that reaches it, and those instances are the active ones: only they have their own chip calls enforced. The instances past them pad the count and are matched by no call.
Implementations§
Source§impl ConstraintSystemM4
impl ConstraintSystemM4
Sourcepub fn validate(&self) -> Result<(), ConstraintSystemError>
pub fn validate(&self) -> Result<(), ConstraintSystemError>
Checks every chip and every chip call, requires the chips to be in topological order, and holds the instances the calls name against the ones the call graph gives them.
Sourcepub fn verify<I: ChipInstances + ?Sized>(
&self,
main: &ValueVec,
chip_instances: &I,
) -> Result<(), VerificationM4Error>
pub fn verify<I: ChipInstances + ?Sized>( &self, main: &ValueVec, chip_instances: &I, ) -> Result<(), VerificationM4Error>
Checks that a witness satisfies this system.
The witness is the main chip’s value vector and, per chip, one value vector per instance. It must satisfy:
- the main chip’s constraints, on
main; - each chip’s constraints, on every one of its instances — the instances past the active ones included, since every instance is committed;
- every chip call, by the instance it names: the caller’s instance
iinvokes the callee’s instancefirst_instanceplusi, and passes exactly the inout words that instance holds. An inout value the call has no operand for must hold zero.
This is the reference the proving protocol’s argument is checked against, in the manner of
ConstraintSystem::verify.
Instances are read through ChipInstances one at a time, so a witness that stores them
packed is never expanded whole. The price is that an instance serving a call is built again
when the call is checked, having already been built for its own constraints.
Malformed systems are Self::validate’s to reject; verifying one may panic, misreport, or
pass. In particular a call passing more operands than the callee has inout values — which
Self::validate rejects — has the operands past them ignored here.
§Errors
Reports the first failure found, in the order listed above.
Auto Trait Implementations§
impl Freeze for ConstraintSystemM4
impl RefUnwindSafe for ConstraintSystemM4
impl Send for ConstraintSystemM4
impl Sync for ConstraintSystemM4
impl Unpin for ConstraintSystemM4
impl UnsafeUnpin for ConstraintSystemM4
impl UnwindSafe for ConstraintSystemM4
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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