Crate snarkvm_circuit
source ·Re-exports
pub use snarkvm_circuit_account as account;
pub use snarkvm_circuit_algorithms as algorithms;
pub use snarkvm_circuit_collections as collections;
pub use snarkvm_circuit_environment as environment;
pub use snarkvm_circuit_network as network;
pub use snarkvm_circuit_program as program;
pub use snarkvm_circuit_types as types;
Modules
Utilities for formatting and printing strings.
From https://github.com/Geal/nom/blob/main/examples/string.rs
This example shows an example of how to parse an escaped string. The
rules for the string are similar to JSON and rust. A string is:
Macros
Derive macro generating an impl of the trait
Debug
.Asserts the count for a given operation and case, and ensure the circuit is satisfied.
Asserts the count for a given operation and case, and ensure the circuit is NOT satisfied.
Asserts the output mode for a given operation and case.
Return early with an error.
The
witness!
macro is a closure that takes in a list of circuits,
eject the value of each circuit, and uses it in the subsequent code block.The
witness_mode!
macro returns the expected mode given a list of circuits.Structs
A struct for tracking the mapping of variables from the virtual machine (first) to the gadget constraint system (second).
BHP is a collision-resistant hash function that takes a variable-length input.
The BHP hash function does not behave like a random oracle, see Poseidon for one.
A helper struct for tracking the number of constants, public inputs, private inputs, and constraints.
The
Error
type, a wrapper around a dynamic error type.Configuration for formatting.
An identifier is an immutable UTF-8 string,
represented as a constant field element in the circuit.
A hash table where the iteration order of the key-value pairs is independent
of the hash values of the keys.
A cell which can be written to only once. It is not thread safe.
Pedersen is a collision-resistant hash function that takes a variable-length input.
The Pedersen hash function does not behave like a random oracle, see Poseidon for one.
A program ID is of the form
{name}.{network}
.
If no network
-level domain is specified, the default network is used.The state path proves existence of the transition leaf to either a global or local state root.
The account view key is able to decrypt records and ciphertext.
Enums
A value stored in program data.
Helper enum used in the case where a circuit’s output mode or counts are determined by
its mode and the actual value of the circuit.
The mode structure for duplex sponges.
An entry stored in program data.
The literal enum represents all supported circuit types in snarkVM.
A
Measurement
is a quantity that can be measured.
The variants of the Measurement
defines a condition associated with the measurable quantity.A value stored in program data.
Traits
Unary operator for retrieving the absolute value, enforcing an overflow never occurs.
Unary operator for retrieving the absolute value, bounding the difference to
MAX
if an overflow occurs.Unary operator for retrieving the absolute value, wrapping the result if an overflow occurs.
The addition operator
+
.The addition assignment operator
+=
.Binary operator for adding two values, enforcing an overflow never occurs.
Binary operator for adding two values, bounding the sum to
MAX
if an overflow occurs.Binary operator for adding two values, wrapping the sum if an overflow occurs.
A single-bit binary adder with a carry bit.
The bitwise AND operator
&
.The bitwise AND assignment operator
&=
.The bitwise OR operator
|
.The bitwise OR assignment operator
|=
.The bitwise XOR operator
^
.The bitwise XOR assignment operator
^=
.Representation of a boolean.
A trait for a commitment scheme.
A trait for a commitment scheme.
Trait for comparator operations.
?
formatting.Used for immutable dereferencing operations, like
*v
.Format trait for an empty format,
{}
.The division operator
/
.The division assignment operator
/=
.Binary operator for dividing two values, enforcing an overflow never occurs.
Binary operator for dividing two values, bounding the quotient to
MAX
or MIN
if an overflow occurs.Binary operator for dividing two values, without checking specific conditions.
Binary operator for dividing two values, wrapping the quotient if an overflow occurs.
Unary operator for retrieving the doubled value.
Operations to eject from a circuit environment into primitive form.
Trait for equality comparisons.
Representation of a base field element.
Unary operator for instantiating from bits.
Unary operator for instantiating from a boolean.
Unary operator for converting from a base field element.
Unary operator for converting from a list of base elements.
Unary operator for converting from an affine group element.
Parse a value from a string
Representation of a group element.
A trait for a hash function.
A trait for a hash function that produces multiple outputs.
A trait for a hash function that projects the value to an affine group element.
A trait for a hash function that projects the value to a scalar.
A trait for a hash function of an uncompressed variant.
Operations to inject from a primitive form into a circuit environment.
Properties common to all integer types.
Representation of an integer.
Trait bound for integer values. Common to both signed and unsigned integers.
Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value.
Unary operator for retrieving the inverse value.
Unary operator for retrieving the most-significant bit.
Trait for integers that can be used as an unsigned magnitude.
Magnitude
s are either used to represent an integer exponent
or the right operand in integer shift operations.Trait for determining the number of constants, public input, private inputs, and constraints for an operation.
Binary operator for modding two values.
The multiplication operator
*
.The multiplication assignment operator
*=
.Binary operator for multiplying two values, enforcing an overflow never occurs.
Binary operator for multiplying two values, bounding the product to
MAX
if an overflow occurs.Binary operator for multiplying two values, wrapping the product if an overflow occurs.
Binary operator for performing
NOT (a AND b)
.The unary negation operator
-
.Binary operator for performing
(NOT a) AND (NOT b)
.The unary logical negation operator
!
.Defines a multiplicative identity element for
Self
.Representation of the one value.
Trait for determining the mode of the output of an operation.
A trait for a pseudorandom function.
Operations to parse a string literal into an object.
Binary operator for raising a value to a power.
Binary operator for exponentiating two values, enforcing an overflow never occurs.
Binary operator for exponentiating two values, wrapping the result if an overflow occurs.
The interface for a prime field.
The remainder operator
%
.The remainder assignment operator
%=
.Binary operator for dividing two values and returning the remainder, enforcing an overflow never occurs.
Binary operator for dividing two values, bounding the remainder to
MAX
or MIN
if an overflow occurs.Binary operator for dividing two values, wrapping the remainder if an overflow occurs.
Representation of a scalar field element.
The left shift operator
<<
. Note that because this trait is implemented
for all integer types with multiple right-hand-side types, Rust’s type
checker has special handling for _ << _
, setting the result type for
integer operations to the type of the left-hand-side operand. This means
that though a << b
and a.shl(b)
are one and the same from an evaluation
standpoint, they are different when it comes to type inference.The left shift assignment operator
<<=
.Binary operator for left shifting a value, checking that the rhs is less than the number
of bits in self.
Binary operator for left shifting a value, safely continuing past the number of bits in self.
The right shift operator
>>
. Note that because this trait is implemented
for all integer types with multiple right-hand-side types, Rust’s type
checker has special handling for _ >> _
, setting the result type for
integer operations to the type of the left-hand-side operand. This means
that though a >> b
and a.shr(b)
are one and the same from an evaluation
standpoint, they are different when it comes to type inference.The right shift assignment operator
>>=
.Binary operator for right shifting a value, checking that the rhs is less than the number
of bits in self.
Binary operator for right shifting a value, safely continuing past the number of bits in self.
Unary operator for retrieving the squared value.
Unary operator for retrieving the square root of the value.
The subtraction operator
-
.The subtraction assignment operator
-=
.Binary operator for subtracting two values, enforcing an underflow never occurs.
Binary operator for subtracting two values, bounding the difference to
MIN
if an underflow occurs.Binary operator for subtracting two values, wrapping the difference if an underflow occurs.
A single-bit binary subtractor with a borrow bit.
Trait for ternary operations.
Unary operator for converting to bits.
Unary operator for converting to a base field.
Unary operator for converting to a list of base fields.
Unary operator for converting to an affine group.
Unary operator for converting to
k
number of bits.Unary operator for converting to
k
number of bits.A trait for values which cannot be negative
Representation of the zero value.
Defines a multiplicative identity element for
Self
.Functions
Recognizes one or more lowercase and uppercase ASCII alphabetic characters: a-z, A-Z
Recognizes one or more ASCII numerical and alphabetic characters: 0-9, a-z, A-Z
Tests a list of parsers one by one until one succeeds.
Recognizes one character.
Returns true if the given iterator has duplicate elements.
Repeats the embedded parser until it fails
and returns the results in a
Vec
.Runs the embedded parser until it fails and
returns the results in a
Vec
. Fails if
the embedded parser does not produce at least
one result.Maps a function on the result of a parser.
Applies a function returning a
Result
over the result of a parser.Recognizes one of the provided characters.
Optional parser: Will return
None
if not successful.Gets an object from the first parser,
then gets another object from the second parser.
If the child parser was successful, return the consumed input as produced value.
Recognizes a pattern
Gets an object from the first parser,
then matches an object from the second parser and discards it.
Type Definitions
BHP256 is a collision-resistant hash function that processes inputs in 256-bit chunks.
BHP512 is a collision-resistant hash function that processes inputs in 512-bit chunks.
BHP768 is a collision-resistant hash function that processes inputs in 768-bit chunks.
BHP1024 is a collision-resistant hash function that processes inputs in 1024-bit chunks.
The
nom
-compatible parser return type.Pedersen64 is an additively-homomorphic collision-resistant hash function that takes up to a 64-bit input.
Pedersen128 is an additively-homomorphic collision-resistant hash function that takes up to a 128-bit input.
Poseidon2 is a cryptographic hash function of input rate 2.
Poseidon4 is a cryptographic hash function of input rate 4.
Poseidon8 is a cryptographic hash function of input rate 8.
Result<T, Error>