pub struct BoxedUint { /* private fields */ }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
impl BoxedUint
Sourcepub fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)
👎Deprecated since 0.7.0: please use carrying_add instead
pub fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)
carrying_add insteadComputes self + rhs + carry, returning the result along with the new carry.
Sourcepub fn carrying_add(
&self,
rhs: impl AsRef<UintRef>,
carry: Limb,
) -> (Self, Limb)
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.
Sourcepub fn adc_assign(&mut self, rhs: impl AsRef<[Limb]>, carry: Limb) -> Limb
👎Deprecated since 0.7.0: please use carrying_add_assign instead
pub fn adc_assign(&mut self, rhs: impl AsRef<[Limb]>, carry: Limb) -> Limb
carrying_add_assign insteadComputes self + rhs + carry in-place, returning the new carry.
§Panics
- if
rhshas a larger precision thanself.
Sourcepub fn concatenating_add(&self, rhs: impl AsRef<UintRef>) -> Self
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.
Sourcepub fn overflowing_add(&self, rhs: impl AsRef<UintRef>) -> (Self, Choice)
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.
Sourcepub fn overflowing_add_assign(&mut self, rhs: impl AsRef<UintRef>) -> Choice
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.
Sourcepub fn wrapping_add(&self, rhs: impl AsRef<UintRef>) -> Self
pub fn wrapping_add(&self, rhs: impl AsRef<UintRef>) -> Self
Perform wrapping addition, discarding overflow.
Sourcepub fn wrapping_add_assign(&mut self, rhs: impl AsRef<UintRef>)
pub fn wrapping_add_assign(&mut self, rhs: impl AsRef<UintRef>)
Perform wrapping addition of rhs to self, discarding overflow.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn add_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self
pub fn add_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self
Computes self + rhs mod p.
Assumes self + rhs as unbounded integer is < 2p.
Sourcepub fn add_mod_assign(&mut self, rhs: &Self, p: &NonZero<Self>)
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.
Sourcepub fn double_mod(&self, p: &NonZero<Self>) -> Self
pub fn double_mod(&self, p: &NonZero<Self>) -> Self
Computes self + self mod p.
Assumes self as unbounded integer is < p.
Sourcepub fn add_mod_special(&self, rhs: &Self, c: Limb) -> Self
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
impl BoxedUint
Sourcepub fn bitand_limb(&self, rhs: Limb) -> Self
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.
Sourcepub fn wrapping_and(&self, rhs: &Self) -> Self
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
Sourcepub fn checked_and(&self, rhs: &Self) -> CtOption<Self>
pub fn checked_and(&self, rhs: &Self) -> CtOption<Self>
Perform checked bitwise AND, returning a CtOption which is_some always
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn wrapping_or(&self, rhs: &Self) -> Self
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
Sourcepub fn checked_or(&self, rhs: &Self) -> CtOption<Self>
pub fn checked_or(&self, rhs: &Self) -> CtOption<Self>
Perform checked bitwise OR, returning a CtOption which is_some always
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn wrapping_xor(&self, rhs: &Self) -> Self
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
Sourcepub fn checked_xor(&self, rhs: &Self) -> CtOption<Self>
pub fn checked_xor(&self, rhs: &Self) -> CtOption<Self>
Perform checked bitwise XOR, returning a CtOption which is_some always
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn bit(&self, index: u32) -> Choice
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.
Sourcepub const fn bit_vartime(&self, index: u32) -> bool
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.
Sourcepub fn bits(&self) -> u32
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.
Sourcepub fn bits_vartime(&self) -> u32
pub fn bits_vartime(&self) -> u32
Calculate the number of bits needed to represent this number in variable-time with respect
to self.
Sourcepub const fn leading_zeros(&self) -> u32
pub const fn leading_zeros(&self) -> u32
Calculate the number of leading zeros in the binary representation of this number.
Sourcepub fn bits_precision(&self) -> u32
pub fn bits_precision(&self) -> u32
Get the precision of this BoxedUint in bits.
Sourcepub fn trailing_zeros(&self) -> u32
pub fn trailing_zeros(&self) -> u32
Calculate the number of trailing zeros in the binary representation of this number.
Sourcepub fn trailing_ones(&self) -> u32
pub fn trailing_ones(&self) -> u32
Calculate the number of trailing ones in the binary representation of this number.
Sourcepub fn trailing_zeros_vartime(&self) -> u32
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.
Sourcepub fn trailing_ones_vartime(&self) -> u32
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
impl BoxedUint
Sourcepub fn cmp_vartime(&self, rhs: impl AsRef<UintRef>) -> Ordering
pub fn cmp_vartime(&self, rhs: impl AsRef<UintRef>) -> Ordering
Returns the Ordering between self and rhs in variable time.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn div_rem_limb_with_reciprocal(
&self,
reciprocal: &Reciprocal,
) -> (Self, Limb)
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).
Sourcepub fn div_rem_limb(&self, rhs: NonZero<Limb>) -> (Self, Limb)
pub fn div_rem_limb(&self, rhs: NonZero<Limb>) -> (Self, Limb)
Computes self / rhs, returns the quotient (q) and remainder (r).
Sourcepub fn rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> Limb
pub fn rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> Limb
Computes self % rhs using a pre-made reciprocal.
Sourcepub fn div_rem<Rhs: ToUnsigned + ?Sized>(
&self,
rhs: &NonZero<Rhs>,
) -> (Self, Rhs::Unsigned)
pub fn div_rem<Rhs: ToUnsigned + ?Sized>( &self, rhs: &NonZero<Rhs>, ) -> (Self, Rhs::Unsigned)
Computes self / rhs, returns the quotient, remainder.
Sourcepub fn rem<Rhs: ToUnsigned + ?Sized>(&self, rhs: &NonZero<Rhs>) -> Rhs::Unsigned
pub fn rem<Rhs: ToUnsigned + ?Sized>(&self, rhs: &NonZero<Rhs>) -> Rhs::Unsigned
Computes self % rhs, returns the remainder.
Sourcepub fn div_rem_vartime<Rhs: ToUnsigned + ?Sized>(
&self,
rhs: &NonZero<Rhs>,
) -> (Self, Rhs::Unsigned)
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
Sourcepub fn rem_vartime<Rhs: ToUnsigned + ?Sized>(
&self,
rhs: &NonZero<Rhs>,
) -> Rhs::Unsigned
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.
Sourcepub fn wrapping_div<Rhs: ToUnsigned + ?Sized>(&self, rhs: &NonZero<Rhs>) -> Self
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.
Sourcepub fn wrapping_div_vartime<Rhs: ToUnsigned + ?Sized>(
&self,
rhs: &NonZero<Rhs>,
) -> Self
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§impl BoxedUint
impl BoxedUint
Sourcepub fn from_be_slice(
bytes: &[u8],
bits_precision: u32,
) -> Result<Self, DecodeError>
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
- Returns
DecodeError::InputSizeif the length ofbytesis larger thanbits_precision(rounded up to a multiple of 8). - Returns
DecodeError::Precisionif the size of the decoded integer is larger thanbits_precision.
Sourcepub fn from_be_slice_vartime(bytes: &[u8]) -> Self
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.
Sourcepub fn from_le_slice(
bytes: &[u8],
bits_precision: u32,
) -> Result<Self, DecodeError>
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
- Returns
DecodeError::InputSizeif the length ofbytesis larger thanbits_precision(rounded up to a multiple of 8). - Returns
DecodeError::Precisionif the size of the decoded integer is larger thanbits_precision.
Sourcepub fn from_le_slice_vartime(bytes: &[u8]) -> Self
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.
Sourcepub fn to_be_bytes(&self) -> Box<[u8]>
pub fn to_be_bytes(&self) -> Box<[u8]>
Serialize this BoxedUint as big-endian.
Sourcepub fn to_be_bytes_trimmed_vartime(&self) -> Box<[u8]>
pub fn to_be_bytes_trimmed_vartime(&self) -> Box<[u8]>
Serialize this BoxedUint as big-endian without leading zeroes.
Sourcepub fn to_le_bytes(&self) -> Box<[u8]>
pub fn to_le_bytes(&self) -> Box<[u8]>
Serialize this BoxedUint as little-endian.
Sourcepub fn to_le_bytes_trimmed_vartime(&self) -> Box<[u8]>
pub fn to_le_bytes_trimmed_vartime(&self) -> Box<[u8]>
Serialize this BoxedUint as little-endian without trailing zeroes.
Sourcepub fn from_be_hex(hex: &str, bits_precision: u32) -> CtOption<Self>
pub fn from_be_hex(hex: &str, bits_precision: u32) -> CtOption<Self>
Sourcepub fn from_str_radix_vartime(
src: &str,
radix: u32,
) -> Result<Self, DecodeError>
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::InvalidDigitif the input value contains non-digit characters or digits outside of the range0..radix.
§Panics
- if
radixis not in the range from 2 to 36.
Sourcepub fn from_str_radix_with_precision_vartime(
src: &str,
radix: u32,
bits_precision: u32,
) -> Result<Self, DecodeError>
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
- Returns
DecodeError::InputSizeif the length ofbytesis larger thanbits_precision(rounded up to a multiple of 8). - Returns
DecodeError::InvalidDigitif the input value contains non-digit characters or digits are outside the range0..radix. - Returns
DecodeError::Precisionif the size of the decoded integer is larger thanbits_precision.
§Panics
- if
radixis not in the range from 2 to 36.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn inv_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>
👎Deprecated since 0.7.0: please use invert_odd_mod instead
pub fn inv_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>
invert_odd_mod insteadComputes the multiplicative inverse of self mod modulus, where modulus is odd.
Sourcepub fn invert_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>
pub fn invert_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>
Computes the multiplicative inverse of self mod modulus, where modulus is odd.
Sourcepub fn invert_odd_mod_vartime(&self, modulus: &Odd<Self>) -> CtOption<Self>
pub fn invert_odd_mod_vartime(&self, modulus: &Odd<Self>) -> CtOption<Self>
Computes the multiplicative inverse of self mod modulus, where modulus is odd.
Sourcepub fn inv_mod2k_vartime(&self, k: u32) -> (Self, Choice)
👎Deprecated since 0.7.0: please use invert_mod2k_vartime instead
pub fn inv_mod2k_vartime(&self, k: u32) -> (Self, Choice)
invert_mod2k_vartime insteadComputes 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.
Sourcepub fn invert_mod2k_vartime(&self, k: u32) -> (Self, Choice)
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.
Sourcepub fn inv_mod2k(&self, k: u32) -> (Self, Choice)
👎Deprecated since 0.7.0: please use invert_mod2k instead
pub fn inv_mod2k(&self, k: u32) -> (Self, Choice)
invert_mod2k insteadComputes 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.
Sourcepub fn invert_mod2k(&self, k: u32) -> (Self, Choice)
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.
Sourcepub fn inv_mod(&self, modulus: &Self) -> CtOption<Self>
👎Deprecated since 0.7.0: please use invert_mod instead
pub fn inv_mod(&self, modulus: &Self) -> CtOption<Self>
invert_mod insteadComputes 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
Sourcepub fn invert_mod(&self, modulus: &NonZero<Self>) -> CtOption<Self>
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
impl BoxedUint
Sourcepub fn mul(&self, rhs: impl AsRef<UintRef>) -> Self
👎Deprecated since 0.7.0: please use concatenating_mul
pub fn mul(&self, rhs: impl AsRef<UintRef>) -> Self
concatenating_mulMultiply self by rhs.
Returns a widened output with a limb count equal to the sums of the input limb counts.
Sourcepub fn wrapping_mul(&self, rhs: impl AsRef<UintRef>) -> Self
pub fn wrapping_mul(&self, rhs: impl AsRef<UintRef>) -> Self
Perform wrapping multiplication, wrapping to the width of self.
Sourcepub fn checked_mul(&self, rhs: impl AsRef<UintRef>) -> CtOption<Self>
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.
Sourcepub fn saturating_mul(&self, rhs: impl AsRef<UintRef>) -> Self
pub fn saturating_mul(&self, rhs: impl AsRef<UintRef>) -> Self
Perform saturating multiplication, returning MAX on overflow.
Sourcepub fn square(&self) -> Self
👎Deprecated since 0.7.0: please use concatenating_square
pub fn square(&self) -> Self
concatenating_squareMultiply self by itself.
Sourcepub fn wrapping_square(&self) -> Self
pub fn wrapping_square(&self) -> Self
Multiply self by itself, wrapping to the width of self.
Sourcepub fn checked_square(&self) -> CtOption<Self>
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.
Sourcepub fn saturating_square(&self) -> Self
pub fn saturating_square(&self) -> Self
Perform saturating squaring, returning MAX on overflow.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn mul_mod(&self, rhs: &BoxedUint, p: &NonZero<BoxedUint>) -> BoxedUint
pub fn mul_mod(&self, rhs: &BoxedUint, p: &NonZero<BoxedUint>) -> BoxedUint
Computes self * rhs mod p for non-zero p.
Sourcepub fn mul_mod_special(&self, rhs: &Self, c: Limb) -> Self
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.
Sourcepub fn square_mod(&self, p: &NonZero<BoxedUint>) -> Self
pub fn square_mod(&self, p: &NonZero<BoxedUint>) -> Self
Computes self * self mod p.
Sourcepub fn square_mod_vartime(&self, p: &NonZero<BoxedUint>) -> Self
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
impl BoxedUint
Sourcepub fn wrapping_neg(&self) -> Self
pub fn wrapping_neg(&self) -> Self
Perform wrapping negation.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn checked_pow(&self, exp: impl AsRef<UintRef>) -> CtOption<Self>
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.
Sourcepub fn checked_pow_bounded_exp(
&self,
exp: impl AsRef<UintRef>,
exp_bits: u32,
) -> CtOption<Self>
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_bitsexceeds the capacity ofrhs
Sourcepub fn checked_pow_vartime(&self, exp: impl AsRef<UintRef>) -> CtOption<Self>
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.
Sourcepub fn saturating_pow(&self, exp: impl AsRef<UintRef>) -> Self
pub fn saturating_pow(&self, exp: impl AsRef<UintRef>) -> Self
Computes self^exp, returning a Self::MAX in the case of overflow.
Sourcepub fn saturating_pow_bounded_exp(
&self,
exp: impl AsRef<UintRef>,
exp_bits: u32,
) -> Self
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_bitsexceeds the capacity ofrhs
Sourcepub fn saturating_pow_vartime(&self, exp: impl AsRef<UintRef>) -> Self
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.
Sourcepub fn wrapping_pow(&self, exp: impl AsRef<UintRef>) -> Self
pub fn wrapping_pow(&self, exp: impl AsRef<UintRef>) -> Self
Computes self^exp, discarding overflow.
Sourcepub fn wrapping_pow_bounded_exp(
&self,
exp: impl AsRef<UintRef>,
exp_bits: u32,
) -> Self
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_bitsexceeds the capacity ofrhs
Sourcepub fn wrapping_pow_vartime(&self, exp: impl AsRef<UintRef>) -> Self
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
impl BoxedUint
Sourcepub fn shl_assign(&mut self, shift: u32)
pub fn shl_assign(&mut self, shift: u32)
Sourcepub fn overflowing_shl(&self, shift: u32) -> CtOption<Self>
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.
Sourcepub fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>
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.
Sourcepub fn overflowing_shl_assign(&mut self, shift: u32) -> Choice
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.
Sourcepub fn overflowing_shl_assign_vartime(&mut self, shift: u32) -> bool
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.
Sourcepub fn unbounded_shl(&self, shift: u32) -> Self
pub fn unbounded_shl(&self, shift: u32) -> Self
Computes self << shift in a panic-free manner, producing zero in the case of overflow.
Sourcepub fn unbounded_shl_assign(&mut self, shift: u32)
pub fn unbounded_shl_assign(&mut self, shift: u32)
Computes self <<= shift in a panic-free manner, producing zero in the case of overflow.
Sourcepub fn unbounded_shl_vartime(&self, shift: u32) -> Self
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.
Sourcepub fn unbounded_shl_assign_vartime(&mut self, shift: u32)
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.
Sourcepub fn wrapping_shl(&self, shift: u32) -> Self
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.
Sourcepub fn wrapping_shl_assign(&mut self, shift: u32)
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.
Sourcepub fn wrapping_shl_vartime(&self, shift: u32) -> Self
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.
Sourcepub fn wrapping_shl_assign_vartime(&mut self, shift: u32)
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.
Sourcepub fn shl_vartime(&self, shift: u32) -> Option<Self>
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
impl BoxedUint
Sourcepub fn shr_assign(&mut self, shift: u32)
pub fn shr_assign(&mut self, shift: u32)
Sourcepub fn overflowing_shr(&self, shift: u32) -> CtOption<Self>
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.
Sourcepub fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>
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.
Sourcepub fn overflowing_shr_assign(&mut self, shift: u32) -> Choice
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.
Sourcepub fn overflowing_shr_assign_vartime(&mut self, shift: u32) -> bool
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.
Sourcepub fn unbounded_shr(&self, shift: u32) -> Self
pub fn unbounded_shr(&self, shift: u32) -> Self
Computes self >> shift in a panic-free manner, producing zero in the case of overflow.
Sourcepub fn unbounded_shr_assign(&mut self, shift: u32)
pub fn unbounded_shr_assign(&mut self, shift: u32)
Computes self >>= shift in a panic-free manner, producing zero in the case of overflow.
Sourcepub fn unbounded_shr_vartime(&self, shift: u32) -> Self
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.
Sourcepub fn unbounded_shr_assign_vartime(&mut self, shift: u32)
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.
Sourcepub fn wrapping_shr(&self, shift: u32) -> Self
pub fn wrapping_shr(&self, shift: u32) -> Self
Computes self >> shift in a panic-free manner, reducing shift modulo the type’s width.
Sourcepub fn wrapping_shr_assign(&mut self, shift: u32)
pub fn wrapping_shr_assign(&mut self, shift: u32)
Computes self >>= shift in a panic-free manner, reducing shift modulo the type’s width.
Sourcepub fn wrapping_shr_vartime(&self, shift: u32) -> Self
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.
Sourcepub fn wrapping_shr_assign_vartime(&mut self, shift: u32)
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.
Sourcepub fn shr_vartime(&self, shift: u32) -> Option<Self>
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
impl BoxedUint
Sourcepub fn sqrt(&self) -> Self
👎Deprecated since 0.7.0: please use floor_sqrt instead
pub fn sqrt(&self) -> Self
floor_sqrt insteadComputes floor(√(self)) in constant time.
Callers can check if self is a square by squaring the result.
Sourcepub fn floor_sqrt(&self) -> Self
pub fn floor_sqrt(&self) -> Self
Computes √(self) in constant time.
Callers can check if self is a square by squaring the result.
Sourcepub fn sqrt_vartime(&self) -> Self
👎Deprecated since 0.7.0: please use floor_sqrt_vartime instead
pub fn sqrt_vartime(&self) -> Self
floor_sqrt_vartime insteadComputes floor(√(self)).
Callers can check if self is a square by squaring the result.
Variable time with respect to self.
Sourcepub fn floor_sqrt_vartime(&self) -> Self
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.
Sourcepub fn wrapping_sqrt(&self) -> Self
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.
Sourcepub fn wrapping_sqrt_vartime(&self) -> Self
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.
Sourcepub fn checked_sqrt(&self) -> CtOption<Self>
pub fn checked_sqrt(&self) -> CtOption<Self>
Perform checked sqrt, returning a CtOption which is_some
only if the square root is exact.
Sourcepub fn checked_sqrt_vartime(&self) -> Option<Self>
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
impl BoxedUint
Sourcepub fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)
👎Deprecated since 0.7.0: please use borrowing_sub instead
pub fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)
borrowing_sub insteadComputes self - (rhs + borrow), returning the result along with the new borrow.
Sourcepub fn borrowing_sub(
&self,
rhs: impl AsRef<UintRef>,
borrow: Limb,
) -> (Self, Limb)
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.
Sourcepub fn sbb_assign(&mut self, rhs: impl AsRef<[Limb]>, borrow: Limb) -> Limb
👎Deprecated since 0.7.0: please use borrowing_sub_assign instead
pub fn sbb_assign(&mut self, rhs: impl AsRef<[Limb]>, borrow: Limb) -> Limb
borrowing_sub_assign insteadComputes a - (b + borrow) in-place, returning the new borrow.
§Panics
- if
rhshas a larger precision thanself.
Sourcepub fn underflowing_sub(&self, rhs: impl AsRef<UintRef>) -> (Self, Choice)
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.
Sourcepub fn underflowing_sub_assign(&mut self, rhs: impl AsRef<UintRef>) -> Choice
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.
Sourcepub fn wrapping_sub(&self, rhs: impl AsRef<UintRef>) -> Self
pub fn wrapping_sub(&self, rhs: impl AsRef<UintRef>) -> Self
Perform wrapping subtraction, discarding underflow.
Sourcepub fn wrapping_sub_assign(&mut self, rhs: impl AsRef<UintRef>)
pub fn wrapping_sub_assign(&mut self, rhs: impl AsRef<UintRef>)
Perform wrapping subtraction of rhs from self, discarding underflow.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn sub_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self
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).
Sourcepub fn sub_mod_special(&self, rhs: &Self, c: Limb) -> Self
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
impl BoxedUint
Sourcepub fn zero_with_precision(at_least_bits_precision: u32) -> Self
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.
Sourcepub fn one_with_precision(at_least_bits_precision: u32) -> Self
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.
Sourcepub fn is_nonzero(&self) -> Choice
pub fn is_nonzero(&self) -> Choice
Is this BoxedUint NOT equal to zero?
Sourcepub fn max(at_least_bits_precision: u32) -> Self
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.
Sourcepub fn from_words(words: impl IntoIterator<Item = Word>) -> Self
pub fn from_words(words: impl IntoIterator<Item = Word>) -> Self
Sourcepub fn from_words_with_precision(
words: impl IntoIterator<Item = Word>,
at_least_bits_precision: u32,
) -> Self
pub fn from_words_with_precision( words: impl IntoIterator<Item = Word>, at_least_bits_precision: u32, ) -> Self
Sourcepub fn as_mut_words(&mut self) -> &mut [Word]
pub fn as_mut_words(&mut self) -> &mut [Word]
Borrow the inner limbs as a mutable slice of Words.
Sourcepub fn as_words_mut(&mut self) -> &mut [Word]
👎Deprecated since 0.7.0: please use as_mut_words instead
pub fn as_words_mut(&mut self) -> &mut [Word]
as_mut_words insteadBorrow the inner limbs as a mutable slice of Words.
Sourcepub fn as_mut_limbs(&mut self) -> &mut [Limb]
pub fn as_mut_limbs(&mut self) -> &mut [Limb]
Borrow the limbs of this BoxedUint mutably.
Sourcepub fn as_limbs_mut(&mut self) -> &mut [Limb]
👎Deprecated since 0.7.0: please use as_mut_limbs instead
pub fn as_limbs_mut(&mut self) -> &mut [Limb]
as_mut_limbs insteadBorrow the limbs of this BoxedUint mutably.
Sourcepub fn into_limbs(self) -> Box<[Limb]>
pub fn into_limbs(self) -> Box<[Limb]>
Convert this BoxedUint into its inner limbs.
Sourcepub const fn as_uint_ref(&self) -> &UintRef
pub const fn as_uint_ref(&self) -> &UintRef
Sourcepub const fn as_mut_uint_ref(&mut self) -> &mut UintRef
pub const fn as_mut_uint_ref(&mut self) -> &mut UintRef
Sourcepub fn to_nz(&self) -> CtOption<NonZero<Self>>
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.
Sourcepub fn to_odd(&self) -> CtOption<Odd<Self>>
pub fn to_odd(&self) -> CtOption<Odd<Self>>
Convert to an Odd<BoxedUint>.
Returns some if the original value is odd, and false otherwise.
Sourcepub fn into_nz(self) -> CtOption<NonZero<Self>>
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.
Sourcepub fn into_odd(self) -> CtOption<Odd<Self>>
pub fn into_odd(self) -> CtOption<Odd<Self>>
Convert to an Odd<BoxedUint>.
Returns some if the original value is odd, and false otherwise.
Trait Implementations§
Source§impl<Rhs: AsRef<UintRef>> AddAssign<Rhs> for BoxedUint
impl<Rhs: AsRef<UintRef>> AddAssign<Rhs> for BoxedUint
Source§fn add_assign(&mut self, rhs: Rhs)
fn add_assign(&mut self, rhs: Rhs)
+= operation. Read moreSource§impl AddAssign<u128> for BoxedUint
impl AddAssign<u128> for BoxedUint
Source§fn add_assign(&mut self, rhs: u128)
fn add_assign(&mut self, rhs: u128)
+= operation. Read moreSource§impl AddAssign<u16> for BoxedUint
impl AddAssign<u16> for BoxedUint
Source§fn add_assign(&mut self, rhs: u16)
fn add_assign(&mut self, rhs: u16)
+= operation. Read moreSource§impl AddAssign<u32> for BoxedUint
impl AddAssign<u32> for BoxedUint
Source§fn add_assign(&mut self, rhs: u32)
fn add_assign(&mut self, rhs: u32)
+= operation. Read moreSource§impl AddAssign<u64> for BoxedUint
impl AddAssign<u64> for BoxedUint
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+= operation. Read moreSource§impl AddAssign<u8> for BoxedUint
impl AddAssign<u8> for BoxedUint
Source§fn add_assign(&mut self, rhs: u8)
fn add_assign(&mut self, rhs: u8)
+= operation. Read moreSource§impl BitAndAssign<&BoxedUint> for BoxedUint
impl BitAndAssign<&BoxedUint> for BoxedUint
Source§fn bitand_assign(&mut self, other: &Self)
fn bitand_assign(&mut self, other: &Self)
&= operation. Read moreSource§impl BitAndAssign for BoxedUint
impl BitAndAssign for BoxedUint
Source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
&= operation. Read moreSource§impl BitOps for BoxedUint
impl BitOps for BoxedUint
Source§fn bits_precision(&self) -> u32
fn bits_precision(&self) -> u32
Source§fn bytes_precision(&self) -> usize
fn bytes_precision(&self) -> usize
Source§fn leading_zeros(&self) -> u32
fn leading_zeros(&self) -> u32
Source§fn bit(&self, index: u32) -> Choice
fn bit(&self, index: u32) -> Choice
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)
fn set_bit(&mut self, index: u32, bit_value: Choice)
index to 0 or 1 depending on the value of bit_value.Source§fn trailing_zeros(&self) -> u32
fn trailing_zeros(&self) -> u32
Source§fn trailing_ones(&self) -> u32
fn trailing_ones(&self) -> u32
Source§fn bit_vartime(&self, index: u32) -> bool
fn bit_vartime(&self, index: u32) -> bool
Source§fn bits_vartime(&self) -> u32
fn bits_vartime(&self) -> u32
self.Source§fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
index to 0 or 1 depending on the value of bit_value,
variable time in self.Source§fn trailing_zeros_vartime(&self) -> u32
fn trailing_zeros_vartime(&self) -> u32
self.Source§fn trailing_ones_vartime(&self) -> u32
fn trailing_ones_vartime(&self) -> u32
self.Source§fn leading_zeros_vartime(&self) -> u32
fn leading_zeros_vartime(&self) -> u32
Source§impl BitOrAssign<&BoxedUint> for BoxedUint
impl BitOrAssign<&BoxedUint> for BoxedUint
Source§fn bitor_assign(&mut self, other: &Self)
fn bitor_assign(&mut self, other: &Self)
|= operation. Read moreSource§impl BitOrAssign for BoxedUint
impl BitOrAssign for BoxedUint
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
|= operation. Read moreSource§impl BitXorAssign<&BoxedUint> for BoxedUint
impl BitXorAssign<&BoxedUint> for BoxedUint
Source§fn bitxor_assign(&mut self, other: &Self)
fn bitxor_assign(&mut self, other: &Self)
^= operation. Read moreSource§impl BitXorAssign for BoxedUint
impl BitXorAssign for BoxedUint
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
^= operation. Read moreSource§impl BorrowMut<UintRef> for BoxedUint
impl BorrowMut<UintRef> for BoxedUint
Source§fn borrow_mut(&mut self) -> &mut UintRef
fn borrow_mut(&mut self) -> &mut UintRef
Source§impl CheckedSquareRoot for BoxedUint
impl CheckedSquareRoot for BoxedUint
Source§fn checked_sqrt(&self) -> CtOption<Self::Output>
fn checked_sqrt(&self) -> CtOption<Self::Output>
sqrt(self), returning none if no root exists.Source§impl ConcatenatingSquare for BoxedUint
impl ConcatenatingSquare for BoxedUint
Source§impl ConditionallyNegatable for BoxedUint
Available on crate feature subtle only.
impl ConditionallyNegatable for BoxedUint
subtle only.Source§fn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
Source§impl ConstantTimeEq for BoxedUint
Available on crate feature subtle only.
impl ConstantTimeEq for BoxedUint
subtle only.Source§impl ConstantTimeGreater for BoxedUint
Available on crate feature subtle only.
impl ConstantTimeGreater for BoxedUint
subtle only.Source§impl ConstantTimeLess for BoxedUint
Available on crate feature subtle only.
impl ConstantTimeLess for BoxedUint
subtle only.Source§impl CtAssignSlice for BoxedUint
impl CtAssignSlice for BoxedUint
Source§fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
Source§impl CtEqSlice for BoxedUint
impl CtEqSlice for BoxedUint
Source§fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
a is equal to b in constant-time.Source§fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
a is NOT equal to b in constant-time.Source§impl CtNeg for BoxedUint
impl CtNeg for BoxedUint
Source§impl<'a> DecodeValue<'a> for BoxedUint
Available on crate features der and hybrid-array only.
impl<'a> DecodeValue<'a> for BoxedUint
der and hybrid-array only.Source§impl<'de> Deserialize<'de> for BoxedUint
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BoxedUint
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<Rhs: ToUnsigned + ?Sized> DivAssign<&NonZero<Rhs>> for BoxedUint
impl<Rhs: ToUnsigned + ?Sized> DivAssign<&NonZero<Rhs>> for BoxedUint
Source§fn div_assign(&mut self, rhs: &NonZero<Rhs>)
fn div_assign(&mut self, rhs: &NonZero<Rhs>)
/= operation. Read moreSource§impl<Rhs: AsMut<UintRef>> DivAssign<NonZero<Rhs>> for BoxedUint
impl<Rhs: AsMut<UintRef>> DivAssign<NonZero<Rhs>> for BoxedUint
Source§fn div_assign(&mut self, rhs: NonZero<Rhs>)
fn div_assign(&mut self, rhs: NonZero<Rhs>)
/= operation. Read moreSource§impl DivRemLimb for BoxedUint
impl DivRemLimb for BoxedUint
Source§fn div_rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> (Self, Limb)
fn div_rem_limb_with_reciprocal(&self, reciprocal: &Reciprocal) -> (Self, Limb)
self / rhs, returns the quotient (q) and remainder (r).Source§impl DivVartime for BoxedUint
impl DivVartime for BoxedUint
Source§fn div_vartime(&self, rhs: &NonZero<BoxedUint>) -> Self
fn div_vartime(&self, rhs: &NonZero<BoxedUint>) -> Self
self / rhs in variable time.Source§impl EncodeValue for BoxedUint
Available on crate features der and hybrid-array only.
impl EncodeValue for BoxedUint
der and hybrid-array only.Source§impl Encoding for BoxedUint
impl Encoding for BoxedUint
Source§fn to_be_bytes(&self) -> Self::Repr
fn to_be_bytes(&self) -> Self::Repr
Source§fn to_le_bytes(&self) -> Self::Repr
fn to_le_bytes(&self) -> Self::Repr
Source§fn from_be_bytes(bytes: Self::Repr) -> Self
fn from_be_bytes(bytes: Self::Repr) -> Self
Source§fn from_le_bytes(bytes: Self::Repr) -> Self
fn from_le_bytes(bytes: Self::Repr) -> Self
Source§impl FloorSquareRoot for BoxedUint
impl FloorSquareRoot for BoxedUint
Source§fn floor_sqrt(&self) -> Self
fn floor_sqrt(&self) -> Self
floor(sqrt(self)).Source§fn floor_sqrt_vartime(&self) -> Self
fn floor_sqrt_vartime(&self) -> Self
floor(sqrt(self)). Read moreSource§impl Integer for BoxedUint
impl Integer for BoxedUint
Source§fn as_mut_limbs(&mut self) -> &mut [Limb]
fn as_mut_limbs(&mut self) -> &mut [Limb]
Source§impl<Rhs: AsRef<UintRef>> MulAssign<Rhs> for BoxedUint
impl<Rhs: AsRef<UintRef>> MulAssign<Rhs> for BoxedUint
Source§fn mul_assign(&mut self, rhs: Rhs)
fn mul_assign(&mut self, rhs: Rhs)
*= operation. Read moreSource§impl Ord for BoxedUint
impl Ord for BoxedUint
Source§impl PartialOrd<Odd<BoxedUint>> for BoxedUint
impl PartialOrd<Odd<BoxedUint>> for BoxedUint
Source§impl<Rhs: AsRef<UintRef> + ?Sized> PartialOrd<Rhs> for BoxedUint
impl<Rhs: AsRef<UintRef> + ?Sized> PartialOrd<Rhs> for BoxedUint
Source§impl PowBoundedExp<BoxedUint> for BoxedMontyForm
impl PowBoundedExp<BoxedUint> for BoxedMontyForm
Source§impl RandomBits for BoxedUint
Available on crate feature rand_core only.
impl RandomBits for BoxedUint
rand_core only.Source§fn try_random_bits<R: TryRng + ?Sized>(
rng: &mut R,
bit_length: u32,
) -> Result<Self, RandomBitsError<R::Error>>
fn try_random_bits<R: TryRng + ?Sized>( rng: &mut R, bit_length: u32, ) -> Result<Self, RandomBitsError<R::Error>>
[0, 2^bit_length). Read moreSource§fn try_random_bits_with_precision<R: TryRng + ?Sized>(
rng: &mut R,
bit_length: u32,
bits_precision: u32,
) -> Result<Self, RandomBitsError<R::Error>>
fn try_random_bits_with_precision<R: TryRng + ?Sized>( rng: &mut R, bit_length: u32, bits_precision: u32, ) -> Result<Self, RandomBitsError<R::Error>>
[0, 2^bit_length),
returning an integer with the closest available size to bits_precision
(if the implementing type supports runtime sizing). Read moreSource§fn random_bits<R: TryRng + ?Sized>(rng: &mut R, bit_length: u32) -> Self
fn random_bits<R: TryRng + ?Sized>(rng: &mut R, bit_length: u32) -> Self
[0, 2^bit_length). Read moreSource§fn random_bits_with_precision<R: TryRng + ?Sized>(
rng: &mut R,
bit_length: u32,
bits_precision: u32,
) -> Self
fn random_bits_with_precision<R: TryRng + ?Sized>( rng: &mut R, bit_length: u32, bits_precision: u32, ) -> Self
[0, 2^bit_length),
returning an integer with the closest available size to bits_precision
(if the implementing type supports runtime sizing). Read moreSource§impl RandomMod for BoxedUint
Available on crate feature rand_core only.
impl RandomMod for BoxedUint
rand_core only.Source§fn random_mod_vartime<R: Rng + ?Sized>(
rng: &mut R,
modulus: &NonZero<Self>,
) -> Self
fn random_mod_vartime<R: Rng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Self
modulus. Read moreSource§fn try_random_mod_vartime<R: TryRng + ?Sized>(
rng: &mut R,
modulus: &NonZero<Self>,
) -> Result<Self, R::Error>
fn try_random_mod_vartime<R: TryRng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Result<Self, R::Error>
modulus. Read moreSource§impl<Rhs: AsRef<UintRef> + ?Sized> RemAssign<&NonZero<Rhs>> for BoxedUint
impl<Rhs: AsRef<UintRef> + ?Sized> RemAssign<&NonZero<Rhs>> for BoxedUint
Source§fn rem_assign(&mut self, rhs: &NonZero<Rhs>)
fn rem_assign(&mut self, rhs: &NonZero<Rhs>)
%= operation. Read moreSource§impl<Rhs: AsRef<UintRef>> RemAssign<NonZero<Rhs>> for BoxedUint
impl<Rhs: AsRef<UintRef>> RemAssign<NonZero<Rhs>> for BoxedUint
Source§fn rem_assign(&mut self, rhs: NonZero<Rhs>)
fn rem_assign(&mut self, rhs: NonZero<Rhs>)
%= operation. Read moreSource§impl Resize for &BoxedUint
impl Resize for &BoxedUint
Source§fn resize_unchecked(self, at_least_bits_precision: u32) -> Self::Output
fn resize_unchecked(self, at_least_bits_precision: u32) -> Self::Output
at_least_bits_precision
without checking if the bit size of self is larger than at_least_bits_precision. Read moreSource§impl Resize for BoxedUint
impl Resize for BoxedUint
Source§fn resize_unchecked(self, at_least_bits_precision: u32) -> Self::Output
fn resize_unchecked(self, at_least_bits_precision: u32) -> Self::Output
at_least_bits_precision
without checking if the bit size of self is larger than at_least_bits_precision. Read moreSource§impl ShlAssign<i32> for BoxedUint
impl ShlAssign<i32> for BoxedUint
Source§fn shl_assign(&mut self, shift: i32)
fn shl_assign(&mut self, shift: i32)
<<= operation. Read moreSource§impl ShlAssign<u32> for BoxedUint
impl ShlAssign<u32> for BoxedUint
Source§fn shl_assign(&mut self, shift: u32)
fn shl_assign(&mut self, shift: u32)
<<= operation. Read moreSource§impl ShlAssign<usize> for BoxedUint
impl ShlAssign<usize> for BoxedUint
Source§fn shl_assign(&mut self, shift: usize)
fn shl_assign(&mut self, shift: usize)
<<= operation. Read moreSource§impl ShlVartime for BoxedUint
impl ShlVartime for BoxedUint
Source§fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>
fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>
self << shift. Read moreSource§fn unbounded_shl_vartime(&self, shift: u32) -> Self
fn unbounded_shl_vartime(&self, shift: u32) -> Self
self << shift. Read moreSource§fn wrapping_shl_vartime(&self, shift: u32) -> Self
fn wrapping_shl_vartime(&self, shift: u32) -> Self
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 ShrAssign<i32> for BoxedUint
impl ShrAssign<i32> for BoxedUint
Source§fn shr_assign(&mut self, shift: i32)
fn shr_assign(&mut self, shift: i32)
>>= operation. Read moreSource§impl ShrAssign<u32> for BoxedUint
impl ShrAssign<u32> for BoxedUint
Source§fn shr_assign(&mut self, shift: u32)
fn shr_assign(&mut self, shift: u32)
>>= operation. Read moreSource§impl ShrAssign<usize> for BoxedUint
impl ShrAssign<usize> for BoxedUint
Source§fn shr_assign(&mut self, shift: usize)
fn shr_assign(&mut self, shift: usize)
>>= operation. Read moreSource§impl ShrVartime for BoxedUint
impl ShrVartime for BoxedUint
Source§fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>
fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>
self >> shift. Read moreSource§fn unbounded_shr_vartime(&self, shift: u32) -> Self
fn unbounded_shr_vartime(&self, shift: u32) -> Self
self >> shift. Read moreSource§fn wrapping_shr_vartime(&self, shift: u32) -> Self
fn wrapping_shr_vartime(&self, shift: u32) -> Self
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<Rhs: AsRef<UintRef>> SubAssign<Rhs> for BoxedUint
impl<Rhs: AsRef<UintRef>> SubAssign<Rhs> for BoxedUint
Source§fn sub_assign(&mut self, rhs: Rhs)
fn sub_assign(&mut self, rhs: Rhs)
-= operation. Read moreSource§impl SubAssign<u128> for BoxedUint
impl SubAssign<u128> for BoxedUint
Source§fn sub_assign(&mut self, rhs: u128)
fn sub_assign(&mut self, rhs: u128)
-= operation. Read moreSource§impl SubAssign<u16> for BoxedUint
impl SubAssign<u16> for BoxedUint
Source§fn sub_assign(&mut self, rhs: u16)
fn sub_assign(&mut self, rhs: u16)
-= operation. Read moreSource§impl SubAssign<u32> for BoxedUint
impl SubAssign<u32> for BoxedUint
Source§fn sub_assign(&mut self, rhs: u32)
fn sub_assign(&mut self, rhs: u32)
-= operation. Read moreSource§impl SubAssign<u64> for BoxedUint
impl SubAssign<u64> for BoxedUint
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
-= operation. Read moreSource§impl SubAssign<u8> for BoxedUint
impl SubAssign<u8> for BoxedUint
Source§fn sub_assign(&mut self, rhs: u8)
fn sub_assign(&mut self, rhs: u8)
-= operation. Read moreSource§impl Unsigned for BoxedUint
impl Unsigned for BoxedUint
Source§fn as_uint_ref(&self) -> &UintRef
fn as_uint_ref(&self) -> &UintRef
UintRef.Source§fn as_mut_uint_ref(&mut self) -> &mut UintRef
fn as_mut_uint_ref(&mut self) -> &mut UintRef
UintRef.Source§fn from_limb_like(limb: Limb, other: &Self) -> Self
fn from_limb_like(limb: Limb, other: &Self) -> Self
limb, and the same precision as other.Source§impl UnsignedWithMontyForm for BoxedUint
impl UnsignedWithMontyForm for BoxedUint
Source§type MontyForm = BoxedMontyForm
type MontyForm = BoxedMontyForm
Source§impl WrappingAdd for BoxedUint
impl WrappingAdd for BoxedUint
Source§fn wrapping_add(&self, v: &Self) -> Self
fn wrapping_add(&self, v: &Self) -> Self
self + other, wrapping around at the boundary of
the type.Source§impl WrappingMul for BoxedUint
impl WrappingMul for BoxedUint
Source§fn wrapping_mul(&self, v: &Self) -> Self
fn wrapping_mul(&self, v: &Self) -> Self
self * other, wrapping around at the boundary
of the type.Source§impl WrappingNeg for BoxedUint
impl WrappingNeg for BoxedUint
Source§fn wrapping_neg(&self) -> Self
fn wrapping_neg(&self) -> Self
-self,
wrapping around at the boundary of the type. Read moreSource§impl WrappingShl for BoxedUint
impl WrappingShl for BoxedUint
Source§impl WrappingShr for BoxedUint
impl WrappingShr for BoxedUint
Source§impl WrappingSub for BoxedUint
impl WrappingSub for BoxedUint
Source§fn wrapping_sub(&self, v: &Self) -> Self
fn wrapping_sub(&self, v: &Self) -> Self
self - other, wrapping around at the boundary
of the type.impl Eq for BoxedUint
Auto Trait Implementations§
impl Freeze for BoxedUint
impl RefUnwindSafe for BoxedUint
impl Send for BoxedUint
impl Sync for BoxedUint
impl Unpin for BoxedUint
impl UnsafeUnpin for BoxedUint
impl UnwindSafe for BoxedUint
Blanket Implementations§
Source§impl<T, Rhs> WideningMul<Rhs> for Twhere
T: ConcatenatingMul<Rhs>,
impl<T, Rhs> WideningMul<Rhs> for Twhere
T: ConcatenatingMul<Rhs>,
Source§type Output = <T as ConcatenatingMul<Rhs>>::Output
type Output = <T as ConcatenatingMul<Rhs>>::Output
ConcatenatingMul insteadSource§fn widening_mul(&self, rhs: Rhs) -> <T as WideningMul<Rhs>>::Output
fn widening_mul(&self, rhs: Rhs) -> <T as WideningMul<Rhs>>::Output
ConcatenatingMul instead