pub trait WideMul: Sized {
type Output: Default + Clone + Sum + Add<Output = Self::Output> + AddAssign + Sub<Output = Self::Output> + SubAssign;
// Required methods
fn wide_mul(a: Self, b: Self) -> Self::Output;
fn reduce(wide: Self::Output) -> Self;
}Expand description
A field type that supports widening (unreduced) multiplication.
The multiply phase produces an Output value that can be accumulated via
addition without overflow (XOR in characteristic 2). A single reduce call at
the end converts back to the field representation. For GF(2^128) inner products this lets us
amortize the reduction across many products, which is a net win when reductions are comparable
in cost to the widening multiply itself.
WideMul is a parent trait of both Field and
PackedField, so every field and packed field supports it (and each type
implements it directly, leaving room for specialized impls). Most types use the trivial
implementation — multiply eagerly, reduce to the identity — except the GF(2^128) scalar field
and its CLMUL-accelerated packings (x86_64 and AArch64), which defer the reduction by
accumulating an unreduced WideGhashProduct.
Required Associated Types§
type Output: Default + Clone + Sum + Add<Output = Self::Output> + AddAssign + Sub<Output = Self::Output> + SubAssign
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.