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)
pub fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)
Computes a + b + carry
, returning the result along with the new carry.
Sourcepub fn adc_assign(&mut self, rhs: impl AsRef<[Limb]>, carry: Limb) -> Limb
pub fn adc_assign(&mut self, rhs: impl AsRef<[Limb]>, carry: Limb) -> Limb
Computes a + b + carry
in-place, returning the new carry.
Panics if rhs
has a larger precision than self
.
Sourcepub fn wrapping_add(&self, rhs: &Self) -> Self
pub fn wrapping_add(&self, rhs: &Self) -> Self
Perform wrapping addition, discarding overflow.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn add_mod(&self, rhs: &Self, p: &Self) -> Self
pub fn add_mod(&self, rhs: &Self, p: &Self) -> Self
Computes self + rhs mod p
.
Assumes self + rhs
as unbounded integer is < 2p
.
Sourcepub fn double_mod(&self, p: &Self) -> Self
pub fn double_mod(&self, p: &Self) -> Self
Computes self + self mod p
.
Assumes self
as unbounded integer is < p
.
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: &Self) -> Ordering
pub fn cmp_vartime(&self, rhs: &Self) -> 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(&self, rhs: &NonZero<Self>) -> (Self, Self)
pub fn div_rem(&self, rhs: &NonZero<Self>) -> (Self, Self)
Computes self / rhs, returns the quotient, remainder.
Sourcepub fn div_rem_vartime(&self, rhs: &NonZero<Self>) -> (Self, Self)
pub fn div_rem_vartime(&self, rhs: &NonZero<Self>) -> (Self, Self)
Computes self / rhs, returns the quotient, remainder.
Variable-time with respect to rhs
Sourcepub fn rem_vartime(&self, rhs: &NonZero<Self>) -> Self
pub fn rem_vartime(&self, rhs: &NonZero<Self>) -> Self
Computes self % rhs, returns the remainder.
Variable-time with respect to rhs
.
Sourcepub fn wrapping_div(&self, rhs: &NonZero<Self>) -> Self
pub fn wrapping_div(&self, rhs: &NonZero<Self>) -> 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(&self, rhs: &NonZero<Self>) -> Self
pub fn wrapping_div_vartime(&self, rhs: &NonZero<Self>) -> 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
Sourcepub fn checked_div(&self, rhs: &Self) -> CtOption<Self>
pub fn checked_div(&self, rhs: &Self) -> CtOption<Self>
Perform checked division, returning a CtOption
which is_some
only if the rhs != 0
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
.
If the length of bytes
is larger than bits_precision
(rounded up to a multiple of 8)
this function will return DecodeError::InputSize
.
If the size of the decoded integer is larger than bits_precision
,
this function will return DecodeError::Precision
.
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
.
If the length of bytes
is larger than bits_precision
(rounded up to a multiple of 8)
this function will return DecodeError::InputSize
.
If the size of the decoded integer is larger than bits_precision
,
this function will return DecodeError::Precision
.
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_le_bytes(&self) -> Box<[u8]>
pub fn to_le_bytes(&self) -> Box<[u8]>
Serialize this BoxedUint
as little-endian.
Sourcepub fn from_be_hex(hex: &str, bits_precision: u32) -> CtOption<Self>
pub fn from_be_hex(hex: &str, bits_precision: u32) -> CtOption<Self>
Create a new BoxedUint
from the provided big endian hex string.
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.
If the input value contains non-digit characters or digits outside of the range 0..radix
this function will return DecodeError::InvalidDigit
.
Panics if radix
is 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
.
If the input value contains non-digit characters or digits outside of the range 0..radix
this function will return DecodeError::InvalidDigit
.
If the length of bytes
is larger than bits_precision
(rounded up to a multiple of 8)
this function will return DecodeError::InputSize
.
If the size of the decoded integer is larger than bits_precision
,
this function will return DecodeError::Precision
.
Panics if radix
is not in the range from 2 to 36.
Sourcepub fn to_string_radix_vartime(&self, radix: u32) -> String
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
impl BoxedUint
Sourcepub fn inv_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>
pub fn inv_odd_mod(&self, modulus: &Odd<Self>) -> CtOption<Self>
Computes the multiplicative inverse of self
mod modulus
, where modulus
is odd.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn mul(&self, rhs: &Self) -> Self
pub fn mul(&self, rhs: &Self) -> Self
Multiply 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: &Self) -> Self
pub fn wrapping_mul(&self, rhs: &Self) -> Self
Perform wrapping multiplication, wrapping to the width of self
.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn mul_mod(&self, rhs: &BoxedUint, p: &BoxedUint) -> BoxedUint
pub fn mul_mod(&self, rhs: &BoxedUint, p: &BoxedUint) -> BoxedUint
Computes self * rhs mod p
for odd p
.
Panics if p
is even.
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.
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 shl(&self, shift: u32) -> BoxedUint
pub fn shl(&self, shift: u32) -> BoxedUint
Computes self << shift
.
Panics if shift >= Self::BITS
.
Sourcepub fn shl_assign(&mut self, shift: u32)
pub fn shl_assign(&mut self, shift: u32)
Computes self <<= shift
.
Panics if shift >= Self::BITS
.
Sourcepub fn overflowing_shl(&self, shift: u32) -> (Self, Choice)
pub fn overflowing_shl(&self, shift: u32) -> (Self, Choice)
Computes self << shift
.
Returns a zero and a truthy Choice
if shift >= self.bits_precision()
,
or the result and a falsy Choice
otherwise.
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 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_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 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(&self, shift: u32) -> BoxedUint
pub fn shr(&self, shift: u32) -> BoxedUint
Computes self >> shift
.
Panics if shift >= Self::BITS
.
Sourcepub fn shr_assign(&mut self, shift: u32)
pub fn shr_assign(&mut self, shift: u32)
Computes self >>= shift
.
Panics if shift >= Self::BITS
.
Sourcepub fn overflowing_shr(&self, shift: u32) -> (Self, Choice)
pub fn overflowing_shr(&self, shift: u32) -> (Self, Choice)
Computes self >> shift
.
Returns a zero and a truthy Choice
if shift >= self.bits_precision()
,
or the result and a falsy Choice
otherwise.
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 wrapping_shr(&self, shift: u32) -> Self
pub fn wrapping_shr(&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_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, masking off bits of shift
which would cause
the shift to exceed the type’s width.
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
pub fn 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
pub fn sqrt_vartime(&self) -> Self
Computes √(self
)
Callers can check if self
is a square by squaring the result
Sourcepub fn wrapping_sqrt(&self) -> Self
pub fn wrapping_sqrt(&self) -> Self
Wrapped sqrt is just normal √(self
)
There’s no way wrapping could ever happen.
This function exists so that all operations are accounted for in the wrapping operations.
Sourcepub fn wrapping_sqrt_vartime(&self) -> Self
pub fn wrapping_sqrt_vartime(&self) -> Self
Wrapped sqrt is just normal √(self
)
There’s no way wrapping could ever happen.
This function exists so that all operations are accounted for in the wrapping operations.
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 √(self
)² == self
Sourcepub fn checked_sqrt_vartime(&self) -> CtOption<Self>
pub fn checked_sqrt_vartime(&self) -> CtOption<Self>
Perform checked sqrt, returning a CtOption
which is_some
only if the √(self
)² == self
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)
pub fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)
Computes a - (b + borrow)
, returning the result along with the new borrow.
Sourcepub fn sbb_assign(&mut self, rhs: impl AsRef<[Limb]>, borrow: Limb) -> Limb
pub fn sbb_assign(&mut self, rhs: impl AsRef<[Limb]>, borrow: Limb) -> Limb
Computes a - (b + borrow)
in-place, returning the new borrow.
Panics if rhs
has a larger precision than self
.
Sourcepub fn wrapping_sub(&self, rhs: &Self) -> Self
pub fn wrapping_sub(&self, rhs: &Self) -> Self
Perform wrapping subtraction, discarding overflow.
Source§impl BoxedUint
impl BoxedUint
Sourcepub fn sub_mod(&self, rhs: &Self, p: &Self) -> Self
pub fn sub_mod(&self, rhs: &Self, p: &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 as_words_mut(&mut self) -> &mut [Word]
pub fn as_words_mut(&mut self) -> &mut [Word]
Borrow the inner limbs as a mutable slice of Word
s.
Sourcepub fn as_limbs_mut(&mut self) -> &mut [Limb]
pub fn as_limbs_mut(&mut self) -> &mut [Limb]
Borrow 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.
Trait Implementations§
Source§impl AddAssign<&BoxedUint> for BoxedUint
impl AddAssign<&BoxedUint> for BoxedUint
Source§fn add_assign(&mut self, rhs: &BoxedUint)
fn add_assign(&mut self, rhs: &BoxedUint)
+=
operation. Read moreSource§impl<const LIMBS: usize> AddAssign<&Uint<LIMBS>> for BoxedUint
impl<const LIMBS: usize> AddAssign<&Uint<LIMBS>> for BoxedUint
Source§fn add_assign(&mut self, rhs: &Uint<LIMBS>)
fn add_assign(&mut self, rhs: &Uint<LIMBS>)
+=
operation. Read moreSource§impl<const LIMBS: usize> AddAssign<Uint<LIMBS>> for BoxedUint
impl<const LIMBS: usize> AddAssign<Uint<LIMBS>> for BoxedUint
Source§fn add_assign(&mut self, rhs: Uint<LIMBS>)
fn add_assign(&mut self, rhs: Uint<LIMBS>)
+=
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 AddAssign for BoxedUint
impl AddAssign for BoxedUint
Source§fn add_assign(&mut self, rhs: BoxedUint)
fn add_assign(&mut self, rhs: BoxedUint)
+=
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
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 CheckedAdd for BoxedUint
impl CheckedAdd for BoxedUint
Source§fn checked_add(&self, rhs: &Self) -> CtOption<Self>
fn checked_add(&self, rhs: &Self) -> CtOption<Self>
CtOption
which is_some
only if the operation
did not overflow.Source§impl CheckedDiv for BoxedUint
impl CheckedDiv for BoxedUint
Source§impl CheckedMul for BoxedUint
impl CheckedMul for BoxedUint
Source§impl CheckedSub for BoxedUint
impl CheckedSub for BoxedUint
Source§fn checked_sub(&self, rhs: &Self) -> CtOption<Self>
fn checked_sub(&self, rhs: &Self) -> CtOption<Self>
CtOption
which is_some
only if the operation did not underflow.Source§impl ConstantTimeEq for BoxedUint
impl ConstantTimeEq for BoxedUint
Source§impl ConstantTimeGreater for BoxedUint
impl ConstantTimeGreater for BoxedUint
Source§impl ConstantTimeLess for BoxedUint
impl ConstantTimeLess for BoxedUint
Source§impl ConstantTimeSelect for BoxedUint
NOTE: can’t impl subtle
’s ConditionallySelectable
trait due to its Copy
bound
impl ConstantTimeSelect for BoxedUint
NOTE: can’t impl subtle
’s ConditionallySelectable
trait due to its Copy
bound
Source§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 Integer for BoxedUint
impl Integer for BoxedUint
Source§type Monty = BoxedMontyForm
type Monty = BoxedMontyForm
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 MulAssign<&BoxedUint> for BoxedUint
impl MulAssign<&BoxedUint> for BoxedUint
Source§fn mul_assign(&mut self, rhs: &BoxedUint)
fn mul_assign(&mut self, rhs: &BoxedUint)
*=
operation. Read moreSource§impl MulAssign for BoxedUint
impl MulAssign for BoxedUint
Source§fn mul_assign(&mut self, rhs: BoxedUint)
fn mul_assign(&mut self, rhs: BoxedUint)
*=
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 PartialOrd for BoxedUint
impl PartialOrd 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(
rng: &mut (impl RngCore + ?Sized),
bit_length: u32,
) -> Result<Self, RandomBitsError>
fn try_random_bits( rng: &mut (impl RngCore + ?Sized), bit_length: u32, ) -> Result<Self, RandomBitsError>
[0, 2^bit_length)
. Read moreSource§fn try_random_bits_with_precision(
rng: &mut (impl RngCore + ?Sized),
bit_length: u32,
bits_precision: u32,
) -> Result<Self, RandomBitsError>
fn try_random_bits_with_precision( rng: &mut (impl RngCore + ?Sized), bit_length: u32, bits_precision: u32, ) -> Result<Self, RandomBitsError>
[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(rng: &mut (impl RngCore + ?Sized), bit_length: u32) -> Self
fn random_bits(rng: &mut (impl RngCore + ?Sized), bit_length: u32) -> Self
[0, 2^bit_length)
. Read moreSource§fn random_bits_with_precision(
rng: &mut (impl RngCore + ?Sized),
bit_length: u32,
bits_precision: u32,
) -> Self
fn random_bits_with_precision( rng: &mut (impl RngCore + ?Sized), 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 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) -> CtOption<Self>
fn overflowing_shl_vartime(&self, shift: u32) -> CtOption<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) -> CtOption<Self>
fn overflowing_shr_vartime(&self, shift: u32) -> CtOption<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 SquareRoot for BoxedUint
impl SquareRoot for BoxedUint
Source§impl SubAssign<&BoxedUint> for BoxedUint
impl SubAssign<&BoxedUint> for BoxedUint
Source§fn sub_assign(&mut self, rhs: &BoxedUint)
fn sub_assign(&mut self, rhs: &BoxedUint)
-=
operation. Read moreSource§impl<const LIMBS: usize> SubAssign<&Uint<LIMBS>> for BoxedUint
impl<const LIMBS: usize> SubAssign<&Uint<LIMBS>> for BoxedUint
Source§fn sub_assign(&mut self, rhs: &Uint<LIMBS>)
fn sub_assign(&mut self, rhs: &Uint<LIMBS>)
-=
operation. Read moreSource§impl<const LIMBS: usize> SubAssign<Uint<LIMBS>> for BoxedUint
impl<const LIMBS: usize> SubAssign<Uint<LIMBS>> for BoxedUint
Source§fn sub_assign(&mut self, rhs: Uint<LIMBS>)
fn sub_assign(&mut self, rhs: Uint<LIMBS>)
-=
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 SubAssign for BoxedUint
impl SubAssign for BoxedUint
Source§fn sub_assign(&mut self, rhs: BoxedUint)
fn sub_assign(&mut self, rhs: BoxedUint)
-=
operation. Read moreSource§impl WideningMul<&BoxedUint> for BoxedUint
impl WideningMul<&BoxedUint> for BoxedUint
Source§impl WideningMul for BoxedUint
impl WideningMul for BoxedUint
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.