traits
traits copied to clipboard
`elliptic_curve::NonZeroScalar` non-zeroness guarantee
Thanks a lot for the great libraries! Apologies if this has already been asked---I looked briefly and didn't see anything.
It looks like in release builds it's quite easy to construct a NonZeroScalar
that equals zero (debug builds will panic).
let sk = SecretKey::new(ScalarPrimitive::ZERO);
let nzs = sk.to_nonzero_scalar();
I could easily be missing something, and of course it's easy enough to avoid with a careful check. But I think probably SecretKey::new
wants to be fallible since ScalarPrimitive
can be zero, while SecretKey
and NonZeroScalar
presumably want to be nonzero.