#[repr(transparent)]pub struct UintRef {
pub(crate) limbs: [Limb],
}Expand description
Fields§
§limbs: [Limb]Inner limb array. Stored from least significant to most significant.
Implementations§
Source§impl UintRef
impl UintRef
Sourcepub const fn add_assign_limb(&mut self, rhs: Limb) -> Limb
pub const fn add_assign_limb(&mut self, rhs: Limb) -> Limb
Perform an in-place carrying add of a limb, returning the carried limb value.
Sourcepub const fn carrying_add_assign(&mut self, rhs: &Self, carry: Limb) -> Limb
pub const fn carrying_add_assign(&mut self, rhs: &Self, carry: Limb) -> Limb
Perform an in-place carrying add of another UintRef, returning the carried limb value.
Sourcepub const fn carrying_add_assign_slice(
&mut self,
rhs: &[Limb],
carry: Limb,
) -> Limb
pub const fn carrying_add_assign_slice( &mut self, rhs: &[Limb], carry: Limb, ) -> Limb
Perform an in-place carrying add of another limb slice, returning the carried limb value.
§Panics
If self and rhs have different lengths.
Sourcepub const fn conditional_add_assign(
&mut self,
rhs: &Self,
carry: Limb,
choice: Choice,
) -> Limb
pub const fn conditional_add_assign( &mut self, rhs: &Self, carry: Limb, choice: Choice, ) -> Limb
Perform an in-place carrying add of another limb slice, returning the carried limb value.
Source§impl UintRef
impl UintRef
Sourcepub const fn bits_precision(&self) -> u32
pub const fn bits_precision(&self) -> u32
Get the precision of this number in bits.
Sourcepub const fn bit(&self, index: u32) -> Choice
pub const fn bit(&self, index: u32) -> Choice
Get the value of the bit at position index, as a truthy or falsy Choice.
Returns the falsy value for indices out of range.
Sourcepub const fn bit_vartime(&self, index: u32) -> bool
pub const fn bit_vartime(&self, index: u32) -> bool
Returns true if the bit at position index is set, false for an unset bit
or for indices out of range.
§Remarks
This operation is variable time with respect to index only.
Sourcepub const fn bits(&self) -> u32
pub const fn bits(&self) -> u32
Calculate the number of bits needed to represent this number, i.e. the index of the highest set bit.
Use UintRef::bits_precision to get the total capacity of this integer.
Sourcepub const fn bits_vartime(&self) -> u32
pub const fn bits_vartime(&self) -> u32
Calculate the number of bits needed to represent this number in variable-time with respect
to self.
Sourcepub const fn set_bit(&mut self, index: u32, bit_value: Choice)
pub const fn set_bit(&mut self, index: u32, bit_value: Choice)
Sets the bit at index to 0 or 1 depending on the value of bit_value.
Sourcepub const fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
pub const fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
Sets the bit at index to 0 or 1 depending on the value of bit_value, in variable-time
with respect to index.
Sourcepub const fn leading_zeros(&self) -> u32
pub const fn leading_zeros(&self) -> u32
Calculate the number of leading zeros in the binary representation of this number.
Sourcepub const fn trailing_zeros(&self) -> u32
pub const fn trailing_zeros(&self) -> u32
Calculate the number of trailing zeros in the binary representation of this number.
Sourcepub const fn trailing_zeros_vartime(&self) -> u32
pub const fn trailing_zeros_vartime(&self) -> u32
Calculate the number of trailing zeros in the binary representation of this number, in
variable-time with respect to self.
Sourcepub const fn trailing_ones(&self) -> u32
pub const fn trailing_ones(&self) -> u32
Calculate the number of trailing ones in the binary representation of this number.
Sourcepub const fn trailing_ones_vartime(&self) -> u32
pub const fn trailing_ones_vartime(&self) -> u32
Calculate the number of trailing ones in the binary representation of this number, in
variable-time with respect to self.
Sourcepub const fn restrict_bits(&mut self, len: u32)
pub const fn restrict_bits(&mut self, len: u32)
Clear all bits at or above a given bit position.
Source§impl UintRef
impl UintRef
Sourcepub const fn is_odd(&self) -> Choice
pub const fn is_odd(&self) -> Choice
Returns the truthy value if self is odd or the falsy value otherwise.
Sourcepub const fn is_nonzero(&self) -> Choice
pub const fn is_nonzero(&self) -> Choice
Returns Choice::TRUE if self != 0 or Choice::FALSE otherwise.
Sourcepub(crate) const fn is_zero_vartime(&self) -> bool
pub(crate) const fn is_zero_vartime(&self) -> bool
Determine in variable time whether the self is zero.
Sourcepub(crate) const fn cmp(lhs: &Self, rhs: &Self) -> Ordering
pub(crate) const fn cmp(lhs: &Self, rhs: &Self) -> Ordering
Returns the Ordering between lhs and rhs.
Sourcepub const fn cmp_vartime(&self, rhs: &Self) -> Ordering
pub const fn cmp_vartime(&self, rhs: &Self) -> Ordering
Returns the Ordering between self and rhs in variable time.
Source§impl UintRef
impl UintRef
Sourcepub(crate) const fn div_rem(&mut self, rhs: &mut Self)
pub(crate) const fn div_rem(&mut self, rhs: &mut Self)
Computes self / rhs, returning the quotient in self and the remainder in rhs.
§Panics
If the divisor is zero.
Sourcepub(crate) const fn div_rem_vartime(&mut self, rhs: &mut Self)
pub(crate) const fn div_rem_vartime(&mut self, rhs: &mut Self)
Computes self / rhs, returning the quotient in self and the remainder in rhs.
This function operates in variable-time with respect to rhs. For a fixed divisor,
it operates in constant-time
§Panics
If the divisor is zero.
Sourcepub(crate) const fn rem_wide(
x_lower_upper: (&mut Self, &mut Self),
rhs: &mut Self,
)
pub(crate) const fn rem_wide( x_lower_upper: (&mut Self, &mut Self), rhs: &mut Self, )
Computes x_lower_upper % rhs, returning the remainder in rhs.
The x_lower_upper tuple represents a wide integer. The size of x_lower_upper.1 must be
at least as large as rhs. x_lower_upper is left in an indeterminate state.
§Panics
If the divisor is zero.
Sourcepub(crate) const fn rem_wide_vartime(
x_lower_upper: (&mut Self, &mut Self),
rhs: &mut Self,
)
pub(crate) const fn rem_wide_vartime( x_lower_upper: (&mut Self, &mut Self), rhs: &mut Self, )
Computes x_lower_upper % rhs, returning the remainder in rhs.
This function operates in variable-time with respect to rhs. For a fixed divisor,
it operates in constant-time.
The x_lower_upper tuple represents a wide integer. The size of x_lower_upper.1
must be at least as large as rhs. x_lower_upper is left in an indeterminate state.
§Panics
If the divisor is zero.
Sourcepub(crate) const fn div_rem_shifted(
&mut self,
x_hi: Limb,
y: &mut Self,
ywords: u32,
)
pub(crate) const fn div_rem_shifted( &mut self, x_hi: Limb, y: &mut Self, ywords: u32, )
Perform in-place division (self / y) for a pre-shifted dividend and divisor.
The dividend and divisor must be left-shifted such that the high bit of the divisor
is set, and x_hi holds the top bits of the dividend.
The quotient is returned in self and the remainder in y, but these values require
additional correction. This is left to the caller for performance reasons.
Sourcepub(crate) const fn div_rem_large_shifted(
&mut self,
x_hi: Limb,
y: &Self,
ywords: u32,
reciprocal: Reciprocal,
vartime: Choice,
) -> Limb
pub(crate) const fn div_rem_large_shifted( &mut self, x_hi: Limb, y: &Self, ywords: u32, reciprocal: Reciprocal, vartime: Choice, ) -> Limb
Computes self / y for a “large” divisor (>1 limbs), returning the quotient and
the remainder in self.
While the divisor may only be a single limb, additional corrections to the result are required in this case.
The dividend and divisor must be left-shifted such that the high bit of the divisor
is set, and x_hi holds the top bits of the dividend.
Sourcepub(crate) const fn div_rem_large_vartime(&mut self, rhs: &mut Self)
pub(crate) const fn div_rem_large_vartime(&mut self, rhs: &mut Self)
Perform in-place variable-time division for a “large” divisor (>1 limbs). The
quotient is returned in self and the remainder in rhs.
Sourceconst fn rem_wide_shifted(
x: (&mut Self, &mut Self),
x_hi: Limb,
y: &mut Self,
ywords: u32,
)
const fn rem_wide_shifted( x: (&mut Self, &mut Self), x_hi: Limb, y: &mut Self, ywords: u32, )
Perform in-place division (x / y) for a pre-shifted dividend and divisor,
tracking only the remainder.
The dividend and divisor must be left-shifted such that the high bit of the divisor
is set, and x_hi holds the top bits of the dividend.
The shifted remainder is returned in y, and must be unshifted by the caller.
x is left in an indeterminate state.
Sourceconst fn rem_wide_large_shifted(
x: (&Self, &mut Self),
x_hi: Limb,
y: &Self,
ywords: u32,
reciprocal: Reciprocal,
vartime: Choice,
) -> Limb
const fn rem_wide_large_shifted( x: (&Self, &mut Self), x_hi: Limb, y: &Self, ywords: u32, reciprocal: Reciprocal, vartime: Choice, ) -> Limb
Computes x % y for a “large” divisor (>1 limbs), returning the remainder in x.1.
While the divisor may only be a single limb, additional corrections to the result are required in this case.
The dividend and divisor must be left-shifted such that the high bit of the divisor
is set, and x_hi holds the top bits of the dividend.
Sourcepub(crate) const fn div_rem_limb(&mut self, rhs: NonZero<Limb>) -> Limb
pub(crate) const fn div_rem_limb(&mut self, rhs: NonZero<Limb>) -> Limb
Divides self by the divisor encoded in the reciprocal, setting self
to the quotient and returning the remainder.
Sourcepub(crate) const fn div_rem_limb_with_reciprocal(
&mut self,
reciprocal: &Reciprocal,
) -> Limb
pub(crate) const fn div_rem_limb_with_reciprocal( &mut self, reciprocal: &Reciprocal, ) -> Limb
Divides self by the divisor encoded in the reciprocal, setting self
to the quotient and returning the remainder.
Sourcepub(crate) const fn div_rem_limb_with_reciprocal_shifted(
&mut self,
hi: Limb,
reciprocal: &Reciprocal,
) -> Limb
pub(crate) const fn div_rem_limb_with_reciprocal_shifted( &mut self, hi: Limb, reciprocal: &Reciprocal, ) -> Limb
Divides self by the divisor encoded in the reciprocal, setting self
to the quotient and returning the remainder.
Sourcepub(crate) const fn rem_limb(&self, rhs: NonZero<Limb>) -> Limb
pub(crate) const fn rem_limb(&self, rhs: NonZero<Limb>) -> Limb
Divides self by the divisor encoded in the reciprocal, returning the remainder.
Sourcepub(crate) const fn rem_limb_with_reciprocal(
&self,
reciprocal: &Reciprocal,
carry: Limb,
) -> Limb
pub(crate) const fn rem_limb_with_reciprocal( &self, reciprocal: &Reciprocal, carry: Limb, ) -> Limb
Divides self by the divisor encoded in the reciprocal, and returns the remainder.
Source§impl UintRef
impl UintRef
Sourcepub fn overflowing_mul(&self, rhs: &UintRef, out: &mut UintRef) -> Choice
pub fn overflowing_mul(&self, rhs: &UintRef, out: &mut UintRef) -> Choice
Compute the wrapping product of self and rhs, placing the result into out
and returning a Choice indicating whether overflow occurred.
Sourcepub fn overflowing_square(&self, out: &mut UintRef) -> Choice
pub fn overflowing_square(&self, out: &mut UintRef) -> Choice
Compute the wrapping squaring of self, placing the result into out
and returning a Choice indicating whether overflow occurred.
Sourcepub fn wrapping_mul(&self, rhs: &UintRef, out: &mut UintRef) -> Limb
pub fn wrapping_mul(&self, rhs: &UintRef, out: &mut UintRef) -> Limb
Compute the wrapping product of self and rhs, placing the result into out
and returning a carry Limb.
Sourcepub fn wrapping_square(&self, out: &mut UintRef) -> Limb
pub fn wrapping_square(&self, out: &mut UintRef) -> Limb
Compute the wrapping squaring of self, placing the result into out and returning
a carry Limb.
Sourcepub(crate) const fn check_mul_overflow(
&self,
rhs: &UintRef,
carry: Choice,
) -> Choice
pub(crate) const fn check_mul_overflow( &self, rhs: &UintRef, carry: Choice, ) -> Choice
Determine whether overflow occurs during wrapped multiplication.
We determine this by comparing limbs in self[i=0..n] and rhs[j=0..m].
Any combination where the sum of indexes i + j >= n, having self[i] != 0
and rhs[j] != 0 would cause an overflow. For efficiency, we OR all limbs in
rhs that would apply to each limb in self in turn.
Sourcepub(crate) const fn check_square_overflow(&self, carry: Choice) -> Choice
pub(crate) const fn check_square_overflow(&self, carry: Choice) -> Choice
Determine whether overflow occurs during wrapped squaring.
Source§impl UintRef
impl UintRef
Sourcepub const fn shl_assign(&mut self, shift: u32)
pub const fn shl_assign(&mut self, shift: u32)
Sourcepub const fn overflowing_shl_assign(&mut self, shift: u32) -> Choice
pub const fn overflowing_shl_assign(&mut self, shift: u32) -> Choice
Left-shifts by shift bits in constant-time.
Returns truthy Choice and leaves self unmodified if shift >= self.bits_precision(),
otherwise returns a falsy Choice and shifts self in place.
Sourcepub const fn unbounded_shl_assign(&mut self, shift: u32)
pub const fn unbounded_shl_assign(&mut self, shift: u32)
Left-shifts by shift bits, producing zero if the shift exceeds the precision.
Sourcepub const fn bounded_shl_assign(&mut self, shift: u32, shift_upper_bound: u32)
pub const fn bounded_shl_assign(&mut self, shift: u32, shift_upper_bound: u32)
Left-shifts by shift bits where shift < shift_upper_bound.
The runtime is determined by shift_upper_bound which may be larger or smaller than
self.bits_precision().
§Panics
- if the shift exceeds the upper bound.
Sourcepub(crate) const fn bounded_shl_by_limbs_assign(
&mut self,
shift: u32,
shift_upper_bound: u32,
)
pub(crate) const fn bounded_shl_by_limbs_assign( &mut self, shift: u32, shift_upper_bound: u32, )
Left-shifts by shift * Limb::BITS bits where shift < shift_upper_bound.
The runtime is determined by shift_upper_bound which may be larger or smaller than
self.bits_precision().
§Panics
- if the shift exceeds the upper bound.
Sourcepub(crate) const fn conditional_shl_assign_by_limbs_vartime(
&mut self,
shift: u32,
c: Choice,
)
pub(crate) const fn conditional_shl_assign_by_limbs_vartime( &mut self, shift: u32, c: Choice, )
Conditionally left-shifts by shift limbs in a panic-free manner, producing zero
if the shift exceeds the precision.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub(crate) const fn unbounded_shl_assign_by_limbs_vartime(&mut self, shift: u32)
pub(crate) const fn unbounded_shl_assign_by_limbs_vartime(&mut self, shift: u32)
Left-shifts by shift limbs in a panic-free manner, producing zero if the shift
exceeds the precision.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub(crate) const fn unbounded_shl_vartime(&self, shift: u32, out: &mut Self)
pub(crate) const fn unbounded_shl_vartime(&self, shift: u32, out: &mut Self)
Copies self << shift into out in a panic-free manner, producing zero if the shift
exceeds the precision.
out is assumed to be initialized with zeros.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub const fn unbounded_shl_assign_vartime(&mut self, shift: u32)
pub const fn unbounded_shl_assign_vartime(&mut self, shift: u32)
Left-shifts by shift bits in a panic-free manner, producing zero if the shift
exceeds the precision.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub const fn wrapping_shl_assign(&mut self, shift: u32)
pub const fn wrapping_shl_assign(&mut self, shift: u32)
Left-shifts by shift bits in a panic-free manner, reducing shift modulo the type’s width.
Sourcepub const fn wrapping_shl_assign_vartime(&mut self, shift: u32)
pub const fn wrapping_shl_assign_vartime(&mut self, shift: u32)
Left-shifts by shift bits 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.
Sourcepub const fn shl1_assign(&mut self) -> Limb
pub const fn shl1_assign(&mut self) -> Limb
Left-shifts by a single bit in constant-time, returning Limb::ONE
if the least significant bit was set, and Limb::ZERO otherwise.
Sourcepub(crate) const fn shl1_assign_with_carry(&mut self, carry: Limb) -> Limb
pub(crate) const fn shl1_assign_with_carry(&mut self, carry: Limb) -> Limb
Left-shifts by a single bit in constant-time, returning Limb::ONE
if the least significant bit was set, and Limb::ZERO otherwise.
Sourcepub(crate) const fn conditional_shl_assign_limb_nonzero(
&mut self,
shift: NonZeroU32,
carry: Limb,
choice: Choice,
) -> Limb
pub(crate) const fn conditional_shl_assign_limb_nonzero( &mut self, shift: NonZeroU32, carry: Limb, choice: Choice, ) -> Limb
Conditionally left-shifts by shift bits where 0 < shift < Limb::BITS, returning
the carry.
§Panics
- if
shift >= Limb::BITS.
Sourcepub const fn shl_assign_limb(&mut self, shift: u32) -> Limb
pub const fn shl_assign_limb(&mut self, shift: u32) -> Limb
Left-shifts by shift bits where 0 < shift < Limb::BITS, returning the carry.
§Panics
- if
shift >= Limb::BITS.
Sourcepub(crate) const fn shl_assign_limb_with_carry(
&mut self,
shift: u32,
carry: Limb,
) -> Limb
pub(crate) const fn shl_assign_limb_with_carry( &mut self, shift: u32, carry: Limb, ) -> Limb
Left-shifts by shift bits where 0 < shift < Limb::BITS, returning the carry.
§Panics
- if
shift >= Limb::BITS.
Sourcepub(crate) const fn shl_assign_limb_vartime(&mut self, shift: u32) -> Limb
pub(crate) const fn shl_assign_limb_vartime(&mut self, shift: u32) -> Limb
Left-shifts by shift bits where 0 < shift < Limb::BITS, returning the carry.
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 the shift size is equal to or larger than the width of the integer.
Sourcepub(crate) const fn shl_assign_limb_with_carry_vartime(
&mut self,
shift: u32,
carry: Limb,
) -> Limb
pub(crate) const fn shl_assign_limb_with_carry_vartime( &mut self, shift: u32, carry: Limb, ) -> Limb
Left-shifts by shift bits where 0 < shift < Limb::BITS, returning the carry.
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 the shift size is equal to or larger than the width of the integer.
Source§impl UintRef
impl UintRef
Sourcepub const fn shr_assign(&mut self, shift: u32)
pub const fn shr_assign(&mut self, shift: u32)
Sourcepub const fn overflowing_shr_assign(&mut self, shift: u32) -> Choice
pub const fn overflowing_shr_assign(&mut self, shift: u32) -> Choice
Right-shifts by shift bits in constant-time.
Returns truthy Choice and leaves self unmodified if shift >= self.bits_precision(),
otherwise returns a falsy Choice and shifts self in place.
Sourcepub const fn unbounded_shr_assign(&mut self, shift: u32)
pub const fn unbounded_shr_assign(&mut self, shift: u32)
Right-shifts by shift bits, producing zero if the shift exceeds the precision.
Sourcepub const fn bounded_shr_assign(&mut self, shift: u32, shift_upper_bound: u32)
pub const fn bounded_shr_assign(&mut self, shift: u32, shift_upper_bound: u32)
Right-shifts by shift bits where shift < shift_upper_bound, producing zero if
the shift exceeds the precision.
The runtime is determined by shift_upper_bound which may be smaller than
self.bits_precision().
§Panics
- if the shift exceeds the upper bound.
Sourcepub(crate) const fn bounded_shr_by_limbs_assign(
&mut self,
shift: u32,
shift_upper_bound: u32,
)
pub(crate) const fn bounded_shr_by_limbs_assign( &mut self, shift: u32, shift_upper_bound: u32, )
Right-shifts by shift * Limb::BITS bits where shift < shift_upper_bound.
The runtime is determined by shift_upper_bound which may be larger or smaller than
self.bits_precision().
§Panics
- if the shift exceeds the upper bound.
Sourcepub(crate) const fn conditional_shr_assign_by_limbs_vartime(
&mut self,
shift: u32,
c: Choice,
)
pub(crate) const fn conditional_shr_assign_by_limbs_vartime( &mut self, shift: u32, c: Choice, )
Conditionally right-shifts by shift limbs in a panic-free manner, producing zero
if the shift exceeds the precision.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub(crate) const fn unbounded_shr_assign_by_limbs(&mut self, shift: u32)
pub(crate) const fn unbounded_shr_assign_by_limbs(&mut self, shift: u32)
Right-shifts by shift limbs in a panic-free manner, producing zero if the shift
exceeds the precision.
Sourcepub(crate) const fn unbounded_shr_assign_by_limbs_vartime(&mut self, shift: u32)
pub(crate) const fn unbounded_shr_assign_by_limbs_vartime(&mut self, shift: u32)
Right-shifts by shift limbs in a panic-free manner, producing zero if the shift
exceeds the precision.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub(crate) const fn unbounded_shr_vartime(&self, shift: u32, out: &mut Self)
pub(crate) const fn unbounded_shr_vartime(&self, shift: u32, out: &mut Self)
Copies self >> shift into out in a panic-free manner, producing zero if the shift
exceeds the precision.
out is assumed to be initialized with zeros.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub const fn unbounded_shr_assign_vartime(&mut self, shift: u32)
pub const fn unbounded_shr_assign_vartime(&mut self, shift: u32)
Right-shifts by shift bits in a panic-free manner, producing zero if the shift
exceeds the precision.
NOTE: this operation is variable time with respect to shift ONLY.
When used with a fixed shift, this function is constant-time with respect to self.
Sourcepub const fn wrapping_shr_assign(&mut self, shift: u32)
pub const fn wrapping_shr_assign(&mut self, shift: u32)
Right-shifts by shift bits in a panic-free manner, reducing shift modulo the type’s width.
Sourcepub const fn wrapping_shr_assign_vartime(&mut self, shift: u32)
pub const fn wrapping_shr_assign_vartime(&mut self, shift: u32)
Right-shifts by shift bits 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.
Sourcepub const fn shr1_assign(&mut self) -> Limb
pub const fn shr1_assign(&mut self) -> Limb
Right-shifts by a single bit in constant-time, returning Limb::ONE << Limb::HI_BIT
if the least significant bit was set, and Limb::ZERO otherwise.
Sourcepub(crate) const fn shr1_assign_with_carry(&mut self, carry: Limb) -> Limb
pub(crate) const fn shr1_assign_with_carry(&mut self, carry: Limb) -> Limb
Right-shifts by a single bit in constant-time, returning Limb::ONE << Limb::HI_BIT
if the least significant bit was set, and Limb::ZERO otherwise.
Sourcepub(crate) const fn conditional_shr_assign_limb_nonzero(
&mut self,
shift: NonZeroU32,
carry: Limb,
choice: Choice,
) -> Limb
pub(crate) const fn conditional_shr_assign_limb_nonzero( &mut self, shift: NonZeroU32, carry: Limb, choice: Choice, ) -> Limb
Conditionally right-shifts by shift bits where 0 < shift < Limb::BITS, returning
the carry.
§Panics
- if
shift >= Limb::BITS.
Sourcepub const fn shr_assign_limb(&mut self, shift: u32) -> Limb
pub const fn shr_assign_limb(&mut self, shift: u32) -> Limb
Right-shifts by shift bits where 0 < shift < Limb::BITS, returning the carry.
§Panics
- if
shift >= Limb::BITS.
Sourcepub(crate) const fn shr_assign_limb_with_carry(
&mut self,
shift: u32,
carry: Limb,
) -> Limb
pub(crate) const fn shr_assign_limb_with_carry( &mut self, shift: u32, carry: Limb, ) -> Limb
Right-shifts by shift bits where 0 < shift < Limb::BITS, returning the carry.
§Panics
- if
shift >= Limb::BITS.
Sourcepub(crate) const fn shr_assign_limb_vartime(&mut self, shift: u32) -> Limb
pub(crate) const fn shr_assign_limb_vartime(&mut self, shift: u32) -> Limb
Right-shifts by shift bits where 0 < shift < Limb::BITS, returning
the carry.
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 the shift size is equal to or larger than the width of the integer.
Sourcepub(crate) const fn shr_assign_limb_with_carry_vartime(
&mut self,
shift: u32,
carry: Limb,
) -> Limb
pub(crate) const fn shr_assign_limb_with_carry_vartime( &mut self, shift: u32, carry: Limb, ) -> Limb
Right-shifts by shift bits where 0 < shift < Limb::BITS, returning
the carry.
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 the shift size is equal to or larger than the width of the integer.
Source§impl UintRef
impl UintRef
Sourcepub const fn conditional_copy_from(&mut self, rhs: &UintRef, copy: Choice)
pub const fn conditional_copy_from(&mut self, rhs: &UintRef, copy: Choice)
Sourcepub const fn copy_from_slice(&mut self, limbs: &[Limb])
pub const fn copy_from_slice(&mut self, limbs: &[Limb])
Sourcepub const fn conditional_copy_from_slice(
&mut self,
limbs: &[Limb],
copy: Choice,
)
pub const fn conditional_copy_from_slice( &mut self, limbs: &[Limb], copy: Choice, )
Sourcepub const fn split_at(&self, mid: usize) -> (&Self, &Self)
pub const fn split_at(&self, mid: usize) -> (&Self, &Self)
Split the limb slice at a fixed position, producing head and tail slices.
Sourcepub const fn split_at_mut(&mut self, mid: usize) -> (&mut Self, &mut Self)
pub const fn split_at_mut(&mut self, mid: usize) -> (&mut Self, &mut Self)
Split the mutable limb slice at index mid, producing head and tail slices.
Sourcepub const fn leading(&self, len: usize) -> &Self
pub const fn leading(&self, len: usize) -> &Self
Access a limb slice up to a number of elements len.
Sourcepub const fn leading_mut(&mut self, len: usize) -> &mut Self
pub const fn leading_mut(&mut self, len: usize) -> &mut Self
Access a mutable limb slice up to a number of elements len.
Sourcepub const fn trailing(&self, start: usize) -> &Self
pub const fn trailing(&self, start: usize) -> &Self
Access a limb slice starting from the index start.
Sourcepub const fn trailing_mut(&mut self, start: usize) -> &mut Self
pub const fn trailing_mut(&mut self, start: usize) -> &mut Self
Access a mutable limb slice starting from the index start.
Source§impl UintRef
impl UintRef
Sourcepub const fn borrowing_sub_assign(&mut self, rhs: &Self, borrow: Limb) -> Limb
pub const fn borrowing_sub_assign(&mut self, rhs: &Self, borrow: Limb) -> Limb
Perform an in-place borrowing subtraction of another UintRef, returning the carried limb
value.
Sourcepub const fn borrowing_sub_assign_slice(
&mut self,
rhs: &[Limb],
borrow: Limb,
) -> Limb
pub const fn borrowing_sub_assign_slice( &mut self, rhs: &[Limb], borrow: Limb, ) -> Limb
Perform an in-place borrowing subtraction of another limb slice, returning the borrowed limb value.
§Panics
If self and rhs have different lengths.
Sourcepub(crate) fn conditional_borrowing_sub_assign(
&mut self,
rhs: &Self,
choice: Choice,
) -> Choice
pub(crate) fn conditional_borrowing_sub_assign( &mut self, rhs: &Self, choice: Choice, ) -> Choice
Perform in-place wrapping subtraction, returning the truthy value as the second element of the tuple if an underflow has occurred.
Source§impl UintRef
impl UintRef
Sourcepub const fn new_flattened_mut<const N: usize>(
slice: &mut [[Limb; N]],
) -> &mut Self
pub const fn new_flattened_mut<const N: usize>( slice: &mut [[Limb; N]], ) -> &mut Self
Sourcepub const fn as_mut_limbs(&mut self) -> &mut [Limb]
pub const fn as_mut_limbs(&mut self) -> &mut [Limb]
Mutably borrow the inner &mut [Limb] slice.
Sourcepub const fn as_mut_words(&mut self) -> &mut [Word] ⓘ
pub const fn as_mut_words(&mut self) -> &mut [Word] ⓘ
Borrow the inner limbs as a mutable slice of Words.
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = &Limb>
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &Limb>
Get an iterator over the inner limbs.
Sourcepub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut Limb>
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut Limb>
Get a mutable iterator over the inner limbs.
Sourcepub const fn conditional_set_zero(&mut self, choice: Choice)
pub const fn conditional_set_zero(&mut self, choice: Choice)
Conditionally assign all of the limbs to zero.
Sourcepub const fn conditional_set_max(&mut self, choice: Choice)
pub const fn conditional_set_max(&mut self, choice: Choice)
Conditionally assign all of the limbs to the maximum.
Sourcepub const fn to_uint_resize<const LIMBS: usize>(&self) -> Uint<LIMBS>
pub const fn to_uint_resize<const LIMBS: usize>(&self) -> Uint<LIMBS>
Extract up to LIMBS limbs into a new Uint.
Sourcepub const fn as_nz_vartime(&self) -> Option<&NonZero<Self>>
pub const fn as_nz_vartime(&self) -> Option<&NonZero<Self>>
Sourcepub(crate) const fn as_nz_unchecked(&self) -> &NonZero<Self>
pub(crate) const fn as_nz_unchecked(&self) -> &NonZero<Self>
Cast to NonZero without first checking that the contained value is non-zero.
Use with care! This method bypasses NonZero invariant checks.
§Warning: Panics
We don’t explicitly flag this function as unsafe because it doesn’t have a memory safety
impact, however functions called with NonZero arguments assume this value is non-zero
and may panic if given a zero value.
Sourcepub const fn as_odd_vartime(&self) -> Option<&Odd<Self>>
pub const fn as_odd_vartime(&self) -> Option<&Odd<Self>>
Sourcepub(crate) const fn as_odd_unchecked(&self) -> &Odd<Self>
pub(crate) const fn as_odd_unchecked(&self) -> &Odd<Self>
Cast to Odd without first checking that the contained value is actually odd.
Use with care! This method bypasses Odd invariant checks.
§Panics
We don’t explicitly flag this function as unsafe because it doesn’t have a memory safety
impact, however functions called with Odd arguments assume this value is actually odd
and may panic if given an even value.
Sourcepub(crate) const fn lowest_u64(&self) -> u64
pub(crate) const fn lowest_u64(&self) -> u64
Get the least significant 64-bits.
Sourcepub(crate) fn fold_limbs<F>(
&mut self,
lhs: &Self,
rhs: &Self,
carry: Limb,
f: F,
) -> Limb
pub(crate) fn fold_limbs<F>( &mut self, lhs: &Self, rhs: &Self, carry: Limb, f: F, ) -> Limb
Perform a carry chain-like operation over the limbs of lhs and rhs inputs, virtually
padding each with Limb::ZERO as needed to match the width of self and assigning the
result to self.
Sourcepub(crate) fn fold_limbs_assign<F>(
&mut self,
rhs: &UintRef,
carry: Limb,
f: F,
) -> Limb
pub(crate) fn fold_limbs_assign<F>( &mut self, rhs: &UintRef, carry: Limb, f: F, ) -> Limb
Perform a carry chain-like operation over the limbs of the inputs, virtually padding
rhs with Limb::ZERO as needed to match the width of self and assigning the result
to self.
Trait Implementations§
Source§impl BitOps for UintRef
impl BitOps for UintRef
Source§fn bits_precision(&self) -> u32
fn bits_precision(&self) -> u32
Source§fn bytes_precision(&self) -> usize
fn bytes_precision(&self) -> usize
Source§fn leading_zeros(&self) -> u32
fn leading_zeros(&self) -> u32
Source§fn bit(&self, index: u32) -> Choice
fn bit(&self, index: u32) -> Choice
index, as a truthy or falsy Choice.
Returns the falsy value for indices out of range.Source§fn set_bit(&mut self, index: u32, bit_value: Choice)
fn set_bit(&mut self, index: u32, bit_value: Choice)
index to 0 or 1 depending on the value of bit_value.Source§fn trailing_zeros(&self) -> u32
fn trailing_zeros(&self) -> u32
Source§fn trailing_ones(&self) -> u32
fn trailing_ones(&self) -> u32
Source§fn bit_vartime(&self, index: u32) -> bool
fn bit_vartime(&self, index: u32) -> bool
Source§fn bits_vartime(&self) -> u32
fn bits_vartime(&self) -> u32
self.Source§fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
index to 0 or 1 depending on the value of bit_value,
variable time in self.Source§fn trailing_zeros_vartime(&self) -> u32
fn trailing_zeros_vartime(&self) -> u32
self.Source§fn trailing_ones_vartime(&self) -> u32
fn trailing_ones_vartime(&self) -> u32
self.Source§fn leading_zeros_vartime(&self) -> u32
fn leading_zeros_vartime(&self) -> u32
Source§impl BorrowMut<UintRef> for BoxedUint
impl BorrowMut<UintRef> for BoxedUint
Source§fn borrow_mut(&mut self) -> &mut UintRef
fn borrow_mut(&mut self) -> &mut UintRef
Source§impl ToOwned for UintRef
Available on crate feature alloc only.
impl ToOwned for UintRef
alloc only.Source§impl ToUnsigned for UintRef
Available on crate feature alloc only.
impl ToUnsigned for UintRef
alloc only.