indcpakeypair function
Implementation
void indcpakeypair(Uint8List pk, Uint8List sk) {
Uint8List seed = randombytes(KYBER_SYMBYTES);
Uint8List seedbuf = shake128(seed, KYBER_SYMBYTES * 2);
Uint8List publicseed = seedbuf.sublist(0, KYBER_SYMBYTES);
Uint8List noiseseed = seedbuf.sublist(KYBER_SYMBYTES, 2 * KYBER_SYMBYTES);
List<List<Poly>> A = genMatrix(publicseed, false);
PolyVec s = PolyVec();
PolyVec e = PolyVec();
for (int i = 0; i < KYBER_K; i++) {
polygetnoise(s.vec[i], noiseseed, i);
polygetnoise(e.vec[i], noiseseed, i + KYBER_K);
}
polyvecntt(s);
polyvecntt(e);
PolyVec pkvec = PolyVec();
for (int i = 0; i < KYBER_K; i++) {
pkvec.vec[i] = Poly();
for (int j = 0; j < KYBER_K; j++) {
Poly t = polybasemul(A[i][j], s.vec[j]);
if (j == 0) {
pkvec.vec[i] = t;
} else {
pkvec.vec[i] = polyadd(pkvec.vec[i], t);
}
}
pkvec.vec[i] = polyadd(pkvec.vec[i], e.vec[i]);
}
Uint8List pkpv = polyveccompress(pkvec);
for (int i = 0; i < pkpv.length; i++) {
pk[i] = pkpv[i];
}
for (int i = 0; i < KYBER_SYMBYTES; i++) {
pk[KYBER_POLYVECCOMPRESSEDBYTES + i] = publicseed[i];
}
Uint8List skpv = polyvectobytes(s);
for (int i = 0; i < skpv.length; i++) {
sk[i] = skpv[i];
}
}