Skip to main content

WideMul

Trait WideMul 

Source
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§

Source

type Output: Default + Clone + Sum + Add<Output = Self::Output> + AddAssign + Sub<Output = Self::Output> + SubAssign

Required Methods§

Source

fn wide_mul(a: Self, b: Self) -> Self::Output

Source

fn reduce(wide: Self::Output) -> Self

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

Source§

impl WideMul for BinaryField1b

Source§

impl WideMul for BinaryField128bGhash

Source§

impl WideMul for GhashSq256b

Source§

impl WideMul for PackedAESBinaryField1x8b

Source§

impl WideMul for PackedAESBinaryField16x8b

Source§

impl WideMul for PackedAESBinaryField32x8b

Source§

impl WideMul for PackedAESBinaryField64x8b

Source§

type Output = <Scaled<PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, AESTowerField8b>> as WideMul>::Output

Source§

impl WideMul for PackedBinaryGhash1x128b

Source§

impl WideMul for PackedBinaryGhash2x128b

Source§

impl WideMul for PackedBinaryGhash4x128b

Source§

type Output = <Divide<M128, PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, BinaryField128bGhash>, 4> as WideMul>::Output

Source§

impl<T> WideMul for TrivialWideMul<T>
where T: Default + Clone + Sum + Add<Output = T> + AddAssign + Sub<Output = T> + SubAssign + Mul<Output = T>,

Source§

impl<U, SubU, F, const N: usize> WideMul for Divide<SubU, PackedPrimitiveType<U, F>, 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.

Source§

impl<U: UnderlierType> WideMul for PackedPrimitiveType<U, BinaryField1b>

Source§

impl<U: Underlier128bLanes> WideMul for GhashWideMul<PackedPrimitiveType<U, BinaryField128bGhash>>