Struct crypto_bigint::UInt[][src]

pub struct UInt<const LIMBS: usize> { /* fields omitted */ }
Expand description

Big unsigned integer.

Generic over the given number of LIMBS

Encoding support

This type supports many different types of encodings, either via the Encoding trait or various const fn decoding and encoding functions that can be used with UInt constants.

Optional crate features for encoding (off-by-default):

Implementations

Computes a + b + carry, returning the result along with the new carry.

Perform wrapping addition, discarding overflow.

Perform checked addition, returning a CtOption which is_some only if the operation did not overflow.

Computes self + rhs mod p in constant time.

Assumes self and rhs are < p.

Computes bitwise a & b.

Perform wrapping bitwise and. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations

Perform checked bitwise and, returning a CtOption which is_some always

Determine if this UInt is equal to zero.

Returns

If zero, return Choice(1). Otherwise, return Choice(0).

Is this UInt an odd number?

Computes self / rhs, returns the quotient, remainder if rhs != 0

Computes self % rhs, returns the remainder if rhs != 0

Wrapped division is just normal division i.e. self / rhs There’s no way wrapping could ever happen. This function exists, so that all operations are accounted for in the wrapping operations.

Perform checked division, returning a CtOption which is_some only if the rhs != 0

Wrapped (modular) remainder calculation is just self % rhs. There’s no way wrapping could ever happen. This function exists, so that all operations are accounted for in the wrapping operations.

Perform checked reduction, returning a CtOption which is_some only if the rhs != 0

Create a new UInt from the provided big endian bytes.

Create a new UInt from the provided big endian hex string.

Create a new UInt from the provided little endian bytes.

Create a new UInt from the provided little endian hex string.

Create a UInt from a u8 (const-friendly)

Create a UInt from a u16 (const-friendly)

Create a UInt from a u32 (const-friendly)

This is supported on 64-bit only.

Create a UInt from a u64 (const-friendly)

Create a UInt from a u128 (const-friendly)

Create a UInt from an array of the limb::Inner unsigned integer type.

Create an array of limb::Inner unsigned integer type from a UInt.

Compute “wide” multiplication, with a product twice the size of the input.

Perform wrapping multiplication, discarding overflow.

Perform checked multiplication, returning a CtOption which is_some only if the operation did not overflow.

Square self, returning a “wide” result.

Computes -a mod p in constant time.

Computes bitwise a & b.

Perform wrapping bitwise or. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations

Perform checked bitwise or, returning a CtOption which is_some always

Computes self << shift.

NOTE: this operation is variable time with respect to n ONLY.

When used with a fixed n, this function is constant-time with respect to self.

Computes self >> n.

NOTE: this operation is variable time with respect to n ONLY.

When used with a fixed n, this function is constant-time with respect to self.

Computes √(self) Uses Brent & Zimmermann, Modern Computer Arithmetic, v0.5.9, Algorithm 1.13

Callers can check if self is a square by squaring the result

Wrapped sqrt is just normal √(self) There’s no way wrapping could ever happen. This function exists, so that all operations are accounted for in the wrapping operations.

Perform checked sqrt, returning a CtOption which is_some only if the √(self)² == self

Computes a - (b + borrow), returning the result along with the new borrow.

Perform wrapping subtraction, discarding underflow and wrapping around the boundary of the type.

Perform checked subtraction, returning a CtOption which is_some only if the operation did not overflow.

Computes self - rhs mod p in constant time.

Assumes self and rhs are < p.

This is supported on crate feature rand only.

Generate a cryptographically secure random UInt.

This is supported on crate feature rand only.

Generate a cryptographically secure random UInt which is less than a given modulus.

This function uses rejection sampling, a method which produces an unbiased distribution of in-range values provided the underlying CryptoRng is unbiased, but runs in variable-time.

The variable-time nature of the algorithm should not pose a security issue so long as the underlying random number generator is truly a CryptoRng, where previous outputs are unrelated to subsequent outputs and do not reveal information about the RNG’s internal state.

The value 0.

The value 1.

Maximum value this UInt can express.

Const-friendly UInt constructor.

Borrow the limbs of this UInt.

Convert this UInt into its inner limbs.

Trait Implementations

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Output type.

Compute self + rhs mod p. Read more

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Concatenated output: twice the width of Self.

Concate the two values, with self as most significant and rhs as the least significant. Read more

Select a or b according to choice. Read more

Conditionally assign other to self, according to choice. Read more

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more

Determine if two items are equal. Read more

Determine whether self > other. Read more

Determine whether self < other. Read more

Formats the value using the given formatter. Read more

Decode a value from RLP bytes

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Append a value to the stream

Get rlp-encoded bytes for this instance

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The value 0.

The value 1.

Maximum value this integer can express.

Is this integer value an odd number?

Is this integer value equal to zero?

Is this integer value an even number?

Formats the value using the given formatter.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

Output type.

Compute -self mod p.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Generate a cryptographically secure random value.

Generate a cryptographically secure random number which is less than a given modulus. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

Performs the %= operation. Read more

Performs the %= operation. Read more

NOTE: this operation is variable time with respect to rhs ONLY.

When used with a fixed rhs, this function is constant-time with respect to self.

The resulting type after applying the << operator.

NOTE: this operation is variable time with respect to rhs ONLY.

When used with a fixed rhs, this function is constant-time with respect to self.

The resulting type after applying the << operator.

NOTE: this operation is variable time with respect to rhs ONLY.

When used with a fixed rhs, this function is constant-time with respect to self.

NOTE: this operation is variable time with respect to rhs ONLY.

When used with a fixed rhs, this function is constant-time with respect to self.

The resulting type after applying the >> operator.

NOTE: this operation is variable time with respect to rhs ONLY.

When used with a fixed rhs, this function is constant-time with respect to self.

The resulting type after applying the >> operator.

Performs the >>= operation. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Split output: high/low components of the value.

Split this number in half, returning its high and low components respectively. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Output type.

Compute self - rhs mod p. Read more

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler. Read more