Skip to main content

Odd

Struct Odd 

Source
#[repr(transparent)]
pub struct Odd<T: ?Sized>(pub(crate) T);
Expand description

Wrapper type for odd integers.

These are frequently used in cryptography, e.g. as a modulus.

Tuple Fields§

§0: T

Implementations§

Source§

impl<const LIMBS: usize> Odd<Uint<LIMBS>>

Source

const fn half_mod(q: &Self) -> Self

Compute 1/2 mod q.

Source

const fn mul_add_div2k( &self, b: Limb, addend: &Uint<LIMBS>, k: u32, ) -> Uint<LIMBS>

Compute ((self * b) + addend) / 2^k

Source§

impl<const LIMBS: usize> Odd<Uint<LIMBS>>

Source

pub(crate) const MINIMAL_BINGCD_ITERATIONS: u32

The minimal number of binary GCD iterations required to guarantee successful completion.

Source

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

Computes gcd(self, rhs), leveraging (a constant time implementation of) the classic Binary GCD algorithm.

Note: this algorithm is efficient for Uints with relatively few LIMBS.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 1. https://eprint.iacr.org/2020/972.pdf

Source

pub(crate) const fn classic_bingcd_(&self, rhs: &Uint<LIMBS>) -> (Self, Word)

Computes gcd(self, rhs), leveraging (a constant time implementation of) the classic Binary GCD algorithm.

Note: this algorithm is efficient for Uints with relatively few LIMBS.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 1. https://eprint.iacr.org/2020/972.pdf

This method returns a pair consisting of the GCD and the sign of the Jacobi symbol, 0 for positive and 1 for negative.

Source

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

Variable time equivalent of Self::classic_bingcd.

Source

pub(crate) const fn classic_bingcd_vartime_( &self, rhs: &Uint<LIMBS>, ) -> (Self, Word)

Variable time equivalent of Self::classic_bingcd_.

Source

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

Computes gcd(self, rhs), leveraging the optimized Binary GCD algorithm.

Note: this algorithm becomes more efficient than the classical algorithm for Uints with relatively many LIMBS. A best-effort threshold is presented in Self::bingcd.

Note: the full algorithm has an additional parameter; this function selects the best-effort value for this parameter. You might be able to further tune your performance by calling the Self::optimized_bingcd_ function directly.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 2. https://eprint.iacr.org/2020/972.pdf

Source

pub(crate) const fn optimized_bingcd_<const K: u32, const LIMBS_K: usize, const LIMBS_2K: usize>( &self, rhs: &Uint<LIMBS>, batch_max: u32, ) -> (Self, Word)

Computes gcd(self, rhs), leveraging the optimized Binary GCD algorithm.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 2. https://eprint.iacr.org/2020/972.pdf

In summary, the optimized algorithm does not operate on self and rhs directly, but instead of condensed summaries that fit in few registers. Based on these summaries, an update matrix is constructed by which self and rhs are updated in larger steps.

This function is generic over the following three values:

  • K: the number of bits used when summarizing self and rhs for the inner loop. The K top bits and K least significant bits are selected. It is recommended to keep K close to a (multiple of) the number of bits that fit in a single register.
  • LIMBS_K: should be chosen as the minimum number s.t. Uint::<LIMBS>::BITS ≥ K,
  • LIMBS_2K: should be chosen as the minimum number s.t. Uint::<LIMBS>::BITS ≥ 2K.

This method returns a pair consisting of the GCD and the sign of the Jacobi symbol, 0 for positive and 1 for negative.

Source

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

Variable time equivalent of Self::optimized_bingcd.

Source

pub(crate) const fn optimized_bingcd_vartime_<const K: u32, const LIMBS_K: usize, const LIMBS_2K: usize>( &self, rhs: &Uint<LIMBS>, batch_max: u32, ) -> (Self, Word)

Variable time equivalent of Self::optimized_bingcd_.

Source§

impl<const LIMBS: usize> Odd<Uint<LIMBS>>

Source

const MIN_BINXGCD_ITERATIONS: u32

The minimal number of binary GCD iterations required to guarantee successful completion.

Source

pub(crate) const fn binxgcd_nz( &self, rhs: &NonZeroUint<LIMBS>, ) -> RawXgcdOutput<LIMBS, PatternMatrix<LIMBS>>

Given (self, rhs), computes (g, x, y) s.t. self * x + rhs * y = g = gcd(self, rhs), leveraging the Binary Extended GCD algorithm.

Source

pub(crate) const fn binxgcd_odd( &self, rhs: &Self, ) -> RawXgcdOutput<LIMBS, PatternMatrix<LIMBS>>

Execute the classic Extended GCD algorithm.

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

Source

pub(crate) const fn classic_binxgcd( &self, rhs: &Self, ) -> RawXgcdOutput<LIMBS, DividedPatternMatrix<LIMBS>>

Execute the classic Binary Extended GCD algorithm.

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

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 1. https://eprint.iacr.org/2020/972.pdf.

Source

pub(crate) const fn optimized_binxgcd( &self, rhs: &Self, ) -> RawXgcdOutput<LIMBS, DividedPatternMatrix<LIMBS>>

Given (self, rhs), computes (g, x, y) s.t. self * x + rhs * y = g = gcd(self, rhs), leveraging the Binary Extended GCD algorithm.

Warning: self and rhs must be contained in an U128 or larger.

Note: this algorithm becomes more efficient than the classical algorithm for Uints with relatively many LIMBS. A best-effort threshold is presented in [Self::binxgcd_].

Note: the full algorithm has an additional parameter; this function selects the best-effort value for this parameter. You might be able to further tune your performance by calling the Self::optimized_bingcd_ function directly.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 2. https://eprint.iacr.org/2020/972.pdf.

Source

pub(crate) const fn optimized_binxgcd_<const K: u32, const LIMBS_K: usize, const LIMBS_2K: usize>( &self, rhs: &Self, ) -> RawXgcdOutput<LIMBS, DividedPatternMatrix<LIMBS>>

Given (self, rhs), computes (g, x, y), s.t. self * x + rhs * y = g = gcd(self, rhs), leveraging the optimized Binary Extended GCD algorithm.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 2. https://eprint.iacr.org/2020/972.pdf

In summary, the optimized algorithm does not operate on self and rhs directly, but instead of condensed summaries that fit in few registers. Based on these summaries, an update matrix is constructed by which self and rhs are updated in larger steps.

This function is generic over the following three values:

  • K: the number of bits used when summarizing self and rhs for the inner loop. The K+1 top bits and K-1 least significant bits are selected. It is recommended to keep K close to a (multiple of) the number of bits that fit in a single register.
  • LIMBS_K: should be chosen as the minimum number s.t. Uint::<LIMBS>::BITS ≥ K,
  • LIMBS_2K: should be chosen as the minimum number s.t. Uint::<LIMBS>::BITS ≥ 2K.
Source

pub(super) const fn partial_binxgcd<const UPDATE_LIMBS: usize>( &self, rhs: &Uint<LIMBS>, iterations: u32, halt_at_zero: Choice, ) -> (Self, Uint<LIMBS>, DividedPatternMatrix<UPDATE_LIMBS>, Word)

Executes the optimized Binary GCD inner loop.

Ref: Pornin, Optimized Binary GCD for Modular Inversion, Algorithm 2. https://eprint.iacr.org/2020/972.pdf.

The function outputs the reduced values (a, b) for the input values (self, rhs) as well as the matrix that yields the former two when multiplied with the latter two.

Note: this implementation deviates slightly from the paper, in that it can be instructed to “run in place” (i.e., execute iterations that do nothing) once a becomes zero. This is done by passing a truthy halt_at_zero.

The function executes in time variable in iterations.

Source§

impl<const LIMBS: usize> Odd<Int<LIMBS>>

Source

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

Compute the greatest common divisor of self and rhs.

Source

pub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> OddUint<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: &NonZero<Int<LIMBS>>, ) -> XgcdOutput<LIMBS, OddUint<LIMBS>>

Execute the Extended GCD algorithm.

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

Source§

impl<T> Odd<T>

Source

pub fn new(n: T) -> CtOption<Self>
where T: Integer,

Create a new odd integer.

Source

pub fn get(self) -> T

Returns the inner value.

Source

pub const fn get_copy(self) -> T
where T: Copy,

Returns a copy of the inner value for Copy types.

This allows the function to be const fn, since Copy is implicitly !Drop, which avoids problems around const fn destructors.

Source§

impl<T: ?Sized> Odd<T>

Source

pub const fn as_ref(&self) -> &T

Provides access to the contents of Odd in a const context.

Source

pub const fn as_nz_ref(&self) -> &NonZero<T>

All odd integers are definitionally non-zero, so we can also obtain a reference to the equivalent NonZero type.

Source§

impl<T> Odd<T>
where T: Bounded + ?Sized,

Source

pub const BITS: u32 = T::BITS

Total size of the represented integer in bits.

Source

pub const BYTES: usize = T::BYTES

Total size of the represented integer in bytes.

Source§

impl<const LIMBS: usize> Odd<Uint<LIMBS>>

Source

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

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

§Panics
  • if the hex is malformed or not zero-padded accordingly for the size.
  • if the value is even.
Source

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

Create a new Odd<Uint<LIMBS>> from the provided little endian hex string.

§Panics
  • if the hex is malformed or not zero-padded accordingly for the size.
  • if the value is even.
Source

pub const fn as_uint_ref(&self) -> &OddUintRef

Borrow this OddUint as a &OddUintRef.

Source

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

Construct an Odd<Uint<T>> from the unsigned integer value, truncating the upper bits if the value is too large to be represented.

Source§

impl<const LIMBS: usize> Odd<Int<LIMBS>>

Source

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

The sign and magnitude of this Odd<Int<{LIMBS}>>.

Source

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

The magnitude of this Odd<Int<{LIMBS}>>.

Source§

impl Odd<UintRef>

Source

pub const fn to_uint_resize<const T: usize>(&self) -> Odd<Uint<T>>

Construct an Odd<Uint<T>> from the unsigned integer value, truncating the upper bits if the value is too large to be represented.

Source§

impl Odd<BoxedUint>

Source

pub const fn as_uint_ref(&self) -> &OddUintRef

Borrow this OddBoxedUint as a &OddUintRef.

Source

pub fn random<R: TryRng + ?Sized>(rng: &mut R, bit_length: u32) -> Self

Generate a random Odd<Uint<T>>.

Source§

impl<const LIMBS: usize> Odd<Uint<LIMBS>>

Source

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

Compute the greatest common divisor of self and rhs.

Source

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

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

Execute 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> Odd<Uint<LIMBS>>

Source

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

Compute a full-width quadratic inversion, self^-1 mod 2^Self::BITS.

Source

pub(crate) const fn invert_mod2k_vartime(&self, k: u32) -> Uint<LIMBS>

Compute a quadratic inversion, self^-1 mod 2^k where k <= Self::BITS.

This method is variable-time in k only.

Source§

impl Odd<UintRef>

Source

pub const fn invert_mod_u64(&self) -> u64

Returns the multiplicative inverse of the argument modulo 2^64. The implementation is based on the Hurchalla’s method for computing the multiplicative inverse modulo a power of two.

For better understanding the implementation, the following paper is recommended: J. Hurchalla, “An Improved Integer Multiplicative Inverse (modulo 2^w)”, https://arxiv.org/pdf/2204.limbs4342.pdf

Variable time with respect to the number of words in value, however that number will be fixed for a given integer size.

Source§

impl Odd<BoxedUint>

Source

pub(crate) fn invert_mod_precision(&self) -> BoxedUint

Compute a full-width quadratic inversion, self^-1 mod 2^bits_precision().

Source

pub(crate) fn invert_mod2k_vartime(&self, k: u32) -> BoxedUint

Compute a quadratic inversion, self^-1 mod 2^k where k <= bits_precision().

This method is variable-time in k only.

Trait Implementations§

Source§

impl<T> AsRef<[Limb]> for Odd<T>
where T: AsRef<[Limb]>,

Source§

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

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

impl<T: ?Sized> AsRef<NonZero<T>> for Odd<T>

Source§

fn as_ref(&self) -> &NonZero<T>

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

impl AsRef<Odd<UintRef>> for OddBoxedUint

Available on crate feature alloc only.
Source§

fn as_ref(&self) -> &OddUintRef

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

impl<const LIMBS: usize> AsRef<Odd<UintRef>> for OddUint<LIMBS>

Source§

fn as_ref(&self) -> &OddUintRef

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

impl<T: ?Sized> AsRef<T> for Odd<T>

Source§

fn as_ref(&self) -> &T

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

impl<T> Binary for Odd<T>
where T: Binary + ?Sized,

Source§

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

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

impl<T: Clone + ?Sized> Clone for Odd<T>

Source§

fn clone(&self) -> Odd<T>

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<T> ConstOne for Odd<T>
where T: ConstOne + One,

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<T> CtAssign for Odd<T>
where T: CtAssign,

Source§

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

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

impl<T> CtAssignSlice for Odd<T>
where T: CtAssignSlice,

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<T> CtEq for Odd<T>
where T: CtEq + ?Sized,

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<T> CtEqSlice for Odd<T>
where T: CtEq,

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<T> CtSelect for Odd<T>
where T: CtSelect,

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<T: Debug + ?Sized> Debug for Odd<T>

Source§

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

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

impl<T> Default for Odd<T>
where T: One,

Source§

fn default() -> Self

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

impl<T: ?Sized> Deref for Odd<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

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

Source§

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

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

impl<const LIMBS: usize> From<&Odd<Uint<LIMBS>>> for BoxedUint

Source§

fn from(uint: &Odd<Uint<LIMBS>>) -> BoxedUint

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<&Odd<Uint<LIMBS>>> for Odd<BoxedUint>

Source§

fn from(uint: &Odd<Uint<LIMBS>>) -> Odd<BoxedUint>

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Odd<Limb>> for Odd<Uint<LIMBS>>

Source§

fn from(limb: Odd<Limb>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Odd<T>> for NonZero<T>

Source§

fn from(odd: Odd<T>) -> NonZero<T>

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Odd<Uint<LIMBS>>> for BoxedUint

Source§

fn from(uint: Odd<Uint<LIMBS>>) -> BoxedUint

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Odd<Uint<LIMBS>>> for Odd<BoxedUint>

Source§

fn from(uint: Odd<Uint<LIMBS>>) -> Odd<BoxedUint>

Converts to this type from the input type.
Source§

impl Gcd<BoxedUint> for Odd<BoxedUint>

Source§

type Output = Odd<BoxedUint>

Output type.
Source§

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

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

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

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

impl Gcd<Limb> for Odd<Limb>

Source§

type Output = Limb

Output type.
Source§

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

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

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

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

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

Source§

type Output = Odd<Uint<LIMBS>>

Output type.
Source§

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

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

fn gcd_vartime(&self, rhs: &OddInt<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<Odd<Uint<LIMBS>>> for NonZeroUint<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<Odd<Uint<LIMBS>>> for Uint<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<T: Hash + ?Sized> Hash for Odd<T>

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<T> LowerHex for Odd<T>
where T: LowerHex + ?Sized,

Source§

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

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

impl<T> Mul for Odd<T>
where T: Mul<T, Output = T>,

Any odd integer multiplied by another odd integer is definitionally odd.

Source§

type Output = Odd<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> Octal for Odd<T>
where T: Octal + ?Sized,

Source§

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

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

impl<T> One for Odd<T>
where T: One,

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<T> One for Odd<T>
where T: One + Mul<T, Output = T>,

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<T: Ord + ?Sized> Ord for Odd<T>

Source§

fn cmp(&self, other: &Odd<T>) -> 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 PartialEq<Odd<BoxedUint>> for BoxedUint

Available on crate feature alloc only.
Source§

fn eq(&self, other: &OddBoxedUint) -> 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> PartialEq<Odd<Uint<LIMBS>>> for Uint<LIMBS>

Source§

fn eq(&self, other: &Odd<Uint<LIMBS>>) -> 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<T: PartialEq + ?Sized> PartialEq for Odd<T>

Source§

fn eq(&self, other: &Odd<T>) -> 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 PartialOrd<Odd<BoxedUint>> for BoxedUint

Available on crate feature alloc only.
Source§

fn partial_cmp(&self, other: &OddBoxedUint) -> 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> PartialOrd<Odd<Uint<LIMBS>>> for Uint<LIMBS>

Source§

fn partial_cmp(&self, other: &Odd<Uint<LIMBS>>) -> 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<T: PartialOrd + ?Sized> PartialOrd for Odd<T>

Source§

fn partial_cmp(&self, other: &Odd<T>) -> 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 Odd<Uint<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 random Odd<Uint<T>>.

Source§

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

Generate a random value. Read more
Source§

impl<T> UpperHex for Odd<T>
where T: UpperHex + ?Sized,

Source§

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

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

impl<T: Zeroize> Zeroize for Odd<T>

Available on crate feature zeroize only.
Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<T: Copy + ?Sized> Copy for Odd<T>

Source§

impl<T: Eq + ?Sized> Eq for Odd<T>

Source§

impl<T: ?Sized> StructuralPartialEq for Odd<T>

Auto Trait Implementations§

§

impl<T> Freeze for Odd<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for Odd<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for Odd<T>
where T: Send + ?Sized,

§

impl<T> Sync for Odd<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for Odd<T>
where T: Unpin + ?Sized,

§

impl<T> UnsafeUnpin for Odd<T>
where T: UnsafeUnpin + ?Sized,

§

impl<T> UnwindSafe for Odd<T>
where T: UnwindSafe + ?Sized,

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, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.