polyreduce function
Reduces all coefficients of a polynomial mod q.
This function iterates over all coefficients in the polynomial a
and applies
the Barrett reduction algorithm to each coefficient, reducing it modulo q
.
The result is a new polynomial with coefficients that are all reduced modulo q
.
Implementation
Poly polyreduce(Poly a) {
for (int i = 0; i < KYBER_N; i++) {
a.coeffs[i] = barrettreduce(a.coeffs[i]);
}
return a;
}