pub trait ConstraintSystem<F: Field>: Sized {
type Root: ConstraintSystem<F>;
// 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>;
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 is_in_setup_mode(&self) -> bool;
// Provided methods
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 constraints between them formed.
Required Associated Types§
Sourcetype 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§
Sourcefn alloc<FN, A, AR>(
&mut self,
annotation: A,
f: FN,
) -> Result<Variable, SynthesisError>
fn alloc<FN, A, AR>( &mut self, annotation: A, f: FN, ) -> Result<Variable, SynthesisError>
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.
Sourcefn alloc_input<FN, A, AR>(
&mut self,
annotation: A,
f: FN,
) -> Result<Variable, SynthesisError>
fn alloc_input<FN, A, AR>( &mut self, annotation: A, f: FN, ) -> Result<Variable, SynthesisError>
Allocate a public variable in the constraint system. The provided function is used to determine the assignment of the variable.
Sourcefn 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 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>,
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.
Sourcefn push_namespace<NR, N>(&mut self, name_fn: N)
fn push_namespace<NR, N>(&mut self, name_fn: N)
Create a new (sub)namespace and enter into it. Not intended
for downstream use; use namespace
instead.
Sourcefn pop_namespace(&mut self)
fn pop_namespace(&mut self)
Exit out of the existing namespace. Not intended for
downstream use; use namespace
instead.
Sourcefn get_root(&mut self) -> &mut Self::Root
fn get_root(&mut self) -> &mut Self::Root
Gets the “root” constraint system, bypassing the namespacing.
Not intended for downstream use; use namespace
instead.
Sourcefn num_constraints(&self) -> usize
fn num_constraints(&self) -> usize
Output the number of constraints in the system.
Sourcefn num_public_variables(&self) -> usize
fn num_public_variables(&self) -> usize
Output the number of public input variables to the system.
Sourcefn num_private_variables(&self) -> usize
fn num_private_variables(&self) -> usize
Output the number of private input variables to the system.
Sourcefn is_in_setup_mode(&self) -> bool
fn is_in_setup_mode(&self) -> bool
Output whether the constraint system is in the setup mode.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<F: Field, CS: ConstraintSystem<F>> ConstraintSystem<F> for &mut CS
impl<F: Field, CS: ConstraintSystem<F>> ConstraintSystem<F> for &mut CS
Convenience implementation of ConstraintSystem