Struct ark_relations::r1cs::ConstraintSystem [−][src]
An Rank-One ConstraintSystem. Enforces constraints of the form
⟨a_i, z⟩ ⋅ ⟨b_i, z⟩ = ⟨c_i, z⟩, where a_i, b_i, and c_i are linear
combinations over variables, and z is the concrete assignment to these
variables.
Fields
mode: SynthesisModeThe mode in which the constraint system is operating. self can either
be in setup mode (i.e., self.mode == SynthesisMode::Setup) or in
proving mode (i.e., self.mode == SynthesisMode::Prove). If we are
in proving mode, then we have the additional option of whether or
not to construct the A, B, and C matrices of the constraint system
(see below).
num_instance_variables: usizeThe number of variables that are “public inputs” to the constraint system.
num_witness_variables: usizeThe number of variables that are “private inputs” to the constraint system.
num_constraints: usizeThe number of constraints in the constraint system.
num_linear_combinations: usizeThe number of linear combinations
optimization_goal: OptimizationGoalThe parameter we aim to minimize in this constraint system (either the number of constraints or their total weight).
instance_assignment: Vec<F>Assignments to the public input variables. This is empty if self.mode == SynthesisMode::Setup.
witness_assignment: Vec<F>Assignments to the private input variables. This is empty if self.mode == SynthesisMode::Setup.
cache_map: Rc<RefCell<BTreeMap<TypeId, Box<dyn Any>>>>Map for gadgets to cache computation results.
Implementations
impl<F: Field> ConstraintSystem<F>[src]
pub fn new() -> Self[src]
Construct an empty ConstraintSystem.
pub fn new_ref() -> ConstraintSystemRef<F>[src]
Create a new ConstraintSystemRef<F>.
pub fn set_mode(&mut self, mode: SynthesisMode)[src]
Set self.mode to mode.
pub fn is_in_setup_mode(&self) -> bool[src]
Check whether self.mode == SynthesisMode::Setup.
pub fn optimization_goal(&self) -> OptimizationGoal[src]
Check whether this constraint system aims to optimize weight, number of constraints, or neither.
pub fn set_optimization_goal(&mut self, goal: OptimizationGoal)[src]
Specify whether this constraint system should aim to optimize weight, number of constraints, or neither.
pub fn should_construct_matrices(&self) -> bool[src]
Check whether or not self will construct matrices.
pub fn zero() -> Variable[src]
Return a variable representing the constant “zero” inside the constraint system.
pub fn one() -> Variable[src]
Return a variable representing the constant “one” inside the constraint system.
pub fn new_input_variable<Func>(&mut self, f: Func) -> Result<Variable> where
Func: FnOnce() -> Result<F>, [src]
Func: FnOnce() -> Result<F>,
Obtain a variable representing a new public instance input.
pub fn new_witness_variable<Func>(&mut self, f: Func) -> Result<Variable> where
Func: FnOnce() -> Result<F>, [src]
Func: FnOnce() -> Result<F>,
Obtain a variable representing a new private witness input.
pub fn new_lc(&mut self, lc: LinearCombination<F>) -> Result<Variable>[src]
Obtain a variable representing a linear combination.
pub fn enforce_constraint(
&mut self,
a: LinearCombination<F>,
b: LinearCombination<F>,
c: LinearCombination<F>
) -> Result<()>[src]
&mut self,
a: LinearCombination<F>,
b: LinearCombination<F>,
c: LinearCombination<F>
) -> Result<()>
Enforce a R1CS constraint with the name name.
pub fn transform_lc_map(
&mut self,
transformer: &mut dyn FnMut(&ConstraintSystem<F>, usize, &mut LinearCombination<F>) -> (usize, Option<Vec<F>>)
)[src]
&mut self,
transformer: &mut dyn FnMut(&ConstraintSystem<F>, usize, &mut LinearCombination<F>) -> (usize, Option<Vec<F>>)
)
Transform the map of linear combinations. Specifically, allow the creation of additional witness assignments.
This method is used as a subroutine of inline_all_lcs and outline_lcs.
The transformer function is given a references of this constraint system (&self),
number of times used, and a mutable reference of the linear combination to be transformed.
(&ConstraintSystem
The transformer function returns the number of new witness variables needed
and a vector of new witness assignments (if not in the setup mode).
(usize, Option<Vec
pub fn inline_all_lcs(&mut self)[src]
Naively inlines symbolic linear combinations into the linear combinations that use them.
Useful for standard pairing-based SNARKs where addition gates are cheap. For example, in the SNARKs such as [Groth16] and [Groth-Maller17], addition gates do not contribute to the size of the multi-scalar multiplication, which is the dominating cost.
pub fn finalize(&mut self)[src]
Finalize the constraint system (either by outlining or inlining, if an optimization goal is set).
pub fn to_matrices(&self) -> Option<ConstraintMatrices<F>>[src]
This step must be called after constraint generation has completed, and after all symbolic LCs have been inlined into the places that they are used.
pub fn is_satisfied(&self) -> Result<bool>[src]
If self is satisfied, outputs Ok(true).
If self is unsatisfied, outputs Ok(false).
If self.is_in_setup_mode(), outputs Err(()).
pub fn which_is_unsatisfied(&self) -> Result<Option<String>>[src]
If self is satisfied, outputs Ok(None).
If self is unsatisfied, outputs Some(i), where i is the index of
the first unsatisfied constraint. If self.is_in_setup_mode(), outputs
Err(()).
pub fn assigned_value(&self, v: Variable) -> Option<F>[src]
Obtain the assignment corresponding to the Variable v.
Trait Implementations
impl<F: Clone + Field> Clone for ConstraintSystem<F>[src]
fn clone(&self) -> ConstraintSystem<F>[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<F: Debug + Field> Debug for ConstraintSystem<F>[src]
impl<F: Field> Default for ConstraintSystem<F>[src]
Auto Trait Implementations
impl<F> !Send for ConstraintSystem<F>
impl<F> !Sync for ConstraintSystem<F>
impl<F> Unpin for ConstraintSystem<F> where
F: Unpin,
F: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,