Struct Int

Source
pub struct Int<const LIMBS: usize>(/* private fields */);
Expand description

Stack-allocated big signed integer. See Uint for unsigned integers.

Created as a Uint newtype.

Implementations§

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const fn checked_add(&self, rhs: &Self) -> ConstCtOption<Self>

Perform checked addition. Returns none when the addition overflowed.

Source

pub const fn overflowing_add(&self, rhs: &Self) -> (Self, ConstChoice)

Perform addition, raising the overflow flag on overflow.

Source

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

Perform wrapping addition, discarding overflow.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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

Computes bitwise a & b.

Source

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.

Source

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

Source

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

Perform checked bitwise AND, returning a ConstCtOption which is_some always

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const fn not(&self) -> Self

Computes bitwise !a.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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

Computes bitwise a & b.

Source

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

Source

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

Perform checked bitwise OR, returning a ConstCtOption which is_some always

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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

Computes bitwise a ^ b.

Source

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

Source

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

Perform checked bitwise XOR, returning a ConstCtOption which is_some always

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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.

Source

pub const fn checked_div_rem( &self, rhs: &NonZero<Self>, ) -> (ConstCtOption<Self>, Self)

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));
Source

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

Perform checked division, returning a CtOption which is_some if

  • the rhs != 0, and
  • self != MIN or rhs != MINUS_ONE.

Note: this operation rounds towards zero, truncating any fractional part of the exact result.

Source

pub const fn rem(&self, rhs: &NonZero<Self>) -> Self

Computes self % rhs, returns the remainder.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Vartime checked division operations.

Source

pub const fn checked_div_rem_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> (ConstCtOption<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.

Source

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

pub const fn rem_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> Int<RHS_LIMBS>

Variable time equivalent of 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.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Vartime checked div-floor operations.

Source

pub const fn checked_div_rem_floor_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Int<RHS_LIMBS>>, ) -> (ConstCtOption<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.

Source

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.

Source

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

Perform checked floored division, returning a ConstCtOption which is_some only if

  • the rhs != 0, and
  • self != MIN or rhs != 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)
)
Source

pub const fn checked_div_rem_floor( &self, rhs: &NonZero<Self>, ) -> (ConstCtOption<Self>, Self)

Perform checked division and mod, returning the quotient and remainder.

The quotient is a ConstCtOption which is_some only if

  • the rhs != 0, and
  • self != MIN or rhs != 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.

Source

pub const fn div_rem_uint(&self, rhs: &NonZero<Uint<LIMBS>>) -> (Self, Self)

Compute the quotient and remainder of self / rhs.

Example:

use crypto_bigint::{I128, NonZero, U128};

let (quotient, remainder) = I128::from(8).div_rem_uint(&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_uint(&U128::from(3u32).to_nz().unwrap());
assert_eq!(quotient, I128::from(-2));
assert_eq!(remainder, I128::from(-2));
Source

pub const fn div_uint(&self, rhs: &NonZero<Uint<LIMBS>>) -> Self

Perform division. Note: this operation rounds towards zero, truncating any fractional part of the exact result.

Source

pub const fn rem_uint(&self, rhs: &NonZero<Uint<LIMBS>>) -> Self

Compute the remainder. The remainder will have the same sign as self (or be zero).

Source§

impl<const LIMBS: usize> Int<LIMBS>

Vartime checked division operations.

Source

pub const fn div_rem_uint_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> (Self, Int<RHS_LIMBS>)

Variable time equivalent of Self::div_rem_uint`.

This is variable only with respect to rhs.

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

Source

pub const fn div_uint_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Self

Variable time equivalent of Self::div_uint`.

This is variable only with respect to rhs.

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

Source

pub const fn rem_uint_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Int<RHS_LIMBS>

Variable time equivalent of Self::rem_uint`.

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

Source

pub fn div_rem_floor_uint( &self, rhs: &NonZero<Uint<LIMBS>>, ) -> (Self, Uint<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_uint(&three),
    (I128::from(2), U128::from(2u32))
);
assert_eq!(
    I128::from(-8).div_rem_floor_uint(&three),
    (I128::from(-3), U128::ONE)
);
Source

pub fn div_floor_uint(&self, rhs: &NonZero<Uint<LIMBS>>) -> Self

Perform checked division. Note: this operation rounds down.

Example:

use crypto_bigint::{I128, U128};
assert_eq!(
    I128::from(8).div_floor_uint(&U128::from(3u32).to_nz().unwrap()),
    I128::from(2)
);
assert_eq!(
    I128::from(-8).div_floor_uint(&U128::from(3u32).to_nz().unwrap()),
    I128::from(-3)
);
Source

pub fn normalized_rem(&self, rhs: &NonZero<Uint<LIMBS>>) -> Uint<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

Source

pub fn div_rem_floor_uint_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> (Self, Uint<RHS_LIMBS>)

Variable time equivalent of Self::div_rem_floor_uint`.

This is variable only with respect to rhs.

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

Source

pub fn div_floor_uint_vartime<const RHS_LIMBS: usize>( &self, rhs: &NonZero<Uint<RHS_LIMBS>>, ) -> Self

Variable time equivalent of Self::div_floor_uint`.

This is variable only with respect to rhs.

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

Source

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>

Source

pub const fn from_be_hex(hex: &str) -> Self

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

Panics if the hex is malformed or not zero-padded accordingly for the size.

See Uint::from_be_hex for more details.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const fn from_i8(n: i8) -> Self

Create a Int from an i8 (const-friendly)

Source

pub const fn from_i16(n: i16) -> Self

Create a Int from an i16 (const-friendly)

Source

pub const fn from_i32(n: i32) -> Self

Create a Int from an i32 (const-friendly)

Source

pub const fn from_i64(n: i64) -> Self

Available on 64-bit only.

Create a Int from an i64 (const-friendly)

Source

pub const fn from_i128(n: i128) -> Self

Create a Int from an i128 (const-friendly)

Source§

impl<const LIMBS: usize, const UNSAT_LIMBS: usize> Int<LIMBS>
where Odd<Uint<LIMBS>>: PrecomputeInverter<Inverter = SafeGcdInverter<LIMBS, UNSAT_LIMBS>>,

Source

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

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

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const fn split_mul<const RHS_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, ConstChoice)

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!

Source

pub const fn widening_mul<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> Int<WIDE_LIMBS>
where Uint<LIMBS>: ConcatMixed<Uint<RHS_LIMBS>, MixedOutput = Uint<WIDE_LIMBS>>,

Multiply self by rhs, returning a concatenated “wide” result.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Squaring operations.

Source

pub fn widening_square<const WIDE_LIMBS: usize>(&self) -> Uint<WIDE_LIMBS>
where Uint<LIMBS>: ConcatMixed<Uint<LIMBS>, MixedOutput = Uint<WIDE_LIMBS>>,

Square self, returning a concatenated “wide” result.

Source

pub fn checked_square(&self) -> ConstCtOption<Uint<LIMBS>>

Square self, checking that the result fits in the original Uint size.

Source

pub const fn wrapping_square(&self) -> Uint<LIMBS>

Perform wrapping square, discarding overflow.

Source

pub const fn saturating_square(&self) -> Uint<LIMBS>

Perform saturating squaring, returning MAX on overflow.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const fn split_mul_uint<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> (Uint<LIMBS>, Uint<RHS_LIMBS>, ConstChoice)

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!

Source

pub const fn split_mul_uint_right<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> (Uint<RHS_LIMBS>, Uint<LIMBS>, ConstChoice)

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, 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!

Source

pub const fn widening_mul_uint<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> Int<WIDE_LIMBS>
where Uint<LIMBS>: ConcatMixed<Uint<RHS_LIMBS>, MixedOutput = Uint<WIDE_LIMBS>>,

Multiply self by Uint rhs, returning a concatenated “wide” result.

Source

pub fn checked_mul_uint_right<const RHS_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> CtOption<Int<RHS_LIMBS>>

Checked 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>

Source

pub const fn overflowing_neg(&self) -> (Self, ConstChoice)

Map this Int to its two’s-complement negation: map self to (self ^ 1111...1111) + 0000...0001.

Returns the negation, as well as whether the operation overflowed. The operation overflows when attempting to negate Int::MIN; the positive counterpart of this value cannot be represented.

Source

pub const fn wrapping_neg(&self) -> Self

Wrapping negate this Int.

Warning: this operation maps Int::MIN to itself, since the positive counterpart of this value cannot be represented.

Source

pub const fn wrapping_neg_if(&self, negate: ConstChoice) -> Int<LIMBS>

Wrapping negate this Int if negate is truthy; otherwise do nothing.

Warning: this operation maps Int::MIN to itself, since the positive counterpart of this value cannot be represented.

Source

pub const fn checked_neg(&self) -> ConstCtOption<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>

Source

pub const fn resize<const T: usize>(&self) -> Int<T>

Resize the representation of self to an Int<T>. Warning: this operation may lead to loss of information.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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

Computes self << shift.

Panics if shift >= Self::BITS.

Source

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

Computes self << shift in variable time.

Panics if shift >= Self::BITS.

Source

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

Computes self << shift.

Returns None if shift >= Self::BITS.

Source

pub const fn overflowing_shl_vartime(&self, shift: u32) -> ConstCtOption<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.

Source

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

Computes self << shift in a panic-free manner, returning zero if the shift exceeds the precision.

Source

pub const fn wrapping_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.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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.

Source

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.

Panics if shift >= Self::BITS.

Source

pub const fn overflowing_shr(&self, shift: u32) -> ConstCtOption<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.

Source

pub const fn overflowing_shr_vartime(&self, shift: u32) -> ConstCtOption<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.

Source

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

Computes self >> shift in a panic-free manner.

If the shift exceeds the precision, returns

  • 0 when self is non-negative, and
  • -1 when self is negative.
Source

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

  • 0 when self is non-negative, and
  • -1 when self is negative.
Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const fn new_from_abs_sign( abs: Uint<LIMBS>, is_negative: ConstChoice, ) -> ConstCtOption<Self>

Construct new Int from an absolute value and sign. Returns None when the absolute value does not fit in an Int<LIMBS>.

Source

pub const fn is_negative(&self) -> ConstChoice

Whether this Int is negative, as a ConstChoice.

Source

pub const fn is_positive(&self) -> ConstChoice

Whether this Int is positive, as a ConstChoice.

Source

pub const fn abs_sign(&self) -> (Uint<LIMBS>, ConstChoice)

The sign and magnitude of this Int.

Source

pub const fn abs(&self) -> Uint<LIMBS>

The magnitude of this Int.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

pub const ZERO: Self

The value 0.

Source

pub const ONE: Self

The value 1.

Source

pub const MINUS_ONE: Self = Self::FULL_MASK

The value -1

Source

pub const MIN: Self

Smallest value this Int can express.

Source

pub const MAX: Self

Maximum value this Int can express.

Source

pub const SIGN_MASK: Self = Self::MIN

Bit mask for the sign bit of this Int.

Source

pub const FULL_MASK: Self

All-one bit mask.

Source

pub const BITS: u32 = Uint<LIMBS>::BITS

Total size of the represented integer in bits.

Source

pub const BYTES: usize = Uint<LIMBS>::BYTES

Total size of the represented integer in bytes.

Source

pub const LIMBS: usize = LIMBS

The number of limbs used on this platform.

Source

pub const fn new(limbs: [Limb; LIMBS]) -> Self

Const-friendly Int constructor.

Source

pub const fn from_words(arr: [Word; LIMBS]) -> Self

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

Source

pub const fn to_words(self) -> [Word; LIMBS]

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

Source

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

Borrow the inner limbs as an array of Words.

Source

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

Borrow the inner limbs as a mutable array of Words.

Source

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

Borrow the limbs of this Int.

Source

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

Borrow the limbs of this Int mutably.

Source

pub const fn to_limbs(self) -> [Limb; LIMBS]

Convert this Int into its inner limbs.

Source

pub const fn to_nz(self) -> ConstCtOption<NonZero<Self>>

Convert to a NonZero<Int<LIMBS>>.

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

Source

pub const fn to_odd(self) -> ConstCtOption<Odd<Self>>

Convert to a Odd<Int<LIMBS>>.

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

Source

pub const fn as_uint(&self) -> &Uint<LIMBS>

Interpret the data in this type as a Uint instead.

Source

pub const fn is_min(&self) -> ConstChoice

Whether this Int is equal to Self::MIN.

Source

pub fn is_max(&self) -> ConstChoice

Whether this Int is equal to Self::MAX.

Trait Implementations§

Source§

impl<const LIMBS: usize> Add<&Int<LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const LIMBS: usize> Add for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const LIMBS: usize> AddAssign<&Int<LIMBS>> for Int<LIMBS>

Source§

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

Performs the += operation. Read more
Source§

impl<const LIMBS: usize> AddAssign for Int<LIMBS>

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl<const LIMBS: usize> AsMut<[Limb]> for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> AsMut<[u64; LIMBS]> for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> AsRef<[Limb]> for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> AsRef<[u64; LIMBS]> for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> Binary for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> BitAnd<&Int<LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &Int<LIMBS>) -> Int<LIMBS>

Performs the & operation. Read more
Source§

impl<const LIMBS: usize> BitAnd<&Int<LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &Int<LIMBS>) -> Int<LIMBS>

Performs the & operation. Read more
Source§

impl<const LIMBS: usize> BitAnd<Int<LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Int<LIMBS>) -> Int<LIMBS>

Performs the & operation. Read more
Source§

impl<const LIMBS: usize> BitAnd for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Int<LIMBS>

Performs the & operation. Read more
Source§

impl<const LIMBS: usize> BitAndAssign<&Int<LIMBS>> for Int<LIMBS>

Source§

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

Performs the &= operation. Read more
Source§

impl<const LIMBS: usize> BitAndAssign for Int<LIMBS>

Source§

fn bitand_assign(&mut self, other: Self)

Performs the &= operation. Read more
Source§

impl<const LIMBS: usize> BitOr<&Int<LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Int<LIMBS>) -> Int<LIMBS>

Performs the | operation. Read more
Source§

impl<const LIMBS: usize> BitOr<&Int<LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Int<LIMBS>) -> Int<LIMBS>

Performs the | operation. Read more
Source§

impl<const LIMBS: usize> BitOr<Int<LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Int<LIMBS>) -> Int<LIMBS>

Performs the | operation. Read more
Source§

impl<const LIMBS: usize> BitOr for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Int<LIMBS>

Performs the | operation. Read more
Source§

impl<const LIMBS: usize> BitOrAssign<&Int<LIMBS>> for Int<LIMBS>

Source§

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

Performs the |= operation. Read more
Source§

impl<const LIMBS: usize> BitOrAssign for Int<LIMBS>

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl<const LIMBS: usize> BitXor<&Int<LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &Int<LIMBS>) -> Int<LIMBS>

Performs the ^ operation. Read more
Source§

impl<const LIMBS: usize> BitXor<&Int<LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &Int<LIMBS>) -> Int<LIMBS>

Performs the ^ operation. Read more
Source§

impl<const LIMBS: usize> BitXor<Int<LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Int<LIMBS>) -> Int<LIMBS>

Performs the ^ operation. Read more
Source§

impl<const LIMBS: usize> BitXor for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Int<LIMBS>

Performs the ^ operation. Read more
Source§

impl<const LIMBS: usize> BitXorAssign<&Int<LIMBS>> for Int<LIMBS>

Source§

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

Performs the ^= operation. Read more
Source§

impl<const LIMBS: usize> BitXorAssign for Int<LIMBS>

Source§

fn bitxor_assign(&mut self, other: Self)

Performs the ^= operation. Read more
Source§

impl<const LIMBS: usize> Bounded for Int<LIMBS>

Source§

const BITS: u32 = Self::BITS

Size of this integer in bits.
Source§

const BYTES: usize = Self::BYTES

Size of this integer in bytes.
Source§

impl<const LIMBS: usize> CheckedAdd for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> CheckedDiv for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize, const RHS_LIMBS: usize> CheckedMul<Int<RHS_LIMBS>> for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize, const RHS_LIMBS: usize> CheckedMul<Uint<RHS_LIMBS>> for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> CheckedSub for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> Clone for Int<LIMBS>

Source§

fn clone(&self) -> Int<LIMBS>

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

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

Performs copy-assignment from source. Read more
Source§

impl<const LIMBS: usize> ConditionallySelectable for Int<LIMBS>

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

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

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl<const LIMBS: usize> ConstZero for Int<LIMBS>

Source§

const ZERO: Self = Self::ZERO

The additive identity element of Self, 0.
Source§

impl<const LIMBS: usize> ConstantTimeEq for Int<LIMBS>

Source§

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

Determine if two items are equal. Read more
Source§

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

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

impl<const LIMBS: usize> ConstantTimeGreater for Int<LIMBS>

Source§

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

Determine whether self > other. Read more
Source§

impl<const LIMBS: usize> ConstantTimeLess for Int<LIMBS>

Source§

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

Determine whether self < other. Read more
Source§

impl<const LIMBS: usize> Constants for Int<LIMBS>

Source§

const ONE: Self = Self::ONE

The value 1.
Source§

const MAX: Self = Self::MAX

Maximum value this integer can express.
Source§

impl<const LIMBS: usize> Debug for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> Default for Int<LIMBS>

Source§

fn default() -> Self

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

impl<'de, const LIMBS: usize> Deserialize<'de> for Int<LIMBS>
where Int<LIMBS>: Encoding,

Available on crate feature serde only.
Source§

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

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

impl<const LIMBS: usize> Display for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> Div<&NonZero<Int<LIMBS>>> for &Int<LIMBS>

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<&NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<&NonZero<Uint<LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<&NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<NonZero<Int<LIMBS>>> for &Int<LIMBS>

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<NonZero<Uint<LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> Div<NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const LIMBS: usize> DivAssign<&NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the /= operation. Read more
Source§

impl<const LIMBS: usize> DivAssign<&NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the /= operation. Read more
Source§

impl<const LIMBS: usize> DivAssign<NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the /= operation. Read more
Source§

impl<const LIMBS: usize> DivAssign<NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the /= operation. Read more
Source§

impl<const LIMBS: usize, const LIMBS2: usize> From<&Int<LIMBS>> for Int<LIMBS2>

Source§

fn from(num: &Int<LIMBS>) -> Int<LIMBS2>

Converts to this type from the input type.
Source§

impl From<Int<1>> for i64

Source§

fn from(n: I64) -> i64

Converts to this type from the input type.
Source§

impl From<Int<2>> for i128

Source§

fn from(n: I128) -> i128

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<i128> for Int<LIMBS>

Source§

fn from(n: i128) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<i16> for Int<LIMBS>

Source§

fn from(n: i16) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<i32> for Int<LIMBS>

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<i64> for Int<LIMBS>

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<i8> for Int<LIMBS>

Source§

fn from(n: i8) -> Self

Converts to this type from the input type.
Source§

impl<const SAT_LIMBS: usize, const UNSAT_LIMBS: usize> Gcd<Int<SAT_LIMBS>> for Uint<SAT_LIMBS>
where Odd<Uint<SAT_LIMBS>>: PrecomputeInverter<Inverter = SafeGcdInverter<SAT_LIMBS, UNSAT_LIMBS>>,

Gcd of a Uint and an Int.

Source§

type Output = Uint<SAT_LIMBS>

Output type.
Source§

fn gcd(&self, rhs: &Int<SAT_LIMBS>) -> Self::Output

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

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

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

impl<const SAT_LIMBS: usize, const UNSAT_LIMBS: usize> Gcd<Uint<SAT_LIMBS>> for Int<SAT_LIMBS>
where Odd<Uint<SAT_LIMBS>>: PrecomputeInverter<Inverter = SafeGcdInverter<SAT_LIMBS, UNSAT_LIMBS>>,

Gcd of an Int and a Uint.

Source§

type Output = Uint<SAT_LIMBS>

Output type.
Source§

fn gcd(&self, rhs: &Uint<SAT_LIMBS>) -> Self::Output

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

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

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

impl<const SAT_LIMBS: usize, const UNSAT_LIMBS: usize> Gcd for Int<SAT_LIMBS>
where Odd<Uint<SAT_LIMBS>>: PrecomputeInverter<Inverter = SafeGcdInverter<SAT_LIMBS, UNSAT_LIMBS>>,

Gcd of two Ints

Source§

type Output = Uint<SAT_LIMBS>

Output type.
Source§

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

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

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

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

impl<const LIMBS: usize> Hash for Int<LIMBS>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const LIMBS: usize> InvMod<NonZero<Uint<LIMBS>>> for Int<LIMBS>
where Uint<LIMBS>: InvMod<Output = Uint<LIMBS>>,

Source§

type Output = Uint<LIMBS>

Output type.
Source§

fn inv_mod(&self, modulus: &NonZero<Uint<LIMBS>>) -> CtOption<Self::Output>

Compute 1 / self mod p.
Source§

impl<const LIMBS: usize> LowerHex for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<&Int<RHS_LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Int<RHS_LIMBS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<&Int<RHS_LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Int<RHS_LIMBS>) -> Self

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<&Uint<RHS_LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Uint<RHS_LIMBS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<&Uint<RHS_LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Uint<RHS_LIMBS>) -> Self

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<Int<RHS_LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Int<RHS_LIMBS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<Int<RHS_LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Int<RHS_LIMBS>) -> Self

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<Uint<RHS_LIMBS>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Uint<RHS_LIMBS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, const RHS_LIMBS: usize> Mul<Uint<RHS_LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Uint<RHS_LIMBS>) -> Self

Performs the * operation. Read more
Source§

impl<const LIMBS: usize> Not for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl<const LIMBS: usize> One for Int<LIMBS>

Source§

fn one() -> Self

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

fn is_one(&self) -> bool

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

fn set_one(&mut self)

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

impl<const LIMBS: usize> Ord for Int<LIMBS>

Source§

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

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

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

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

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

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

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

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

impl<const LIMBS: usize> PartialEq for Int<LIMBS>

Source§

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

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

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

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

impl<const LIMBS: usize> PartialOrd for Int<LIMBS>

Source§

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

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

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

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

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

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

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

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

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

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

impl<const LIMBS: usize> Random for Int<LIMBS>

Available on crate feature rand_core only.
Source§

fn random(rng: &mut (impl RngCore + ?Sized)) -> Self

Generate a cryptographically secure random Int.

Source§

impl<const LIMBS: usize> RandomBits for Int<LIMBS>

Available on crate feature rand_core only.
Source§

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

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

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

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

fn random_bits(rng: &mut (impl RngCore + ?Sized), bit_length: u32) -> Self

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

fn random_bits_with_precision( rng: &mut (impl RngCore + ?Sized), bit_length: u32, bits_precision: u32, ) -> Self

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

impl<const LIMBS: usize> Rem<&NonZero<Int<LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<&NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<&NonZero<Uint<LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<&NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<NonZero<Int<LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<NonZero<Uint<LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> Rem<NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const LIMBS: usize> RemAssign<&NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the %= operation. Read more
Source§

impl<const LIMBS: usize> RemAssign<&NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the %= operation. Read more
Source§

impl<const LIMBS: usize> RemAssign<NonZero<Int<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the %= operation. Read more
Source§

impl<const LIMBS: usize> RemAssign<NonZero<Uint<LIMBS>>> for Int<LIMBS>

Source§

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

Performs the %= operation. Read more
Source§

impl<const LIMBS: usize> Serialize for Int<LIMBS>
where Int<LIMBS>: Encoding,

Available on crate feature serde only.
Source§

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

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

impl<const LIMBS: usize> Shl<i32> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shl(self, shift: i32) -> Int<LIMBS>

Performs the << operation. Read more
Source§

impl<const LIMBS: usize> Shl<i32> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shl(self, shift: i32) -> Int<LIMBS>

Performs the << operation. Read more
Source§

impl<const LIMBS: usize> Shl<u32> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shl(self, shift: u32) -> Int<LIMBS>

Performs the << operation. Read more
Source§

impl<const LIMBS: usize> Shl<u32> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shl(self, shift: u32) -> Int<LIMBS>

Performs the << operation. Read more
Source§

impl<const LIMBS: usize> Shl<usize> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shl(self, shift: usize) -> Int<LIMBS>

Performs the << operation. Read more
Source§

impl<const LIMBS: usize> Shl<usize> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shl(self, shift: usize) -> Int<LIMBS>

Performs the << operation. Read more
Source§

impl<const LIMBS: usize> ShlAssign<i32> for Int<LIMBS>

Source§

fn shl_assign(&mut self, shift: i32)

Performs the <<= operation. Read more
Source§

impl<const LIMBS: usize> ShlAssign<u32> for Int<LIMBS>

Source§

fn shl_assign(&mut self, shift: u32)

Performs the <<= operation. Read more
Source§

impl<const LIMBS: usize> ShlAssign<usize> for Int<LIMBS>

Source§

fn shl_assign(&mut self, shift: usize)

Performs the <<= operation. Read more
Source§

impl<const LIMBS: usize> ShlVartime for Int<LIMBS>

Source§

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

Computes self << shift. Read more
Source§

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

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

impl<const LIMBS: usize> Shr<i32> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shr(self, shift: i32) -> Int<LIMBS>

Performs the >> operation. Read more
Source§

impl<const LIMBS: usize> Shr<i32> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shr(self, shift: i32) -> Int<LIMBS>

Performs the >> operation. Read more
Source§

impl<const LIMBS: usize> Shr<u32> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shr(self, shift: u32) -> Int<LIMBS>

Performs the >> operation. Read more
Source§

impl<const LIMBS: usize> Shr<u32> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shr(self, shift: u32) -> Int<LIMBS>

Performs the >> operation. Read more
Source§

impl<const LIMBS: usize> Shr<usize> for &Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shr(self, shift: usize) -> Int<LIMBS>

Performs the >> operation. Read more
Source§

impl<const LIMBS: usize> Shr<usize> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

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

fn shr(self, shift: usize) -> Int<LIMBS>

Performs the >> operation. Read more
Source§

impl<const LIMBS: usize> ShrAssign<i32> for Int<LIMBS>

Source§

fn shr_assign(&mut self, shift: i32)

Performs the >>= operation. Read more
Source§

impl<const LIMBS: usize> ShrAssign<u32> for Int<LIMBS>

Source§

fn shr_assign(&mut self, shift: u32)

Performs the >>= operation. Read more
Source§

impl<const LIMBS: usize> ShrAssign<usize> for Int<LIMBS>

Source§

fn shr_assign(&mut self, shift: usize)

Performs the >>= operation. Read more
Source§

impl<const LIMBS: usize> ShrVartime for Int<LIMBS>

Source§

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

Computes self >> shift. Read more
Source§

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

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

impl<const LIMBS: usize> Sub<&Int<LIMBS>> for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const LIMBS: usize> Sub for Int<LIMBS>

Source§

type Output = Int<LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const LIMBS: usize> UpperHex for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> WrappingAdd for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> WrappingShl for Int<LIMBS>

Source§

fn wrapping_shl(&self, shift: u32) -> Int<LIMBS>

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

impl<const LIMBS: usize> WrappingShr for Int<LIMBS>

Source§

fn wrapping_shr(&self, shift: u32) -> Int<LIMBS>

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

impl<const LIMBS: usize> WrappingSub for Int<LIMBS>

Source§

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

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

impl<const LIMBS: usize> Zero for Int<LIMBS>

Source§

fn zero() -> Self

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

fn is_zero(&self) -> bool

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

fn set_zero(&mut self)

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

impl<const LIMBS: usize> Copy for Int<LIMBS>

Source§

impl<const LIMBS: usize> Eq for Int<LIMBS>

Auto Trait Implementations§

§

impl<const LIMBS: usize> Freeze for Int<LIMBS>

§

impl<const LIMBS: usize> RefUnwindSafe for Int<LIMBS>

§

impl<const LIMBS: usize> Send for Int<LIMBS>

§

impl<const LIMBS: usize> Sync for Int<LIMBS>

§

impl<const LIMBS: usize> Unpin for Int<LIMBS>

§

impl<const LIMBS: usize> UnwindSafe for Int<LIMBS>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T> ConstantTimeSelect for T

Source§

fn ct_select(a: &T, b: &T, choice: Choice) -> T

Select a or b according to choice. Read more
Source§

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

Conditionally assign other to self, according to choice.
Source§

fn ct_swap(a: &mut T, b: &mut T, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> Zero for T

Source§

fn zero() -> T

The value 0.
Source§

fn is_zero(&self) -> Choice

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

fn set_zero(&mut self)

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

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

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

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