Skip to main content

bmul

Function bmul 

Source
fn bmul<T>(x: T, y: T, m0: T) -> T
where T: BitAnd<Output = T> + BitOr<Output = T> + Copy + Shl<u32, Output = T>, Wrapping<T>: BitXor<Output = Wrapping<T>> + Mul<Output = Wrapping<T>>,
Expand description

Multiplication in GF(2)[X], implemented generically for use with u32 and u64.

Uses “holes” (sequences of zeroes) to avoid carry spilling, as specified in the mask operand m0 which should have a full-width value with the following bit pattern:

0b100010001...0001 (e.g. 0x1111_1111u32)

When carries do occur, they wind up in a “hole” and are subsequently masked out of the result.