snarkvm_circuit_environment::environment

Trait Environment

Source
pub trait Environment:
    'static
    + Copy
    + Clone
    + Debug
    + Display
    + Eq
    + PartialEq
    + Hash {
    type Network: Network<Affine = Self::Affine, Field = Self::BaseField, Scalar = Self::ScalarField>;
    type Affine: AffineCurve<BaseField = Self::BaseField, ScalarField = Self::ScalarField, Coordinates = (Self::BaseField, Self::BaseField)>;
    type BaseField: PrimeField + SquareRootField + Copy;
    type ScalarField: PrimeField<BigInteger = <Self::BaseField as PrimeField>::BigInteger> + Copy;

    const EDWARDS_A: Self::BaseField = <Self::Network as console::Environment>::EDWARDS_A;
    const EDWARDS_D: Self::BaseField = <Self::Network as console::Environment>::EDWARDS_D;
    const MONTGOMERY_A: Self::BaseField = <Self::Network as console::Environment>::MONTGOMERY_A;
    const MONTGOMERY_B: Self::BaseField = <Self::Network as console::Environment>::MONTGOMERY_B;
    const MAX_STRING_BYTES: u32 = <Self::Network as console::Environment>::MAX_STRING_BYTES;
Show 33 methods // Required 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: FnOnce() -> Output::Primitive, Output: Inject>( mode: Mode, value: Fn, ) -> Output; fn scope<S: Into<String>, Fn, Output>(name: S, logic: Fn) -> Output where 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_variables() -> u64; fn num_constraints() -> u64; fn num_nonzeros() -> (u64, u64, 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_nonzeros_in_scope() -> (u64, u64, u64); fn get_variable_limit() -> Option<u64>; fn set_variable_limit(limit: Option<u64>); fn get_constraint_limit() -> Option<u64>; fn set_constraint_limit(limit: Option<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(); // Provided methods fn assert<Boolean: Into<LinearCombination<Self::BaseField>>>( boolean: Boolean, ) { ... } fn assert_eq<A, B>(a: A, b: B) where A: Into<LinearCombination<Self::BaseField>>, B: Into<LinearCombination<Self::BaseField>> { ... } fn assert_neq<A, B>(a: A, b: B) where A: Into<LinearCombination<Self::BaseField>>, B: Into<LinearCombination<Self::BaseField>> { ... } fn count() -> (u64, u64, u64, u64, (u64, u64, u64)) { ... } fn count_in_scope() -> (u64, u64, u64, u64, (u64, u64, u64)) { ... } fn halt<S: Into<String>, T>(message: S) -> T { ... }
}
Expand description

Attention: Do not use Send + Sync on this trait, as it is not thread-safe.

Provided Associated Constants§

Source

const EDWARDS_A: Self::BaseField = <Self::Network as console::Environment>::EDWARDS_A

The coefficient A of the twisted Edwards curve.

Source

const EDWARDS_D: Self::BaseField = <Self::Network as console::Environment>::EDWARDS_D

The coefficient D of the twisted Edwards curve.

Source

const MONTGOMERY_A: Self::BaseField = <Self::Network as console::Environment>::MONTGOMERY_A

The coefficient A of the Montgomery curve.

Source

const MONTGOMERY_B: Self::BaseField = <Self::Network as console::Environment>::MONTGOMERY_B

The coefficient B of the Montgomery curve.

Source

const MAX_STRING_BYTES: u32 = <Self::Network as console::Environment>::MAX_STRING_BYTES

The maximum number of bytes allowed in a string.

Required Associated Types§

Source

type Network: Network<Affine = Self::Affine, Field = Self::BaseField, Scalar = Self::ScalarField>

Source

type Affine: AffineCurve<BaseField = Self::BaseField, ScalarField = Self::ScalarField, Coordinates = (Self::BaseField, Self::BaseField)>

Source

type BaseField: PrimeField + SquareRootField + Copy

Source

type ScalarField: PrimeField<BigInteger = <Self::BaseField as PrimeField>::BigInteger> + Copy

Required Methods§

Source

fn zero() -> LinearCombination<Self::BaseField>

Returns the zero constant.

Source

fn one() -> LinearCombination<Self::BaseField>

Returns the one constant.

Source

fn new_variable(mode: Mode, value: Self::BaseField) -> Variable<Self::BaseField>

Returns a new variable of the given mode and value.

Source

fn new_witness<Fn: FnOnce() -> Output::Primitive, Output: Inject>( mode: Mode, value: Fn, ) -> Output

Returns a new witness of the given mode and value.

Source

fn scope<S: Into<String>, Fn, Output>(name: S, logic: Fn) -> Output
where Fn: FnOnce() -> Output,

Enters a new scope for the environment.

Source

fn enforce<Fn, A, B, C>(constraint: Fn)

Adds one constraint enforcing that (A * B) == C.

Source

fn is_satisfied() -> bool

Returns true if all constraints in the environment are satisfied.

Source

fn is_satisfied_in_scope() -> bool

Returns true if all constraints in the current scope are satisfied.

Source

fn num_constants() -> u64

Returns the number of constants in the entire environment.

Source

fn num_public() -> u64

Returns the number of public variables in the entire environment.

Source

fn num_private() -> u64

Returns the number of private variables in the entire environment.

Source

fn num_variables() -> u64

Returns the number of constant, public, and private variables in the entire environment.

Source

fn num_constraints() -> u64

Returns the number of constraints in the entire environment.

Source

fn num_nonzeros() -> (u64, u64, u64)

Returns the number of nonzeros in the entire circuit.

Source

fn num_constants_in_scope() -> u64

Returns the number of constants for the current scope.

Source

fn num_public_in_scope() -> u64

Returns the number of public variables for the current scope.

Source

fn num_private_in_scope() -> u64

Returns the number of private variables for the current scope.

Source

fn num_constraints_in_scope() -> u64

Returns the number of constraints for the current scope.

Source

fn num_nonzeros_in_scope() -> (u64, u64, u64)

Returns the number of nonzeros for the current scope.

Source

fn get_variable_limit() -> Option<u64>

Returns the variable limit for the circuit, if one exists.

Source

fn set_variable_limit(limit: Option<u64>)

Sets the variable limit for the circuit.

Source

fn get_constraint_limit() -> Option<u64>

Returns the constraint limit for the circuit, if one exists.

Source

fn set_constraint_limit(limit: Option<u64>)

Sets the constraint limit for the circuit.

Source

fn inject_r1cs(r1cs: R1CS<Self::BaseField>)

Returns the R1CS circuit, resetting the circuit.

Source

fn eject_r1cs_and_reset() -> R1CS<Self::BaseField>

Returns the R1CS circuit, resetting the circuit.

Source

fn eject_assignment_and_reset() -> Assignment<<Self::Network as Environment>::Field>

Returns the R1CS assignment of the circuit, resetting the circuit.

Source

fn reset()

Clears and initializes an empty environment.

Provided Methods§

Source

fn assert<Boolean: Into<LinearCombination<Self::BaseField>>>(boolean: Boolean)

Adds one constraint enforcing that the given boolean is true.

Source

fn assert_eq<A, B>(a: A, b: B)

Adds one constraint enforcing that the A == B.

Source

fn assert_neq<A, B>(a: A, b: B)

Adds one constraint enforcing that the A != B.

Source

fn count() -> (u64, u64, u64, u64, (u64, u64, u64))

Returns a tuple containing the number of constants, public variables, private variables, constraints, and nonzeros in the entire environment.

Source

fn count_in_scope() -> (u64, u64, u64, u64, (u64, u64, u64))

Returns a tuple containing the number of constants, public variables, private variables, constraints, and nonzeros for the current scope.

Source

fn halt<S: Into<String>, T>(message: S) -> T

Halts the program from further synthesis, evaluation, and execution in the current environment.

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.

Implementors§