Skip to main content

BoxedUint

Struct BoxedUint 

Source
pub struct BoxedUint { /* private fields */ }
Available on crate feature alloc only.
Expand description

Fixed-precision heap-allocated big unsigned integer.

Alternative to the stack-allocated Uint but with a fixed precision chosen at runtime instead of compile time.

Unlike many other heap-allocated big integer libraries, this type is not arbitrary precision and will wrap at its fixed-precision rather than automatically growing.

Implementations§

Source§

impl BoxedUint

Source

pub fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)

👎Deprecated since 0.7.0: please use carrying_add instead

Computes self + rhs + carry, returning the result along with the new carry.

Source

pub fn carrying_add( &self, rhs: impl AsRef<UintRef>, carry: Limb, ) -> (Self, Limb)

Computes self + rhs + carry, returning the result along with the new carry.

The result is widened to the same width as the widest input.

Source

pub fn adc_assign(&mut self, rhs: impl AsRef<[Limb]>, carry: Limb) -> Limb

👎Deprecated since 0.7.0: please use carrying_add_assign instead

Computes self + rhs + carry in-place, returning the new carry.

§Panics
  • if rhs has a larger precision than self.
Source

pub fn concatenating_add(&self, rhs: impl AsRef<UintRef>) -> Self

Computes self + rhs, returning a result which is concatenated with the overflow limb which would be returned if carrying_add were called with the same operands.

Source

pub fn overflowing_add(&self, rhs: impl AsRef<UintRef>) -> (Self, Choice)

Computes self + rhs, returning a tuple of the sum along with a Choice which indicates whether an overflow occurred.

If an overflow occurred, then the wrapped value is returned.

Source

pub fn overflowing_add_assign(&mut self, rhs: impl AsRef<UintRef>) -> Choice

Adds rhs to self, returning a Choice which indicates whether an overflow occurred.

If an overflow occurred, then the wrapped value is returned.

Source

pub fn wrapping_add(&self, rhs: impl AsRef<UintRef>) -> Self

Perform wrapping addition, discarding overflow.

Source

pub fn wrapping_add_assign(&mut self, rhs: impl AsRef<UintRef>)

Perform wrapping addition of rhs to self, discarding overflow.

Source§

impl BoxedUint

Source

pub fn add_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self

Computes self + rhs mod p.

Assumes self + rhs as unbounded integer is < 2p.

Source

pub fn add_mod_assign(&mut self, rhs: &Self, p: &NonZero<Self>)

Computes self + rhs mod p and writes the result in self.

Assumes self + rhs as unbounded integer is < 2p.

Source

pub fn double_mod(&self, p: &NonZero<Self>) -> Self

Computes self + self mod p.

Assumes self as unbounded integer is < p.

Source

pub fn add_mod_special(&self, rhs: &Self, c: Limb) -> Self

Computes self + rhs mod p for the special modulus p = MAX+1-c where c is small enough to fit in a single Limb.

Assumes self + rhs as unbounded integer is < 2p.

Source§

impl BoxedUint

Source

pub fn bitand(&self, rhs: &Self) -> Self

Computes bitwise a & b.

Source

pub fn bitand_limb(&self, rhs: Limb) -> Self

Perform bitwise AND between self and the given Limb, performing the AND operation on every limb of self.

Source

pub fn wrapping_and(&self, rhs: &Self) -> Self

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

Source

pub fn checked_and(&self, rhs: &Self) -> CtOption<Self>

Perform checked bitwise AND, returning a CtOption which is_some always

Source§

impl BoxedUint

Source

pub fn not(&self) -> Self

Computes bitwise !a.

Source§

impl BoxedUint

Source

pub fn bitor(&self, rhs: &Self) -> Self

Computes bitwise a | b.

Source

pub fn wrapping_or(&self, rhs: &Self) -> Self

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

Source

pub fn checked_or(&self, rhs: &Self) -> CtOption<Self>

Perform checked bitwise OR, returning a CtOption which is_some always

Source§

impl BoxedUint

Source

pub fn bitxor(&self, rhs: &Self) -> Self

Computes bitwise a ^ b.

Source

pub fn wrapping_xor(&self, rhs: &Self) -> Self

Perform wrapping bitwise XOR.

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

Source

pub fn checked_xor(&self, rhs: &Self) -> CtOption<Self>

Perform checked bitwise XOR, returning a CtOption which is_some always

Source§

impl BoxedUint

Source

pub fn bit(&self, index: u32) -> Choice

Get the value of the bit at position index, as a truthy or falsy Choice. Returns the falsy value for indices out of range.

Source

pub const fn bit_vartime(&self, index: u32) -> bool

Returns true if the bit at position index is set, false otherwise.

§Remarks

This operation is variable time with respect to index only.

Source

pub fn bits(&self) -> u32

Calculate the number of bits needed to represent this number, i.e. the index of the highest set bit.

Use BoxedUint::bits_precision to get the total capacity of this integer.

Source

pub fn bits_vartime(&self) -> u32

Calculate the number of bits needed to represent this number in variable-time with respect to self.

Source

pub const fn leading_zeros(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.

Source

pub fn bits_precision(&self) -> u32

Get the precision of this BoxedUint in bits.

Source

pub fn trailing_zeros(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number.

Source

pub fn trailing_ones(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number.

Source

pub fn trailing_zeros_vartime(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number in variable-time with respect to self.

Source

pub fn trailing_ones_vartime(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number, variable time in self.

Source§

impl BoxedUint

Source

pub fn cmp_vartime(&self, rhs: impl AsRef<UintRef>) -> Ordering

Returns the Ordering between self and rhs in variable time.

Source§

impl BoxedUint

Source

pub fn div_rem_limb_with_reciprocal( &self, reciprocal: &Reciprocal, ) -> (Self, Limb)

Computes self / rhs using a pre-made reciprocal, returns the quotient (q) and remainder (r).

Source

pub fn div_rem_limb(&self, rhs: NonZero<Limb>) -> (Self, Limb)

Computes self / rhs, returns the quotient (q) and remainder (r).

Source

pub fn rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> Limb

Computes self % rhs using a pre-made reciprocal.

Source

pub fn rem_limb(&self, rhs: NonZero<Limb>) -> Limb

Computes self % rhs.

Source

pub fn div_rem<Rhs: ToUnsigned + ?Sized>( &self, rhs: &NonZero<Rhs>, ) -> (Self, Rhs::Unsigned)

Computes self / rhs, returns the quotient, remainder.

Source

pub fn rem<Rhs: ToUnsigned + ?Sized>(&self, rhs: &NonZero<Rhs>) -> Rhs::Unsigned

Computes self % rhs, returns the remainder.

Source

pub fn div_rem_vartime<Rhs: ToUnsigned + ?Sized>( &self, rhs: &NonZero<Rhs>, ) -> (Self, Rhs::Unsigned)

Computes self / rhs, returns the quotient and remainder.

Variable-time with respect to rhs

Source

pub fn rem_vartime<Rhs: ToUnsigned + ?Sized>( &self, rhs: &NonZero<Rhs>, ) -> Rhs::Unsigned

Computes self % rhs, returns the remainder.

Variable-time with respect to rhs.

Source

pub fn wrapping_div<Rhs: ToUnsigned + ?Sized>(&self, rhs: &NonZero<Rhs>) -> Self

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.

§Panics
  • if rhs == 0.
Source

pub fn wrapping_div_vartime<Rhs: ToUnsigned + ?Sized>( &self, rhs: &NonZero<Rhs>, ) -> Self

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

Source

pub fn checked_div(&self, rhs: impl AsRef<UintRef>) -> CtOption<Self>

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

Source§

impl BoxedUint

Source

pub fn from_be_slice( bytes: &[u8], bits_precision: u32, ) -> Result<Self, DecodeError>

Create a new BoxedUint from the provided big endian bytes.

The bits_precision argument represents the precision of the resulting integer, which is fixed as this type is not arbitrary-precision.

The new BoxedUint will be created with bits_precision rounded up to a multiple of Limb::BITS.

§Errors
Source

pub fn from_be_slice_vartime(bytes: &[u8]) -> Self

Create a new BoxedUint from the provided big endian bytes, automatically selecting its precision based on the size of the input.

This method is variable-time with respect to all subsequent operations since it chooses the limb count based on the input size, and is therefore only suitable for public inputs.

When working with secret values, use BoxedUint::from_be_slice.

Source

pub fn from_le_slice( bytes: &[u8], bits_precision: u32, ) -> Result<Self, DecodeError>

Create a new BoxedUint from the provided little endian bytes.

The bits_precision argument represents the precision of the resulting integer, which is fixed as this type is not arbitrary-precision.

The new BoxedUint will be created with bits_precision rounded up to a multiple of Limb::BITS.

§Errors
Source

pub fn from_le_slice_vartime(bytes: &[u8]) -> Self

Create a new BoxedUint from the provided little endian bytes, automatically selecting its precision based on the size of the input.

This method is variable-time with respect to all subsequent operations since it chooses the limb count based on the input size, and is therefore only suitable for public inputs.

When working with secret values, use BoxedUint::from_le_slice.

Source

pub fn to_be_bytes(&self) -> Box<[u8]>

Serialize this BoxedUint as big-endian.

Source

pub fn to_be_bytes_trimmed_vartime(&self) -> Box<[u8]>

Serialize this BoxedUint as big-endian without leading zeroes.

Source

pub fn to_le_bytes(&self) -> Box<[u8]>

Serialize this BoxedUint as little-endian.

Source

pub fn to_le_bytes_trimmed_vartime(&self) -> Box<[u8]>

Serialize this BoxedUint as little-endian without trailing zeroes.

Source

pub fn from_be_hex(hex: &str, bits_precision: u32) -> CtOption<Self>

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

§Panics
  • if hex string is not the expected size
Source

pub fn from_str_radix_vartime( src: &str, radix: u32, ) -> Result<Self, DecodeError>

Create a new BoxedUint from a big-endian string in a given base.

The string may begin with a + character, and may use underscore characters to separate digits.

§Errors
  • Returns DecodeError::InvalidDigit if the input value contains non-digit characters or digits outside of the range 0..radix.
§Panics
  • if radix is not in the range from 2 to 36.
Source

pub fn from_str_radix_with_precision_vartime( src: &str, radix: u32, bits_precision: u32, ) -> Result<Self, DecodeError>

Create a new BoxedUint from a big-endian string in a given base, with a given precision.

The string may begin with a + character, and may use underscore characters to separate digits.

The bits_precision argument represents the precision of the resulting integer, which is fixed as this type is not arbitrary-precision.

The new BoxedUint will be created with bits_precision rounded up to a multiple of Limb::BITS.

§Errors
§Panics
  • if radix is not in the range from 2 to 36.
Source

pub fn to_string_radix_vartime(&self, radix: u32) -> String

Format a BoxedUint as a string in a given base.

§Panics
  • if radix is not in the range from 2 to 36.
Source§

impl BoxedUint

Source

pub fn inv_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>

👎Deprecated since 0.7.0: please use invert_odd_mod instead

Computes the multiplicative inverse of self mod modulus, where modulus is odd.

Source

pub fn invert_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>

Computes the multiplicative inverse of self mod modulus, where modulus is odd.

Source

pub fn invert_odd_mod_vartime(&self, modulus: &Odd<Self>) -> CtOption<Self>

Computes the multiplicative inverse of self mod modulus, where modulus is odd.

Source

pub fn inv_mod2k_vartime(&self, k: u32) -> (Self, Choice)

👎Deprecated since 0.7.0: please use invert_mod2k_vartime instead

Computes 1/self mod 2^k. This method is constant-time w.r.t. self but not k.

If the inverse does not exist (k > 0 and self is even, or k > bits_precision()), returns Choice::FALSE as the second element of the tuple, otherwise returns Choice::TRUE.

Source

pub fn invert_mod2k_vartime(&self, k: u32) -> (Self, Choice)

Computes 1/self mod 2^k. This method is constant-time w.r.t. self but not k.

If the inverse does not exist (k > 0 and self is even, or k > bits_precision()), returns Choice::FALSE as the second element of the tuple, otherwise returns Choice::TRUE.

Source

pub fn inv_mod2k(&self, k: u32) -> (Self, Choice)

👎Deprecated since 0.7.0: please use invert_mod2k instead

Computes 1/self mod 2^k.

If the inverse does not exist (k > 0 and self is even, or k > bits_precision()), returns Choice::FALSE as the second element of the tuple, otherwise returns Choice::TRUE.

Source

pub fn invert_mod2k(&self, k: u32) -> (Self, Choice)

Computes 1/self mod 2^k.

If the inverse does not exist (k > 0 and self is even, or k > bits_precision()), returns Choice::FALSE as the second element of the tuple, otherwise returns Choice::TRUE.

Source

pub fn inv_mod(&self, modulus: &Self) -> CtOption<Self>

👎Deprecated since 0.7.0: please use invert_mod instead

Computes the multiplicative inverse of self mod modulus

self and modulus must have the same number of limbs, or the function will panic

TODO: maybe some better documentation is needed

Source

pub fn invert_mod(&self, modulus: &NonZero<Self>) -> CtOption<Self>

Computes the multiplicative inverse of self mod modulus

self and modulus must have the same number of limbs, or the function will panic

TODO: maybe some better documentation is needed

Source§

impl BoxedUint

Source

pub fn mul(&self, rhs: impl AsRef<UintRef>) -> Self

👎Deprecated since 0.7.0: please use concatenating_mul

Multiply self by rhs.

Returns a widened output with a limb count equal to the sums of the input limb counts.

Source

pub fn wrapping_mul(&self, rhs: impl AsRef<UintRef>) -> Self

Perform wrapping multiplication, wrapping to the width of self.

Source

pub fn checked_mul(&self, rhs: impl AsRef<UintRef>) -> CtOption<Self>

Multiply self by rhs, wrapping to the width of self. Returns CtOption::None if the result overflowed the precision of self.

Source

pub fn saturating_mul(&self, rhs: impl AsRef<UintRef>) -> Self

Perform saturating multiplication, returning MAX on overflow.

Source

pub fn square(&self) -> Self

👎Deprecated since 0.7.0: please use concatenating_square

Multiply self by itself.

Source

pub fn wrapping_square(&self) -> Self

Multiply self by itself, wrapping to the width of self.

Source

pub fn checked_square(&self) -> CtOption<Self>

Multiply self by itself, wrapping to the width of self. Returns CtOption::None if the result overflowed the precision of self.

Source

pub fn saturating_square(&self) -> Self

Perform saturating squaring, returning MAX on overflow.

Source§

impl BoxedUint

Source

pub fn mul_mod(&self, rhs: &BoxedUint, p: &NonZero<BoxedUint>) -> BoxedUint

Computes self * rhs mod p for non-zero p.

Source

pub fn mul_mod_special(&self, rhs: &Self, c: Limb) -> Self

Computes self * rhs mod p for the special modulus p = MAX+1-c where c is small enough to fit in a single Limb.

For the modulus reduction, this function implements Algorithm 14.47 from the “Handbook of Applied Cryptography”, by A. Menezes, P. van Oorschot, and S. Vanstone, CRC Press, 1996.

Source

pub fn square_mod(&self, p: &NonZero<BoxedUint>) -> Self

Computes self * self mod p.

Source

pub fn square_mod_vartime(&self, p: &NonZero<BoxedUint>) -> Self

Computes self * self mod p in variable time with respect to p.

Source§

impl BoxedUint

Source

pub fn wrapping_neg(&self) -> Self

Perform wrapping negation.

Source§

impl BoxedUint

Source

pub fn neg_mod(&self, p: &NonZero<Self>) -> Self

Computes -a mod p. Assumes self is in [0, p).

Source

pub fn neg_mod_special(&self, c: Limb) -> Self

Computes -a mod p for the special modulus p = MAX+1-c where c is small enough to fit in a single Limb.

Source§

impl BoxedUint

Source

pub fn checked_pow(&self, exp: impl AsRef<UintRef>) -> CtOption<Self>

Computes self^exp, returning a CtOption which is none in the case of overflow.

Source

pub fn checked_pow_bounded_exp( &self, exp: impl AsRef<UintRef>, exp_bits: u32, ) -> CtOption<Self>

Computes self^exp, returning a CtOption which is none in the case of overflow.

NOTE: exp_bits may be leaked in the time pattern.

§Panics
  • if exp_bits exceeds the capacity of rhs
Source

pub fn checked_pow_vartime(&self, exp: impl AsRef<UintRef>) -> CtOption<Self>

Computes self^exp, returning a CtOption which is none in the case of overflow.

This method is variable time in the exponent exp only.

Source

pub fn saturating_pow(&self, exp: impl AsRef<UintRef>) -> Self

Computes self^exp, returning a Self::MAX in the case of overflow.

Source

pub fn saturating_pow_bounded_exp( &self, exp: impl AsRef<UintRef>, exp_bits: u32, ) -> Self

Computes self^exp, returning a Self::MAX in the case of overflow.

NOTE: exp_bits may be leaked in the time pattern.

§Panics
  • if exp_bits exceeds the capacity of rhs
Source

pub fn saturating_pow_vartime(&self, exp: impl AsRef<UintRef>) -> Self

Computes self^exp, returning a Self::MAX in the case of overflow.

This method is variable time in the exponent exp.

Source

pub fn wrapping_pow(&self, exp: impl AsRef<UintRef>) -> Self

Computes self^exp, discarding overflow.

Source

pub fn wrapping_pow_bounded_exp( &self, exp: impl AsRef<UintRef>, exp_bits: u32, ) -> Self

Computes self^exp, discarding overflow.

NOTE: exp_bits may be leaked in the time pattern.

§Panics
  • if exp_bits exceeds the capacity of rhs
Source

pub fn wrapping_pow_vartime(&self, exp: impl AsRef<UintRef>) -> Self

Computes self^exp, discarding overflow.

This method is variable time in the exponent exp only.

Source§

impl BoxedUint

Source

pub fn pow_mod(&self, rhs: &BoxedUint, p: &Odd<BoxedUint>) -> BoxedUint

Computes self ^ rhs mod p for odd p.

Source§

impl BoxedUint

Source

pub fn shl(&self, shift: u32) -> BoxedUint

Computes self << shift.

§Panics
  • if shift >= self.bits_precision().
Source

pub fn shl_assign(&mut self, shift: u32)

Computes self <<= shift.

§Panics
  • if shift >= self.bits_precision().
Source

pub fn overflowing_shl(&self, shift: u32) -> CtOption<Self>

Computes self << shift.

Returns self and a truthy Choice if shift >= self.bits_precision(), or the result and a falsy Choice otherwise.

Source

pub fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>

Computes self << shift in variable-time.

Returns None if shift >= self.bits_precision(), otherwise the shifted result.

Source

pub fn overflowing_shl_assign(&mut self, shift: u32) -> Choice

Computes self <<= shift.

Returns a truthy Choice if shift >= self.bits_precision() or a falsy Choice otherwise.

Source

pub fn overflowing_shl_assign_vartime(&mut self, shift: u32) -> bool

Computes self <<= shift in variable-time.

If shift >= self.bits_precision(), shifts self in place and returns false. Otherwise returns true and leaves self unmodified.

Source

pub fn unbounded_shl(&self, shift: u32) -> Self

Computes self << shift in a panic-free manner, producing zero in the case of overflow.

Source

pub fn unbounded_shl_assign(&mut self, shift: u32)

Computes self <<= shift in a panic-free manner, producing zero in the case of overflow.

Source

pub fn unbounded_shl_vartime(&self, shift: u32) -> Self

Computes self << shift in variable-time in a panic-free manner, producing zero in the case of overflow.

Source

pub fn unbounded_shl_assign_vartime(&mut self, shift: u32)

Computes self <<= shift in variable-time in a panic-free manner, producing zero in the case of overflow.

Source

pub fn wrapping_shl(&self, shift: u32) -> Self

Computes self << shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.

Source

pub fn wrapping_shl_assign(&mut self, shift: u32)

Computes self <<= shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.

Source

pub fn wrapping_shl_vartime(&self, shift: u32) -> Self

Computes self << shift in variable-time in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.

Source

pub fn wrapping_shl_assign_vartime(&mut self, shift: u32)

Computes self <<= shift in variable-time in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.

Source

pub fn shl_vartime(&self, shift: u32) -> Option<Self>

Computes self << shift. Returns None if shift >= self.bits_precision().

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

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

Source§

impl BoxedUint

Source

pub fn shr(&self, shift: u32) -> BoxedUint

Computes self >> shift.

§Panics
  • if shift >= self.bits_precision().
Source

pub fn shr_assign(&mut self, shift: u32)

Computes self >>= shift.

§Panics
  • if shift >= self.bits_precision().
Source

pub fn overflowing_shr(&self, shift: u32) -> CtOption<Self>

Computes self >> shift.

Returns self and a truthy Choice if shift >= self.bits_precision(), or the result and a falsy Choice otherwise.

Source

pub fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>

Computes self >> shift in variable-time.

Returns None if shift >= self.bits_precision(), otherwise the shifted result.

Source

pub fn overflowing_shr_assign(&mut self, shift: u32) -> Choice

Computes self >>= shift.

Returns a truthy Choice if shift >= self.bits_precision() or a falsy Choice otherwise.

Source

pub fn overflowing_shr_assign_vartime(&mut self, shift: u32) -> bool

Computes self >>= shift in variable-time.

If shift >= self.bits_precision(), shifts self in place and returns false. Otherwise returns true and leaves self unmodified.

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

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

Source

pub fn unbounded_shr(&self, shift: u32) -> Self

Computes self >> shift in a panic-free manner, producing zero in the case of overflow.

Source

pub fn unbounded_shr_assign(&mut self, shift: u32)

Computes self >>= shift in a panic-free manner, producing zero in the case of overflow.

Source

pub fn unbounded_shr_vartime(&self, shift: u32) -> Self

Computes self >> shift in variable-time in a panic-free manner, producing zero in the case of overflow.

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

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

Source

pub fn unbounded_shr_assign_vartime(&mut self, shift: u32)

Computes self >>= shift in variable-time in a panic-free manner, producing zero in the case of overflow.

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

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

Source

pub fn wrapping_shr(&self, shift: u32) -> Self

Computes self >> shift in a panic-free manner, reducing shift modulo the type’s width.

Source

pub fn wrapping_shr_assign(&mut self, shift: u32)

Computes self >>= shift in a panic-free manner, reducing shift modulo the type’s width.

Source

pub fn wrapping_shr_vartime(&self, shift: u32) -> Self

Computes self >> shift in variable-time in a panic-free manner, reducing shift modulo the type’s width.

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

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

Source

pub fn wrapping_shr_assign_vartime(&mut self, shift: u32)

Computes self >>= shift in variable-time in a panic-free manner, reducing shift modulo the type’s width.

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

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

Source

pub fn shr_vartime(&self, shift: u32) -> Option<Self>

Computes self >> shift. Returns None if shift >= self.bits_precision().

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

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

Source§

impl BoxedUint

Source

pub fn sqrt(&self) -> Self

👎Deprecated since 0.7.0: please use floor_sqrt instead

Computes floor(√(self)) in constant time.

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

Source

pub fn floor_sqrt(&self) -> Self

Computes √(self) in constant time.

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

Source

pub fn sqrt_vartime(&self) -> Self

👎Deprecated since 0.7.0: please use floor_sqrt_vartime instead

Computes floor(√(self)).

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

Variable time with respect to self.

Source

pub fn floor_sqrt_vartime(&self) -> Self

Computes √(self).

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

Variable time with respect to self.

Source

pub fn wrapping_sqrt(&self) -> Self

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

Source

pub fn wrapping_sqrt_vartime(&self) -> Self

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

Variable time with respect to self.

Source

pub fn checked_sqrt(&self) -> CtOption<Self>

Perform checked sqrt, returning a CtOption which is_some only if the square root is exact.

Source

pub fn checked_sqrt_vartime(&self) -> Option<Self>

Perform checked sqrt, returning an Option which is_some only if the square root is exact.

Variable time with respect to self.

Source§

impl BoxedUint

Source

pub fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)

👎Deprecated since 0.7.0: please use borrowing_sub instead

Computes self - (rhs + borrow), returning the result along with the new borrow.

Source

pub fn borrowing_sub( &self, rhs: impl AsRef<UintRef>, borrow: Limb, ) -> (Self, Limb)

Computes self - (rhs + borrow), returning the result along with the new borrow.

The result is widened to the same width as the widest input.

Source

pub fn sbb_assign(&mut self, rhs: impl AsRef<[Limb]>, borrow: Limb) -> Limb

👎Deprecated since 0.7.0: please use borrowing_sub_assign instead

Computes a - (b + borrow) in-place, returning the new borrow.

§Panics
  • if rhs has a larger precision than self.
Source

pub fn underflowing_sub(&self, rhs: impl AsRef<UintRef>) -> (Self, Choice)

Computes self - rhs, returning a tuple of the difference along with a Choice which indicates whether an underflow occurred.

If an underflow occurred, then the wrapped value is returned.

Source

pub fn underflowing_sub_assign(&mut self, rhs: impl AsRef<UintRef>) -> Choice

Subtracts rhs from self, returning a Choice which indicates whether an underflow occurred.

If an underflow occurred, then the wrapped value is returned.

Source

pub fn wrapping_sub(&self, rhs: impl AsRef<UintRef>) -> Self

Perform wrapping subtraction, discarding underflow.

Source

pub fn wrapping_sub_assign(&mut self, rhs: impl AsRef<UintRef>)

Perform wrapping subtraction of rhs from self, discarding underflow.

Source§

impl BoxedUint

Source

pub fn sub_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self

Computes self - rhs mod p.

Assumes self - rhs as unbounded signed integer is in [-p, p).

Source

pub fn sub_mod_special(&self, rhs: &Self, c: Limb) -> Self

Computes self - rhs mod p for the special modulus p = MAX+1-c where c is small enough to fit in a single Limb.

Assumes self - rhs as unbounded signed integer is in [-p, p).

Source§

impl BoxedUint

Source

pub fn zero() -> Self

Get the value 0 represented as succinctly as possible.

Source

pub fn zero_with_precision(at_least_bits_precision: u32) -> Self

Get the value 0 with the given number of bits of precision.

at_least_bits_precision is rounded up to a multiple of Limb::BITS.

Source

pub fn one() -> Self

Get the value 1, represented as succinctly as possible.

Source

pub fn one_with_precision(at_least_bits_precision: u32) -> Self

Get the value 1 with the given number of bits of precision.

at_least_bits_precision is rounded up to a multiple of Limb::BITS.

Source

pub fn is_zero(&self) -> Choice

Is this BoxedUint equal to zero?

Source

pub fn is_nonzero(&self) -> Choice

Is this BoxedUint NOT equal to zero?

Source

pub fn is_one(&self) -> Choice

Is this BoxedUint equal to one?

Source

pub fn max(at_least_bits_precision: u32) -> Self

Get the maximum value for a BoxedUint created with at_least_bits_precision precision bits requested.

That is, returns the value 2^self.bits_precision() - 1.

Source

pub fn from_words(words: impl IntoIterator<Item = Word>) -> Self

Create a BoxedUint from an array of Words (i.e. word-sized unsigned integers).

Source

pub fn from_words_with_precision( words: impl IntoIterator<Item = Word>, at_least_bits_precision: u32, ) -> Self

Create a BoxedUint from an array of Words (i.e. word-sized unsigned integers), specifying the precision of the result. Any words above the given precision will be dropped.

Source

pub fn to_words(&self) -> Box<[Word]>

Create a boxed slice of Words (i.e. word-sized unsigned integers) from a BoxedUint.

Source

pub fn as_words(&self) -> &[Word]

Borrow the inner limbs as a slice of Words.

Source

pub fn as_mut_words(&mut self) -> &mut [Word]

Borrow the inner limbs as a mutable slice of Words.

Source

pub fn as_words_mut(&mut self) -> &mut [Word]

👎Deprecated since 0.7.0: please use as_mut_words instead

Borrow the inner limbs as a mutable slice of Words.

Source

pub fn as_limbs(&self) -> &[Limb]

Borrow the limbs of this BoxedUint.

Source

pub fn as_mut_limbs(&mut self) -> &mut [Limb]

Borrow the limbs of this BoxedUint mutably.

Source

pub fn as_limbs_mut(&mut self) -> &mut [Limb]

👎Deprecated since 0.7.0: please use as_mut_limbs instead

Borrow the limbs of this BoxedUint mutably.

Source

pub fn to_limbs(&self) -> Box<[Limb]>

Convert this BoxedUint into its inner limbs.

Source

pub fn into_limbs(self) -> Box<[Limb]>

Convert this BoxedUint into its inner limbs.

Source

pub const fn as_uint_ref(&self) -> &UintRef

Borrow the limbs of this BoxedUint as a UintRef.

Source

pub const fn as_mut_uint_ref(&mut self) -> &mut UintRef

Mutably borrow the limbs of this BoxedUint as a UintRef.

Source

pub fn nlimbs(&self) -> usize

Get the number of limbs in this BoxedUint.

Source

pub fn to_nz(&self) -> CtOption<NonZero<Self>>

Convert to a NonZero<BoxedUint>.

Returns some if the original value is non-zero, and false otherwise.

Source

pub fn to_odd(&self) -> CtOption<Odd<Self>>

Convert to an Odd<BoxedUint>.

Returns some if the original value is odd, and false otherwise.

Source

pub fn into_nz(self) -> CtOption<NonZero<Self>>

Convert to a NonZero<BoxedUint>.

Returns some if the original value is non-zero, and false otherwise.

Source

pub fn into_odd(self) -> CtOption<Odd<Self>>

Convert to an Odd<BoxedUint>.

Returns some if the original value is odd, and false otherwise.

Source

pub fn widen(&self, at_least_bits_precision: u32) -> BoxedUint

👎Deprecated since 0.7.0: please use resize instead

Widen this type’s precision to the given number of bits.

§Panics
  • if at_least_bits_precision is smaller than the current precision.
Source

pub fn shorten(&self, at_least_bits_precision: u32) -> BoxedUint

👎Deprecated since 0.7.0: please use resize instead

Shortens this type’s precision to the given number of bits.

§Panics
  • if at_least_bits_precision is larger than the current precision.

Trait Implementations§

Source§

impl<Rhs: AsRef<UintRef>> Add<Rhs> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Rhs) -> BoxedUint

Performs the + operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> Add<Rhs> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Rhs) -> Self

Performs the + operation. Read more
Source§

impl Add<u128> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u128) -> BoxedUint

Performs the + operation. Read more
Source§

impl Add<u128> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u128) -> BoxedUint

Performs the + operation. Read more
Source§

impl Add<u16> for &BoxedUint

Source§

type Output = <&BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u16) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u16> for BoxedUint

Source§

type Output = <BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u16) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u32> for &BoxedUint

Source§

type Output = <&BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u32> for BoxedUint

Source§

type Output = <BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u64> for &BoxedUint

Source§

type Output = <&BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u64> for BoxedUint

Source§

type Output = <BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u8> for &BoxedUint

Source§

type Output = <&BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u8) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u8> for BoxedUint

Source§

type Output = <BoxedUint as Add<Uint<{ nlimbs($bits) }>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u8) -> Self::Output

Performs the + operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> AddAssign<Rhs> for BoxedUint

Source§

fn add_assign(&mut self, rhs: Rhs)

Performs the += operation. Read more
Source§

impl AddAssign<u128> for BoxedUint

Source§

fn add_assign(&mut self, rhs: u128)

Performs the += operation. Read more
Source§

impl AddAssign<u16> for BoxedUint

Source§

fn add_assign(&mut self, rhs: u16)

Performs the += operation. Read more
Source§

impl AddAssign<u32> for BoxedUint

Source§

fn add_assign(&mut self, rhs: u32)

Performs the += operation. Read more
Source§

impl AddAssign<u64> for BoxedUint

Source§

fn add_assign(&mut self, rhs: u64)

Performs the += operation. Read more
Source§

impl AddAssign<u8> for BoxedUint

Source§

fn add_assign(&mut self, rhs: u8)

Performs the += operation. Read more
Source§

impl AddMod for BoxedUint

Source§

type Output = BoxedUint

Output type.
Source§

fn add_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self

Compute self + rhs mod p. Read more
Source§

impl AsMut<[Limb]> for BoxedUint

Source§

fn as_mut(&mut self) -> &mut [Limb]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<[u64]> for BoxedUint

Source§

fn as_mut(&mut self) -> &mut [Word]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<UintRef> for BoxedUint

Source§

fn as_mut(&mut self) -> &mut UintRef

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[Limb]> for BoxedUint

Source§

fn as_ref(&self) -> &[Limb]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<[u64]> for BoxedUint

Source§

fn as_ref(&self) -> &[Word]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<UintRef> for BoxedUint

Source§

fn as_ref(&self) -> &UintRef

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Binary for BoxedUint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl BitAnd<&BoxedUint> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BoxedUint) -> BoxedUint

Performs the & operation. Read more
Source§

impl BitAnd<&BoxedUint> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BoxedUint) -> BoxedUint

Performs the & operation. Read more
Source§

impl BitAnd<BoxedUint> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BoxedUint) -> BoxedUint

Performs the & operation. Read more
Source§

impl BitAnd for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> BoxedUint

Performs the & operation. Read more
Source§

impl BitAndAssign<&BoxedUint> for BoxedUint

Source§

fn bitand_assign(&mut self, other: &Self)

Performs the &= operation. Read more
Source§

impl BitAndAssign for BoxedUint

Source§

fn bitand_assign(&mut self, other: Self)

Performs the &= operation. Read more
Source§

impl BitOps for BoxedUint

Source§

fn bits_precision(&self) -> u32

Precision of this integer in bits.
Source§

fn bytes_precision(&self) -> usize

Precision of this integer in bytes.
Source§

fn leading_zeros(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.
Source§

fn bits(&self) -> u32

Calculate the number of bits required to represent a given number.
Source§

fn bit(&self, index: u32) -> Choice

Get the value of the bit at position index, as a truthy or falsy Choice. Returns the falsy value for indices out of range.
Source§

fn set_bit(&mut self, index: u32, bit_value: Choice)

Sets the bit at index to 0 or 1 depending on the value of bit_value.
Source§

fn trailing_zeros(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number.
Source§

fn trailing_ones(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number.
Source§

fn bit_vartime(&self, index: u32) -> bool

Returns true if the bit at position index is set, false otherwise. Read more
Source§

fn bits_vartime(&self) -> u32

Calculate the number of bits required to represent a given number in variable-time with respect to self.
Source§

fn set_bit_vartime(&mut self, index: u32, bit_value: bool)

Sets the bit at index to 0 or 1 depending on the value of bit_value, variable time in self.
Source§

fn trailing_zeros_vartime(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number in variable-time with respect to self.
Source§

fn trailing_ones_vartime(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number, variable time in self.
Source§

fn log2_bits(&self) -> u32

floor(log2(self.bits_precision())).
Source§

fn leading_zeros_vartime(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.
Source§

impl BitOr<&BoxedUint> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BoxedUint) -> BoxedUint

Performs the | operation. Read more
Source§

impl BitOr<&BoxedUint> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BoxedUint) -> BoxedUint

Performs the | operation. Read more
Source§

impl BitOr<BoxedUint> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BoxedUint) -> BoxedUint

Performs the | operation. Read more
Source§

impl BitOr for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> BoxedUint

Performs the | operation. Read more
Source§

impl BitOrAssign<&BoxedUint> for BoxedUint

Source§

fn bitor_assign(&mut self, other: &Self)

Performs the |= operation. Read more
Source§

impl BitOrAssign for BoxedUint

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl BitXor<&BoxedUint> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BoxedUint) -> BoxedUint

Performs the ^ operation. Read more
Source§

impl BitXor<&BoxedUint> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BoxedUint) -> BoxedUint

Performs the ^ operation. Read more
Source§

impl BitXor<BoxedUint> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BoxedUint) -> BoxedUint

Performs the ^ operation. Read more
Source§

impl BitXor for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> BoxedUint

Performs the ^ operation. Read more
Source§

impl BitXorAssign<&BoxedUint> for BoxedUint

Source§

fn bitxor_assign(&mut self, other: &Self)

Performs the ^= operation. Read more
Source§

impl BitXorAssign for BoxedUint

Source§

fn bitxor_assign(&mut self, other: Self)

Performs the ^= operation. Read more
Source§

impl Borrow<UintRef> for BoxedUint

Source§

fn borrow(&self) -> &UintRef

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<UintRef> for BoxedUint

Source§

fn borrow_mut(&mut self) -> &mut UintRef

Mutably borrows from an owned value. Read more
Source§

impl<Rhs: AsRef<UintRef>> CheckedAdd<Rhs> for BoxedUint

Source§

fn checked_add(&self, rhs: &Rhs) -> CtOption<Self>

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

impl<Rhs: AsRef<UintRef>> CheckedDiv<Rhs> for BoxedUint

Source§

fn checked_div(&self, rhs: &Rhs) -> CtOption<Self>

Perform checked division, returning a CtOption which is_some only if the divisor is non-zero.
Source§

impl<Rhs: AsRef<UintRef>> CheckedMul<Rhs> for BoxedUint

Source§

fn checked_mul(&self, rhs: &Rhs) -> CtOption<Self>

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

impl CheckedSquareRoot for BoxedUint

Source§

type Output = BoxedUint

Output of the square root operation.
Source§

fn checked_sqrt(&self) -> CtOption<Self::Output>

Computes sqrt(self), returning none if no root exists.
Source§

fn checked_sqrt_vartime(&self) -> Option<Self::Output>

Computes sqrt(self), returning none if no root exists. Read more
Source§

impl<Rhs: AsRef<UintRef>> CheckedSub<Rhs> for BoxedUint

Source§

fn checked_sub(&self, rhs: &Rhs) -> CtOption<Self>

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

impl Clone for BoxedUint

Source§

fn clone(&self) -> BoxedUint

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Rhs: AsRef<UintRef>> ConcatenatingMul<Rhs> for BoxedUint

Source§

type Output = BoxedUint

Output of the widening multiplication.
Source§

fn concatenating_mul(&self, rhs: Rhs) -> Self

Perform widening multiplication.
Source§

impl ConcatenatingSquare for BoxedUint

Source§

type Output = BoxedUint

Output of the widening multiplication.
Source§

fn concatenating_square(&self) -> Self

Perform widening squaring.
Source§

impl ConditionallyNegatable for BoxedUint

Available on crate feature subtle only.
Source§

fn conditional_negate(&mut self, choice: Choice)

Negate self if choice == Choice(1); otherwise, leave it unchanged. Read more
Source§

impl ConstantTimeEq for BoxedUint

Available on crate feature subtle only.
Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl ConstantTimeGreater for BoxedUint

Available on crate feature subtle only.
Source§

fn ct_gt(&self, other: &Self) -> Choice

Determine whether self > other. Read more
Source§

impl ConstantTimeLess for BoxedUint

Available on crate feature subtle only.
Source§

fn ct_lt(&self, other: &Self) -> Choice

Determine whether self < other. Read more
Source§

impl CtAssign for BoxedUint

Source§

fn ct_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign src to self if choice is Choice::TRUE.
Source§

impl CtAssignSlice for BoxedUint

Source§

fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)

Conditionally assign src to dst if choice is Choice::TRUE, or leave it unchanged for Choice::FALSE.
Source§

impl<Rhs: AsRef<UintRef> + ?Sized> CtEq<Rhs> for BoxedUint

Source§

fn ct_eq(&self, other: &Rhs) -> Choice

Determine if self is equal to other in constant-time.
Source§

fn ct_ne(&self, other: &Rhs) -> Choice

Determine if self is NOT equal to other in constant-time.
Source§

impl CtEqSlice for BoxedUint

Source§

fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice

Determine if a is equal to b in constant-time.
Source§

fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice

Determine if a is NOT equal to b in constant-time.
Source§

impl CtGt for BoxedUint

Source§

fn ct_gt(&self, other: &Self) -> Choice

Compute whether self > other in constant time.
Source§

impl CtLt for BoxedUint

Source§

fn ct_lt(&self, other: &Self) -> Choice

Compute whether self < other in constant time.
Source§

impl CtNeg for BoxedUint

Source§

fn ct_neg(&self, choice: Choice) -> Self

Conditionally negate self, returning -self if choice is Choice::TRUE, or self otherwise.
Source§

fn ct_neg_assign(&mut self, choice: Choice)

Conditionally negate self in-place, replacing it with -self if choice is Choice::TRUE.
Source§

impl CtSelect for BoxedUint

Source§

fn ct_select(&self, other: &Self, choice: Choice) -> Self

Select between self and other based on choice, returning a copy of the value. Read more
Source§

fn ct_swap(&mut self, other: &mut Self, choice: Choice)

Conditionally swap self and other if choice is Choice::TRUE.
Source§

impl Debug for BoxedUint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> DecodeValue<'a> for BoxedUint

Available on crate features der and hybrid-array only.
Source§

type Error = Error

Type returned in the event of a decoding error.
Source§

fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> Result<Self>

Attempt to decode this value using the provided Reader. Read more
Source§

impl Default for BoxedUint

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for BoxedUint

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for BoxedUint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Rhs: ToUnsigned + ?Sized> Div<&NonZero<Rhs>> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NonZero<Rhs>) -> Self::Output

Performs the / operation. Read more
Source§

impl<Rhs: ToUnsigned + ?Sized> Div<&NonZero<Rhs>> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NonZero<Rhs>) -> Self::Output

Performs the / operation. Read more
Source§

impl<Rhs: AsMut<UintRef>> Div<NonZero<Rhs>> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZero<Rhs>) -> Self::Output

Performs the / operation. Read more
Source§

impl<Rhs: AsMut<UintRef>> Div<NonZero<Rhs>> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZero<Rhs>) -> Self::Output

Performs the / operation. Read more
Source§

impl<Rhs: ToUnsigned + ?Sized> DivAssign<&NonZero<Rhs>> for BoxedUint

Source§

fn div_assign(&mut self, rhs: &NonZero<Rhs>)

Performs the /= operation. Read more
Source§

impl<Rhs: AsMut<UintRef>> DivAssign<NonZero<Rhs>> for BoxedUint

Source§

fn div_assign(&mut self, rhs: NonZero<Rhs>)

Performs the /= operation. Read more
Source§

impl DivRemLimb for BoxedUint

Source§

fn div_rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> (Self, Limb)

Computes self / rhs, returns the quotient (q) and remainder (r).
Source§

fn div_rem_limb(&self, rhs: NonZero<Limb>) -> (Self, Limb)

Computes self / rhs using a pre-made reciprocal, returns the quotient (q) and remainder (r).
Source§

impl DivVartime for BoxedUint

Source§

fn div_vartime(&self, rhs: &NonZero<BoxedUint>) -> Self

Computes self / rhs in variable time.
Source§

impl EncodeValue for BoxedUint

Available on crate features der and hybrid-array only.
Source§

fn value_len(&self) -> Result<Length>

Compute the length of this value (sans [Tag]+Length header) when encoded as ASN.1 DER. Read more
Source§

fn encode_value(&self, encoder: &mut impl Writer) -> Result<()>

Encode value (sans [Tag]+Length header) as ASN.1 DER using the provided Writer. Read more
Source§

fn header(&self) -> Result<Header, Error>
where Self: Tagged,

Get the Header used to encode this value. Read more
Source§

impl Encoding for BoxedUint

Source§

type Repr = Box<[u8]>

Byte array representation.
Source§

fn to_be_bytes(&self) -> Self::Repr

Encode to big endian bytes.
Source§

fn to_le_bytes(&self) -> Self::Repr

Encode to little endian bytes.
Source§

fn from_be_bytes(bytes: Self::Repr) -> Self

Decode from big endian bytes.
Source§

fn from_le_bytes(bytes: Self::Repr) -> Self

Decode from little endian bytes.
Source§

impl FixedTag for BoxedUint

Available on crate features der and hybrid-array only.
Source§

const TAG: Tag = Tag::Integer

ASN.1 tag
Source§

impl FloorSquareRoot for BoxedUint

Source§

fn floor_sqrt(&self) -> Self

Computes floor(sqrt(self)).
Source§

fn floor_sqrt_vartime(&self) -> Self

Computes floor(sqrt(self)). Read more
Source§

impl From<&[Limb]> for BoxedUint

Source§

fn from(limbs: &[Limb]) -> BoxedUint

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<&Odd<Uint<LIMBS>>> for BoxedUint

Source§

fn from(uint: &Odd<Uint<LIMBS>>) -> BoxedUint

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<&Uint<LIMBS>> for BoxedUint

Source§

fn from(uint: &Uint<LIMBS>) -> BoxedUint

Converts to this type from the input type.
Source§

impl From<&UintRef> for BoxedUint

Source§

fn from(uint_ref: &UintRef) -> BoxedUint

Converts to this type from the input type.
Source§

impl From<Box<[Limb]>> for BoxedUint

Source§

fn from(limbs: Box<[Limb]>) -> BoxedUint

Converts to this type from the input type.
Source§

impl From<Limb> for BoxedUint

Source§

fn from(limb: Limb) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Odd<Uint<LIMBS>>> for BoxedUint

Source§

fn from(uint: Odd<Uint<LIMBS>>) -> BoxedUint

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Uint<LIMBS>> for BoxedUint

Source§

fn from(uint: Uint<LIMBS>) -> BoxedUint

Converts to this type from the input type.
Source§

impl From<Vec<Limb>> for BoxedUint

Source§

fn from(limbs: Vec<Limb>) -> BoxedUint

Converts to this type from the input type.
Source§

impl From<Vec<u64>> for BoxedUint

Source§

fn from(words: Vec<Word>) -> BoxedUint

Converts to this type from the input type.
Source§

impl From<u128> for BoxedUint

Source§

fn from(n: u128) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for BoxedUint

Source§

fn from(n: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for BoxedUint

Source§

fn from(n: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for BoxedUint

Source§

fn from(n: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for BoxedUint

Source§

fn from(n: u8) -> Self

Converts to this type from the input type.
Source§

impl Gcd<BoxedUint> for NonZero<BoxedUint>

Source§

type Output = NonZero<BoxedUint>

Output type.
Source§

fn gcd(&self, rhs: &BoxedUint) -> Self::Output

Compute the greatest common divisor of self and rhs.
Source§

fn gcd_vartime(&self, rhs: &BoxedUint) -> Self::Output

Compute the greatest common divisor of self and rhs in variable time.
Source§

impl Gcd<BoxedUint> for Odd<BoxedUint>

Source§

type Output = Odd<BoxedUint>

Output type.
Source§

fn gcd(&self, rhs: &BoxedUint) -> Self::Output

Compute the greatest common divisor of self and rhs.
Source§

fn gcd_vartime(&self, rhs: &BoxedUint) -> Self::Output

Compute the greatest common divisor of self and rhs in variable time.
Source§

impl Gcd for BoxedUint

Source§

fn gcd(&self, rhs: &Self) -> Self

Compute the greatest common divisor (GCD) of this number and another.

Source§

type Output = BoxedUint

Output type.
Source§

fn gcd_vartime(&self, rhs: &Self) -> Self::Output

Compute the greatest common divisor of self and rhs in variable time.
Source§

impl Integer for BoxedUint

Source§

fn as_limbs(&self) -> &[Limb]

Borrow the raw limbs used to represent this integer.
Source§

fn as_mut_limbs(&mut self) -> &mut [Limb]

Mutably borrow the raw limbs used to represent this integer.
Source§

fn nlimbs(&self) -> usize

Number of limbs in this integer.
Source§

fn is_odd(&self) -> Choice

Is this integer value an odd number? Read more
Source§

fn is_even(&self) -> Choice

Is this integer value an even number? Read more
Source§

impl InvertMod for BoxedUint

Source§

type Output = BoxedUint

Output type.
Source§

fn invert_mod(&self, modulus: &NonZero<Self>) -> CtOption<Self>

Compute 1 / self mod p.
Source§

impl LowerHex for BoxedUint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Rhs: AsRef<UintRef>> Mul<Rhs> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> Mul<Rhs> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rhs) -> Self

Performs the * operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> MulAssign<Rhs> for BoxedUint

Source§

fn mul_assign(&mut self, rhs: Rhs)

Performs the *= operation. Read more
Source§

impl MulMod for BoxedUint

Source§

type Output = BoxedUint

Output type.
Source§

fn mul_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self

Compute self * rhs mod p.
Source§

impl NegMod for BoxedUint

Source§

type Output = BoxedUint

Output type.
Source§

fn neg_mod(&self, p: &NonZero<Self>) -> Self

Compute -self mod p.
Source§

impl Not for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl One for BoxedUint

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1.
Source§

fn one_like(other: &Self) -> Self

Return the value 0 with the same precision as other.
Source§

fn is_one(&self) -> Choice

Determine if this value is equal to 1. Read more
Source§

fn set_one(&mut self)

Set self to its multiplicative identity, i.e. Self::one.
Source§

impl One for BoxedUint

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

impl Ord for BoxedUint

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<Odd<BoxedUint>> for BoxedUint

Source§

fn eq(&self, other: &OddBoxedUint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Rhs: AsRef<UintRef> + ?Sized> PartialEq<Rhs> for BoxedUint

Source§

fn eq(&self, other: &Rhs) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<Odd<BoxedUint>> for BoxedUint

Source§

fn partial_cmp(&self, other: &OddBoxedUint) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Rhs: AsRef<UintRef> + ?Sized> PartialOrd<Rhs> for BoxedUint

Source§

fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PowBoundedExp<BoxedUint> for BoxedMontyForm

Source§

fn pow_bounded_exp(&self, exponent: &BoxedUint, exponent_bits: u32) -> Self

Raises to the exponent power, with exponent_bits representing the number of (least significant) bits to take into account for the exponent. Read more
Source§

impl RandomBits for BoxedUint

Available on crate feature rand_core only.
Source§

fn try_random_bits<R: TryRng + ?Sized>( rng: &mut R, bit_length: u32, ) -> Result<Self, RandomBitsError<R::Error>>

Generate a random value in range [0, 2^bit_length). Read more
Source§

fn try_random_bits_with_precision<R: TryRng + ?Sized>( rng: &mut R, bit_length: u32, bits_precision: u32, ) -> Result<Self, RandomBitsError<R::Error>>

Generate a random value in range [0, 2^bit_length), returning an integer with the closest available size to bits_precision (if the implementing type supports runtime sizing). Read more
Source§

fn random_bits<R: TryRng + ?Sized>(rng: &mut R, bit_length: u32) -> Self

Generate a random value in range [0, 2^bit_length). Read more
Source§

fn random_bits_with_precision<R: TryRng + ?Sized>( rng: &mut R, bit_length: u32, bits_precision: u32, ) -> Self

Generate a random value in range [0, 2^bit_length), returning an integer with the closest available size to bits_precision (if the implementing type supports runtime sizing). Read more
Source§

impl RandomMod for BoxedUint

Available on crate feature rand_core only.
Source§

fn random_mod_vartime<R: Rng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Self

Generate a random number which is less than a given modulus. Read more
Source§

fn try_random_mod_vartime<R: TryRng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Result<Self, R::Error>

Generate a random number which is less than a given modulus. Read more
Source§

fn random_mod<R: Rng + ?Sized>(rng: &mut R, modulus: &NonZero<Self>) -> Self

👎Deprecated since 0.7.0: please use random_mod_vartime instead
Generate a random number which is less than a given modulus. Read more
Source§

fn try_random_mod<R: TryRng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Result<Self, R::Error>

👎Deprecated since 0.7.0: please use try_random_mod_vartime instead
Generate a random number which is less than a given modulus. Read more
Source§

impl<Rhs: ToUnsigned + ?Sized> Rem<&NonZero<Rhs>> for &BoxedUint

Source§

type Output = <Rhs as ToUnsigned>::Unsigned

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &NonZero<Rhs>) -> Self::Output

Performs the % operation. Read more
Source§

impl<Rhs: ToUnsigned + ?Sized> Rem<&NonZero<Rhs>> for BoxedUint

Source§

type Output = <Rhs as ToUnsigned>::Unsigned

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &NonZero<Rhs>) -> Self::Output

Performs the % operation. Read more
Source§

impl<Rhs: AsMut<UintRef>> Rem<NonZero<Rhs>> for &BoxedUint

Source§

type Output = Rhs

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NonZero<Rhs>) -> Self::Output

Performs the % operation. Read more
Source§

impl<Rhs: AsMut<UintRef>> Rem<NonZero<Rhs>> for BoxedUint

Source§

type Output = Rhs

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NonZero<Rhs>) -> Self::Output

Performs the % operation. Read more
Source§

impl<Rhs: AsRef<UintRef> + ?Sized> RemAssign<&NonZero<Rhs>> for BoxedUint

Source§

fn rem_assign(&mut self, rhs: &NonZero<Rhs>)

Performs the %= operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> RemAssign<NonZero<Rhs>> for BoxedUint

Source§

fn rem_assign(&mut self, rhs: NonZero<Rhs>)

Performs the %= operation. Read more
Source§

impl RemLimb for BoxedUint

Source§

fn rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> Limb

Computes self % rhs.
Source§

fn rem_limb(&self, rhs: NonZero<Limb>) -> Limb

Computes self % rhs using a pre-made reciprocal.
Source§

impl<Rhs: Unsigned> RemMixed<Rhs> for BoxedUint

Source§

fn rem_mixed(&self, reductor: &NonZero<Rhs>) -> Rhs

Calculate the remainder of self by the reductor.
Source§

impl Resize for &BoxedUint

Source§

type Output = BoxedUint

The result of the resizing.
Source§

fn resize_unchecked(self, at_least_bits_precision: u32) -> Self::Output

Resizes to the minimum storage that fits at_least_bits_precision without checking if the bit size of self is larger than at_least_bits_precision. Read more
Source§

fn try_resize(self, at_least_bits_precision: u32) -> Option<BoxedUint>

Resizes to the minimum storage that fits at_least_bits_precision returning None if the bit size of self is larger than at_least_bits_precision. Read more
Source§

fn resize(self, at_least_bits_precision: u32) -> Self::Output

Resizes to the minimum storage that fits at_least_bits_precision panicking if the bit size of self is larger than at_least_bits_precision. Read more
Source§

impl Resize for BoxedUint

Source§

type Output = BoxedUint

The result of the resizing.
Source§

fn resize_unchecked(self, at_least_bits_precision: u32) -> Self::Output

Resizes to the minimum storage that fits at_least_bits_precision without checking if the bit size of self is larger than at_least_bits_precision. Read more
Source§

fn try_resize(self, at_least_bits_precision: u32) -> Option<BoxedUint>

Resizes to the minimum storage that fits at_least_bits_precision returning None if the bit size of self is larger than at_least_bits_precision. Read more
Source§

fn resize(self, at_least_bits_precision: u32) -> Self::Output

Resizes to the minimum storage that fits at_least_bits_precision panicking if the bit size of self is larger than at_least_bits_precision. Read more
Source§

impl Serialize for BoxedUint

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Shl<i32> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the << operator.
Source§

fn shl(self, shift: i32) -> BoxedUint

Performs the << operation. Read more
Source§

impl Shl<i32> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the << operator.
Source§

fn shl(self, shift: i32) -> BoxedUint

Performs the << operation. Read more
Source§

impl Shl<u32> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the << operator.
Source§

fn shl(self, shift: u32) -> BoxedUint

Performs the << operation. Read more
Source§

impl Shl<u32> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the << operator.
Source§

fn shl(self, shift: u32) -> BoxedUint

Performs the << operation. Read more
Source§

impl Shl<usize> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the << operator.
Source§

fn shl(self, shift: usize) -> BoxedUint

Performs the << operation. Read more
Source§

impl Shl<usize> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the << operator.
Source§

fn shl(self, shift: usize) -> BoxedUint

Performs the << operation. Read more
Source§

impl ShlAssign<i32> for BoxedUint

Source§

fn shl_assign(&mut self, shift: i32)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u32> for BoxedUint

Source§

fn shl_assign(&mut self, shift: u32)

Performs the <<= operation. Read more
Source§

impl ShlAssign<usize> for BoxedUint

Source§

fn shl_assign(&mut self, shift: usize)

Performs the <<= operation. Read more
Source§

impl ShlVartime for BoxedUint

Source§

fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>

Computes self << shift. Read more
Source§

fn unbounded_shl_vartime(&self, shift: u32) -> Self

Computes self << shift. Read more
Source§

fn wrapping_shl_vartime(&self, shift: u32) -> Self

Computes self << shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.
Source§

impl Shr<i32> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: i32) -> BoxedUint

Performs the >> operation. Read more
Source§

impl Shr<i32> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: i32) -> BoxedUint

Performs the >> operation. Read more
Source§

impl Shr<u32> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: u32) -> BoxedUint

Performs the >> operation. Read more
Source§

impl Shr<u32> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: u32) -> BoxedUint

Performs the >> operation. Read more
Source§

impl Shr<usize> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: usize) -> BoxedUint

Performs the >> operation. Read more
Source§

impl Shr<usize> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: usize) -> BoxedUint

Performs the >> operation. Read more
Source§

impl ShrAssign<i32> for BoxedUint

Source§

fn shr_assign(&mut self, shift: i32)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u32> for BoxedUint

Source§

fn shr_assign(&mut self, shift: u32)

Performs the >>= operation. Read more
Source§

impl ShrAssign<usize> for BoxedUint

Source§

fn shr_assign(&mut self, shift: usize)

Performs the >>= operation. Read more
Source§

impl ShrVartime for BoxedUint

Source§

fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>

Computes self >> shift. Read more
Source§

fn unbounded_shr_vartime(&self, shift: u32) -> Self

Computes self >> shift. Read more
Source§

fn wrapping_shr_vartime(&self, shift: u32) -> Self

Computes self >> shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.
Source§

impl SquareMod for BoxedUint

Source§

type Output = BoxedUint

Output type.
Source§

fn square_mod(&self, p: &NonZero<Self>) -> Self

Compute self * self mod p.
Source§

impl<Rhs: AsRef<UintRef>> Sub<Rhs> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Rhs) -> BoxedUint

Performs the - operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> Sub<Rhs> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Rhs) -> Self

Performs the - operation. Read more
Source§

impl Sub<u128> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u128) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u128> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u128) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u16> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u16) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u16> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u16) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u32> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u32) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u32> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u32) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u64> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u64) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u64> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u64) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u8> for &BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u8) -> BoxedUint

Performs the - operation. Read more
Source§

impl Sub<u8> for BoxedUint

Source§

type Output = BoxedUint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u8) -> BoxedUint

Performs the - operation. Read more
Source§

impl<Rhs: AsRef<UintRef>> SubAssign<Rhs> for BoxedUint

Source§

fn sub_assign(&mut self, rhs: Rhs)

Performs the -= operation. Read more
Source§

impl SubAssign<u128> for BoxedUint

Source§

fn sub_assign(&mut self, rhs: u128)

Performs the -= operation. Read more
Source§

impl SubAssign<u16> for BoxedUint

Source§

fn sub_assign(&mut self, rhs: u16)

Performs the -= operation. Read more
Source§

impl SubAssign<u32> for BoxedUint

Source§

fn sub_assign(&mut self, rhs: u32)

Performs the -= operation. Read more
Source§

impl SubAssign<u64> for BoxedUint

Source§

fn sub_assign(&mut self, rhs: u64)

Performs the -= operation. Read more
Source§

impl SubAssign<u8> for BoxedUint

Source§

fn sub_assign(&mut self, rhs: u8)

Performs the -= operation. Read more
Source§

impl SubMod for BoxedUint

Source§

type Output = BoxedUint

Output type.
Source§

fn sub_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self

Compute self - rhs mod p. Read more
Source§

impl Unsigned for BoxedUint

Source§

fn as_uint_ref(&self) -> &UintRef

Borrow the limbs of this unsigned integer as a UintRef.
Source§

fn as_mut_uint_ref(&mut self) -> &mut UintRef

Mutably borrow the limbs of this unsigned integer as a UintRef.
Source§

fn from_limb_like(limb: Limb, other: &Self) -> Self

Returns an integer with the first limb set to limb, and the same precision as other.
Source§

impl UnsignedWithMontyForm for BoxedUint

Source§

type MontyForm = BoxedMontyForm

The corresponding Montgomery representation, optimized for the performance of modular operations at the price of a conversion overhead.
Source§

impl UpperHex for BoxedUint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl WrappingAdd for BoxedUint

Source§

fn wrapping_add(&self, v: &Self) -> Self

Wrapping (modular) addition. Computes self + other, wrapping around at the boundary of the type.
Source§

impl WrappingMul for BoxedUint

Source§

fn wrapping_mul(&self, v: &Self) -> Self

Wrapping (modular) multiplication. Computes self * other, wrapping around at the boundary of the type.
Source§

impl WrappingNeg for BoxedUint

Source§

fn wrapping_neg(&self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type. Read more
Source§

impl WrappingShl for BoxedUint

Source§

fn wrapping_shl(&self, shift: u32) -> BoxedUint

Panic-free bitwise shift-left; yields self << mask(rhs), where mask removes any high order bits of rhs that would cause the shift to exceed the bitwidth of the type. Read more
Source§

impl WrappingShr for BoxedUint

Source§

fn wrapping_shr(&self, shift: u32) -> BoxedUint

Panic-free bitwise shift-right; yields self >> mask(rhs), where mask removes any high order bits of rhs that would cause the shift to exceed the bitwidth of the type. Read more
Source§

impl WrappingSub for BoxedUint

Source§

fn wrapping_sub(&self, v: &Self) -> Self

Wrapping (modular) subtraction. Computes self - other, wrapping around at the boundary of the type.
Source§

impl Zero for BoxedUint

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0.
Source§

fn is_zero(&self) -> Choice

Determine if this value is equal to 0. Read more
Source§

fn set_zero(&mut self)

Set self to its additive identity, i.e. Self::zero.
Source§

fn zero_like(other: &Self) -> Self
where Self: Clone,

Return the value 0 with the same precision as other.
Source§

impl Zero for BoxedUint

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Zeroize for BoxedUint

Available on crate feature zeroize only.
Source§

fn zeroize(&mut self)

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

impl Eq for BoxedUint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T, Rhs> InvMod<Rhs> for T
where T: InvertMod<Rhs>,

Source§

type Output = <T as InvertMod<Rhs>>::Output

👎Deprecated since 0.7.0: please use InvertMod instead
Output type.
Source§

fn inv_mod(&self, p: &Rhs) -> CtOption<<T as InvMod<Rhs>>::Output>

👎Deprecated since 0.7.0: please use InvertMod instead
Compute 1 / self mod p.
Source§

impl<T, Rhs> WideningMul<Rhs> for T
where T: ConcatenatingMul<Rhs>,

Source§

type Output = <T as ConcatenatingMul<Rhs>>::Output

👎Deprecated since 0.7.0: please use ConcatenatingMul instead
Output of the widening multiplication.
Source§

fn widening_mul(&self, rhs: Rhs) -> <T as WideningMul<Rhs>>::Output

👎Deprecated since 0.7.0: please use ConcatenatingMul instead
Perform widening multiplication.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<'a, T> Choice<'a> for T
where T: Decode<'a> + FixedTag,

Source§

fn can_decode(tag: Tag) -> bool

Is the provided Tag decodable as a variant of this CHOICE?
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, const N: usize> CtSelectArray<N> for T

Source§

fn ct_select_array(a: &[T; N], b: &[T; N], choice: Choice) -> [T; N]

Select between a and b in constant-time based on choice.
Source§

impl<'a, T> Decode<'a> for T
where T: DecodeValue<'a> + FixedTag + 'a,

Source§

type Error = <T as DecodeValue<'a>>::Error

Type returned in the event of a decoding error.
Source§

fn decode<R>(reader: &mut R) -> Result<T, <T as DecodeValue<'a>>::Error>
where R: Reader<'a>,

Attempt to decode this TLV message using the provided decoder. Read more
Source§

fn from_der(bytes: &'a [u8]) -> Result<Self, Self::Error>

Parse Self from the provided DER-encoded byte slice. Read more
Source§

fn from_der_partial(bytes: &'a [u8]) -> Result<(Self, &'a [u8]), Self::Error>

Parse Self from the provided DER-encoded byte slice. Read more
Source§

impl<T> Encode for T
where T: EncodeValue + Tagged + ?Sized,

Source§

fn encoded_len(&self) -> Result<Length, Error>

Compute the length of this TLV object in bytes when encoded as ASN.1 DER. Read more
Source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

Encode this TLV object as ASN.1 DER using the provided Writer. Read more
Source§

fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>

Encode this TLV object to the provided byte slice, returning a sub-slice containing the encoded message. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IsConstructed for T
where T: FixedTag + ?Sized,

Source§

const CONSTRUCTED: bool

ASN.1 constructed bit
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tagged for T
where T: FixedTag + ?Sized,

Source§

fn tag(&self) -> Tag

Get the ASN.1 tag that this type is encoded with.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToUnsigned for T
where T: Unsigned,

Source§

type Unsigned = T

The corresponding owned Unsigned type.
Source§

fn to_unsigned(&self) -> <T as ToUnsigned>::Unsigned

Convert from a reference into an owned instance.
Source§

fn to_unsigned_zero(&self) -> <T as ToUnsigned>::Unsigned

Convert from a reference into an owned instance representing zero.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DecodeOwned for T
where T: for<'a> Decode<'a>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,