packed_mod_sub

Function packed_mod_sub 

Source
pub fn packed_mod_sub<const WIDTH: usize>(
    a: &[u32; WIDTH],
    b: &[u32; WIDTH],
    res: &mut [u32; WIDTH],
    _p: u32,
    scalar_sub: fn(u32, u32) -> u32,
)
Expand description

Subtract two arrays of integers modulo P using packing.

This is a fallback which should only be compiled in situations where packings are unavailable.

Assumes that p is less than 2^31 and |a - b| <= P. If the inputs are not in this range, the result may be incorrect. The result will be in the range [0, P] and equal to (a - b) mod p. It will be equal to P if and only if a - b = P so provided a - b < P the result is guaranteed to be less than P.

Scalar sub is assumed to be a function which implements a - b % P with the same specifications as above.