Skip to main content

Int

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) -> CtOption<Self>

Perform checked addition. Returns none when the addition overflowed.

Source

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

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) -> CtOption<Self>

Perform checked bitwise AND, returning a CtOption 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) -> CtOption<Self>

Perform checked bitwise OR, returning a CtOption 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) -> CtOption<Self>

Perform checked bitwise XOR, returning a CtOption 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<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));
Source

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 != MIN or rhs != MINUS_ONE.

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

Source

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

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>>, ) -> (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.

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>>, ) -> (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.

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<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 != 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<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 != 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_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));
Source

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

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

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_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.

Source

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.

Source

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

Source

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

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

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

Source

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.

Source

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.

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.

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>

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

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> Int<LIMBS>

Source

pub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Uint<LIMBS>

Compute the greatest common divisor of self and rhs.

Source

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

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

Executes the Extended GCD algorithm.

Given (self, rhs), computes (g, x, y), s.t. self * x + rhs * y = g = gcd(self, rhs).

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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

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

Source

pub const fn invert_mod( &self, modulus: &NonZero<Uint<LIMBS>>, ) -> CtOption<Uint<LIMBS>>

Computes the multiplicative inverse of self mod modulus.

Returns some if an inverse exists, otherwise none.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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.

Source

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>

Source

pub 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

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>( &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!

Source

pub const fn concatenating_mul<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>( &self, rhs: &Int<RHS_LIMBS>, ) -> Int<WIDE_LIMBS>
where Uint<LIMBS>: Concat<RHS_LIMBS, Output = Uint<WIDE_LIMBS>>,

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

Source

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.

Source

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.

Source

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.

Source

pub fn concatenating_square<const WIDE_LIMBS: usize>(&self) -> Uint<WIDE_LIMBS>
where Uint<LIMBS>: Concat<LIMBS, Output = Uint<WIDE_LIMBS>>,

Square self, returning a concatenated “wide” result.

Source

pub fn checked_square(&self) -> CtOption<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_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

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

Source

pub 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

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

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 concatenating_mul_unsigned<const RHS_LIMBS: usize, const WIDE_LIMBS: usize>( &self, rhs: &Uint<RHS_LIMBS>, ) -> Int<WIDE_LIMBS>
where Uint<LIMBS>: Concat<RHS_LIMBS, Output = Uint<WIDE_LIMBS>>,

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

Source

pub 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

Checked multiplication of self with an Uint<RHS_LIMBS>, where the result is to be stored in an Int<RHS_LIMBS>.

Source

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

Checked multiplication with a Uint.

Source§

impl<const LIMBS: usize> Int<LIMBS>

Source

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

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: Choice) -> 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) -> 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>

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.

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.
Source

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

Computes self << shift.

Returns None if shift >= Self::BITS.

Source

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.

Source

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.

Source

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.

Source

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

Computes self << shift in a panic-free manner, reducing shift modulo the type’s width.

Source

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>

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.

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.
Source

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.

Source

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.

Source

pub const fn unbounded_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 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

  • 0 when self is non-negative, and
  • -1 when self is 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

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.

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>

Source

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

Source

pub const fn is_negative(&self) -> Choice

Whether this Int is negative, as a Choice.

Source

pub const fn is_positive(&self) -> Choice

Whether this Int is positive, as a Choice.

Source

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

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

Source

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>

Source

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.

Source

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>

Source

pub const ZERO: Self

The value 0.

Source

pub const ONE: Self

The value 1.

Source

pub const MINUS_ONE: Self

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 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 const fn as_mut_words(&mut self) -> &mut [Word; LIMBS]

Borrow the inner limbs as a mutable array of Words.

Source

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

👎Deprecated since 0.7.0: please use as_mut_words instead

Borrow the inner limbs as a mutable slice of Words.

Source

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

Borrow the limbs of this Int.

Source

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

Borrow the limbs of this Int mutably.

Source

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

👎Deprecated since 0.7.0: please use as_mut_limbs instead

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) -> CtOption<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) -> CtOption<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 object as a Uint instead.

Note: this is a casting operation. See

Source

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

Source

pub const fn is_min(&self) -> Choice

Whether this Int is equal to Self::MIN.

Source

pub const fn is_max(&self) -> Choice

Whether this Int is equal to Self::MAX.

Source

pub const fn is_zero(&self) -> Choice

Is this Int equal to zero?

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, const RHS_LIMBS: usize> CheckedDiv<Int<RHS_LIMBS>> for Int<LIMBS>

Source§

fn checked_div(&self, rhs: &Int<RHS_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> CheckedSquareRoot for Int<LIMBS>

Source§

type Output = Int<LIMBS>

Output of the square root operation.
Source§

fn checked_sqrt(&self) -> CtOption<Self::Output>

Computes sqrt(self), returning none if no root exists.
Source§

fn checked_sqrt_vartime(&self) -> Option<Self::Output>

Computes sqrt(self), returning none if no root exists. Read more
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 duplicate 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>

Available on crate feature subtle only.
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> ConstOne for Int<LIMBS>

Source§

const ONE: Self = Self::ONE

The multiplicative identity element of Self, 1.
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>

Available on crate feature subtle only.
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>

Available on crate feature subtle only.
Source§

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

Determine whether self > other. Read more
Source§

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

Available on crate feature subtle only.
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 MAX: Self = Self::MAX

Maximum value this integer can express.
Source§

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

Source§

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

Conditionally assign src to self if choice is Choice::TRUE.
Source§

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

Source§

fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)

Conditionally assign src to dst if choice is Choice::TRUE, or leave it unchanged for Choice::FALSE.
Source§

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

Source§

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

Determine if self is equal to other in constant-time.
Source§

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

Determine if self is NOT equal to other in constant-time.
Source§

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

Source§

fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice

Determine if a is equal to b in constant-time.
Source§

fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice

Determine if a is NOT equal to b in constant-time.
Source§

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

Source§

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

Compute whether self > other in constant time.
Source§

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

Source§

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

Compute whether self < other in constant time.
Source§

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

Source§

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

Select between self and other based on choice, returning a copy of the value. Read more
Source§

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

Conditionally swap self and other if choice is Choice::TRUE.
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, const RHS_LIMBS: usize> Div<&NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = CtOption<Int<LIMBS>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

type Output = Int<LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZero<Uint<RHS_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> DivVartime for Int<LIMBS>

Source§

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

Computes self / rhs in variable time.
Source§

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

Source§

const LIMBS: usize = LIMBS

The number of limbs used on this platform.
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 LIMBS: usize> Gcd<Int<LIMBS>> for NonZeroInt<LIMBS>

Source§

type Output = NonZero<Uint<LIMBS>>

Output type.
Source§

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

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

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

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

impl<const LIMBS: usize> Gcd<Int<LIMBS>> for OddInt<LIMBS>

Source§

type Output = Odd<Uint<LIMBS>>

Output type.
Source§

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

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

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

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

impl<const LIMBS: usize> Gcd<Int<LIMBS>> for Uint<LIMBS>

Source§

type Output = Uint<LIMBS>

Output type.
Source§

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

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

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

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

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

Source§

type Output = NonZero<Uint<LIMBS>>

Output type.
Source§

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

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

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

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

impl<const LIMBS: usize> Gcd<Odd<Uint<LIMBS>>> for Int<LIMBS>

Source§

type Output = Odd<Uint<LIMBS>>

Output type.
Source§

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

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

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

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

impl<const LIMBS: usize> Gcd<Uint<LIMBS>> for Int<LIMBS>

Source§

type Output = Uint<LIMBS>

Output type.
Source§

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

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

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

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

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

Source§

type Output = Uint<LIMBS>

Output type.
Source§

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

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

fn gcd_vartime(&self, rhs: &Int<LIMBS>) -> 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> Integer for Int<LIMBS>

Source§

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

Borrow the raw limbs used to represent this integer.
Source§

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

Mutably borrow the raw limbs used to represent this integer.
Source§

fn nlimbs(&self) -> usize

Number of limbs in this integer.
Source§

fn is_odd(&self) -> Choice

Is this integer value an odd number? Read more
Source§

fn is_even(&self) -> Choice

Is this integer value an even number? Read more
Source§

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

Source§

type Output = Uint<LIMBS>

Output type.
Source§

fn invert_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, const RHS_LIMBS: usize> MulAssign<&Int<RHS_LIMBS>> for Int<LIMBS>

Source§

fn mul_assign(&mut self, rhs: &Int<RHS_LIMBS>)

Performs the *= operation. Read more
Source§

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

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.
Source§

fn is_one(&self) -> Choice

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

fn set_one(&mut self)

Set self to its multiplicative identity, i.e. Self::one.
Source§

fn one_like(_other: &Self) -> Self

Return the value 0 with the same precision as other.
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 try_random_from_rng<R: TryRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>

Generate a cryptographically secure random Int.

Source§

fn random_from_rng<R: Rng + ?Sized>(rng: &mut R) -> Self

Generate a random value. Read more
Source§

fn try_random() -> Result<Self, Error>

Available on crate feature getrandom only.
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

fn random() -> Self

Available on crate feature getrandom only.
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

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

Available on crate feature rand_core only.
Source§

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

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

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

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<R: TryRng + ?Sized>(rng: &mut R, bit_length: u32) -> Self

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

fn random_bits_with_precision<R: TryRng + ?Sized>( rng: &mut R, 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, const RHS_LIMBS: usize> Rem<&NonZero<Int<RHS_LIMBS>>> for &Int<LIMBS>

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

type Output = Int<RHS_LIMBS>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NonZero<Uint<RHS_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) -> Option<Self>

Computes self << shift. Read more
Source§

fn unbounded_shl_vartime(&self, shift: u32) -> 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) -> Option<Self>

Computes self >> shift. Read more
Source§

fn unbounded_shr_vartime(&self, shift: u32) -> 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> Signed for Int<LIMBS>

Source§

type Unsigned = Uint<LIMBS>

Corresponding unsigned integer type.
Source§

fn abs_sign(&self) -> (Uint<LIMBS>, Choice)

The sign and magnitude of this Signed.
Source§

fn is_negative(&self) -> Choice

Whether this Signed is negative (and non-zero), as a Choice.
Source§

fn is_positive(&self) -> Choice

Whether this Signed is positive (and non-zero), as a Choice.
Source§

fn abs(&self) -> Self::Unsigned

The magnitude of this Signed.
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> SubAssign<&Int<LIMBS>> for Int<LIMBS>

Source§

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

Performs the -= operation. Read more
Source§

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

Source§

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

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> WrappingMul for Int<LIMBS>

Source§

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

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

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

Source§

fn wrapping_neg(&self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type. Read more
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> Xgcd for Int<LIMBS>

Source§

type Output = XgcdOutput<LIMBS, Uint<LIMBS>>

Output type.
Source§

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

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

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

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

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

Source§

fn zero() -> Self

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

fn is_zero(&self) -> Choice

Determine if this value is equal to 0. 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<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> UnsafeUnpin for Int<LIMBS>

§

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

Blanket Implementations§

Source§

impl<T, Rhs> InvMod<Rhs> for T
where T: InvertMod<Rhs>,

Source§

type Output = <T as InvertMod<Rhs>>::Output

👎Deprecated since 0.7.0: please use InvertMod instead
Output type.
Source§

fn inv_mod(&self, p: &Rhs) -> CtOption<<T as InvMod<Rhs>>::Output>

👎Deprecated since 0.7.0: please use InvertMod instead
Compute 1 / self mod p.
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, dest: *mut u8)

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

impl<T, const N: usize> CtSelectArray<N> for T

Source§

fn ct_select_array(a: &[T; N], b: &[T; N], choice: Choice) -> [T; N]

Select between a and b in constant-time based on choice.
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, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

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