Skip to main content

invert_b128

Function invert_b128 

Source
pub fn invert_b128<P>(x: P) -> P
where P: Copy + Square + Mul<Output = P> + Divisible<BinaryField128bGhash>,
Expand description

Invert each GHASH element (scalar or packed) via the Itoh-Tsujii algorithm.

Zero elements map to zero, matching InvertOrZero semantics.

The bound is phrased in terms of the field operations (Square, Mul) plus Divisible<GhashB128> rather than P: PackedField. PackedField’s blanket impl lists InvertOrZero in its where-clause, so requiring it here would form a trait-resolution cycle when this function backs the InvertOrZero impls. Divisible<GhashB128> carries no such obligation, keeps the function statically GHASH-typed, and is satisfied both by the GHASH packed fields and (reflexively) by the scalar BinaryField128bGhash, so the scalar inverts directly without routing through a packed type.