Skip to content

Add VerifyLowS helper function to ECDSA signature#2524

Merged
Roasbeef merged 3 commits into
btcsuite:masterfrom
MPins:verifylows
May 14, 2026
Merged

Add VerifyLowS helper function to ECDSA signature#2524
Roasbeef merged 3 commits into
btcsuite:masterfrom
MPins:verifylows

Conversation

@MPins
Copy link
Copy Markdown
Contributor

@MPins MPins commented Apr 18, 2026

Fix #2462
Fix #2522

Add VerifyLowS helper function to ECDSA signature. It will be used on lightningnetwork/lnd#10372.

@MPins MPins changed the title Verifylows Add VerifyLowS helper function to ECDSA signature Apr 18, 2026
@MPins
Copy link
Copy Markdown
Contributor Author

MPins commented Apr 18, 2026

@gijswijs, @GustavoStingelin, @guibressan, @saubyk I opened issue #2522 to note that after upgrading secp256k1 to v4.4.0, the expected error strings in recoveryTests need to be updated to match the new error message format.

The update was done because the new version exposes Signature.S(), giving direct access to the S scalar without re-parsing the DER bytes. This enables a cleaner implementation of the VerifyLowS helper added in this PR.

The new version exposes Signature.S(), giving direct access to the S
scalar without re-parsing the DER bytes. This enables a cleaner
implementation of the VerifyLowS helper added in this branch.
@saubyk saubyk added this to the v0.25.1 milestone Apr 19, 2026
@saubyk saubyk requested a review from gijswijs April 19, 2026 17:24
Copy link
Copy Markdown

@GustavoStingelin GustavoStingelin left a comment

Choose a reason for hiding this comment

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

LGTM as LND already uses github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0

tACK.

Comment thread btcec/ecdsa/signature.go Outdated
Comment thread btcec/ecdsa/signature_test.go Outdated
Introduce a VerifyLowS helper to detect non-canonical
high-S ECDSA signatures, along with unit tests.
Comment thread btcec/ecdsa/signature_test.go Outdated
Update the expected error strings in recoveryTests to match the new
error message format introduced by the secp256k1 v4.4.0 upgrade.
Also replace reflect.DeepEqual with a string-based errorStringEqual
helper to avoid type mismatches between fmt.Errorf and wrapped errors,
and drop the now-unused "reflect" import.
Copy link
Copy Markdown

@GustavoStingelin GustavoStingelin left a comment

Choose a reason for hiding this comment

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

Ack

@guibressan
Copy link
Copy Markdown

ACK

Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

🪰

@Roasbeef Roasbeef merged commit 90540b8 into btcsuite:master May 14, 2026
3 checks passed
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.

ecdsa: signature recovery tests fail after secp256k1 v4.4.0 upgrade [feature]: add VerifyLowS helper function in btcec for ECDSA signatures

5 participants