Trait snarkvm_r1cs::ConstraintSystem[][src]

pub trait ConstraintSystem<F: Field>: Sized {
    type Root: ConstraintSystem<F>;
    fn alloc<FN, A, AR>(
        &mut self,
        annotation: A,
        f: FN
    ) -> Result<Variable, SynthesisError>
    where
        FN: FnOnce() -> Result<F, SynthesisError>,
        A: FnOnce() -> AR,
        AR: AsRef<str>
;
fn alloc_input<FN, A, AR>(
        &mut self,
        annotation: A,
        f: FN
    ) -> Result<Variable, SynthesisError>
    where
        FN: FnOnce() -> Result<F, SynthesisError>,
        A: FnOnce() -> AR,
        AR: AsRef<str>
;
fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC)
    where
        A: FnOnce() -> AR,
        AR: AsRef<str>,
        LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
        LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
        LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>
;
fn push_namespace<NR, N>(&mut self, name_fn: N)
    where
        NR: AsRef<str>,
        N: FnOnce() -> NR
;
fn pop_namespace(&mut self);
fn get_root(&mut self) -> &mut Self::Root;
fn num_constraints(&self) -> usize;
fn num_public_variables(&self) -> usize;
fn num_private_variables(&self) -> usize; fn one() -> Variable { ... }
fn ns<NR, N>(&mut self, name_fn: N) -> Namespace<'_, F, Self::Root>
    where
        NR: AsRef<str>,
        N: FnOnce() -> NR
, { ... } }
Expand description

Represents a constraint system which can have new variables allocated and constrains between them formed.

Associated Types

type Root: ConstraintSystem<F>[src]

Represents the type of the “root” of this constraint system so that nested namespaces can minimize indirection.

Required methods

fn alloc<FN, A, AR>(
    &mut self,
    annotation: A,
    f: FN
) -> Result<Variable, SynthesisError> where
    FN: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

Allocate a private variable in the constraint system. The provided function is used to determine the assignment of the variable. The given annotation function is invoked in testing contexts in order to derive a unique name for this variable in the current namespace.

fn alloc_input<FN, A, AR>(
    &mut self,
    annotation: A,
    f: FN
) -> Result<Variable, SynthesisError> where
    FN: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

Allocate a public variable in the constraint system. The provided function is used to determine the assignment of the variable.

fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC) where
    A: FnOnce() -> AR,
    AR: AsRef<str>,
    LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>, 
[src]

Enforce that A * B = C. The annotation function is invoked in testing contexts in order to derive a unique name for the constraint in the current namespace.

fn push_namespace<NR, N>(&mut self, name_fn: N) where
    NR: AsRef<str>,
    N: FnOnce() -> NR, 
[src]

Create a new (sub)namespace and enter into it. Not intended for downstream use; use namespace instead.

fn pop_namespace(&mut self)[src]

Exit out of the existing namespace. Not intended for downstream use; use namespace instead.

fn get_root(&mut self) -> &mut Self::Root[src]

Gets the “root” constraint system, bypassing the namespacing. Not intended for downstream use; use namespace instead.

fn num_constraints(&self) -> usize[src]

Output the number of constraints in the system.

fn num_public_variables(&self) -> usize[src]

Output the number of public input variables to the system.

fn num_private_variables(&self) -> usize[src]

Output the number of private input variables to the system.

Provided methods

fn one() -> Variable[src]

Return the “one” input variable

fn ns<NR, N>(&mut self, name_fn: N) -> Namespace<'_, F, Self::Root> where
    NR: AsRef<str>,
    N: FnOnce() -> NR, 
[src]

Begin a namespace for this constraint system.

Implementations on Foreign Types

impl<F: Field, CS: ConstraintSystem<F>> ConstraintSystem<F> for &mut CS[src]

Convenience implementation of ConstraintSystem for mutable references to constraint systems.

type Root = CS::Root

fn one() -> Variable[src]

fn alloc<FN, A, AR>(
    &mut self,
    annotation: A,
    f: FN
) -> Result<Variable, SynthesisError> where
    FN: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn alloc_input<FN, A, AR>(
    &mut self,
    annotation: A,
    f: FN
) -> Result<Variable, SynthesisError> where
    FN: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC) where
    A: FnOnce() -> AR,
    AR: AsRef<str>,
    LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>, 
[src]

fn push_namespace<NR, N>(&mut self, name_fn: N) where
    NR: AsRef<str>,
    N: FnOnce() -> NR, 
[src]

fn pop_namespace(&mut self)[src]

fn get_root(&mut self) -> &mut Self::Root[src]

fn num_constraints(&self) -> usize[src]

fn num_public_variables(&self) -> usize[src]

fn num_private_variables(&self) -> usize[src]

Implementors

impl<ConstraintF: Field> ConstraintSystem<ConstraintF> for ConstraintCounter[src]

type Root = Self

fn alloc<F, A, AR>(&mut self, _: A, _: F) -> Result<Variable, SynthesisError> where
    F: FnOnce() -> Result<ConstraintF, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn alloc_input<F, A, AR>(
    &mut self,
    _: A,
    _: F
) -> Result<Variable, SynthesisError> where
    F: FnOnce() -> Result<ConstraintF, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn enforce<A, AR, LA, LB, LC>(&mut self, _: A, _: LA, _: LB, _: LC) where
    A: FnOnce() -> AR,
    AR: AsRef<str>,
    LA: FnOnce(LinearCombination<ConstraintF>) -> LinearCombination<ConstraintF>,
    LB: FnOnce(LinearCombination<ConstraintF>) -> LinearCombination<ConstraintF>,
    LC: FnOnce(LinearCombination<ConstraintF>) -> LinearCombination<ConstraintF>, 
[src]

fn push_namespace<NR, N>(&mut self, _: N) where
    NR: AsRef<str>,
    N: FnOnce() -> NR, 
[src]

fn pop_namespace(&mut self)[src]

fn get_root(&mut self) -> &mut Self::Root[src]

fn num_constraints(&self) -> usize[src]

fn num_public_variables(&self) -> usize[src]

fn num_private_variables(&self) -> usize[src]

impl<F: Field> ConstraintSystem<F> for TestConstraintSystem<F>[src]

type Root = Self

fn alloc<Fn, A, AR>(
    &mut self,
    annotation: A,
    f: Fn
) -> Result<Variable, SynthesisError> where
    Fn: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn alloc_input<Fn, A, AR>(
    &mut self,
    annotation: A,
    f: Fn
) -> Result<Variable, SynthesisError> where
    Fn: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC) where
    A: FnOnce() -> AR,
    AR: AsRef<str>,
    LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>, 
[src]

fn push_namespace<NR: AsRef<str>, N: FnOnce() -> NR>(&mut self, name_fn: N)[src]

fn pop_namespace(&mut self)[src]

fn get_root(&mut self) -> &mut Self::Root[src]

fn num_constraints(&self) -> usize[src]

fn num_public_variables(&self) -> usize[src]

fn num_private_variables(&self) -> usize[src]

impl<F: Field, CS: ConstraintSystem<F>> ConstraintSystem<F> for Namespace<'_, F, CS>[src]

type Root = CS::Root

fn one() -> Variable[src]

fn alloc<FN, A, AR>(
    &mut self,
    annotation: A,
    f: FN
) -> Result<Variable, SynthesisError> where
    FN: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn alloc_input<FN, A, AR>(
    &mut self,
    annotation: A,
    f: FN
) -> Result<Variable, SynthesisError> where
    FN: FnOnce() -> Result<F, SynthesisError>,
    A: FnOnce() -> AR,
    AR: AsRef<str>, 
[src]

fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC) where
    A: FnOnce() -> AR,
    AR: AsRef<str>,
    LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
    LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>, 
[src]

fn push_namespace<NR, N>(&mut self, _: N) where
    NR: AsRef<str>,
    N: FnOnce() -> NR, 
[src]

fn pop_namespace(&mut self)[src]

fn get_root(&mut self) -> &mut Self::Root[src]

fn num_constraints(&self) -> usize[src]

fn num_public_variables(&self) -> usize[src]

fn num_private_variables(&self) -> usize[src]