Fix typo in an old comment, and avoid useless hash

This commit is contained in:
Frank Denis 2024-03-10 19:54:38 +01:00
parent 1ca3a48b87
commit 2dba5eaa64

View File

@ -274,18 +274,18 @@ fn Kyber(comptime p: Params) type {
g.update(&pk.hpk);
g.final(&kr);
// c = innerEncrypy(pk, m, r)
// c = innerEncrypt(pk, m, r)
const ct = pk.pk.encrypt(&m, kr[32..64]);
// Compute H(c) and put in second slot of kr, which will be (K', H(c)).
sha3.Sha3_256.hash(&ct, kr[32..], .{});
if (p.ml_kem) {
return EncapsulatedSecret{
.shared_secret = kr[0..shared_length].*, // ML-KEM: K = K'
.ciphertext = ct,
};
} else {
// Compute H(c) and put in second slot of kr, which will be (K', H(c)).
sha3.Sha3_256.hash(&ct, kr[32..], .{});
var ss: [shared_length]u8 = undefined;
sha3.Shake256.hash(&kr, &ss, .{});
return EncapsulatedSecret{