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
impl ConstraintSystem
Sourcepub const SERIALIZATION_VERSION: u32 = 2u32
pub const SERIALIZATION_VERSION: u32 = 2u32
Serialization format version for compatibility checking
Source§impl ConstraintSystem
impl ConstraintSystem
Sourcepub fn new(
constants: Vec<Word>,
value_vec_layout: ValueVecLayout,
and_constraints: Vec<AndConstraint>,
mul_constraints: Vec<MulConstraint>,
) -> Self
pub fn new( constants: Vec<Word>, value_vec_layout: ValueVecLayout, and_constraints: Vec<AndConstraint>, mul_constraints: Vec<MulConstraint>, ) -> Self
Creates a new constraint system.
Sourcepub fn validate(&self) -> Result<(), ConstraintSystemError>
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.
Sourcepub fn validate_and_prepare(&mut self) -> Result<(), ConstraintSystemError>
pub fn validate_and_prepare(&mut self) -> Result<(), ConstraintSystemError>
Validates and prepares this constraint system for proving/verifying.
This function performs the following:
- Validates the value vector layout (including public input checks)
- Validates the constraints.
- Pads the AND and MUL constraints to the next po2 size
Sourcepub fn n_and_constraints(&self) -> usize
pub fn n_and_constraints(&self) -> usize
Returns the number of AND constraints in the system.
Sourcepub fn n_mul_constraints(&self) -> usize
pub fn n_mul_constraints(&self) -> usize
Returns the number of MUL constraints in the system.
Sourcepub fn value_vec_len(&self) -> usize
pub fn value_vec_len(&self) -> usize
The total length of the ValueVec
expected by this constraint system.
Sourcepub fn new_value_vec(&self) -> ValueVec
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
impl Clone for ConstraintSystem
Source§fn clone(&self) -> ConstraintSystem
fn clone(&self) -> ConstraintSystem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ConstraintSystem
impl Debug for ConstraintSystem
Source§impl DeserializeBytes for ConstraintSystem
impl DeserializeBytes for ConstraintSystem
fn deserialize(read_buf: impl Buf) -> Result<Self, SerializationError>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for ConstraintSystem
impl RefUnwindSafe for ConstraintSystem
impl Send for ConstraintSystem
impl Sync for ConstraintSystem
impl Unpin for ConstraintSystem
impl UnwindSafe for ConstraintSystem
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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