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".
Implementors§
Source§impl WideMul for BinaryField1b
impl WideMul for BinaryField1b
type Output = <PackedPrimitiveType<SmallU<1>, BinaryField1b> as WideMul>::Output
Source§impl WideMul for GhashSq256b
impl WideMul for GhashSq256b
type Output = <PackedPrimitiveType<ScaledUnderlier<M128, 2>, GhashSq256b> as WideMul>::Output
Source§impl WideMul for PackedGhash1x128b
impl WideMul for PackedGhash1x128b
type Output = <GhashWideMul<PackedPrimitiveType<M128, Ghash128b>> as WideMul>::Output
Source§impl WideMul for PackedGhash2x128b
impl WideMul for PackedGhash2x128b
Source§impl WideMul for PackedGhash4x128b
impl WideMul for PackedGhash4x128b
Source§impl WideMul for PackedGhashSq1x256b
impl WideMul for PackedGhashSq1x256b
type Output = <GhashSqSlicedWideMul<PackedPrimitiveType<ScaledUnderlier<M128, 2>, GhashSq256b>> as WideMul>::Output
Source§impl WideMul for PackedGhashSq2x256b
impl WideMul for PackedGhashSq2x256b
type Output = <Divide<ScaledUnderlier<M128, 2>, PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, GhashSq256b>, 2> as WideMul>::Output
Source§impl WideMul for PackedRijndael1x8b
impl WideMul for PackedRijndael1x8b
type Output = <AesLookupWideMul<PackedPrimitiveType<u8, Rijndael8b>> as WideMul>::Output
Source§impl WideMul for PackedRijndael16x8b
impl WideMul for PackedRijndael16x8b
type Output = <Divide<u8, PackedPrimitiveType<M128, Rijndael8b>, 16> as WideMul>::Output
Source§impl WideMul for PackedRijndael32x8b
impl WideMul for PackedRijndael32x8b
type Output = <Scaled<PackedPrimitiveType<ScaledUnderlier<M128, 2>, Rijndael8b>> as WideMul>::Output
Source§impl WideMul for PackedRijndael64x8b
impl WideMul for PackedRijndael64x8b
type Output = <Scaled<PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, Rijndael8b>> as WideMul>::Output
Source§impl WideMul for Rijndael8b
impl WideMul for Rijndael8b
type Output = <PackedPrimitiveType<u8, Rijndael8b> as WideMul>::Output
Source§impl<U, SubU, F, const N: usize> WideMul for Divide<SubU, PackedPrimitiveType<U, F>, N>where
U: Underlier + Divisible<SubU>,
SubU: Underlier,
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: Underlier + Divisible<SubU>,
SubU: Underlier,
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: Underlier128bLanes> WideMul for GhashWideMul<PackedPrimitiveType<U, Ghash128b>>
impl<U: Underlier128bLanes> WideMul for GhashWideMul<PackedPrimitiveType<U, Ghash128b>>
type Output = WideGhashProduct<U>
Source§impl<U: Underlier + 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: Underlier + 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.