Skip to main content

ConstraintSystemM4

Struct ConstraintSystemM4 

Source
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 chips must have a chip_id value that indexes into chips
  • 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: EmbeddedConstraintSystem

The 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

Source

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.

Source

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 i invokes the callee’s instance first_instance plus i, 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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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