Skip to content

btcec/schnorr: don't check message length, add test vectors#2501

Open
aakselrod wants to merge 1 commit into
btcsuite:masterfrom
aakselrod:update-bip340-arbitrary-length
Open

btcec/schnorr: don't check message length, add test vectors#2501
aakselrod wants to merge 1 commit into
btcsuite:masterfrom
aakselrod:update-bip340-arbitrary-length

Conversation

@aakselrod

@aakselrod aakselrod commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Change Description

Per bitcoin/bips@200f9b2 there is no longer a requirement to check message length when signing or verifying BIP-0340 Schnorr signatures. This commit updates the signing and verification algorithm and adds test vectors from the BIP for arbitrary-length messages.

Steps to Test

Check the added test vectors against the ones in BIP-0340, then run the unit tests for the btcec/schnorr directory. The tests already automatically run in CI.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

Per bitcoin/bips@200f9b2
there is no longer a requirement to check message length when
signing or verifying BIP-0340 Schnorr signatures. This commit
updates the signing and verification algorithm and adds test
vectors from the BIP for arbitray-length messages.
@aakselrod

aakselrod commented Mar 22, 2026

Copy link
Copy Markdown
Contributor Author

Currently I've commented out the code paths I've eliminated, but happy to fully erase them if that's preferred. I can also renumber the signing/verification algorithm steps if desired.

Alternatively, I could also gate this behind a functional option so the length check is still done by default unless the option is included. The option could pass in an expected length, or just allow arbitrary length if specified.

The desired application is that I'm writing a btcec-based implementation of the ChillDKG BIP which requires a 4-byte message to be signed.

An aside: there's also a requirement in ChillDKG to use different tags for the tagged hashes than what's specified by BIP-0340. I'll address that in a followup PR by passing in the alternate tags as functional options and make it clear that those options aren't for use with Bitcoin consensus/transaction signing.

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