Trait snarkvm_wasm::ConstraintSystem [−][src]
pub trait ConstraintSystem<F> where
F: Field, { type Root: ConstraintSystem<F>; fn alloc<FN, A, AR>(
&mut self,
annotation: A,
f: FN
) -> Result<Variable, SynthesisError>
where
A: FnOnce() -> AR,
FN: FnOnce() -> Result<F, SynthesisError>,
AR: AsRef<str>; fn alloc_input<FN, A, AR>(
&mut self,
annotation: A,
f: FN
) -> Result<Variable, SynthesisError>
where
A: FnOnce() -> AR,
FN: FnOnce() -> Result<F, SynthesisError>,
AR: AsRef<str>; fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC)
where
LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
A: FnOnce() -> AR,
AR: AsRef<str>,
LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>; fn push_namespace<NR, N>(&mut self, name_fn: N)
where
N: FnOnce() -> NR,
NR: AsRef<str>; 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
N: FnOnce() -> NR,
NR: AsRef<str>, { ... } }
Expand description
Represents a constraint system which can have new variables allocated and constrains between them formed.
Associated Types
type Root: ConstraintSystem<F>
type Root: ConstraintSystem<F>
Represents the type of the “root” of this constraint system so that nested namespaces can minimize indirection.
Required methods
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
A: FnOnce() -> AR,
FN: FnOnce() -> Result<F, SynthesisError>,
AR: AsRef<str>,
fn alloc_input<FN, A, AR>(
&mut self,
annotation: A,
f: FN
) -> Result<Variable, SynthesisError> where
A: FnOnce() -> AR,
FN: FnOnce() -> Result<F, SynthesisError>,
AR: AsRef<str>,
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
LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
A: FnOnce() -> AR,
AR: AsRef<str>,
LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC) where
LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
A: FnOnce() -> AR,
AR: AsRef<str>,
LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
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
N: FnOnce() -> NR,
NR: AsRef<str>,
fn push_namespace<NR, N>(&mut self, name_fn: N) where
N: FnOnce() -> NR,
NR: AsRef<str>,
Create a new (sub)namespace and enter into it. Not intended
for downstream use; use namespace
instead.
fn pop_namespace(&mut self)
fn pop_namespace(&mut self)
Exit out of the existing namespace. Not intended for
downstream use; use namespace
instead.
Gets the “root” constraint system, bypassing the namespacing.
Not intended for downstream use; use namespace
instead.
fn num_constraints(&self) -> usize
fn num_constraints(&self) -> usize
Output the number of constraints in the system.
fn num_public_variables(&self) -> usize
fn num_public_variables(&self) -> usize
Output the number of public input variables to the system.
fn num_private_variables(&self) -> usize
fn num_private_variables(&self) -> usize
Output the number of private input variables to the system.
Provided methods
Implementations on Foreign Types
Convenience implementation of ConstraintSystem
type Root = <CS as ConstraintSystem<F>>::Root
pub fn alloc<FN, A, AR>(
&mut self,
annotation: A,
f: FN
) -> Result<Variable, SynthesisError> where
A: FnOnce() -> AR,
FN: FnOnce() -> Result<F, SynthesisError>,
AR: AsRef<str>,
pub fn alloc_input<FN, A, AR>(
&mut self,
annotation: A,
f: FN
) -> Result<Variable, SynthesisError> where
A: FnOnce() -> AR,
FN: FnOnce() -> Result<F, SynthesisError>,
AR: AsRef<str>,
pub fn enforce<A, AR, LA, LB, LC>(&mut self, annotation: A, a: LA, b: LB, c: LC) where
LC: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
A: FnOnce() -> AR,
AR: AsRef<str>,
LA: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
LB: FnOnce(LinearCombination<F>) -> LinearCombination<F>,
Implementors
impl<'_, F, CS> ConstraintSystem<F> for Namespace<'_, F, CS> where
CS: ConstraintSystem<F>,
F: Field,
impl<ConstraintF> ConstraintSystem<ConstraintF> for ConstraintCounter where
ConstraintF: Field,
impl<E> ConstraintSystem<<E as PairingEngine>::Fr> for snarkvm_wasm::gm17::KeypairAssembly<E> where
E: PairingEngine,
impl<E> ConstraintSystem<<E as PairingEngine>::Fr> for snarkvm_wasm::gm17::ProvingAssignment<E> where
E: PairingEngine,
impl<E> ConstraintSystem<<E as PairingEngine>::Fr> for snarkvm_wasm::groth16::KeypairAssembly<E> where
E: PairingEngine,
impl<E> ConstraintSystem<<E as PairingEngine>::Fr> for snarkvm_wasm::groth16::ProvingAssignment<E> where
E: PairingEngine,