Skip to content

Entropy handling #814

Open
Open
@Kixunil

Description

@Kixunil

When it comes to signing, today we have these methods:

  • schnorr_sign which currently means "please use fast, perhaps less-secure RNG" and requires std
  • schnorr_sign_with_aux_rand (or _with_rng) which supplies specific entropy externally
  • chnorr_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 needs getrandom, not std.
  • "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 supports no_std and asks for a more secure implementation
  • sign_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions