Struct ConstraintSystem

Source
pub struct ConstraintSystem {
    pub value_vec_layout: ValueVecLayout,
    pub constants: Vec<Word>,
    pub and_constraints: Vec<AndConstraint>,
    pub mul_constraints: Vec<MulConstraint>,
}
Expand description

The ConstraintSystem is the core data structure in Binius64 that defines the computational constraints to be proven in zero-knowledge. It represents a system of equations over 64-bit words that must be satisfied by a valid values vector ValueVec.

§Clone

While this type is cloneable it may be expensive to do so since the constraint systems often can have millions of constraints.

Fields§

§value_vec_layout: ValueVecLayout

Description of the value vector layout expected by this constraint system.

§constants: Vec<Word>

The constants that this constraint system defines.

Those constants will be going to be available for constraints in the value vector. Those are known to both prover and verifier.

§and_constraints: Vec<AndConstraint>

List of AND constraints that must be satisfied by the values vector.

§mul_constraints: Vec<MulConstraint>

List of MUL constraints that must be satisfied by the values vector.

Implementations§

Source§

impl ConstraintSystem

Source

pub const SERIALIZATION_VERSION: u32 = 2u32

Serialization format version for compatibility checking

Source§

impl ConstraintSystem

Source

pub fn new( constants: Vec<Word>, value_vec_layout: ValueVecLayout, and_constraints: Vec<AndConstraint>, mul_constraints: Vec<MulConstraint>, ) -> Self

Creates a new constraint system.

Source

pub fn validate(&self) -> Result<(), ConstraintSystemError>

Ensures that this constraint system is well-formed and ready for proving.

Specifically checks that:

  • the value vec layout is valid.
  • every shifted value index is canonical.
  • referenced values indices are in the range.
  • constraints do not reference values in the padding area.
  • shifts amounts are valid.
Source

pub fn validate_and_prepare(&mut self) -> Result<(), ConstraintSystemError>

Validates and prepares this constraint system for proving/verifying.

This function performs the following:

  1. Validates the value vector layout (including public input checks)
  2. Validates the constraints.
  3. Pads the AND and MUL constraints to the next po2 size
Source

pub fn n_and_constraints(&self) -> usize

Returns the number of AND constraints in the system.

Source

pub fn n_mul_constraints(&self) -> usize

Returns the number of MUL constraints in the system.

Source

pub fn value_vec_len(&self) -> usize

The total length of the ValueVec expected by this constraint system.

Source

pub fn new_value_vec(&self) -> ValueVec

Create a new ValueVec with the size expected by this constraint system.

Trait Implementations§

Source§

impl Clone for ConstraintSystem

Source§

fn clone(&self) -> ConstraintSystem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConstraintSystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DeserializeBytes for ConstraintSystem

Source§

fn deserialize(read_buf: impl Buf) -> Result<Self, SerializationError>
where Self: Sized,

Source§

impl SerializeBytes for ConstraintSystem

Source§

fn serialize(&self, write_buf: impl BufMut) -> Result<(), SerializationError>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.