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

Stateless BOLT 12 message verification #1989

Merged
merged 16 commits into from
Apr 20, 2023

Commits on Apr 18, 2023

  1. Common offers test_utils module

    Move utility functions used across all offers modules into a common
    module. Avoids duplicating larger utilities such as payment_path across
    more than one module.
    jkczyz committed Apr 18, 2023
    Configuration menu
    Copy the full SHA
    ce7a02d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fd426a0 View commit details
    Browse the repository at this point in the history
  3. Add another ExpandedKey derivation for Offers

    To support transient signing pubkeys and payer ids for Offers, add
    another key derivation to ExpandedKey. Also useful for constructing
    metadata for stateless message authentication.
    jkczyz committed Apr 18, 2023
    Configuration menu
    Copy the full SHA
    336fc02 View commit details
    Browse the repository at this point in the history

Commits on Apr 20, 2023

  1. Offer metadata and signing pubkey derivation

    Add support for deriving a transient signing pubkey for each Offer from
    an ExpandedKey and a nonce. This facilitates recipient privacy by not
    tying any Offer to any other nor to the recipient's node id.
    
    Additionally, support stateless Offer verification by setting its
    metadata using an HMAC over the nonce and the remaining TLV records,
    which will be later verified when receiving an InvoiceRequest.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    1cad430 View commit details
    Browse the repository at this point in the history
  2. TlvStream range iterator

    Add an iterator that yields TlvRecords over a range of a TlvStream.
    Useful for verifying that, e.g., an InvoiceRequest was sent in response
    to an Offer constructed by the intended recipient.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    b2e87ff View commit details
    Browse the repository at this point in the history
  3. 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.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    dd2ccd2 View commit details
    Browse the repository at this point in the history
  4. Refactor InvoiceRequestContents fields into a sub-struct

    InvoiceRequestBuilder has a field containing InvoiceRequestContents.
    When deriving the payer_id from the remaining fields, a struct is needed
    without payer_id as it not optional. Refactor InvoiceRequestContents to
    have an inner struct without the payer_id such that
    InvoiceRequestBuilder can use it instead.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    e15044b View commit details
    Browse the repository at this point in the history
  5. InvoiceRequest metadata and payer id derivation

    Add support for deriving a transient payer id for each InvoiceRequest
    from an ExpandedKey and a nonce. This facilitates payer privacy by not
    tying any InvoiceRequest to any other nor to the payer's node id.
    
    Additionally, support stateless Invoice verification by setting payer
    metadata using an HMAC over the nonce and the remaining TLV records,
    which will be later verified when receiving an Invoice response.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    3880e69 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    9bd43e0 View commit details
    Browse the repository at this point in the history
  7. Stateless verification of Invoice for Offer

    Verify that an Invoice was produced from an InvoiceRequest constructed
    by the payer using the payer metadata reflected in the Invoice. The
    payer metadata consists of a 128-bit encrypted nonce and possibly a
    256-bit HMAC over the nonce and InvoiceRequest TLV records (excluding
    the payer id) using an ExpandedKey.
    
    Thus, the HMAC can be reproduced from the invoice request 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
    payer id.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    022eadc View commit details
    Browse the repository at this point in the history
  8. Refund metadata and payer id derivation

    Add support for deriving a transient payer id for each Refund from an
    ExpandedKey and a nonce. This facilitates payer privacy by not tying any
    Refund to any other nor to the payer's node id.
    
    Additionally, support stateless Invoice verification by setting payer
    metadata using an HMAC over the nonce and the remaining TLV records,
    which will be later verified when receiving an Invoice response.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    1a7540f View commit details
    Browse the repository at this point in the history
  9. Stateless verification of Invoice for Refund

    Stateless verification of Invoice for Offer
    
    Verify that an Invoice was produced from a Refund constructed by the
    payer using the payer metadata reflected in the Invoice. The payer
    metadata consists of a 128-bit encrypted nonce and possibly a 256-bit
    HMAC over the nonce and Refund TLV records (excluding the payer id)
    using an ExpandedKey.
    
    Thus, the HMAC can be reproduced from the refund 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 payer id.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    2298af4 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    259aa9a View commit details
    Browse the repository at this point in the history
  11. Extract keys from Offer::metadata to sign Invoice

    For offers where the signing pubkey is derived, the keys need to be
    extracted from the Offer::metadata in order to sign an invoice.
    Parameterize InvoiceBuilder such that a build_and_sign method is
    available for this situation.
    jkczyz committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    e1a6bc3 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    c8a847a View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    8afe694 View commit details
    Browse the repository at this point in the history