docs: the stack a signing key needs, and a release test that pins it (QA S-11)
ML-DSA-65 keeps large vectors on the stack, and a thread that is too small aborts the process; that is not an Error a caller can handle. Measured here with tests/sig_stack.rs (Windows x86-64, a thread per run): release: 128 KiB overflows, 256/512/1024 KiB pass debug (deps at opt-level 2): 128 and 256 KiB overflow, 512/1024 KiB pass SigningKey's docs now say so and advise at least 512 KiB for threads that sign. generate_and_sign_fit_in_256_kib_of_stack pins the release figure (ignored in debug builds); the four on_a_<n>_kib_stack measurements are ignored and run by hand, one at a time.
This commit is contained in:
@@ -285,6 +285,14 @@ impl fmt::Debug for Signature {
|
||||
|
||||
/// A composite signing key: two independent 32-byte seeds and the keys expanded from them, all
|
||||
/// zeroised on drop. Not `Clone`; `Debug` prints nothing secret.
|
||||
///
|
||||
/// **Stack** (QA S-11): building a key ([`SigningKey::generate`], [`SigningKey::from_bytes`]) and
|
||||
/// signing keep ML-DSA-65's polynomial vectors on the stack. Measured on Windows x86-64
|
||||
/// (`tests/sig_stack.rs`): a release build needs more than 128 KiB and fits in 256 KiB; a debug
|
||||
/// build (with dependencies at `opt-level = 2`, as in Arcanum's own profile) needs more than
|
||||
/// 256 KiB and fits in 512 KiB. Too small a thread **aborts the process** with a stack overflow;
|
||||
/// it is not an error that can be caught. Default threads (1–2 MiB) are fine; give worker,
|
||||
/// blocking-pool or JNI threads that sign at least 512 KiB, and measure unoptimised debug builds.
|
||||
pub struct SigningKey {
|
||||
seeds: Zeroizing<[u8; SIGNING_KEY_LEN]>,
|
||||
// Boxed: the expanded ML-DSA-65 key is about 64 kB.
|
||||
|
||||
Reference in New Issue
Block a user