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 PackedPrimitiveType<u128, AESTowerField8b>

Source§

impl WideMul for PackedPrimitiveType<u128, BinaryField1b>

Source§

impl WideMul for PackedPrimitiveType<u128, BinaryField128bGhash>

Source§

impl WideMul for BinaryField1b

Source§

impl WideMul for BinaryField128bGhash

Source§

impl WideMul for PackedAESBinaryField1x8b

Source§

impl WideMul for PackedAESBinaryField2x8b

Source§

impl WideMul for PackedAESBinaryField4x8b

Source§

impl WideMul for PackedAESBinaryField8x8b

Source§

impl WideMul for PackedAESBinaryField16x8b

Source§

impl WideMul for PackedAESBinaryField32x8b

Source§

impl WideMul for PackedAESBinaryField64x8b

Source§

type Output = PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, AESTowerField8b>

Source§

impl WideMul for PackedBinaryField1x1b

Source§

impl WideMul for PackedBinaryField2x1b

Source§

impl WideMul for PackedBinaryField4x1b

Source§

impl WideMul for PackedBinaryField8x1b

Source§

impl WideMul for PackedBinaryField16x1b

Source§

impl WideMul for PackedBinaryField32x1b

Source§

impl WideMul for PackedBinaryField64x1b

Source§

impl WideMul for PackedBinaryField128x1b

Source§

impl WideMul for PackedBinaryField256x1b

Source§

impl WideMul for PackedBinaryField512x1b

Source§

type Output = PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, BinaryField1b>

Source§

impl WideMul for PackedBinaryGhash1x128b

Source§

impl WideMul for PackedBinaryGhash2x128b

Source§

impl WideMul for PackedBinaryGhash4x128b

Source§

type Output = PackedPrimitiveType<ScaledUnderlier<ScaledUnderlier<M128, 2>, 2>, BinaryField128bGhash>