Struct crypto_bigint::Uint
source · pub struct Uint<const LIMBS: usize> { /* private fields */ }Expand description
Big unsigned integer.
Generic over the given number of LIMBS
Encoding support
This type supports many different types of encodings, either via the
Encoding trait or various const fn decoding and
encoding functions that can be used with Uint constants.
Optional crate features for encoding (off-by-default):
generic-array: enablesArrayEncodingtrait which can be used toUintasGenericArray<u8, N>and aArrayDecodingtrait which can be used toGenericArray<u8, N>asUint.rlp: support for Recursive Length Prefix (RLP) encoding.
Implementations§
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)
pub const fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)
Computes a + b + carry, returning the result along with the new carry.
sourcepub const fn saturating_add(&self, rhs: &Self) -> Self
pub const fn saturating_add(&self, rhs: &Self) -> Self
Perform saturating addition, returning MAX on overflow.
sourcepub const fn wrapping_add(&self, rhs: &Self) -> Self
pub const fn wrapping_add(&self, rhs: &Self) -> Self
Perform wrapping addition, discarding overflow.
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn add_mod(&self, rhs: &Uint<LIMBS>, p: &Uint<LIMBS>) -> Uint<LIMBS>
pub const fn add_mod(&self, rhs: &Uint<LIMBS>, p: &Uint<LIMBS>) -> Uint<LIMBS>
Computes self + rhs mod p in constant time.
Assumes self + rhs as unbounded integer is < 2p.
sourcepub const fn add_mod_special(&self, rhs: &Self, c: Limb) -> Self
pub const fn add_mod_special(&self, rhs: &Self, c: Limb) -> Self
Computes self + rhs mod p in constant time 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<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn wrapping_and(&self, rhs: &Self) -> Self
pub const 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<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn wrapping_or(&self, rhs: &Self) -> Self
pub const 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<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn wrapping_xor(&self, rhs: &Self) -> Self
pub const 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<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn bit_vartime(self, index: usize) -> bool
pub const fn bit_vartime(self, index: usize) -> bool
Returns true if the bit at position index is set, false otherwise.
sourcepub const fn bits_vartime(self) -> usize
pub const fn bits_vartime(self) -> usize
Calculate the number of bits needed to represent this number.
sourcepub const fn leading_zeros(self) -> usize
pub const fn leading_zeros(self) -> usize
Calculate the number of leading zeros in the binary representation of this number.
sourcepub const fn trailing_zeros(self) -> usize
pub const fn trailing_zeros(self) -> usize
Calculate the number of trailing zeros in the binary representation of this number.
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn ct_div_rem_limb_with_reciprocal(
&self,
reciprocal: &Reciprocal
) -> (Self, Limb)
pub const fn ct_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_with_reciprocal(
&self,
reciprocal: &CtOption<Reciprocal>
) -> CtOption<(Self, Limb)>
pub fn div_rem_limb_with_reciprocal( &self, reciprocal: &CtOption<Reciprocal> ) -> CtOption<(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 const fn const_rem(&self, rhs: &Self) -> (Self, CtChoice)
pub const fn const_rem(&self, rhs: &Self) -> (Self, CtChoice)
Computes self % rhs, returns the remainder and
and the truthy value for is_some or the falsy value for is_none.
NOTE: Use only if you need to access const fn. Otherwise use Self::rem.
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
sourcepub const fn const_rem_wide(
lower_upper: (Self, Self),
rhs: &Self
) -> (Self, CtChoice)
pub const fn const_rem_wide( lower_upper: (Self, Self), rhs: &Self ) -> (Self, CtChoice)
Computes self % rhs, returns the remainder and
and the truthy value for is_some or the falsy value for is_none.
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
sourcepub const fn rem2k(&self, k: usize) -> Self
pub const fn rem2k(&self, k: usize) -> Self
Computes self % 2^k. Faster than reduce since its a power of 2.
Limited to 2^16-1 since Uint doesn’t support higher.
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 const fn wrapping_div(&self, rhs: &Self) -> Self
pub const fn wrapping_div(&self, rhs: &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 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
sourcepub const fn wrapping_rem(&self, rhs: &Self) -> Self
pub const fn wrapping_rem(&self, rhs: &Self) -> Self
Wrapped (modular) remainder calculation is just self % rhs.
There’s no way wrapping could ever happen.
This function exists, so that all operations are accounted for in the wrapping operations.
Panics if rhs == 0.
sourcepub fn checked_rem(&self, rhs: &Self) -> CtOption<Self>
pub fn checked_rem(&self, rhs: &Self) -> CtOption<Self>
Perform checked reduction, returning a CtOption which is_some
only if the rhs != 0
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn from_be_slice(bytes: &[u8]) -> Self
pub const fn from_be_slice(bytes: &[u8]) -> Self
Create a new Uint from the provided big endian bytes.
sourcepub const fn from_be_hex(hex: &str) -> Self
pub const fn from_be_hex(hex: &str) -> Self
Create a new Uint from the provided big endian hex string.
sourcepub const fn from_le_slice(bytes: &[u8]) -> Self
pub const fn from_le_slice(bytes: &[u8]) -> Self
Create a new Uint from the provided little endian bytes.
sourcepub const fn from_le_hex(hex: &str) -> Self
pub const fn from_le_hex(hex: &str) -> Self
Create a new Uint from the provided little endian hex string.
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn inv_mod2k(&self, k: usize) -> Self
pub const fn inv_mod2k(&self, k: usize) -> Self
Computes 1/self mod 2^k as specified in Algorithm 4 from
A Secure Algorithm for Inversion Modulo 2k by
Sadiel de la Fe and Carles Ferrer. See
https://www.mdpi.com/2410-387X/2/3/23.
Conditions: self < 2^k and self must be odd
sourcepub const fn inv_odd_mod_bounded(
&self,
modulus: &Self,
bits: usize,
modulus_bits: usize
) -> (Self, CtChoice)
pub const fn inv_odd_mod_bounded( &self, modulus: &Self, bits: usize, modulus_bits: usize ) -> (Self, CtChoice)
Computes the multiplicative inverse of self mod modulus, where modulus is odd.
In other words self^-1 mod modulus.
bits and modulus_bits are the bounds on the bit size
of self and modulus, respectively
(the inversion speed will be proportional to bits + modulus_bits).
The second element of the tuple is the truthy value if an inverse exists,
otherwise it is a falsy value.
Note: variable time in bits and modulus_bits.
The algorithm is the same as in GMP 6.2.1’s mpn_sec_invert.
sourcepub const fn inv_odd_mod(&self, modulus: &Self) -> (Self, CtChoice)
pub const fn inv_odd_mod(&self, modulus: &Self) -> (Self, CtChoice)
Computes the multiplicative inverse of self mod modulus, where modulus is odd.
Returns (inverse, Word::MAX) if an inverse exists, otherwise (undefined, Word::ZERO).
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn mul_wide(&self, rhs: &Self) -> (Self, Self)
pub const fn mul_wide(&self, rhs: &Self) -> (Self, Self)
Compute “wide” multiplication, with a product twice the size of the input.
Returns a tuple containing the (lo, hi) components of the product.
Ordering note
Releases of crypto-bigint prior to v0.3 used (hi, lo) ordering
instead. This has been changed for better consistency with the rest of
the APIs in this crate.
For more info see: https://github.com/RustCrypto/crypto-bigint/issues/4
sourcepub const fn saturating_mul(&self, rhs: &Self) -> Self
pub const fn saturating_mul(&self, rhs: &Self) -> Self
Perform saturating multiplication, returning MAX on overflow.
sourcepub const fn wrapping_mul(&self, rhs: &Self) -> Self
pub const fn wrapping_mul(&self, rhs: &Self) -> Self
Perform wrapping multiplication, discarding overflow.
sourcepub fn square(&self) -> <Self as Concat>::Outputwhere
Self: Concat,
pub fn square(&self) -> <Self as Concat>::Outputwhere Self: Concat,
Square self, returning a concatenated “wide” result.
sourcepub const fn square_wide(&self) -> (Self, Self)
pub const fn square_wide(&self) -> (Self, Self)
Square self, returning a “wide” result in two parts as (lo, hi).
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn mul_mod_special(&self, rhs: &Self, c: Limb) -> Self
pub const fn mul_mod_special(&self, rhs: &Self, c: Limb) -> Self
Computes self * rhs mod p in constant time 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<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn shl_vartime(&self, n: usize) -> Self
pub const fn shl_vartime(&self, n: usize) -> Self
Computes self << shift.
NOTE: this operation is variable time with respect to n ONLY.
When used with a fixed n, this function is constant-time with respect
to self.
sourcepub const fn shl_vartime_wide(
lower_upper: (Self, Self),
n: usize
) -> (Self, Self)
pub const fn shl_vartime_wide( lower_upper: (Self, Self), n: usize ) -> (Self, Self)
Computes a left shift on a wide input as (lo, hi).
NOTE: this operation is variable time with respect to n ONLY.
When used with a fixed n, this function is constant-time with respect
to self.
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn shr_vartime(&self, shift: usize) -> Self
pub const fn shr_vartime(&self, shift: usize) -> Self
Computes self >> n.
NOTE: this operation is variable time with respect to n ONLY.
When used with a fixed n, this function is constant-time with respect
to self.
sourcepub const fn shr_vartime_wide(
lower_upper: (Self, Self),
n: usize
) -> (Self, Self)
pub const fn shr_vartime_wide( lower_upper: (Self, Self), n: usize ) -> (Self, Self)
Computes a right shift on a wide input as (lo, hi).
NOTE: this operation is variable time with respect to n ONLY.
When used with a fixed n, this function is constant-time with respect
to self.
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn sqrt(&self) -> Self
pub const fn sqrt(&self) -> Self
Computes √(self)
Uses Brent & Zimmermann, Modern Computer Arithmetic, v0.5.9, Algorithm 1.13
Callers can check if self is a square by squaring the result
sourcepub const fn wrapping_sqrt(&self) -> Self
pub const 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 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
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)
pub const fn sbb(&self, rhs: &Self, borrow: Limb) -> (Self, Limb)
Computes a - (b + borrow), returning the result along with the new borrow.
sourcepub const fn saturating_sub(&self, rhs: &Self) -> Self
pub const fn saturating_sub(&self, rhs: &Self) -> Self
Perform saturating subtraction, returning ZERO on underflow.
sourcepub const fn wrapping_sub(&self, rhs: &Self) -> Self
pub const fn wrapping_sub(&self, rhs: &Self) -> Self
Perform wrapping subtraction, discarding underflow and wrapping around the boundary of the type.
source§impl<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn sub_mod(&self, rhs: &Uint<LIMBS>, p: &Uint<LIMBS>) -> Uint<LIMBS>
pub const fn sub_mod(&self, rhs: &Uint<LIMBS>, p: &Uint<LIMBS>) -> Uint<LIMBS>
Computes self - rhs mod p in constant time.
Assumes self - rhs as unbounded signed integer is in [-p, p).
sourcepub const fn sub_mod_special(&self, rhs: &Self, c: Limb) -> Self
pub const fn sub_mod_special(&self, rhs: &Self, c: Limb) -> Self
Computes self - rhs mod p in constant time 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<const LIMBS: usize> Uint<LIMBS>
impl<const LIMBS: usize> Uint<LIMBS>
sourcepub const fn from_words(arr: [Word; LIMBS]) -> Self
pub const fn from_words(arr: [Word; LIMBS]) -> Self
sourcepub fn as_words_mut(&mut self) -> &mut [Word; LIMBS]
pub fn as_words_mut(&mut self) -> &mut [Word; LIMBS]
Borrow the inner limbs as a mutable array of Words.
sourcepub fn as_limbs_mut(&mut self) -> &mut [Limb; LIMBS]
pub fn as_limbs_mut(&mut self) -> &mut [Limb; LIMBS]
Borrow the limbs of this Uint mutably.
Trait Implementations§
source§impl<const LIMBS: usize> BitAndAssign<&Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> BitAndAssign<&Uint<LIMBS>> for Uint<LIMBS>
source§fn bitand_assign(&mut self, other: &Self)
fn bitand_assign(&mut self, other: &Self)
&= operation. Read moresource§impl<const LIMBS: usize> BitAndAssign<Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> BitAndAssign<Uint<LIMBS>> for Uint<LIMBS>
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
&= operation. Read moresource§impl<const LIMBS: usize> BitOrAssign<&Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> BitOrAssign<&Uint<LIMBS>> for Uint<LIMBS>
source§fn bitor_assign(&mut self, other: &Self)
fn bitor_assign(&mut self, other: &Self)
|= operation. Read moresource§impl<const LIMBS: usize> BitOrAssign<Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> BitOrAssign<Uint<LIMBS>> for Uint<LIMBS>
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
|= operation. Read moresource§impl<const LIMBS: usize> BitXorAssign<&Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> BitXorAssign<&Uint<LIMBS>> for Uint<LIMBS>
source§fn bitxor_assign(&mut self, other: &Self)
fn bitxor_assign(&mut self, other: &Self)
^= operation. Read moresource§impl<const LIMBS: usize> BitXorAssign<Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> BitXorAssign<Uint<LIMBS>> for Uint<LIMBS>
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
^= operation. Read moresource§impl<const LIMBS: usize> ConditionallySelectable for Uint<LIMBS>
impl<const LIMBS: usize> ConditionallySelectable for Uint<LIMBS>
source§impl<const LIMBS: usize> ConstantTimeEq for Uint<LIMBS>
impl<const LIMBS: usize> ConstantTimeEq for Uint<LIMBS>
source§impl<const LIMBS: usize> ConstantTimeGreater for Uint<LIMBS>
impl<const LIMBS: usize> ConstantTimeGreater for Uint<LIMBS>
source§impl<const LIMBS: usize> ConstantTimeLess for Uint<LIMBS>
impl<const LIMBS: usize> ConstantTimeLess for Uint<LIMBS>
source§impl<const LIMBS: usize> Decodable for Uint<LIMBS>where
Self: Encoding,
<Self as Encoding>::Repr: Default,
Available on crate feature rlp only.
impl<const LIMBS: usize> Decodable for Uint<LIMBS>where Self: Encoding, <Self as Encoding>::Repr: Default,
rlp only.source§impl<'a, const LIMBS: usize> DecodeValue<'a> for Uint<LIMBS>where
Uint<LIMBS>: ArrayEncoding,
Available on crate features der and generic-array only.
impl<'a, const LIMBS: usize> DecodeValue<'a> for Uint<LIMBS>where Uint<LIMBS>: ArrayEncoding,
der and generic-array only.source§impl<'de, const LIMBS: usize> Deserialize<'de> for Uint<LIMBS>where
Uint<LIMBS>: Encoding,
Available on crate feature serde only.
impl<'de, const LIMBS: usize> Deserialize<'de> for Uint<LIMBS>where Uint<LIMBS>: Encoding,
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<const LIMBS: usize> Encodable for Uint<LIMBS>where
Self: Encoding,
Available on crate feature rlp only.
impl<const LIMBS: usize> Encodable for Uint<LIMBS>where Self: Encoding,
rlp only.source§impl<const LIMBS: usize> EncodeValue for Uint<LIMBS>where
Uint<LIMBS>: ArrayEncoding,
Available on crate features der and generic-array only.
impl<const LIMBS: usize> EncodeValue for Uint<LIMBS>where Uint<LIMBS>: ArrayEncoding,
der and generic-array only.source§impl<const LIMBS: usize> FixedTag for Uint<LIMBS>where
Uint<LIMBS>: ArrayEncoding,
Available on crate features der and generic-array only.
impl<const LIMBS: usize> FixedTag for Uint<LIMBS>where Uint<LIMBS>: ArrayEncoding,
der and generic-array only.source§impl<const LIMBS: usize> Ord for Uint<LIMBS>
impl<const LIMBS: usize> Ord for Uint<LIMBS>
source§impl<const LIMBS: usize> PartialEq<Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> PartialEq<Uint<LIMBS>> for Uint<LIMBS>
source§impl<const LIMBS: usize> PartialOrd<Uint<LIMBS>> for Uint<LIMBS>
impl<const LIMBS: usize> PartialOrd<Uint<LIMBS>> for Uint<LIMBS>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<const LIMBS: usize> PowBoundedExp<Uint<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> PowBoundedExp<Uint<LIMBS>> for DynResidue<LIMBS>
source§impl<MOD: ResidueParams<LIMBS>, const LIMBS: usize> PowBoundedExp<Uint<LIMBS>> for Residue<MOD, LIMBS>
impl<MOD: ResidueParams<LIMBS>, const LIMBS: usize> PowBoundedExp<Uint<LIMBS>> for Residue<MOD, LIMBS>
source§impl<const LIMBS: usize> Random for Uint<LIMBS>
Available on crate feature rand_core only.
impl<const LIMBS: usize> Random for Uint<LIMBS>
rand_core only.source§fn random(rng: &mut impl CryptoRngCore) -> Self
fn random(rng: &mut impl CryptoRngCore) -> Self
Generate a cryptographically secure random Uint.
source§impl<const LIMBS: usize> RandomMod for Uint<LIMBS>
Available on crate feature rand_core only.
impl<const LIMBS: usize> RandomMod for Uint<LIMBS>
rand_core only.source§fn random_mod(rng: &mut impl CryptoRngCore, modulus: &NonZero<Self>) -> Self
fn random_mod(rng: &mut impl CryptoRngCore, modulus: &NonZero<Self>) -> Self
Generate a cryptographically secure random Uint which is less than
a given modulus.
This function uses rejection sampling, a method which produces an unbiased distribution of in-range values provided the underlying CSRNG is unbiased, but runs in variable-time.
The variable-time nature of the algorithm should not pose a security issue so long as the underlying random number generator is truly a CSRNG, where previous outputs are unrelated to subsequent outputs and do not reveal information about the RNG’s internal state.
source§impl<const LIMBS: usize> Serialize for Uint<LIMBS>where
Uint<LIMBS>: Encoding,
Available on crate feature serde only.
impl<const LIMBS: usize> Serialize for Uint<LIMBS>where Uint<LIMBS>: Encoding,
serde only.source§impl<const LIMBS: usize> ShlAssign<usize> for Uint<LIMBS>
impl<const LIMBS: usize> ShlAssign<usize> for Uint<LIMBS>
source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
NOTE: this operation is variable time with respect to rhs ONLY.
When used with a fixed rhs, this function is constant-time with respect
to self.
source§impl<const LIMBS: usize> ShrAssign<usize> for Uint<LIMBS>
impl<const LIMBS: usize> ShrAssign<usize> for Uint<LIMBS>
source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>= operation. Read moresource§impl<'a, const LIMBS: usize> TryFrom<AnyRef<'a>> for Uint<LIMBS>where
Uint<LIMBS>: ArrayEncoding,
Available on crate features der and generic-array only.
impl<'a, const LIMBS: usize> TryFrom<AnyRef<'a>> for Uint<LIMBS>where Uint<LIMBS>: ArrayEncoding,
der and generic-array only.source§impl<'a, const LIMBS: usize> TryFrom<UintRef<'a>> for Uint<LIMBS>where
Uint<LIMBS>: ArrayEncoding,
Available on crate features der and generic-array only.
impl<'a, const LIMBS: usize> TryFrom<UintRef<'a>> for Uint<LIMBS>where Uint<LIMBS>: ArrayEncoding,
der and generic-array only.impl<const LIMBS: usize> Copy for Uint<LIMBS>
impl<const LIMBS: usize> DefaultIsZeroes for Uint<LIMBS>
zeroize only.