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.
Implementors§
Source§impl WideMul for AESTowerField8b
impl WideMul for AESTowerField8b
type Output = AESTowerField8b
Source§impl WideMul for BinaryField1b
impl WideMul for BinaryField1b
type Output = BinaryField1b
Source§impl WideMul for BinaryField128bGhash
impl WideMul for BinaryField128bGhash
type Output = <GhashWideMul<PackedPrimitiveType<M128, BinaryField128bGhash>> as WideMul>::Output
Source§impl WideMul for GhashSq256b
impl WideMul for GhashSq256b
type Output = WideGhashSqProduct
Source§impl WideMul for PackedAESBinaryField1x8b
impl WideMul for PackedAESBinaryField1x8b
type Output = <AesLookupWideMul<PackedPrimitiveType<u8, AESTowerField8b>> as WideMul>::Output
Source§impl WideMul for PackedAESBinaryField16x8b
impl WideMul for PackedAESBinaryField16x8b
type Output = <Divide<u8, PackedPrimitiveType<M128, AESTowerField8b>, 16> as WideMul>::Output
Source§impl WideMul for PackedAESBinaryField32x8b
impl WideMul for PackedAESBinaryField32x8b
type Output = <Scaled<PackedPrimitiveType<ScaledUnderlier<M128, 2>, AESTowerField8b>> as WideMul>::Output
Source§impl WideMul for PackedAESBinaryField64x8b
impl WideMul for PackedAESBinaryField64x8b
type Output = <Scaled<PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, AESTowerField8b>> as WideMul>::Output
Source§impl WideMul for PackedBinaryGhash1x128b
impl WideMul for PackedBinaryGhash1x128b
type Output = <GhashWideMul<PackedPrimitiveType<M128, BinaryField128bGhash>> as WideMul>::Output
Source§impl WideMul for PackedBinaryGhash2x128b
impl WideMul for PackedBinaryGhash2x128b
type Output = <Divide<M128, PackedPrimitiveType<ScaledUnderlier<M128, 2>, BinaryField128bGhash>, 2> as WideMul>::Output
Source§impl WideMul for PackedBinaryGhash4x128b
impl WideMul for PackedBinaryGhash4x128b
type Output = <Divide<M128, PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, BinaryField128bGhash>, 4> as WideMul>::Output
Source§impl<T> WideMul for TrivialWideMul<T>
impl<T> WideMul for TrivialWideMul<T>
Source§impl<U, SubU, F, const N: usize> WideMul for Divide<SubU, PackedPrimitiveType<U, F>, N>where
U: UnderlierType + Divisible<SubU>,
SubU: UnderlierType,
F: BinaryField,
PackedPrimitiveType<SubU, F>: WideMul,
<PackedPrimitiveType<SubU, F> as WideMul>::Output: Copy + Default,
impl<U, SubU, F, const N: usize> WideMul for Divide<SubU, PackedPrimitiveType<U, F>, N>where
U: UnderlierType + Divisible<SubU>,
SubU: UnderlierType,
F: BinaryField,
PackedPrimitiveType<SubU, F>: WideMul,
<PackedPrimitiveType<SubU, F> as WideMul>::Output: Copy + Default,
type Output = LaneWideProduct<<PackedPrimitiveType<SubU, F> as WideMul>::Output, N>
Source§impl<U: UnderlierType + Pod, Scalar: BinaryField, const N: usize> WideMul for Scaled<PackedPrimitiveType<ScaledUnderlier<U, N>, Scalar>>where
PackedPrimitiveType<U, Scalar>: WideMul,
<PackedPrimitiveType<U, Scalar> as WideMul>::Output: Copy + Default,
Widening multiply for a ScaledUnderlier packing: apply the sub-underlier packing’s WideMul
to each of the N lanes independently, deferring reduction per lane via LaneWideProduct.
The Scaled analogue of Divide’s WideMul, but addressing the inner
sub-underliers of ScaledUnderlier directly instead of splitting an underlier with Divisible.
impl<U: UnderlierType + Pod, Scalar: BinaryField, const N: usize> WideMul for Scaled<PackedPrimitiveType<ScaledUnderlier<U, N>, Scalar>>where
PackedPrimitiveType<U, Scalar>: WideMul,
<PackedPrimitiveType<U, Scalar> as WideMul>::Output: Copy + Default,
Widening multiply for a ScaledUnderlier packing: apply the sub-underlier packing’s WideMul
to each of the N lanes independently, deferring reduction per lane via LaneWideProduct.
The Scaled analogue of Divide’s WideMul, but addressing the inner
sub-underliers of ScaledUnderlier directly instead of splitting an underlier with Divisible.