Crate snarkvm_console_algorithms
SourceRe-exports§
Modules§
- bech32
- Encoding and decoding of the Bech32 format
- bhp
- de
- Generic data structure deserialization framework.
- environment
- error
- field
- fmt
- Utilities for formatting and printing strings.
- group
- integer_
magnitude - Trait pattern to prevent abuse of Magnitude.
- integer_
type - integers
- scalar
- ser
- Generic data structure serialization framework.
- str
- String manipulation.
- string_
parser - From https://github.com/Geal/nom/blob/main/examples/string.rs
- variable_
length
Macros§
- anyhow
- Construct an ad-hoc error from a string or existing non-
anyhow
error value. - bail
- Return early with an error.
- cfg_
chunks - Returns an iterator over
chunk_size
elements of the slice at a time. - cfg_
chunks_ mut - Returns an iterator over
chunk_size
elements of the slice at a time. - cfg_
find - Finds the first element that satisfies the predicate function
- cfg_
find_ map - Applies a function and returns the first value that is not None
- cfg_
into_ iter - Creates parallel iterator if
parallel
feature is enabled. - cfg_
iter - Creates parallel iterator over refs if
parallel
feature is enabled. - cfg_
iter_ mut - Creates parallel iterator over mut refs if
parallel
feature is enabled. - cfg_
keys - Turns a collection into an iterator.
- cfg_
par_ bridge - Creates parallel iterator from iterator if
parallel
feature is enabled. - cfg_
reduce - Applies the reduce operation over an iterator.
- cfg_
reduce_ with - Applies
reduce_with
orreduce
depending on theserial
feature. - cfg_
sort_ by_ cached_ key - Performs a sort that caches the extracted keys
- cfg_
sort_ unstable_ by - Performs an unstable sort
- cfg_
sorted_ by - Returns a sorted, by-value iterator for the given IndexMap/IndexSet
- cfg_
values - Turns a collection into an iterator.
- cfg_
zip_ fold - Applies fold to the iterator
- ensure
- Return early with an error if a condition is not satisfied.
- to_
bits_ le - Takes as input a sequence of objects, and converts them to a series of little-endian bits.
All traits that implement
ToBits
can be automatically converted to bits in this manner.
Structs§
- Alphanumeric
- Sample a
u8
, uniformly distributed over ASCII letters and numbers: a-z, A-Z and 0-9. - Blake2
Xs - Console
- Elligator2
- Error
- The
Error
type, a wrapper around a dynamic error type. - Field
- Formatter
- Configuration for formatting.
- From
Bytes Deserializer - Group
- Keccak
- The sponge construction
Sponge[f, pad, r]
is a function that takes a variable-length input and produces a fixed-length output (the hash value). - Limited
Writer - A wrapper around a
Write
instance that limits the number of bytes that can be written. - Pedersen
- 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.
- Poseidon
- Sanitizer
- Scalar
- Standard
- A generic random value distribution, implemented for many primitive types. Usually generates values with a numerically uniform distribution, and with a range appropriate to the type.
- TestRng
- A fast RNG used solely for testing and benchmarking, not for any real world purposes.
- ToBytes
Serializer
Enums§
- Err
- The
Err
enum indicates the parser was not successful - Error
Kind - Indicates which parser returned an error
- Ordering
- An
Ordering
is the result of a comparison between two values.
Traits§
- AbsChecked
- Unary operator for retrieving the absolute value, enforcing an overflow never occurs.
- AbsSaturating
- Unary operator for retrieving the absolute value, bounding the difference to
MAX
if an overflow occurs. - AbsWrapped
- Unary operator for retrieving the absolute value, wrapping the result if an overflow occurs.
- Add
- The addition operator
+
. - AddAssign
- The addition assignment operator
+=
. - AddChecked
- Binary operator for adding two values, enforcing an overflow never occurs.
- AddSaturating
- Binary operator for adding two values, bounding the sum to
MAX
if an overflow occurs. - AddWrapped
- Binary operator for adding two values, wrapping the sum if an overflow occurs.
- Address
Trait - Representation of an address.
- Affine
Curve - Affine representation of an elliptic curve point guaranteed to be in the correct prime order subgroup.
- AsPrimitive
- A generic interface for casting between machine scalars with the
as
operator, which admits narrowing and precision loss. Implementers of this traitAsPrimitive
should behave like a primitive numeric type (e.g. a newtype around another primitive), and the intended conversion must never fail. - BitAnd
- The bitwise AND operator
&
. - BitAnd
Assign - The bitwise AND assignment operator
&=
. - BitOr
- The bitwise OR operator
|
. - BitOr
Assign - The bitwise OR assignment operator
|=
. - BitXor
- The bitwise XOR operator
^
. - BitXor
Assign - The bitwise XOR assignment operator
^=
. - Boolean
Trait - Representation of a boolean.
- Checked
Pow - Checked
Shl - Commit
- A trait for a commitment scheme.
- Commit
Uncompressed - A trait for a commitment scheme.
- Compare
- Trait for comparator operations.
- Crypto
Rng - A marker trait used to indicate that an
RngCore
orBlockRngCore
implementation is supposed to be cryptographically secure. - Debug
?
formatting.- Deref
- Used for immutable dereferencing operations, like
*v
. - Deref
Mut - Used for mutable dereferencing operations, like in
*v = 1;
. - Deserialize
- A data structure that can be deserialized from any data format supported by Serde.
- Deserialize
Ext - A helper trait used to simplify value extraction.
- Deserialize
Owned - A data structure that can be deserialized without borrowing any data from the deserializer.
- Deserializer
- A data format that can deserialize any data structure supported by Serde.
- Display
- Format trait for an empty format,
{}
. - Distribution
- Types (distributions) that can be used to create a random instance of
T
. - Div
- The division operator
/
. - DivAssign
- The division assignment operator
/=
. - DivChecked
- Binary operator for dividing two values, enforcing an overflow never occurs.
- DivSaturating
- Binary operator for dividing two values, bounding the quotient to
MAX
orMIN
if an overflow occurs. - DivUnchecked
- Binary operator for dividing two values, without checking specific conditions.
- DivWrapped
- Binary operator for dividing two values, wrapping the quotient if an overflow occurs.
- Double
- Unary operator for retrieving the doubled value.
- Enum
Access - Provides a
Visitor
access to the data of an enum in the input. - Environment
- Equal
- Trait for equality comparisons.
- Field
Trait - Representation of a base field element.
- From
Base32 - Parse/convert base32 slice to
Self
. It is the reciprocal ofToBase32
. - From
Bits - From
Bytes - From
Field - Unary operator for converting from a base field element.
- From
Fields - Unary operator for converting from a list of base elements.
- FromStr
- Parse a value from a string
- Group
Trait - Representation of a group element.
- Hash
- A trait for a hash function.
- Hash
Many - A trait for a hash function that produces multiple outputs.
- Hash
ToGroup - A trait for a hash function that projects the value to an affine group element.
- Hash
ToScalar - A trait for a hash function that projects the value to a scalar.
- Hash
Uncompressed - A trait for a hash function of an uncompressed variant.
- Integer
Core - Integer
Properties - Properties common to all integer types.
- Integer
Trait - Representation of an integer.
- Integer
Type - Trait bound for integer values. Common to both signed and unsigned integers.
- Inverse
- Unary operator for retrieving the inverse value.
- Itertools
- An
Iterator
blanket implementation that provides extra adaptors and methods. - Magnitude
- 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. - MapAccess
- Provides a
Visitor
access to each entry of a map in the input. - Modulo
- Binary operator for modding two values.
- Montgomery
Parameters - Mul
- The multiplication operator
*
. - MulAssign
- The multiplication assignment operator
*=
. - MulChecked
- Binary operator for multiplying two values, enforcing an overflow never occurs.
- MulSaturating
- Binary operator for multiplying two values, bounding the product to
MAX
if an overflow occurs. - MulWrapped
- Binary operator for multiplying two values, wrapping the product if an overflow occurs.
- Nand
- Binary operator for performing
NOT (a AND b)
. - Neg
- The unary negation operator
-
. - Nor
- Binary operator for performing
(NOT a) AND (NOT b)
. - Not
- The unary logical negation operator
!
. - One
- Defines a multiplicative identity element for
Self
. - OrHalt
- A trait to unwrap a
Result
orHalt
. - PRF
- A trait for a pseudorandom function.
- Parser
- Operations to parse a string literal into an object.
- Pow
- Binary operator for raising a value to a power.
- PowChecked
- Binary operator for exponentiating two values, enforcing an overflow never occurs.
- PowWrapped
- Binary operator for exponentiating two values, wrapping the result if an overflow occurs.
- Product
- Trait to represent types that can be created by multiplying elements of an iterator.
- Projective
Curve - Projective representation of an elliptic curve point guaranteed to be in the prime order subgroup.
- Read
- The
Read
trait allows for reading bytes from a source. - Rem
- The remainder operator
%
. - RemAssign
- The remainder assignment operator
%=
. - RemChecked
- Binary operator for dividing two values and returning the remainder, enforcing an overflow never occurs.
- RemSaturating
- Binary operator for dividing two values, bounding the remainder to
MAX
orMIN
if an overflow occurs. - RemWrapped
- Binary operator for dividing two values, wrapping the remainder if an overflow occurs.
- Rng
- An automatically-implemented extension trait on
RngCore
providing high-level generic methods for sampling values and other convenience methods. - Scalar
Trait - Representation of a scalar field element.
- SeqAccess
- Provides a
Visitor
access to each element of a sequence in the input. - Serialize
- A data structure that can be serialized into any data format supported by Serde.
- Serialize
Seq - Returned from
Serializer::serialize_seq
. - Serialize
Struct - Returned from
Serializer::serialize_struct
. - Serializer
- A data format that can serialize any data structure supported by Serde.
- Shl
- 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 thougha << b
anda.shl(b)
are one and the same from an evaluation standpoint, they are different when it comes to type inference. - ShlAssign
- The left shift assignment operator
<<=
. - ShlChecked
- Binary operator for left shifting a value, checking that the rhs is less than the number of bits in self.
- ShlWrapped
- Binary operator for left shifting a value, safely continuing past the number of bits in self.
- Shr
- 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 thougha >> b
anda.shr(b)
are one and the same from an evaluation standpoint, they are different when it comes to type inference. - ShrAssign
- The right shift assignment operator
>>=
. - ShrChecked
- Binary operator for right shifting a value, checking that the rhs is less than the number of bits in self.
- ShrWrapped
- Binary operator for right shifting a value, safely continuing past the number of bits in self.
- Size
InBits - Size
InBytes - Size
InData Bits - Square
- Unary operator for retrieving the squared value.
- Square
Root - Unary operator for retrieving the square root of the value.
- String
Trait - Representation of a string.
- Sub
- The subtraction operator
-
. - SubAssign
- The subtraction assignment operator
-=
. - SubChecked
- Binary operator for subtracting two values, enforcing an underflow never occurs.
- SubSaturating
- Binary operator for subtracting two values, bounding the difference to
MIN
if an underflow occurs. - SubWrapped
- Binary operator for subtracting two values, wrapping the difference if an underflow occurs.
- Sum
- Trait to represent types that can be created by summing up an iterator.
- Ternary
- Trait for ternary operations.
- ToBase32
- A trait for converting a value to a type
T
that represents au5
slice. - ToBits
- ToBytes
- ToField
- Unary operator for converting to a base field.
- ToFields
- Unary operator for converting to a list of base fields.
- Twisted
Edwards Parameters - Type
Name - Uniform
- A trait for a uniform random number generator.
- Variant
Access VariantAccess
is a visitor that is created by theDeserializer
and passed to theDeserialize
to deserialize the content of a particular enum variant.- Visibility
- Visitor
- This trait represents a visitor that walks through a deserializer.
- Wrapping
Div - Wrapping
Pow - Wrapping
Rem - Write
- A trait for objects which are byte-oriented sinks.
- Zero
- Defines an additive identity element for
Self
. - _
- The interface for a generic field.
Functions§
- alpha1
- Recognizes one or more lowercase and uppercase ASCII alphabetic characters: a-z, A-Z
- alphanumeric1
- Recognizes one or more ASCII numerical and alphabetic characters: 0-9, a-z, A-Z
- alt
- Tests a list of parsers one by one until one succeeds.
- char
- Recognizes one character.
- complete
- Transforms Incomplete into
Error
. - convert_
result - Converts a
ParserResult
into a human-readable message. - count
- Runs the embedded parser
count
times, gathering the results in aVec
- error
- fail
- A parser which always fails.
- has_
duplicates - Returns true if the given iterator has duplicate elements.
- make_
error - Creates an error from the input position and an ErrorKind
- many0
- Repeats the embedded parser, gathering the results in a
Vec
. - many0_
count - Repeats the embedded parser, counting the results
- many1
- Runs the embedded parser, gathering the results in a
Vec
. - map
- Maps a function on the result of a parser.
- map_res
- Applies a function returning a
Result
over the result of a parser. - one_of
- Recognizes one of the provided characters.
- opt
- Optional parser, will return
None
onErr::Error
. - pair
- Gets an object from the first parser, then gets another object from the second parser.
- read_
variable_ length_ integer - Decode the value of a variable length integer. https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
- recognize
- If the child parser was successful, return the consumed input as produced value.
- separated_
list0 - Alternates between two parsers to produce a list of elements.
- separated_
list1 - Alternates between two parsers to produce a list of elements until
Err::Error
. - tag
- Recognizes a pattern
- take
- Returns an input slice containing the first N input elements (Input[..N]).
- terminated
- Gets an object from the first parser, then matches an object from the second parser and discards it.
- variable_
length_ integer - Returns the variable length integer of the given value. https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
Type Aliases§
- I8
- I16
- I32
- I64
- I128
- IoResult
- A specialized
Result
type for I/O operations. - Keccak224
- The Keccak-224 hash function.
- Keccak256
- The Keccak-256 hash function.
- Keccak384
- The Keccak-384 hash function.
- Keccak512
- The Keccak-512 hash function.
- Parser
Result - The
nom
-compatible parser return type. - Pedersen64
- Pedersen64 is an additively-homomorphic collision-resistant hash function that takes up to a 64-bit input.
- Pedersen128
- Pedersen128 is an additively-homomorphic collision-resistant hash function that takes up to a 128-bit input.
- Poseidon2
- Poseidon2 is a cryptographic hash function of input rate 2.
- Poseidon4
- Poseidon4 is a cryptographic hash function of input rate 4.
- Poseidon8
- Poseidon8 is a cryptographic hash function of input rate 8.
- Result
Result<T, Error>
- Sha3_
224 - The SHA3-224 hash function.
- Sha3_
256 - The SHA3-256 hash function.
- Sha3_
384 - The SHA3-384 hash function.
- Sha3_
512 - The SHA3-512 hash function.
- U8
- U16
- U32
- U64
- U128
Derive Macros§
- Debug
- Derive macro generating an impl of the trait
Debug
. - Deserialize
- Serialize
- _
- Derive macro generating an impl of the trait
Hash
.