montgomeryReduce function

int montgomeryReduce(
  1. int a
)

Implementation

int montgomeryReduce(int a) {
  // R = 2^16 = 65536.
  int t = (a * KYBER_QINV) % 65536;
  int r = (a + t * KYBER_Q) ~/ 65536;
  if (r >= KYBER_Q) {
    r -= KYBER_Q;
  }
  return r;
}