Skip to content

Enforces low-S canonical signatures when the n field is present in a BOLT11 invoice#10372

Open
MPins wants to merge 3 commits into
lightningnetwork:masterfrom
MPins:issue-10222
Open

Enforces low-S canonical signatures when the n field is present in a BOLT11 invoice#10372
MPins wants to merge 3 commits into
lightningnetwork:masterfrom
MPins:issue-10222

Conversation

@MPins
Copy link
Copy Markdown
Contributor

@MPins MPins commented Nov 14, 2025

Fixes #10222

This change enforces low-S canonical signatures in BOLT11 invoices when n is present and adds the corresponding Bolts test vectors (PR#1284 and PR#1298).

This PR depends on btcd PR btcsuite/btcd#2524

This cannot be merged until that PR is merged and LND updates btcdc/v2.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @MPins, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a critical update to LND's BOLT11 invoice processing by enforcing low-S canonical signatures when the n field is present. This ensures that LND strictly adheres to the BOLT specifications, preventing the acceptance of invoices with non-canonical high-S signatures. The change enhances the network's security and interoperability by standardizing signature validation, complemented by new test vectors to verify the correct implementation of this enforcement.

Highlights

  • BOLT11 Signature Enforcement: LND now enforces low-S canonical signatures for BOLT11 invoices that include the n field, rejecting non-canonical high-S signatures to ensure protocol compliance.
  • BOLT Spec Alignment: This change aligns LND with the latest BOLT specifications regarding signature canonicalization, improving interoperability and security within the Lightning Network.
  • Test Vector Additions: New test cases have been added to validate the enforcement of low-S signatures, including specific tests for high-S signatures in invoices with the n field, ensuring the new logic functions as expected.
  • Release Notes Update: The release notes for version 0.21.0 have been updated to reflect this significant protocol enforcement, and the contributor list has been expanded.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enforces low-S canonical signatures for BOLT11 invoices when the destination public key is provided in the n field, aligning with recent BOLT spec updates. The changes include the core logic in zpay32/decode.go and corresponding test cases. My review focuses on improving the implementation's maintainability by leveraging existing library functions. Overall, the change is correct and well-tested.

Comment thread zpay32/decode.go
Comment thread zpay32/decode.go Outdated
@MPins
Copy link
Copy Markdown
Contributor Author

MPins commented Nov 18, 2025

Hello @Roasbeef the helper function was created btcsuite/btcd#2463

@MPins MPins marked this pull request as draft November 19, 2025 10:31
@saubyk saubyk moved this to In progress in v0.21 Nov 27, 2025
@saubyk saubyk removed this from v0.21 Mar 5, 2026
@saubyk saubyk modified the milestones: v0.21.0, v0.22.0 Mar 5, 2026
@github-actions github-actions Bot added the severity-medium Focused review required label Apr 15, 2026
@github-actions
Copy link
Copy Markdown

🟡 PR Severity: MEDIUM

Automated classification | 2 files (excl. tests) | 8 lines changed (excl. tests)

MEDIUM files (1):

  • zpay32/decode.go — zpay32/* package (BOLT-11 invoice codec)

LOW files (1):

  • docs/release-notes/release-notes-0.21.0.md — release notes/docs

Excluded from classification (1):

  • zpay32/invoice_test.go — test file (*_test.go)

Analysis: This PR modifies zpay32/decode.go in the zpay32 package (BOLT-11 invoice encoding/decoding). Per classification rules, zpay32/* is MEDIUM severity. The change is small (4 lines added to the decoder) with an accompanying test and release note.

No severity bump conditions apply: only 2 non-test files changed (threshold >20), only 8 lines changed (threshold >500), no multiple critical packages touched.

Recommendation: Focused review by an engineer familiar with BOLT-11 invoice parsing.

To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

@MPins MPins marked this pull request as ready for review May 15, 2026 20:51
@lightninglabs-deploy
Copy link
Copy Markdown
Collaborator

@Roasbeef: review reminder
@MPins, remember to re-request review from reviewers when ready

MPins added 2 commits May 15, 2026 18:40
Enforce low-S canonical signatures when the `n` is present and include
test vectors to validate the new behavior.
@MPins
Copy link
Copy Markdown
Contributor Author

MPins commented May 15, 2026

Hello @Roasbeef and @yyforyongyu, since the btcd dependency has been merged, we can move this PR forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-medium Focused review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow up signature normalization requirements

5 participants