pub struct Int<const LIMBS: usize>(/* private fields */);Expand description
Implementations§
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn checked_add(&self, rhs: &Self) -> CtOption<Self>
pub const fn checked_add(&self, rhs: &Self) -> CtOption<Self>
Perform checked addition. Returns none when the addition overflowed.
Sourcepub const fn overflowing_add(&self, rhs: &Self) -> (Self, Choice)
pub const fn overflowing_add(&self, rhs: &Self) -> (Self, Choice)
Perform addition, raising the overflow flag 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> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn bitand_limb(&self, rhs: Limb) -> Self
pub const 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 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 const fn checked_and(&self, rhs: &Self) -> CtOption<Self>
pub const fn checked_and(&self, rhs: &Self) -> CtOption<Self>
Perform checked bitwise AND, returning a CtOption which is_some always
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<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 const fn checked_or(&self, rhs: &Self) -> CtOption<Self>
pub const fn checked_or(&self, rhs: &Self) -> CtOption<Self>
Perform checked bitwise OR, returning a CtOption which is_some always
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<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> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn cmp_vartime(&self, rhs: &Self) -> Ordering
pub const fn cmp_vartime(&self, rhs: &Self) -> Ordering
Returns the Ordering between self and rhs in variable time.
Source§impl<const LIMBS: usize> Int<LIMBS>
Checked division operations.
impl<const LIMBS: usize> Int<LIMBS>
Checked division operations.
Sourcepub const fn checked_div_rem<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Int<RHS_LIMBS>>,
) -> (CtOption<Self>, Int<RHS_LIMBS>)
pub const fn checked_div_rem<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> (CtOption<Self>, Int<RHS_LIMBS>)
Compute the quotient and remainder of self / rhs.
Returns none for the quotient when Int::MIN / Int::MINUS_ONE; that quotient cannot
be captured in an Int.
Example:
use crypto_bigint::{I128, NonZero};
let (quotient, remainder) = I128::from(8).checked_div_rem(&I128::from(3).to_nz().unwrap());
assert_eq!(quotient.unwrap(), I128::from(2));
assert_eq!(remainder, I128::from(2));
let (quotient, remainder) = I128::from(-8).checked_div_rem(&I128::from(3).to_nz().unwrap());
assert_eq!(quotient.unwrap(), I128::from(-2));
assert_eq!(remainder, I128::from(-2));
let (quotient, remainder) = I128::from(8).checked_div_rem(&I128::from(-3).to_nz().unwrap());
assert_eq!(quotient.unwrap(), I128::from(-2));
assert_eq!(remainder, I128::from(2));
let (quotient, remainder) = I128::from(-8).checked_div_rem(&I128::from(-3).to_nz().unwrap());
assert_eq!(quotient.unwrap(), I128::from(2));
assert_eq!(remainder, I128::from(-2));Sourcepub fn checked_div<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> CtOption<Self>
pub fn checked_div<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> CtOption<Self>
Perform checked division, returning a CtOption which is_some if
- the
rhs != 0, and self != MINorrhs != MINUS_ONE.
Note: this operation rounds towards zero, truncating any fractional part of the exact result.
Source§impl<const LIMBS: usize> Int<LIMBS>
Vartime checked division operations.
impl<const LIMBS: usize> Int<LIMBS>
Vartime checked division operations.
Sourcepub const fn checked_div_rem_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Int<RHS_LIMBS>>,
) -> (CtOption<Self>, Int<RHS_LIMBS>)
pub const fn checked_div_rem_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> (CtOption<Self>, Int<RHS_LIMBS>)
Variable time equivalent of Self::checked_div_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 fn checked_div_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> CtOption<Self>
pub fn checked_div_vartime<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> CtOption<Self>
Variable time equivalent of Self::checked_div
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Source§impl<const LIMBS: usize> Int<LIMBS>
Vartime checked div-floor operations.
impl<const LIMBS: usize> Int<LIMBS>
Vartime checked div-floor operations.
Sourcepub const fn checked_div_rem_floor_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Int<RHS_LIMBS>>,
) -> (CtOption<Self>, Int<RHS_LIMBS>)
pub const fn checked_div_rem_floor_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> (CtOption<Self>, Int<RHS_LIMBS>)
Variable time equivalent of Self::checked_div_rem_floor
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Sourcepub fn checked_div_floor_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> CtOption<Self>
pub fn checked_div_floor_vartime<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> CtOption<Self>
Variable time equivalent of Self::checked_div_floor
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Source§impl<const LIMBS: usize> Int<LIMBS>
Checked div-floor operations.
impl<const LIMBS: usize> Int<LIMBS>
Checked div-floor operations.
Sourcepub fn checked_div_floor<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> CtOption<Self>
pub fn checked_div_floor<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> CtOption<Self>
Perform checked floored division, returning a CtOption which is_some only if
- the
rhs != 0, and self != MINorrhs != MINUS_ONE.
Note: this operation rounds down.
Example:
use crypto_bigint::I128;
assert_eq!(
I128::from(8).checked_div_floor(&I128::from(3)).unwrap(),
I128::from(2)
);
assert_eq!(
I128::from(-8).checked_div_floor(&I128::from(3)).unwrap(),
I128::from(-3)
);
assert_eq!(
I128::from(8).checked_div_floor(&I128::from(-3)).unwrap(),
I128::from(-3)
);
assert_eq!(
I128::from(-8).checked_div_floor(&I128::from(-3)).unwrap(),
I128::from(2)
)Sourcepub const fn checked_div_rem_floor<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Int<RHS_LIMBS>>,
) -> (CtOption<Self>, Int<RHS_LIMBS>)
pub const fn checked_div_rem_floor<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> (CtOption<Self>, Int<RHS_LIMBS>)
Perform checked division and mod, returning the quotient and remainder.
The quotient is a CtOption which is_some only if
- the
rhs != 0, and self != MINorrhs != MINUS_ONE.
Note: this operation rounds down.
Example:
use crypto_bigint::I128;
let three = I128::from(3).to_nz().unwrap();
let (quotient, remainder) = I128::from(8).checked_div_rem_floor(&three);
assert_eq!(quotient.unwrap(), I128::from(2));
assert_eq!(remainder, I128::from(2));
let (quotient, remainder) = I128::from(-8).checked_div_rem_floor(&three);
assert_eq!(quotient.unwrap(), I128::from(-3));
assert_eq!(remainder, I128::from(-1));
let minus_three = I128::from(-3).to_nz().unwrap();
let (quotient, remainder) = I128::from(8).checked_div_rem_floor(&minus_three);
assert_eq!(quotient.unwrap(), I128::from(-3));
assert_eq!(remainder, I128::from(-1));
let (quotient, remainder) = I128::from(-8).checked_div_rem_floor(&minus_three);
assert_eq!(quotient.unwrap(), I128::from(2));
assert_eq!(remainder, I128::from(2));Source§impl<const LIMBS: usize> Int<LIMBS>
Checked division operations.
impl<const LIMBS: usize> Int<LIMBS>
Checked division operations.
Sourcepub const fn div_rem_unsigned<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> (Self, Int<RHS_LIMBS>)
pub const fn div_rem_unsigned<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> (Self, Int<RHS_LIMBS>)
Compute the quotient and remainder of self / rhs.
Example:
use crypto_bigint::{I128, NonZero, U128};
let (quotient, remainder) = I128::from(8).div_rem_unsigned(&U128::from(3u32).to_nz().unwrap());
assert_eq!(quotient, I128::from(2));
assert_eq!(remainder, I128::from(2));
let (quotient, remainder) = I128::from(-8).div_rem_unsigned(&U128::from(3u32).to_nz().unwrap());
assert_eq!(quotient, I128::from(-2));
assert_eq!(remainder, I128::from(-2));Sourcepub const fn div_unsigned<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Self
pub const fn div_unsigned<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Self
Perform division. Note: this operation rounds towards zero, truncating any fractional part of the exact result.
Source§impl<const LIMBS: usize> Int<LIMBS>
Vartime checked division operations.
impl<const LIMBS: usize> Int<LIMBS>
Vartime checked division operations.
Sourcepub const fn div_rem_unsigned_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> (Self, Int<RHS_LIMBS>)
pub const fn div_rem_unsigned_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> (Self, Int<RHS_LIMBS>)
Variable time equivalent of Self::div_rem_unsigned.
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 div_unsigned_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Self
pub const fn div_unsigned_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Self
Variable time equivalent of Self::div_unsigned.
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 rem_unsigned_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Int<RHS_LIMBS>
pub const fn rem_unsigned_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Int<RHS_LIMBS>
Variable time equivalent of Self::rem_unsigned.
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Source§impl<const LIMBS: usize> Int<LIMBS>
Checked div-floor operations
impl<const LIMBS: usize> Int<LIMBS>
Checked div-floor operations
Sourcepub fn div_rem_floor_unsigned<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> (Self, Uint<RHS_LIMBS>)
pub fn div_rem_floor_unsigned<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> (Self, Uint<RHS_LIMBS>)
Perform floored division and mod:
given n and d, computes q and r s.t. n = qd + r and q = ⌊n/d⌋.
Note: this operation rounds down, not towards zero.
Example:
use crypto_bigint::{I128, U128};
let three = U128::from(3u32).to_nz().unwrap();
assert_eq!(
I128::from(8).div_rem_floor_unsigned(&three),
(I128::from(2), U128::from(2u32))
);
assert_eq!(
I128::from(-8).div_rem_floor_unsigned(&three),
(I128::from(-3), U128::ONE)
);Sourcepub fn div_floor_unsigned<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Self
pub fn div_floor_unsigned<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Self
Perform checked division. Note: this operation rounds down.
Example:
use crypto_bigint::{I128, U128};
assert_eq!(
I128::from(8).div_floor_unsigned(&U128::from(3u32).to_nz().unwrap()),
I128::from(2)
);
assert_eq!(
I128::from(-8).div_floor_unsigned(&U128::from(3u32).to_nz().unwrap()),
I128::from(-3)
);Sourcepub fn normalized_rem<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Uint<RHS_LIMBS>
pub fn normalized_rem<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Uint<RHS_LIMBS>
Compute self % rhs and return the result contained in the interval [0, rhs).
Example:
use crypto_bigint::{I128, U128};
assert_eq!(
I128::from(8).normalized_rem(&U128::from(3u32).to_nz().unwrap()),
U128::from(2u32)
);
assert_eq!(
I128::from(-8).normalized_rem(&U128::from(3u32).to_nz().unwrap()),
U128::ONE
);Source§impl<const LIMBS: usize> Int<LIMBS>
Vartime checked div-floor operations
impl<const LIMBS: usize> Int<LIMBS>
Vartime checked div-floor operations
Sourcepub fn div_rem_floor_unsigned_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> (Self, Uint<RHS_LIMBS>)
pub fn div_rem_floor_unsigned_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> (Self, Uint<RHS_LIMBS>)
Variable time equivalent of Self::div_rem_floor_unsigned.
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Sourcepub fn div_floor_unsigned_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Self
pub fn div_floor_unsigned_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Self
Variable time equivalent of Self::div_floor_unsigned.
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Sourcepub fn normalized_rem_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &NonZero<Uint<RHS_LIMBS>>,
) -> Uint<RHS_LIMBS>
pub fn normalized_rem_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Uint<RHS_LIMBS>
Variable time equivalent of Self::normalized_rem.
This is variable only with respect to rhs.
When used with a fixed rhs, this function is constant-time with respect
to self.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn from_be_hex(hex: &str) -> Self
pub const fn from_be_hex(hex: &str) -> Self
Create a new Int from the provided big endian hex string.
See Uint::from_be_hex for more details.
§Panics
- if the hex is malformed or not zero-padded accordingly for the size.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Uint<LIMBS>
pub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Uint<LIMBS>
Compute the greatest common divisor of self and rhs.
Sourcepub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Uint<LIMBS>
pub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Uint<LIMBS>
Compute the greatest common divisor of self and rhs.
Executes in variable time w.r.t. all input parameters.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn jacobi_symbol<const RHS_LIMBS: usize>(
&self,
rhs: &Odd<Uint<RHS_LIMBS>>,
) -> JacobiSymbol
pub const fn jacobi_symbol<const RHS_LIMBS: usize>( &self, rhs: &Odd<Uint<RHS_LIMBS>>, ) -> JacobiSymbol
Compute the Jacobi symbol (self|rhs).
For prime rhs, this corresponds to the Legendre symbol and
indicates whether self is quadratic residue modulo rhs.
Sourcepub const fn jacobi_symbol_vartime<const RHS_LIMBS: usize>(
&self,
rhs: &Odd<Uint<RHS_LIMBS>>,
) -> JacobiSymbol
pub const fn jacobi_symbol_vartime<const RHS_LIMBS: usize>( &self, rhs: &Odd<Uint<RHS_LIMBS>>, ) -> JacobiSymbol
Compute the Jacobi symbol (self|rhs).
For prime rhs, this corresponds to the Legendre symbol and
indicates whether self is quadratic residue modulo rhs.
This method executes in variable-time for the value of self.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn split_mul<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
👎Deprecated since 0.7.0: please use widening_mul instead
pub const fn split_mul<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
widening_mul insteadCompute “wide” multiplication as a 3-tuple (lo, hi, negate).
The (lo, hi) components contain the magnitude of the product, with sizes
corresponding to the sizes of the operands; negate indicates whether the result should be
negated when converted from Uint to Int.
Note: even if negate is truthy, the magnitude might be zero!
Sourcepub const fn widening_mul<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
pub const fn widening_mul<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
Compute “wide” multiplication as a 3-tuple (lo, hi, negate).
The (lo, hi) components contain the magnitude of the product, with sizes
corresponding to the sizes of the operands; negate indicates whether the result should be
negated when converted from Uint to Int.
Note: even if negate is truthy, the magnitude might be zero!
Sourcepub const fn concatenating_mul<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> Int<WIDE_LIMBS>
pub const fn concatenating_mul<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> Int<WIDE_LIMBS>
Multiply self by rhs, returning a concatenated “wide” result.
Sourcepub const fn checked_mul<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> CtOption<Self>
pub const fn checked_mul<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> CtOption<Self>
Multiply self by rhs, returning a CtOption which is is_some only if
overflow did not occur.
Sourcepub const fn saturating_mul<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> Self
pub const fn saturating_mul<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> Self
Multiply self by rhs, saturating at the numeric bounds instead of overflowing.
Sourcepub const fn wrapping_mul<const RHS_LIMBS: usize>(
&self,
rhs: &Int<RHS_LIMBS>,
) -> Self
pub const fn wrapping_mul<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> Self
Multiply self by rhs, wrapping the result in case of overflow.
This is equivalent to (self * rhs) % (Uint::<LIMBS>::MAX + 1).
Source§impl<const LIMBS: usize> Int<LIMBS>
Squaring operations.
impl<const LIMBS: usize> Int<LIMBS>
Squaring operations.
Sourcepub fn concatenating_square<const WIDE_LIMBS: usize>(&self) -> Uint<WIDE_LIMBS>
pub fn concatenating_square<const WIDE_LIMBS: usize>(&self) -> Uint<WIDE_LIMBS>
Square self, returning a concatenated “wide” result.
Sourcepub fn checked_square(&self) -> CtOption<Uint<LIMBS>>
pub fn checked_square(&self) -> CtOption<Uint<LIMBS>>
Square self, checking that the result fits in the original Uint size.
Sourcepub const fn wrapping_square(&self) -> Uint<LIMBS>
pub const fn wrapping_square(&self) -> Uint<LIMBS>
Perform wrapping square, discarding overflow.
Sourcepub const fn saturating_square(&self) -> Uint<LIMBS>
pub const fn saturating_square(&self) -> Uint<LIMBS>
Perform saturating squaring, returning MAX on overflow.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn split_mul_unsigned<const RHS_LIMBS: usize>(
&self,
rhs: &Uint<RHS_LIMBS>,
) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
👎Deprecated since 0.7.0: please use widening_mul_unsigned instead
pub const fn split_mul_unsigned<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
widening_mul_unsigned insteadCompute “wide” multiplication between an Int and Uint as 3-tuple (lo, hi, negate).
The (lo, hi) components contain the magnitude of the product, with sizes
corresponding to the sizes of the operands; negate indicates whether the result should be
negated when converted from Uint to Int.
Note: even if negate is truthy, the magnitude might be zero!
Sourcepub const fn widening_mul_unsigned<const RHS_LIMBS: usize>(
&self,
rhs: &Uint<RHS_LIMBS>,
) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
pub const fn widening_mul_unsigned<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, Choice)
Compute “wide” multiplication between an Int and Uint as 3-tuple (lo, hi, negate).
The (lo, hi) components contain the magnitude of the product, with sizes
corresponding to the sizes of the operands; negate indicates whether the result should be
negated when converted from Uint to Int.
Note: even if negate is truthy, the magnitude might be zero!
Sourcepub const fn split_mul_unsigned_right<const RHS_LIMBS: usize>(
&self,
rhs: &Uint<RHS_LIMBS>,
) -> (Uint<RHS_LIMBS>, Uint<LIMBS>, Choice)
👎Deprecated since 0.7.0: please use Uint::widening_mul_signed instead
pub const fn split_mul_unsigned_right<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> (Uint<RHS_LIMBS>, Uint<LIMBS>, Choice)
Uint::widening_mul_signed insteadCompute “wide” multiplication between an Int and Uint as 3-tuple (lo, hi, negate).
The (lo, hi) components contain the magnitude of the product, with sizes
corresponding to the sizes of the operands, in reversed order; negate indicates whether
the result should be negated when converted from Uint to Int.
Note: even if negate is truthy, the magnitude might be zero!
Sourcepub const fn widening_mul_unsigned_right<const RHS_LIMBS: usize>(
&self,
rhs: &Uint<RHS_LIMBS>,
) -> (Uint<RHS_LIMBS>, Uint<LIMBS>, Choice)
👎Deprecated since 0.7.0: please use Uint::widening_mul_signed instead
pub const fn widening_mul_unsigned_right<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> (Uint<RHS_LIMBS>, Uint<LIMBS>, Choice)
Uint::widening_mul_signed insteadCompute “wide” multiplication between an Int and Uint as 3-tuple (lo, hi, negate).
The (lo, hi) components contain the magnitude of the product, with sizes
corresponding to the sizes of the operands, in reversed order; negate indicates whether
the result should be negated when converted from Uint to Int.
Note: even if negate is truthy, the magnitude might be zero!
Sourcepub const fn concatenating_mul_unsigned<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>(
&self,
rhs: &Uint<RHS_LIMBS>,
) -> Int<WIDE_LIMBS>
pub const fn concatenating_mul_unsigned<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> Int<WIDE_LIMBS>
Multiply self by Uint rhs, returning a concatenated “wide” result.
Sourcepub fn checked_mul_unsigned_right<const RHS_LIMBS: usize>(
&self,
rhs: &Uint<RHS_LIMBS>,
) -> CtOption<Int<RHS_LIMBS>>
👎Deprecated since 0.7.0: please use Uint::checked_mul(_int) instead
pub fn checked_mul_unsigned_right<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> CtOption<Int<RHS_LIMBS>>
Uint::checked_mul(_int) insteadChecked multiplication of self with an Uint<RHS_LIMBS>, where the result is to be stored
in an Int<RHS_LIMBS>.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn overflowing_neg(&self) -> (Self, Choice)
pub const fn overflowing_neg(&self) -> (Self, Choice)
Sourcepub const fn wrapping_neg(&self) -> Self
pub const fn wrapping_neg(&self) -> Self
Sourcepub const fn wrapping_neg_if(&self, negate: Choice) -> Int<LIMBS>
pub const fn wrapping_neg_if(&self, negate: Choice) -> Int<LIMBS>
Sourcepub const fn checked_neg(&self) -> CtOption<Self>
pub const fn checked_neg(&self) -> CtOption<Self>
Negate this Int.
Yields None when self == Self::MIN, since the positive counterpart of this value cannot
be represented.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn shl_vartime(&self, shift: u32) -> Self
pub const fn shl_vartime(&self, shift: u32) -> Self
Computes self << shift in variable time.
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.
§Panics
- if
shift >= Self::BITS.
Sourcepub const fn overflowing_shl(&self, shift: u32) -> CtOption<Self>
pub const fn overflowing_shl(&self, shift: u32) -> CtOption<Self>
Computes self << shift.
Returns None if shift >= Self::BITS.
Sourcepub const fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>
pub const fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>
Computes self << shift.
Returns None if shift >= Self::BITS.
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 const fn unbounded_shl(&self, shift: u32) -> Self
pub const fn unbounded_shl(&self, shift: u32) -> Self
Computes self << shift in a panic-free manner, returning zero if the shift exceeds the
precision.
Sourcepub const fn unbounded_shl_vartime(&self, shift: u32) -> Self
pub const fn unbounded_shl_vartime(&self, shift: u32) -> Self
Computes self << shift in variable-time in a panic-free manner, returning zero if the
shift exceeds the 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.
Sourcepub const fn wrapping_shl(&self, shift: u32) -> Self
pub const fn wrapping_shl(&self, shift: u32) -> Self
Computes self << shift in a panic-free manner, reducing shift modulo the type’s width.
Sourcepub const fn wrapping_shl_vartime(&self, shift: u32) -> Self
pub const fn wrapping_shl_vartime(&self, shift: u32) -> Self
Computes self << shift in variable-time in a panic-free manner, reducing shift modulo
the type’s width.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn shr(&self, shift: u32) -> Self
pub const fn shr(&self, shift: u32) -> Self
Computes self >> shift.
Note, this is signed shift right, i.e., the value shifted in on the left is equal to the most significant bit.
§Panics
- if
shift >= Self::BITS.
Sourcepub const fn shr_vartime(&self, shift: u32) -> Self
pub const fn shr_vartime(&self, shift: u32) -> Self
Computes self >> shift in variable time.
Note, this is signed shift right, i.e., the value shifted in on the left is equal to the most significant bit.
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.
§Panics
- if
shift >= Self::BITS.
Sourcepub const fn overflowing_shr(&self, shift: u32) -> CtOption<Self>
pub const fn overflowing_shr(&self, shift: u32) -> CtOption<Self>
Computes self >> shift.
Note, this is signed shift right, i.e., the value shifted in on the left is equal to the most significant bit.
Returns None if shift >= Self::BITS.
Sourcepub const fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>
pub const fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>
Computes self >> shift.
NOTE: this is signed shift right, i.e., the value shifted in on the left is equal to the most significant bit.
Returns None if shift >= Self::BITS.
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 const fn unbounded_shr(&self, shift: u32) -> Self
pub const fn unbounded_shr(&self, shift: u32) -> Self
Computes self >> shift in a panic-free manner.
If the shift exceeds the precision, returns
0whenselfis non-negative, and-1whenselfis negative.
Sourcepub const fn unbounded_shr_vartime(&self, shift: u32) -> Self
pub const fn unbounded_shr_vartime(&self, shift: u32) -> Self
Computes self >> shift in variable-time in a panic-free manner.
If the shift exceeds the precision, returns
0whenselfis non-negative, and-1whenselfis negative.
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 const fn wrapping_shr(&self, shift: u32) -> Self
pub const fn wrapping_shr(&self, shift: u32) -> Self
Computes self >> shift in a panic-free manner.
If the shift exceeds the precision, returns
0whenselfis non-negative, and-1whenselfis negative.
Sourcepub const fn wrapping_shr_vartime(&self, shift: u32) -> Self
pub const fn wrapping_shr_vartime(&self, shift: u32) -> Self
Computes self >> shift in variable-time in a panic-free manner.
If the shift exceeds the precision, returns
0whenselfis non-negative, and-1whenselfis negative.
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<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn new_from_abs_sign(
abs: Uint<LIMBS>,
is_negative: Choice,
) -> CtOption<Self>
pub const fn new_from_abs_sign( abs: Uint<LIMBS>, is_negative: Choice, ) -> CtOption<Self>
Construct new Int from an absolute value and sign.
Returns None when the result exceeds the bounds of an Int<LIMBS>.
Sourcepub const fn is_negative(&self) -> Choice
pub const fn is_negative(&self) -> Choice
Whether this Int is negative, as a Choice.
Sourcepub const fn is_positive(&self) -> Choice
pub const fn is_positive(&self) -> Choice
Whether this Int is positive, as a Choice.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
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 integer is non-negative and 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 a CtOption which is_some
only if the integer is non-negative and the square root is exact.
Variable time with respect to self.
Source§impl<const LIMBS: usize> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn underflowing_sub(&self, rhs: &Self) -> (Self, Choice)
pub const fn underflowing_sub(&self, rhs: &Self) -> (Self, Choice)
Perform subtraction, returning the result along with a Choice which is_true
only if the operation underflowed.
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> Int<LIMBS>
impl<const LIMBS: usize> Int<LIMBS>
Sourcepub const fn from_words(arr: [Word; LIMBS]) -> Self
pub const fn from_words(arr: [Word; LIMBS]) -> Self
Sourcepub const fn as_mut_words(&mut self) -> &mut [Word; LIMBS]
pub const fn as_mut_words(&mut self) -> &mut [Word; LIMBS]
Borrow the inner limbs as a mutable array 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 const fn as_mut_limbs(&mut self) -> &mut [Limb; LIMBS]
pub const fn as_mut_limbs(&mut self) -> &mut [Limb; LIMBS]
Borrow the limbs of this Int mutably.
Sourcepub const fn as_limbs_mut(&mut self) -> &mut [Limb]
👎Deprecated since 0.7.0: please use as_mut_limbs instead
pub const fn as_limbs_mut(&mut self) -> &mut [Limb]
as_mut_limbs insteadBorrow the limbs of this Int mutably.
Sourcepub const fn to_nz(self) -> CtOption<NonZero<Self>>
pub const fn to_nz(self) -> CtOption<NonZero<Self>>
Convert to a NonZero<Int<LIMBS>>.
Returns some if the original value is non-zero, and false otherwise.
Sourcepub const fn to_odd(self) -> CtOption<Odd<Self>>
pub const fn to_odd(self) -> CtOption<Odd<Self>>
Convert to a Odd<Int<LIMBS>>.
Returns some if the original value is odd, and false otherwise.
Sourcepub const fn as_uint(&self) -> &Uint<LIMBS>
pub const fn as_uint(&self) -> &Uint<LIMBS>
Interpret the data in this object as a Uint instead.
Note: this is a casting operation. See
Self::try_into_uintfor the checked equivalent, andSelf::absto obtain the absolute value ofself.
Sourcepub const fn try_into_uint(self) -> CtOption<Uint<LIMBS>>
pub const fn try_into_uint(self) -> CtOption<Uint<LIMBS>>
Get a Uint equivalent of this value; returns None if self is negative.
Note: this is a checked conversion operation. See
Self::as_uintfor the unchecked equivalent, andSelf::absto obtain the absolute value ofself.
Trait Implementations§
Source§impl<const LIMBS: usize> AddAssign<&Int<LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize> AddAssign<&Int<LIMBS>> for Int<LIMBS>
Source§fn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
+= operation. Read moreSource§impl<const LIMBS: usize> AddAssign for Int<LIMBS>
impl<const LIMBS: usize> AddAssign for Int<LIMBS>
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moreSource§impl<const LIMBS: usize> BitAndAssign<&Int<LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize> BitAndAssign<&Int<LIMBS>> for Int<LIMBS>
Source§fn bitand_assign(&mut self, other: &Self)
fn bitand_assign(&mut self, other: &Self)
&= operation. Read moreSource§impl<const LIMBS: usize> BitAndAssign for Int<LIMBS>
impl<const LIMBS: usize> BitAndAssign for Int<LIMBS>
Source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
&= operation. Read moreSource§impl<const LIMBS: usize> BitOrAssign<&Int<LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize> BitOrAssign<&Int<LIMBS>> for Int<LIMBS>
Source§fn bitor_assign(&mut self, other: &Self)
fn bitor_assign(&mut self, other: &Self)
|= operation. Read moreSource§impl<const LIMBS: usize> BitOrAssign for Int<LIMBS>
impl<const LIMBS: usize> BitOrAssign for Int<LIMBS>
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
|= operation. Read moreSource§impl<const LIMBS: usize> BitXorAssign<&Int<LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize> BitXorAssign<&Int<LIMBS>> for Int<LIMBS>
Source§fn bitxor_assign(&mut self, other: &Self)
fn bitxor_assign(&mut self, other: &Self)
^= operation. Read moreSource§impl<const LIMBS: usize> BitXorAssign for Int<LIMBS>
impl<const LIMBS: usize> BitXorAssign for Int<LIMBS>
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
^= operation. Read moreSource§impl<const LIMBS: usize> CheckedAdd for Int<LIMBS>
impl<const LIMBS: usize> CheckedAdd for Int<LIMBS>
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<const LIMBS: usize> CheckedSquareRoot for Int<LIMBS>
impl<const LIMBS: usize> CheckedSquareRoot for Int<LIMBS>
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<const LIMBS: usize> CheckedSub for Int<LIMBS>
impl<const LIMBS: usize> CheckedSub for Int<LIMBS>
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<const LIMBS: usize> ConditionallySelectable for Int<LIMBS>
Available on crate feature subtle only.
impl<const LIMBS: usize> ConditionallySelectable for Int<LIMBS>
subtle only.Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreSource§impl<const LIMBS: usize> ConstantTimeEq for Int<LIMBS>
Available on crate feature subtle only.
impl<const LIMBS: usize> ConstantTimeEq for Int<LIMBS>
subtle only.Source§impl<const LIMBS: usize> ConstantTimeGreater for Int<LIMBS>
Available on crate feature subtle only.
impl<const LIMBS: usize> ConstantTimeGreater for Int<LIMBS>
subtle only.Source§impl<const LIMBS: usize> ConstantTimeLess for Int<LIMBS>
Available on crate feature subtle only.
impl<const LIMBS: usize> ConstantTimeLess for Int<LIMBS>
subtle only.Source§impl<const LIMBS: usize> CtAssign for Int<LIMBS>
impl<const LIMBS: usize> CtAssign for Int<LIMBS>
Source§impl<const LIMBS: usize> CtAssignSlice for Int<LIMBS>
impl<const LIMBS: usize> CtAssignSlice for Int<LIMBS>
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<const LIMBS: usize> CtEqSlice for Int<LIMBS>
impl<const LIMBS: usize> CtEqSlice for Int<LIMBS>
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<'de, const LIMBS: usize> Deserialize<'de> for Int<LIMBS>
Available on crate feature serde only.
impl<'de, const LIMBS: usize> Deserialize<'de> for Int<LIMBS>
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, const RHS_LIMBS: usize> Div<&NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Int<RHS_LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Int<RHS_LIMBS>>> for Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<&NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Div<NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
Source§impl<const LIMBS: usize> DivVartime for Int<LIMBS>
impl<const LIMBS: usize> DivVartime for Int<LIMBS>
Source§fn div_vartime(&self, rhs: &NonZero<Int<LIMBS>>) -> Self
fn div_vartime(&self, rhs: &NonZero<Int<LIMBS>>) -> Self
self / rhs in variable time.Source§impl<const LIMBS: usize> FixedInteger for Int<LIMBS>
impl<const LIMBS: usize> FixedInteger for Int<LIMBS>
Source§impl<const LIMBS: usize> Gcd<NonZero<Uint<LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize> Gcd<NonZero<Uint<LIMBS>>> for Int<LIMBS>
Source§fn gcd(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output
fn gcd(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output
self and rhs.Source§fn gcd_vartime(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output
fn gcd_vartime(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output
self and rhs in variable time.Source§impl<const LIMBS: usize> Integer for Int<LIMBS>
impl<const LIMBS: usize> Integer for Int<LIMBS>
Source§fn as_mut_limbs(&mut self) -> &mut [Limb]
fn as_mut_limbs(&mut self) -> &mut [Limb]
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> MulAssign<&Int<RHS_LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> MulAssign<&Int<RHS_LIMBS>> for Int<LIMBS>
Source§fn mul_assign(&mut self, rhs: &Int<RHS_LIMBS>)
fn mul_assign(&mut self, rhs: &Int<RHS_LIMBS>)
*= operation. Read moreSource§impl<const LIMBS: usize, const RHS_LIMBS: usize> MulAssign<Int<RHS_LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> MulAssign<Int<RHS_LIMBS>> for Int<LIMBS>
Source§fn mul_assign(&mut self, rhs: Int<RHS_LIMBS>)
fn mul_assign(&mut self, rhs: Int<RHS_LIMBS>)
*= operation. Read moreSource§impl<const LIMBS: usize> Ord for Int<LIMBS>
impl<const LIMBS: usize> Ord for Int<LIMBS>
Source§impl<const LIMBS: usize> PartialOrd for Int<LIMBS>
impl<const LIMBS: usize> PartialOrd for Int<LIMBS>
Source§impl<const LIMBS: usize> Random for Int<LIMBS>
Available on crate feature rand_core only.
impl<const LIMBS: usize> Random for Int<LIMBS>
rand_core only.Source§fn try_random_from_rng<R: TryRng + ?Sized>(
rng: &mut R,
) -> Result<Self, R::Error>
fn try_random_from_rng<R: TryRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>
Generate a cryptographically secure random Int.
Source§impl<const LIMBS: usize> RandomBits for Int<LIMBS>
Available on crate feature rand_core only.
impl<const LIMBS: usize> RandomBits for Int<LIMBS>
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<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Int<RHS_LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Int<RHS_LIMBS>>> for Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<&NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<NonZero<Uint<RHS_LIMBS>>> for &Int<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> Rem<NonZero<Uint<RHS_LIMBS>>> for Int<LIMBS>
Source§impl<const LIMBS: usize> ShlAssign<i32> for Int<LIMBS>
impl<const LIMBS: usize> ShlAssign<i32> for Int<LIMBS>
Source§fn shl_assign(&mut self, shift: i32)
fn shl_assign(&mut self, shift: i32)
<<= operation. Read moreSource§impl<const LIMBS: usize> ShlAssign<u32> for Int<LIMBS>
impl<const LIMBS: usize> ShlAssign<u32> for Int<LIMBS>
Source§fn shl_assign(&mut self, shift: u32)
fn shl_assign(&mut self, shift: u32)
<<= operation. Read moreSource§impl<const LIMBS: usize> ShlAssign<usize> for Int<LIMBS>
impl<const LIMBS: usize> ShlAssign<usize> for Int<LIMBS>
Source§fn shl_assign(&mut self, shift: usize)
fn shl_assign(&mut self, shift: usize)
<<= operation. Read moreSource§impl<const LIMBS: usize> ShlVartime for Int<LIMBS>
impl<const LIMBS: usize> ShlVartime for Int<LIMBS>
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<const LIMBS: usize> ShrAssign<i32> for Int<LIMBS>
impl<const LIMBS: usize> ShrAssign<i32> for Int<LIMBS>
Source§fn shr_assign(&mut self, shift: i32)
fn shr_assign(&mut self, shift: i32)
>>= operation. Read moreSource§impl<const LIMBS: usize> ShrAssign<u32> for Int<LIMBS>
impl<const LIMBS: usize> ShrAssign<u32> for Int<LIMBS>
Source§fn shr_assign(&mut self, shift: u32)
fn shr_assign(&mut self, shift: u32)
>>= operation. Read moreSource§impl<const LIMBS: usize> ShrAssign<usize> for Int<LIMBS>
impl<const LIMBS: usize> ShrAssign<usize> for Int<LIMBS>
Source§fn shr_assign(&mut self, shift: usize)
fn shr_assign(&mut self, shift: usize)
>>= operation. Read moreSource§impl<const LIMBS: usize> ShrVartime for Int<LIMBS>
impl<const LIMBS: usize> ShrVartime for Int<LIMBS>
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<const LIMBS: usize> SubAssign<&Int<LIMBS>> for Int<LIMBS>
impl<const LIMBS: usize> SubAssign<&Int<LIMBS>> for Int<LIMBS>
Source§fn sub_assign(&mut self, rhs: &Int<LIMBS>)
fn sub_assign(&mut self, rhs: &Int<LIMBS>)
-= operation. Read moreSource§impl<const LIMBS: usize> SubAssign for Int<LIMBS>
impl<const LIMBS: usize> SubAssign for Int<LIMBS>
Source§fn sub_assign(&mut self, rhs: Int<LIMBS>)
fn sub_assign(&mut self, rhs: Int<LIMBS>)
-= operation. Read moreSource§impl<const LIMBS: usize> WrappingAdd for Int<LIMBS>
impl<const LIMBS: usize> WrappingAdd for Int<LIMBS>
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<const LIMBS: usize> WrappingMul for Int<LIMBS>
impl<const LIMBS: usize> WrappingMul for Int<LIMBS>
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<const LIMBS: usize> WrappingNeg for Int<LIMBS>
impl<const LIMBS: usize> WrappingNeg for Int<LIMBS>
Source§fn wrapping_neg(&self) -> Self
fn wrapping_neg(&self) -> Self
-self,
wrapping around at the boundary of the type. Read moreSource§impl<const LIMBS: usize> WrappingShl for Int<LIMBS>
impl<const LIMBS: usize> WrappingShl for Int<LIMBS>
Source§impl<const LIMBS: usize> WrappingShr for Int<LIMBS>
impl<const LIMBS: usize> WrappingShr for Int<LIMBS>
Source§impl<const LIMBS: usize> WrappingSub for Int<LIMBS>
impl<const LIMBS: usize> WrappingSub for Int<LIMBS>
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.