Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elliptic-curve: make ScalarBytes<C> the SecretKey<C> internal repr #649

Merged

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Jun 3, 2021

Previously SecretKey had a generic internal value, depending on whether or not the arithmetic feature was activated. This was mostly trying to work around the fact that there wasn't a baseline arithmetic impl available to validate secret keys.

Now there is! SecretBytes uses C::UInt and its may features as a crypto-bigint to always validate the internal bytes.

This means we can simply use SecretBytes<C> as the inner value of a SecretKey<C>, and still provide infallible conversions to NonZeroScalar<C>.

Previously SecretKey<C> had a generic internal value, depending on
whether or not the `arithmetic` feature was activated. This was mostly
trying to work around the fact that there wasn't a baseline arithmetic
impl available to validate secret keys.

Now there is! SecretBytes<C> uses C::UInt and its may features as a
`crypto-bigint` to always validate the internal bytes.

This means we can simply use `SecretBytes<C>` as the inner value of a
`SecretKey<C>`, and still provide infallible conversions to
`NonZeroScalar<C>`.
@tarcieri tarcieri force-pushed the elliptic-curve/use-secretbytes-as-secretkey-inner-value branch from 03bfa97 to 97269d5 Compare June 3, 2021 02:59
@tarcieri tarcieri merged commit 79f14e4 into master Jun 3, 2021
@tarcieri tarcieri deleted the elliptic-curve/use-secretbytes-as-secretkey-inner-value branch June 3, 2021 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant