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

Non-overflowing parse for signatures #67

Merged
merged 9 commits into from
Apr 14, 2021
Merged

Non-overflowing parse for signatures #67

merged 9 commits into from
Apr 14, 2021

Conversation

sorpaas
Copy link
Member

@sorpaas sorpaas commented Apr 9, 2021

This changes the current method to parse_overflowing and parse_overflowing_slice, and a new non-overflowing signature parse function under parse_standard and parse_standard_slice.

@sorpaas
Copy link
Member Author

sorpaas commented Apr 11, 2021

(Have to fix some issues on #65 before we can merge this!)

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

Minor nitpicks. LGTM otherwise.

src/lib.rs Outdated Show resolved Hide resolved
/// meaning you will have compatibility issues if you also use other
/// SECP256K! libraries. It's not recommended to use this function. Please
/// use `parse_standard` instead.
pub fn parse_overflowing(p: &[u8; util::SIGNATURE_SIZE]) -> Signature {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to use #[deprecated(…)] here?

Copy link
Member Author

Choose a reason for hiding this comment

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

deprecated imply that we can eventually remove this, which we cannot do. Same reason why der-lax is not marked deprecated.

Copy link
Contributor

Choose a reason for hiding this comment

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

While that is true I’d probably use it anyway to get those nice compile time warnings. You could set the depreciation version very far out perhaps?
Either way, your call.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just think we simply can't get rid of it. In Substrate we'll have to create a new function version of this, with the old one always exist (and we cannot remove). In this sense, deprecated warning is just noise and not really useful.

We changed the function names, so when people upgrade they'll have a compile failure anyway and have to change the function name, which is more than safe enough to make sure they don't use the incorrect function.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
sorpaas and others added 4 commits April 14, 2021 17:43
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: David <dvdplm@gmail.com>
@t-nelson
Copy link

Are there test vectors available that pass Signature::parse_overflowing_slice(), but fail Signature::parse_standard_slice()?

trevor-crypto pushed a commit to monacohq/libsecp256k1 that referenced this pull request May 31, 2022
* Non-overflowing parse for signatures

* Fix tests

* Fix styling

* Add docs for Signature struct functions

* Update src/lib.rs

Co-authored-by: David <dvdplm@gmail.com>

* Update src/lib.rs

Co-authored-by: David <dvdplm@gmail.com>

* Update src/lib.rs

Co-authored-by: David <dvdplm@gmail.com>

* Update src/lib.rs

Co-authored-by: David <dvdplm@gmail.com>

Co-authored-by: David <dvdplm@gmail.com>
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.

3 participants