Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow user-provided payer_signing_pubkey #3264

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Aug 21, 2024

When creating an InvoiceRequests, users may choose to either use a transient signing pubkey generated by LDK or provide a static one. Disallow the latter as it allows users to reuse the same pubkey, which results in poor sender privacy.

Based on #3237.
Fixes #3198.

@jkczyz jkczyz force-pushed the 2024-08-remove-user-provided-payer-id branch from ee91a75 to 0100dc4 Compare August 22, 2024 20:44
@jkczyz jkczyz force-pushed the 2024-08-remove-user-provided-payer-id branch from 0100dc4 to 53ba3a9 Compare September 5, 2024 23:28
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 93.85965% with 98 lines in your changes missing coverage. Please review.

Project coverage is 90.29%. Comparing base (d35239c) to head (174a0f4).
Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/util/ser.rs 11.76% 35 Missing and 10 partials ⚠️
lightning/src/offers/invoice.rs 96.18% 13 Missing and 7 partials ⚠️
lightning/src/offers/invoice_request.rs 96.35% 17 Missing and 3 partials ⚠️
lightning/src/offers/offer.rs 97.16% 5 Missing and 2 partials ⚠️
lightning/src/offers/refund.rs 95.93% 2 Missing and 3 partials ⚠️
lightning/src/ln/channelmanager.rs 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3264      +/-   ##
==========================================
+ Coverage   89.85%   90.29%   +0.44%     
==========================================
  Files         126      126              
  Lines      104145   107500    +3355     
  Branches   104145   107500    +3355     
==========================================
+ Hits        93577    97070    +3493     
+ Misses       7894     7724     -170     
- Partials     2674     2706      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jkczyz jkczyz force-pushed the 2024-08-remove-user-provided-payer-id branch 3 times, most recently from 9838435 to 174a0f4 Compare September 11, 2024 20:24
The spec was recently changed to use offer_issuer_id instead of
offer_node_id. LDK always used signing_pubkey to avoid confusion with a
node_id. Rename it to issuer_signing_pubkey now as InvoiceRequest and
Bolt12Invoice will have similarly named methods in upcoming commits.
Useful for determining if the signing_pubkey is the
issuer_signing_pubkey or is from a blinded path.
For consistency with Offer::issuer_signing_pubkey, rename
InvoiceRequest::payer_id to use "signing_pubkey" instead of "id".
For consistency with Offer::issuer_signing_pubkey, rename
Refund::payer_id to use "signing_pubkey" instead of "id".
Using the tlv_stream macro without a type needing a reference results in
a compilation error because of an unused lifetime parameter. To avoid
this, add an optional lifetime parameter to the macro. This allows for
experimental TLVs, which will be empty initially, and TLVs of entirely
primitive types.
TlvRecord has a few fields, but comparing only the record_bytes is
sufficient for equality since the other fields are initialized from it.
Remove the Eq and PartialEq derives as they compare these other fields.
When constructing UnsignedInvoiceRequest or UnsignedBolt12Invoice, use a
separate field for experimental TLV bytes. This allows for properly
inserting the signature TLVs before the experimental TLVs when signing.
Add a utility function for iterating over Offer TLV records contained in
any valid TLV stream bytes. Using a common function ensures th
Passing bytes directly to InvoiceContents::verify improves readability.
The BOLT12 spec defines an experimental TLV range that are allowed in
offer messages. Allow this range when parsing an offer and include those
bytes in any invoice requests. Also include those bytes when computing
an OfferId and verifying that an InvoiceRequest is for a valid Offer.
Offer metadata is generated from the offer TLVs and should included
those in the experimental range. When verifying invoice request and
invoice messages, these TLVs must be included. Similarly, OfferId
construction should included these TLVs as well. Modify the BOLT12
verification tests to cover these TLVs.
The BOLT12 spec defines an experimental TLV range that are allowed in
invoice_request messages. Allow this range when parsing an invoice
request and include those bytes in any invoice. Also include those bytes
when verifying that a Bolt12Invoice is for a valid InvoiceRequest.
Payer metadata is generated from the invreq TLVs and should included
those in the experimental range. When verifying invoice messages, these
TLVs must be included. Modify the BOLT12 verification tests to cover
them.
The BOLT12 spec defines an experimental TLV range that is allowed in
offer and invoice_request messages. The remaining TLV-space is for
experimental use in invoice messages. Allow this range when parsing an
invoice and include it when signing one.
When creating an InvoiceRequests, users may choose to either use a
transient signing pubkey generated by LDK or provide a static one.
Disallow the latter as it allows users to reuse the same pubkey, which
results in poor sender privacy.
Now that InvoiceRequest::payer_signing_pubkey is always a derived
pubkey, there is no longer a need for PayerSigningPubkeyStrategy.
Now that invoice requests are signed using transient keys only, remove
the corresponding signing method from NodeSigner since it is never used.
@jkczyz jkczyz force-pushed the 2024-08-remove-user-provided-payer-id branch from 174a0f4 to 4baba94 Compare September 16, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop user-provided payer_id from InvoiceRequestBuilder
1 participant