polygetnoise function

void polygetnoise(
  1. Poly r,
  2. Uint8List seed,
  3. int nonce
)

Generates a pseudorandom polynomial from a seed and nonce using SHAKE128 and CBD.

Implementation

void polygetnoise(Poly r, Uint8List seed, int nonce) {
  Uint8List extseed = Uint8List(KYBER_SYMBYTES + 1);
  for (int i = 0; i < KYBER_SYMBYTES; i++) {
    extseed[i] = seed[i];
  }
  extseed[KYBER_SYMBYTES] = nonce;
  // For η=2 and KYBER_N=256, (2*256)/4 = 128 bytes are generated.
  Uint8List buf = shake128(extseed, (KYBER_ETA * KYBER_N) ~/ 4);
  cbd(r, buf);
}