Skip to main content

field_mul

Function field_mul 

Source
pub fn field_mul<const LIMBS: usize>(
    a: &FieldElement<LIMBS>,
    b: &FieldElement<LIMBS>,
    p: &[u64; LIMBS],
) -> FieldElement<LIMBS>
Expand description

Multiply two field elements modulo p. Uses operand-scanning with interleaved reduction. For each word of a, we multiply by all of b and add to accumulator, then reduce the lowest word using Montgomery-like reduction.

Since we need to support arbitrary primes (not just special form), we compute the full 2*LIMBS product first, then reduce using a simple shift-subtract algorithm.