Stateless verification of InvoiceRequest
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 8 Feb 2023 01:15:44 +0000 (19:15 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 20 Apr 2023 02:30:40 +0000 (21:30 -0500)
commitdd2ccd232234d93c482c333b20dc71d53c4b7247
treef567dd5c336c538f1783c537e63a0f79b3778c05
parentb2e87ff25b2aef7860ac3c280adf06f642773600
Stateless verification of InvoiceRequest

Verify that an InvoiceRequest was produced from an Offer constructed by
the recipient using the Offer metadata reflected in the InvoiceRequest.
The Offer metadata consists of a 128-bit encrypted nonce and possibly a
256-bit HMAC over the nonce and Offer TLV records (excluding the signing
pubkey) using an ExpandedKey.

Thus, the HMAC can be reproduced from the offer bytes using the nonce
and the original ExpandedKey, and then checked against the metadata. If
metadata does not contain an HMAC, then the reproduced HMAC was used to
form the signing keys, and thus can be checked against the signing
pubkey.
lightning/src/ln/inbound_payment.rs
lightning/src/offers/invoice_request.rs
lightning/src/offers/offer.rs
lightning/src/offers/signer.rs
lightning/src/offers/test_utils.rs