Include Nonce in payer_metadata again#4685
Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
|
Consistent with my prior analysis. The slicing at line 326 is safe since it's only reached after No issues found. I re-verified the critical verification path ( Cross-cutting note (non-blocking, for maintainer confirmation only): invoice requests created by the prior commit ( |
InvoiceRequest and Refund have payer metadata consisting of an encrypted payment id and, originally, a nonce used to derive the payer signing keys and authenticate any corresponding invoices. The nonce was elided to save space once it was included in the OffersContext of blinded reply paths, but that means verifying a Bolt12Invoice requires state outside the invoice itself. Upcoming payment proofs (lightningdevkit#4297) need the invoice signing keys derivable from the invoice request alone, so include the nonce in the payer metadata again and verify invoices using it rather than the context's nonce. This breaks verification of invoices for invoice requests and refunds with blinded paths created by prior versions, as their payer metadata lacks the nonce; such payments will fail and must be retried with a new payment id. Refunds without blinded paths are unaffected, as their metadata always included the nonce. Co-Authored-By: Claude <noreply@anthropic.com>
Now that the payer nonce is included in the payer metadata of InvoiceRequest and Refund, Bolt12Invoice verification no longer needs the nonce from the blinded path's OffersContext. Remove it from OffersContext::OutboundPaymentForOffer and OffersContext::OutboundPaymentForRefund, along with enqueue_invoice_request's nonce parameter, which only existed to supply it. The nonce in RetryableInvoiceRequest is no longer used either but is still persisted -- and retained when reading state written by prior versions -- so that such versions can retry the payment and verify the resulting invoice after a downgrade. The payment_id is kept in both variants, however. While no longer needed to verify the invoice, it is still used when handling a received Bolt12Invoice to confirm the invoice arrived over the reply path created for that payment. This prevents a payee from de-anonymizing us by minting invoices and delivering them to candidate nodes over other paths to observe which one we pay. Co-Authored-By: Claude <noreply@anthropic.com>
bd796d0 to
bc88836
Compare
InvoiceRequestandRefundpayer metadata originally contained a nonce used to derive the payer signing keys and authenticate any corresponding invoices. df5d7ea elided it once it was also included in theOffersContextof blinded reply paths, but that makes verifying aBolt12Invoicedepend on state outside the invoice itself. Upcoming payment proofs need the invoice signing keys derivable from the invoice request alone, so this includes the nonce in the payer metadata again and removes it from the outbound paymentOffersContextvariants.The two commits:
Include payer nonce in payer metadata again. Verify invoices via
Bolt12Invoice::verify_using_metadatarather than the context's nonce, soBolt12Invoice::verify_using_payer_datais removed.Remove nonce from outbound payment
OffersContexts. Drop it fromOffersContext::OutboundPaymentForOfferandOffersContext::OutboundPaymentForRefund, along withenqueue_invoice_request'snonceparameter. Thepayment_idis kept in both variants: it is no longer needed to verify the invoice, but is still used when handling a receivedBolt12Invoiceto confirm it arrived over the reply path created for that payment, preventing a payee from de-anonymizing us by minting invoices and delivering them to candidate nodes over other paths to observe which one we pay.Compatibility
Invoices for invoice requests and refunds with blinded paths created by prior versions will no longer verify, since their payer metadata lacks the nonce; such outstanding payments will fail and must be retried with a new
payment_id. Refunds without blinded paths are unaffected. PendingRetryableInvoiceRequests still persist the nonce, so payments retried after a downgrade continue to work.