-
Notifications
You must be signed in to change notification settings - Fork 366
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
Authenticate use of offer blinded paths #3139
Authenticate use of offer blinded paths #3139
Commits on Jul 22, 2024
-
Change Nonce visibility to pub
A nonce is generated in OfferBuilder::deriving_signing_pubkey from an EntropySource for use in Offer::metadata. The same nonce will need to be included as recipient data in any blinded paths in the Offer. Increase the visibility to allow for this.
Configuration menu - View commit details
-
Copy full SHA for 5278d31 - Browse repository at this point
Copy the full SHA 5278d31View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0a5918e - Browse repository at this point
Copy the full SHA 0a5918eView commit details -
Move Nonce to a separate offers sub-module
Nonce is used when constructing Offer::metadata and will soon be need when constructing BlindedPath for use in authentication. Move it to separate module now that it is public and will be more widely used.
Configuration menu - View commit details
-
Copy full SHA for d7aeaa0 - Browse repository at this point
Copy the full SHA d7aeaa0View commit details -
Pass Nonce directly to OfferBuilder
When using OfferBuilder::deriving_signing_pubkey, the nonce generated needs to be the same one included in any OfferBuilder::paths. This is because the nonce is used along with the offer TLVs to derive a signing pubkey and will soon be elided from the metadata entirely.
Configuration menu - View commit details
-
Copy full SHA for 219691f - Browse repository at this point
Copy the full SHA 219691fView commit details -
Add InvoiceRequest::verify_using_recipient_data
Invoice requests are authenticated by checking the metadata in the corresponding offer. For offers using blinded paths, this will simply be a 128-bit nonce. Allows checking this nonce explicitly instead of the metadata. This will be used by an upcoming change that includes the nonce in the offer's blinded paths instead of the metadata, which mitigate de-anonymization attacks.
Configuration menu - View commit details
-
Copy full SHA for e156415 - Browse repository at this point
Copy the full SHA e156415View commit details -
Assert and document valid Metadata states
Metadata is an internal type used within Offer messages. For any constructed message, Metadata::Bytes is always used. The other variants are used during construction or verification time. Document this and debug_assert!(false) accordingly.
Configuration menu - View commit details
-
Copy full SHA for c0cae08 - Browse repository at this point
Copy the full SHA c0cae08View commit details -
Configuration menu - View commit details
-
Copy full SHA for c58a1bb - Browse repository at this point
Copy the full SHA c58a1bbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7904e3c - Browse repository at this point
Copy the full SHA 7904e3cView commit details -
Configuration menu - View commit details
-
Copy full SHA for f546aad - Browse repository at this point
Copy the full SHA f546aadView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1ff8c8d - Browse repository at this point
Copy the full SHA 1ff8c8dView commit details -
Configuration menu - View commit details
-
Copy full SHA for a5145e4 - Browse repository at this point
Copy the full SHA a5145e4View commit details -
Add OffersContext::InvoiceRequest
To authenticate that an InvoiceRequest is for a valid Offer, include the nonce from the Offer::metadata in the Offer::paths. This can be used to prevent de-anonymization attacks where an attacker sends requests using self-constructed paths to nodes near the Offer::paths' introduction nodes.
Configuration menu - View commit details
-
Copy full SHA for 6a54618 - Browse repository at this point
Copy the full SHA 6a54618View commit details -
Authenticate InvoiceRequest using OfferContext
When an InvoiceRequest is handled with an OfferContext, use the containing nonce to verify that it is for a valid Offer. Otherwise, fall back to using Offer::metadata, which also contains the nonce. The latter is useful for supporting offers without blinded paths or those created prior to including an OffersContext in their blinded paths.
Configuration menu - View commit details
-
Copy full SHA for 35b75fd - Browse repository at this point
Copy the full SHA 35b75fdView commit details -
Elide metadata from Offer with derived keys
When an Offer uses blinded paths, its metadata consists of a nonce used to derive its signing keys. Now that the blinded paths contain this nonce, elide the metadata as it is now redundant. This saves space and also makes it impossible to derive the signing keys if an invoice request is received with the incorrect nonce. The nonce shouldn't be revealed in this case either to prevent de-anonymization attacks.
Configuration menu - View commit details
-
Copy full SHA for bf42847 - Browse repository at this point
Copy the full SHA bf42847View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9d46340 - Browse repository at this point
Copy the full SHA 9d46340View commit details -
Configuration menu - View commit details
-
Copy full SHA for f537abd - Browse repository at this point
Copy the full SHA f537abdView commit details -
Authenticate Bolt12Invoice using OfferContext
When a Bolt12Invoice is handled with an OfferContext, use the containing payment_id to verify that it is for a pending outbound payment. Only invoices for refunds without any blinded paths can be verified without an OfferContext.
Configuration menu - View commit details
-
Copy full SHA for c2a120e - Browse repository at this point
Copy the full SHA c2a120eView commit details -
Don't send InvoiceError on failed authentication
When an invoice or invoice request cannot be authenticated from an OffersContext, simply do not respond instead of sending an InvoiceError message. According to BOLT4, messages sent over a blinded path not intended for its use MUST be ignored.
Configuration menu - View commit details
-
Copy full SHA for 559daeb - Browse repository at this point
Copy the full SHA 559daebView commit details -
Configuration menu - View commit details
-
Copy full SHA for bdf3330 - Browse repository at this point
Copy the full SHA bdf3330View commit details -
Pass Nonce directly to InvoiceRequestBuilder
When using InvoiceRequestBuilder::deriving_payer_id, the nonce generated needs to be the same one included in any reply path. This is because the nonce is used along with the invoice request TLVs to derive a payer id. While this data is also included in the payer_metadata, including it in the blinded path would allow reducing the amount of data needed there to just enough to provide entropy (i.e., 16 bytes). This is more important for Refund because it can be transmitted via a QR code. But using the same payer_metadata structure for both InvoiceRequest and Refund would be beneficial to avoid more code.
Configuration menu - View commit details
-
Copy full SHA for fd596c3 - Browse repository at this point
Copy the full SHA fd596c3View commit details -
Pass Nonce directly to RefundBuilder
When using RefundBuilder::deriving_payer_id, the nonce generated needs to be the same one included in any RefundBuilder::paths. This is because the nonce is used along with the refund TLVs to derive a payer id and will soon be used to authenticate any invoices.
Configuration menu - View commit details
-
Copy full SHA for 114954c - Browse repository at this point
Copy the full SHA 114954cView commit details -
Add Bolt12Invoice::verify_using_payer_data
Invoices are authenticated by checking the payer metadata in the corresponding invoice request or refund. For all invoices requests and for refunds using blinded paths, this will be the encrypted payment id and a 128-bit nonce. Allows checking the unencrypted payment id and nonce explicitly instead of the payer metadata. This will be used by an upcoming change that includes the payment id and nonce in the invoice request's reply path and the refund's blinded paths instead of completely in the payer metadata, which mitigates de-anonymization attacks.
Configuration menu - View commit details
-
Copy full SHA for 868fee7 - Browse repository at this point
Copy the full SHA 868fee7View commit details -
Add nonce to OffersContext::OutboundPayment
To authenticate that a Bolt12Invoice is for a valid InvoiceRequest or Refund, include the nonce from the payer_metadata in the InvoiceRequest reply path or Refund::paths, respectively. This can be used to prevent de-anonymization attacks where an attacker sends invoices using self-constructed paths to nodes near the blinded paths' introduction nodes.
Configuration menu - View commit details
-
Copy full SHA for 14634c6 - Browse repository at this point
Copy the full SHA 14634c6View commit details -
Authenticate Bolt12Invoice using BlindedPath data
When a Bolt12Invoice is handled with an OfferContext, use both the containing payment_id and nonce to verify that it is for a pending outbound payment. Previously, the nonce the payment_id were taken from the payer_metadata and the latter was compared against the payment_id in the OfferContext. The payer_metadata thus no longer needs to include either when a blinded path is used. However, some payer_metadata will still be needed as per the spec.
Configuration menu - View commit details
-
Copy full SHA for 2c2f3fe - Browse repository at this point
Copy the full SHA 2c2f3feView commit details -
Include OffersContext in Event::InvoiceReceived
When authenticating that an invoice is for a valid invoice request, the payer metadata is needed. Some of this data will be removed in the next commit and instead be included in the message context of the request's reply path. Add this data to Event::InvoiceReceived so that asynchronous invoice handling can verify properly.
Configuration menu - View commit details
-
Copy full SHA for e6ee194 - Browse repository at this point
Copy the full SHA e6ee194View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4ed37d8 - Browse repository at this point
Copy the full SHA 4ed37d8View commit details -
Elide nonce from payer metadata
InvoiceRequest and Refund have payer_metadata which consists of an encrypted payment id and a nonce used to derive its signing keys and authenticate any corresponding invoices. Now that the blinded paths include this data in their OffersContext, remove the nonce as it is now redundant. Keep the encrypted payment id as some data is needed in the payer metadata according to the spec. This saves space and prevents de-anonymization attacks as along as the nonce isn't revealed.
Configuration menu - View commit details
-
Copy full SHA for df5d7ea - Browse repository at this point
Copy the full SHA df5d7eaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 718bc47 - Browse repository at this point
Copy the full SHA 718bc47View commit details -
Configuration menu - View commit details
-
Copy full SHA for 825bda0 - Browse repository at this point
Copy the full SHA 825bda0View commit details