Trait snarkvm_circuit::prelude::Environment
source · [−]pub trait Environment: 'static + Copy + Clone + Debug + Display + Eq + PartialEq<Self> + Hash {
type Network: Network
where
<Self::Network as Environment>::Affine == Self::Affine,
<Self::Network as Environment>::Field == Self::BaseField,
<Self::Network as Environment>::Scalar == Self::ScalarField;
type Affine: AffineCurve
where
<Self::Affine as AffineCurve>::BaseField == Self::BaseField,
<Self::Affine as AffineCurve>::ScalarField == Self::ScalarField,
<Self::Affine as AffineCurve>::Coordinates == (Self::BaseField, Self::BaseField);
type BaseField: PrimeField + SquareRootField + Copy;
type ScalarField: PrimeField + Copy
where
<Self::ScalarField as PrimeField>::BigInteger == <Self::BaseField as PrimeField>::BigInteger;
const EDWARDS_A: Self::BaseField = const EDWARDS_A: Self::BaseField =
<Self::Network as console::Environment>::EDWARDS_A;;
const EDWARDS_D: Self::BaseField = const EDWARDS_D: Self::BaseField =
<Self::Network as console::Environment>::EDWARDS_D;;
const MONTGOMERY_A: Self::BaseField = const MONTGOMERY_A: Self::BaseField =
<Self::Network as console::Environment>::MONTGOMERY_A;;
const MONTGOMERY_B: Self::BaseField = const MONTGOMERY_B: Self::BaseField =
<Self::Network as console::Environment>::MONTGOMERY_B;;
const MAX_STRING_BYTES: u32 = const MAX_STRING_BYTES: u32 =
<Self::Network as console::Environment>::MAX_STRING_BYTES;;
Show 27 methods
fn zero() -> LinearCombination<Self::BaseField>;
fn one() -> LinearCombination<Self::BaseField>;
fn new_variable(
mode: Mode,
value: Self::BaseField
) -> Variable<Self::BaseField>;
fn new_witness<Fn, Output>(mode: Mode, value: Fn) -> Output
where
Fn: FnOnce() -> <Output as Inject>::Primitive,
Output: Inject;
fn scope<S, Fn, Output>(name: S, logic: Fn) -> Output
where
S: Into<String>,
Fn: FnOnce() -> Output;
fn enforce<Fn, A, B, C>(constraint: Fn)
where
Fn: FnOnce() -> (A, B, C),
A: Into<LinearCombination<Self::BaseField>>,
B: Into<LinearCombination<Self::BaseField>>,
C: Into<LinearCombination<Self::BaseField>>;
fn is_satisfied() -> bool;
fn is_satisfied_in_scope() -> bool;
fn num_constants() -> u64;
fn num_public() -> u64;
fn num_private() -> u64;
fn num_constraints() -> u64;
fn num_gates() -> u64;
fn num_constants_in_scope() -> u64;
fn num_public_in_scope() -> u64;
fn num_private_in_scope() -> u64;
fn num_constraints_in_scope() -> u64;
fn num_gates_in_scope() -> u64;
fn inject_r1cs(r1cs: R1CS<Self::BaseField>);
fn eject_r1cs_and_reset() -> R1CS<Self::BaseField>;
fn eject_assignment_and_reset(
) -> Assignment<<Self::Network as Environment>::Field>;
fn reset();
fn assert<Boolean>(boolean: Boolean)
where
Boolean: Into<LinearCombination<Self::BaseField>>,
{ ... }
fn assert_eq<A, B>(a: A, b: B)
where
A: Into<LinearCombination<Self::BaseField>>,
B: Into<LinearCombination<Self::BaseField>>,
{ ... }
fn count() -> (u64, u64, u64, u64, u64) { ... }
fn count_in_scope() -> (u64, u64, u64, u64, u64) { ... }
fn halt<S, T>(message: S) -> T
where
S: Into<String>,
{ ... }
}
Required Associated Types
type Network: Network
where
<Self::Network as Environment>::Affine == Self::Affine,
<Self::Network as Environment>::Field == Self::BaseField,
<Self::Network as Environment>::Scalar == Self::ScalarField
type Affine: AffineCurve
where
<Self::Affine as AffineCurve>::BaseField == Self::BaseField,
<Self::Affine as AffineCurve>::ScalarField == Self::ScalarField,
<Self::Affine as AffineCurve>::Coordinates == (Self::BaseField, Self::BaseField)
type BaseField: PrimeField + SquareRootField + Copy
type ScalarField: PrimeField + Copy
where
<Self::ScalarField as PrimeField>::BigInteger == <Self::BaseField as PrimeField>::BigInteger
Provided Associated Constants
The coefficient A
of the twisted Edwards curve.
The coefficient D
of the twisted Edwards curve.
sourceconst MONTGOMERY_A: Self::BaseField = const MONTGOMERY_A: Self::BaseField =
<Self::Network as console::Environment>::MONTGOMERY_A;
const MONTGOMERY_A: Self::BaseField = const MONTGOMERY_A: Self::BaseField = <Self::Network as console::Environment>::MONTGOMERY_A;
The coefficient A
of the Montgomery curve.
sourceconst MONTGOMERY_B: Self::BaseField = const MONTGOMERY_B: Self::BaseField =
<Self::Network as console::Environment>::MONTGOMERY_B;
const MONTGOMERY_B: Self::BaseField = const MONTGOMERY_B: Self::BaseField = <Self::Network as console::Environment>::MONTGOMERY_B;
The coefficient B
of the Montgomery curve.
sourceconst MAX_STRING_BYTES: u32 = const MAX_STRING_BYTES: u32 =
<Self::Network as console::Environment>::MAX_STRING_BYTES;
const MAX_STRING_BYTES: u32 = const MAX_STRING_BYTES: u32 = <Self::Network as console::Environment>::MAX_STRING_BYTES;
The maximum number of bytes allowed in a string.
Required Methods
sourcefn zero() -> LinearCombination<Self::BaseField>
fn zero() -> LinearCombination<Self::BaseField>
Returns the zero
constant.
sourcefn one() -> LinearCombination<Self::BaseField>
fn one() -> LinearCombination<Self::BaseField>
Returns the one
constant.
Returns a new variable of the given mode and value.
Returns a new witness of the given mode and value.
Enters a new scope for the environment.
sourcefn enforce<Fn, A, B, C>(constraint: Fn) where
Fn: FnOnce() -> (A, B, C),
A: Into<LinearCombination<Self::BaseField>>,
B: Into<LinearCombination<Self::BaseField>>,
C: Into<LinearCombination<Self::BaseField>>,
fn enforce<Fn, A, B, C>(constraint: Fn) where
Fn: FnOnce() -> (A, B, C),
A: Into<LinearCombination<Self::BaseField>>,
B: Into<LinearCombination<Self::BaseField>>,
C: Into<LinearCombination<Self::BaseField>>,
Adds one constraint enforcing that (A * B) == C
.
sourcefn is_satisfied() -> bool
fn is_satisfied() -> bool
Returns true
if all constraints in the environment are satisfied.
sourcefn is_satisfied_in_scope() -> bool
fn is_satisfied_in_scope() -> bool
Returns true
if all constraints in the current scope are satisfied.
sourcefn num_constants() -> u64
fn num_constants() -> u64
Returns the number of constants in the entire environment.
sourcefn num_public() -> u64
fn num_public() -> u64
Returns the number of public variables in the entire environment.
sourcefn num_private() -> u64
fn num_private() -> u64
Returns the number of private variables in the entire environment.
sourcefn num_constraints() -> u64
fn num_constraints() -> u64
Returns the number of constraints in the entire environment.
sourcefn num_constants_in_scope() -> u64
fn num_constants_in_scope() -> u64
Returns the number of constants for the current scope.
sourcefn num_public_in_scope() -> u64
fn num_public_in_scope() -> u64
Returns the number of public variables for the current scope.
sourcefn num_private_in_scope() -> u64
fn num_private_in_scope() -> u64
Returns the number of private variables for the current scope.
sourcefn num_constraints_in_scope() -> u64
fn num_constraints_in_scope() -> u64
Returns the number of constraints for the current scope.
sourcefn num_gates_in_scope() -> u64
fn num_gates_in_scope() -> u64
Returns the number of gates for the current scope.
sourcefn inject_r1cs(r1cs: R1CS<Self::BaseField>)
fn inject_r1cs(r1cs: R1CS<Self::BaseField>)
Returns the R1CS circuit, resetting the circuit.
sourcefn eject_r1cs_and_reset() -> R1CS<Self::BaseField>
fn eject_r1cs_and_reset() -> R1CS<Self::BaseField>
Returns the R1CS circuit, resetting the circuit.
sourcefn eject_assignment_and_reset(
) -> Assignment<<Self::Network as Environment>::Field>
fn eject_assignment_and_reset(
) -> Assignment<<Self::Network as Environment>::Field>
Returns the R1CS assignment of the circuit, resetting the circuit.
Provided Methods
sourcefn assert<Boolean>(boolean: Boolean) where
Boolean: Into<LinearCombination<Self::BaseField>>,
fn assert<Boolean>(boolean: Boolean) where
Boolean: Into<LinearCombination<Self::BaseField>>,
Adds one constraint enforcing that the given boolean is true
.
sourcefn assert_eq<A, B>(a: A, b: B) where
A: Into<LinearCombination<Self::BaseField>>,
B: Into<LinearCombination<Self::BaseField>>,
fn assert_eq<A, B>(a: A, b: B) where
A: Into<LinearCombination<Self::BaseField>>,
B: Into<LinearCombination<Self::BaseField>>,
Adds one constraint enforcing that the A == B
.
Returns a tuple containing the number of constants, public variables, private variables, constraints, and gates in the entire environment.
Returns a tuple containing the number of constants, public variables, private variables, constraints, and gates for the current scope.