pub fn on_signing_stack<F, T>(f: F) -> TExpand description
Run f on a dedicated worker thread with RECOMMENDED_SIGNING_STACK_BYTES
of stack, returning its value.
This is the shared, audited guard for ML-DSA signing / keygen on small-stack
native runtimes (notably the BEAM dirty-CPU scheduler). The calling thread
blocks on the worker’s join, so this is synchronous from the caller’s point of
view — it simply borrows a bigger stack for the duration of f.
The closure must return owned, Send values; keep any FFI term/handle
construction on the caller so only plain data crosses the thread boundary. If
f panics, the panic is propagated to the calling thread unchanged (via
std::panic::resume_unwind), so catch_unwind and NIF panic handling behave
exactly as if f had run inline.
§Panics
Panics if the worker thread cannot be spawned (e.g. the OS refuses the stack
reservation), or re-raises any panic that occurred inside f.
§Examples
use metamorphic_crypto::on_signing_stack;
let sig = on_signing_stack(|| vec![0u8; 32]);
assert_eq!(sig.len(), 32);