ark_relations::r1cs

Enum ConstraintSystemRef

Source
pub enum ConstraintSystemRef<F: Field> {
    None,
    CS(Rc<RefCell<ConstraintSystem<F>>>),
}
Expand description

A shared reference to a constraint system that can be stored in high level variables.

Variants§

§

None

Represents the case where we don’t need to allocate variables or enforce constraints. Encountered when operating over constant values.

§

CS(Rc<RefCell<ConstraintSystem<F>>>)

Represents the case where we do allocate variables or enforce constraints.

Implementations§

Source§

impl<F: Field> ConstraintSystemRef<F>

Source

pub fn or(self, other: Self) -> Self

Returns self if !self.is_none(), otherwise returns other.

Source

pub fn is_none(&self) -> bool

Returns true is self == ConstraintSystemRef::None.

Source

pub fn new(inner: ConstraintSystem<F>) -> Self

Construct a ConstraintSystemRef from a ConstraintSystem.

Source

pub fn into_inner(self) -> Option<ConstraintSystem<F>>

Consumes self to return the inner ConstraintSystem<F>. Returns None if Self::CS is None or if any other references to Self::CS exist.

Source

pub fn borrow(&self) -> Option<Ref<'_, ConstraintSystem<F>>>

Obtain an immutable reference to the underlying ConstraintSystem.

§Panics

This method panics if self is already mutably borrowed.

Source

pub fn borrow_mut(&self) -> Option<RefMut<'_, ConstraintSystem<F>>>

Obtain a mutable reference to the underlying ConstraintSystem.

§Panics

This method panics if self is already mutably borrowed.

Source

pub fn set_mode(&self, mode: SynthesisMode)

Set self.mode to mode.

Source

pub fn is_in_setup_mode(&self) -> bool

Check whether self.mode == SynthesisMode::Setup.

Source

pub fn num_constraints(&self) -> usize

Returns the number of constraints.

Source

pub fn num_instance_variables(&self) -> usize

Returns the number of instance variables.

Source

pub fn num_witness_variables(&self) -> usize

Returns the number of witness variables.

Source

pub fn optimization_goal(&self) -> OptimizationGoal

Check whether this constraint system aims to optimize weight, number of constraints, or neither.

Source

pub fn set_optimization_goal(&self, goal: OptimizationGoal)

Specify whether this constraint system should aim to optimize weight, number of constraints, or neither.

Source

pub fn should_construct_matrices(&self) -> bool

Check whether or not self will construct matrices.

Source

pub fn new_input_variable<Func>(&self, f: Func) -> Result<Variable>
where Func: FnOnce() -> Result<F>,

Obtain a variable representing a new public instance input.

Source

pub fn new_witness_variable<Func>(&self, f: Func) -> Result<Variable>
where Func: FnOnce() -> Result<F>,

Obtain a variable representing a new private witness input.

Source

pub fn new_lc(&self, lc: LinearCombination<F>) -> Result<Variable>

Obtain a variable representing a linear combination.

Source

pub fn enforce_constraint( &self, a: LinearCombination<F>, b: LinearCombination<F>, c: LinearCombination<F>, ) -> Result<()>

Enforce a R1CS constraint with the name name.

Source

pub fn inline_all_lcs(&self)

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.

Source

pub fn finalize(&self)

Finalize the constraint system (either by outlining or inlining, if an optimization goal is set).

Source

pub fn to_matrices(&self) -> Option<ConstraintMatrices<F>>

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.

Source

pub fn is_satisfied(&self) -> Result<bool>

If self is satisfied, outputs Ok(true). If self is unsatisfied, outputs Ok(false). If self.is_in_setup_mode() or if self == None, outputs Err(()).

Source

pub fn which_is_unsatisfied(&self) -> Result<Option<String>>

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() or self == None, outputs Err(()).

Source

pub fn assigned_value(&self, v: Variable) -> Option<F>

Obtain the assignment corresponding to the Variable v.

Source

pub fn constraint_names(&self) -> Option<Vec<String>>

Get trace information about all constraints in the system

Trait Implementations§

Source§

impl<F: Clone + Field> Clone for ConstraintSystemRef<F>

Source§

fn clone(&self) -> ConstraintSystemRef<F>

Returns a copy 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<F: Debug + Field> Debug for ConstraintSystemRef<F>

Source§

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

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

impl<F: Field> From<ConstraintSystemRef<F>> for Namespace<F>

Source§

fn from(other: ConstraintSystemRef<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> PartialEq for ConstraintSystemRef<F>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: Field> Eq for ConstraintSystemRef<F>

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, dst: *mut T)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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