pub(crate) trait Limbs:
AsRef<[Limb]>
+ AsMut<[Limb]>
+ CtEq
+ Zero
+ BitOps {
// Required method
fn like_zero(&self) -> Self;
// Provided method
fn swap(&mut self, b: &mut Self, choice: Choice) { ... }
}Expand description
A collection of limbs and associated helper methods.
The provided reduction algorithm dances along the Limb boundaries, performance requiring
correct decision of when to terminate execution of a given function. This API unifies Uint
and BoxedUint (in a way Integer appeared ineligible for) while providing the niche methods
required for performance.
Implementations MAY iterate up to the limbs argument (for performance) or MAY ignore it.
Callers MUST NOT expect that if they specify a limbs argument, operations will only occur to
that subset of limbs, and any results are undefined when any non-included limbs are non-zero.
Callers MUST NOT specify more limbs than the value has.
Implementations MUST implement all functions in time constant to the value of the inputs, except for the amount of limbs, unless otherwise stated. Implementations MUST NOT panic for any input which the caller MAY pass.
A long-term goal is to replace this entirely for just UintRef. Currently, the reduction
algorithm still requires allocating one scratch variable however, making this non-immediate.
Required Methods§
Sourcefn like_zero(&self) -> Self
fn like_zero(&self) -> Self
The number but with precision equal to self.
This is equivalent to crypto_bigint::Zero::zero_like but avoids requiring Self: Clone.
We do not want to bound Self: Clone for performance reasons. Specifically, it’s a goal of
the reduction algorithm to not allocate at all (for performance reasons), this one function
being necessary in one spot and the current sole exception.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".