Skip to content

Commit b7a1ac2

Browse files
committed
get rid of unnecessary memory allocation when turning ml-kem into kyber
1 parent 76d9dfc commit b7a1ac2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tuta-sdk/rust/sdk/src/crypto/kyber.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ fn bind_shared_secret_to_ciphertext(
126126
ciphertext: PQCryptoMlKem1024Ciphertext,
127127
) -> KyberSharedSecret {
128128
let hashed_ciphertext = sha::sha3_256(ciphertext.as_bytes());
129-
let kdf_input = vec![
129+
let kdf_input = [
130130
unbound_shared_secret.as_bytes(),
131131
hashed_ciphertext.as_slice(),
132132
];
133-
let shared_secret = shake256(kdf_input);
133+
let shared_secret = shake256(kdf_input.as_slice());
134134
KyberSharedSecret(shared_secret)
135135
}
136136

137-
fn shake256(input: Vec<&[u8]>) -> [u8; SHAKE_BYTE_LENGTH] {
137+
fn shake256(input: &[&[u8]]) -> [u8; SHAKE_BYTE_LENGTH] {
138138
let mut hasher = Shake256::default();
139-
for data in &input {
140-
hasher.update(data);
139+
for data in input {
140+
hasher.update(*data);
141141
}
142142
let mut reader = hasher.finalize_xof();
143143
let mut output = [0; SHAKE_BYTE_LENGTH];

0 commit comments

Comments
 (0)