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

ecdsa: refactor Signature constructors and improve docs #730

Merged

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Jul 8, 2023

Implements from_bytes in terms of from_scalars, rather than the other way around.

This places the logic for checking that r and s are nonzero inside of the from_scalars method.

Additionally improves the documentation to note the various failure cases, i.e. if r and/or s is out of the range 1..n, where n is the scalar modulus.

Implements `from_bytes` in terms of `from_scalars`, rather than the
other way around.

This places the logic for checking that `r` and `s` are nonzero inside
of the `from_scalars` method.

Additionally improves the documentation to note the various failure
cases, i.e. if `r` and/or `s` is out of the range `1..n`, where `n` is
the scalar modulus.
@tarcieri tarcieri force-pushed the ecdsa/refactor-constructors-and-improve-documentation branch from 94a1e54 to a2bdb7e Compare July 8, 2023 22:00
return Err(Error::new());
}

// NOTE: `Signature::from_scalars` checks that both `r` and `s` are non-zero.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarri perhaps you could add a comment like this in RustCrypto/elliptic-curves#907 ?

Comment on lines +250 to +251
let r = ScalarPrimitive::from_slice(&r.into()).map_err(|_| Error::new())?;
let s = ScalarPrimitive::from_slice(&s.into()).map_err(|_| Error::new())?;
Copy link
Member Author

@tarcieri tarcieri Jul 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the next breaking release it might make sense to change the r and s parameters to impl Into<ScalarPrimitive<C>> to simplify these conversions.

@tarcieri tarcieri requested a review from fjarri July 8, 2023 23:13
@tarcieri tarcieri merged commit 2c3d90e into master Jul 10, 2023
8 checks passed
@tarcieri tarcieri deleted the ecdsa/refactor-constructors-and-improve-documentation branch July 10, 2023 18:46
@tarcieri tarcieri mentioned this pull request Jul 21, 2023
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