Description
When it comes to signing, today we have these methods:
schnorr_sign
which currently means "please use fast, perhaps less-secure RNG" and requiresstd
schnorr_sign_with_aux_rand
(or_with_rng
) which supplies specific entropy externallychnorr_sign_no_aux_rand
which requests no auxiliary entropy to be added
Similarly we have "please use fast, perhaps less-secure RNG" for key generation (!) and MuSig nonce generation (!!).
However, there are other valid cases:
- "I want the RNG to be secure, regardless of speed" - needs to use
OsRng
and curiously only needsgetrandom
, notstd
. - "I want fast RNG, if available, slow otherwise" - use different RNG based on
std
availability - "Use any auxiliary entropy if available, fine to not use it" -
std
|getrandom
-> use any RNG, ignore if unavailable - "I want some kind of default policy selectable via cfg"
- "I want auxiliary entropy but only if it's fast"
- Probably more
Arguably, there are many combinations and it might be unreasonable to support all of them (people can do it anyway) but it feels like we ought to at least support some variation of getrandom
+no_std
.
These two seem natural to me:
new_slower_more_secure
(or should this be the default and the other called_fast_less_secure
?) - this both supportsno_std
and asks for a more secure implementationsign_schnorr_maybe_slower
- asks to use some entropy, acknowledging that it might be slow
Or perhaps security-oriented approach: just use secure entropy for key generation and MuSig nonce generation, and use faster for signing if available, let people deal with the other cases on their own. I think this makes sense since signing/key derivation is slower than OS RNG (which I heard is quite fast these days with specially optimized OS calls). This is a breaking change but likely worth it.