Skip to content

Conversation

@21M4TW
Copy link
Contributor

@21M4TW 21M4TW commented Jan 19, 2026

This PR is an extension to #8238. In addition to signing invoices that don't have an offer_issuer_id using the key from the last used blinded_path node, this new PR generates the private path key deterministically (see derive_first_path_privkey from common/blindedpath.c) in such situation and it is then used to recover the offer paths' node IDs (unblind_paths from common/blindedpath.c). It also derives the path_pubkey that is then used to tweak the private key to sign the invoice. In contrast, in #8238, path_pubkey was derived using information from the onion message, but the offer paths' node IDs could not be recovered, as the path_privkey information was lost after the offer was generated.

So in addition to generating offers without an issuer_id and signing related invoices using the proper key, this PR recovers the offer paths' node IDs, which will enable the generation of invoices with matching paths (addressing #8041) in a future PR.

In this PR, the first path private key for a given path is generated using
e_0 = HMAC256(\text{"first_path_privkey"}, SHA256(path_id || N_0 || path_index))

where path_id is the secret stored in the offer's encrypted_data_tlv and that is only known by the payee, and where N_0 and path_index are the first_node_id and the 64-bit index of the path, respectively.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

offers: offers that include offer_paths now omit offer_issuer_id and
sign with the blinded path alias' key by default. An optional force_issuer_id
field is also added to the offer command so the offer_issuer_id is
included even when not required to reach the issuer due to the existence
of offer_paths.
…m the offer's `path_id`, `N_0` and the path's index so the offer's paths can be recovered when an invoice is fetched. Offer paths' node IDs and the used path index stored in struct invreq.
@21M4TW 21M4TW requested a review from cdecker as a code owner January 19, 2026 15:38
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