Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.

Commit ba7b5ae

Browse files
committed
fix: wipe decoded falcon coefficient buffers on drop
Wrap the f, g, and big_F byte vectors produced by decode_i8 in Zeroizing so the raw secret coefficients are wiped when read_from returns, on both the success and error paths.
1 parent a91eff7 commit ba7b5ae

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

miden-crypto/src/dsa/falcon512_poseidon2/keys/secret_key.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
hash::blake::Blake3_256,
2323
utils::{
2424
read_sensitive_array,
25-
zeroize::{Zeroize, ZeroizeOnDrop},
25+
zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing},
2626
},
2727
};
2828

@@ -370,20 +370,26 @@ impl Deserializable for SecretKey {
370370
let chunk_size_g = ((n * WIDTH_SMALL_POLY_COEFFICIENT) + 7) >> 3;
371371
let chunk_size_big_f = ((n * WIDTH_BIG_POLY_COEFFICIENT) + 7) >> 3;
372372

373-
let f = decode_i8(&byte_vector[1..chunk_size_f + 1], WIDTH_SMALL_POLY_COEFFICIENT).ok_or(
374-
DeserializationError::InvalidValue("Failed to decode f coefficients".to_string()),
375-
)?;
376-
let g = decode_i8(
377-
&byte_vector[chunk_size_f + 1..(chunk_size_f + chunk_size_g + 1)],
378-
WIDTH_SMALL_POLY_COEFFICIENT,
379-
)
380-
.unwrap();
381-
let big_f = decode_i8(
382-
&byte_vector[(chunk_size_f + chunk_size_g + 1)
383-
..(chunk_size_f + chunk_size_g + chunk_size_big_f + 1)],
384-
WIDTH_BIG_POLY_COEFFICIENT,
385-
)
386-
.unwrap();
373+
let f = Zeroizing::new(
374+
decode_i8(&byte_vector[1..chunk_size_f + 1], WIDTH_SMALL_POLY_COEFFICIENT).ok_or(
375+
DeserializationError::InvalidValue("Failed to decode f coefficients".to_string()),
376+
)?,
377+
);
378+
let g = Zeroizing::new(
379+
decode_i8(
380+
&byte_vector[chunk_size_f + 1..(chunk_size_f + chunk_size_g + 1)],
381+
WIDTH_SMALL_POLY_COEFFICIENT,
382+
)
383+
.unwrap(),
384+
);
385+
let big_f = Zeroizing::new(
386+
decode_i8(
387+
&byte_vector[(chunk_size_f + chunk_size_g + 1)
388+
..(chunk_size_f + chunk_size_g + chunk_size_big_f + 1)],
389+
WIDTH_BIG_POLY_COEFFICIENT,
390+
)
391+
.unwrap(),
392+
);
387393

388394
let f = Polynomial::new(f.iter().map(|&c| FalconFelt::new(c.into())).collect());
389395
let g = Polynomial::new(g.iter().map(|&c| FalconFelt::new(c.into())).collect());

0 commit comments

Comments
 (0)