Changed/Added: Bolt12 deterministic path key for offer paths' node IDs recovery #8853
+936
−657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is an extension to #8238. In addition to signing invoices that don't have an
offer_issuer_idusing the key from the last usedblinded_pathnode, this new PR generates the private path key deterministically (seederive_first_path_privkeyfromcommon/blindedpath.c) in such situation and it is then used to recover the offer paths' node IDs (unblind_pathsfromcommon/blindedpath.c). It also derives thepath_pubkeythat is then used to tweak the private key to sign the invoice. In contrast, in #8238,path_pubkeywas derived using information from the onion message, but the offer paths' node IDs could not be recovered, as thepath_privkeyinformation was lost after the offer was generated.So in addition to generating offers without an
issuer_idand 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_idis the secret stored in the offer'sencrypted_data_tlvand that is only known by the payee, and whereN_0andpath_indexare thefirst_node_idand 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:
tools/lightning-downgrade