Skip to content

elliptic_curve::NonZeroScalar non-zeroness guarantee #1607

@kwantam

Description

@kwantam

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.

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