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

btcec: validate R and S signature components in RecoverCompact #1691

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

onyb
Copy link
Collaborator

@onyb onyb commented Feb 3, 2021

Issue GH-1651

Prevent panic in btcec.RecoverCompact by validating signature components. We check if r and s values are:

  • Less than the elliptic curve order (N).
  • Non-zero.

The RecoverCompact algorithm relies on a multiplicative inverse of the r value. The panic in #1651 was due to the fact that the r value (i.e., x-coordinate of random point R) was 0. Such a point does not lie on the secp256k1 curve either, making the signature invalid.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 535078472

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 53.427%

Files with Coverage Reduction New Missed Lines %
database/ffldb/blockio.go 4 92.62%
Totals Coverage Status
Change from base Build 530986489: 0.02%
Covered Lines: 20868
Relevant Lines: 39059

💛 - Coveralls

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

Looks great!
OK

@jcvernaleo jcvernaleo merged commit 31b6648 into btcsuite:master Feb 9, 2021
@onyb onyb deleted the gh-1651 branch February 9, 2021 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants