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

Onion messages v1 #1503

Merged
merged 11 commits into from
Aug 3, 2022

Commits on Aug 2, 2022

  1. Add onion messages module + enable the construction of blinded routes

    Blinded routes can be provided as destinations for onion messages, when the
    recipient prefers to remain anonymous.
    
    We also add supporting utilities for constructing blinded path keys, and
    control TLVs structs representing blinded payloads prior to being
    encoded/encrypted. These utilities and struct will be re-used in upcoming
    commits for sending and receiving/forwarding onion messages.
    
    Finally, add utilities for reading the padding from an onion message's
    encrypted TLVs without an intermediate Vec.
    valentinewallace committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    4e5381a View commit details
    Browse the repository at this point in the history
  2. Add onion_message::Packet and adapt construct_onion_packet_with_init_…

    …noise for it
    
    We need to add a new Packet struct because onion message packet hop_data fields
    can be of variable length, whereas regular payment packets are always 1366
    bytes.
    
    Co-authored-by: Valentine Wallace <[email protected]>
    Co-authored-by: Jeffrey Czyz <[email protected]>
    valentinewallace and jkczyz committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    33ff274 View commit details
    Browse the repository at this point in the history
  3. KeysInterface: add new ecdh method

    This method will help us avoid retrieving our node secret, something we want to
    get rid of entirely.  It will be used in upcoming commits when decoding the
    onion message packet, and in future PRs to help us get rid of
    KeysInterface::get_node_secret usages across the codebase
    valentinewallace committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    6017379 View commit details
    Browse the repository at this point in the history
  4. Add baseline OnionMessenger and msgs::OnionMessage and its serialization

    OnionMessenger will be hooked up to the PeerManager to send and receive OMs in
    a follow-up PR.
    valentinewallace committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    4c8dc2c View commit details
    Browse the repository at this point in the history
  5. Support sending onion messages

    This adds several utilities in service of then adding
    OnionMessenger::send_onion_message, which can send to either an unblinded
    pubkey or a blinded route. Sending custom TLVs and sending an onion message
    containing a reply path are not yet supported.
    
    We also need to split the construct_keys_callback macro into two macros to
    avoid an unused assignment warning.
    valentinewallace committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    9051c38 View commit details
    Browse the repository at this point in the history
  6. Implement receiving and forwarding onion messages

    This required adapting `onion_utils::decode_next_hop` to work for both payments
    and onion messages.
    
    Currently we just print out the path_id of any onion messages we receive. In
    the future, these received onion messages will be redirected to their
    respective handlers: i.e. an invoice_request will go to an InvoiceHandler,
    custom onion messages will go to a custom handler, etc.
    valentinewallace committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    bf007ea View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    b26fb85 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    eaff561 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    6500c99 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    39397d4 View commit details
    Browse the repository at this point in the history
  11. Fix possible incomplete read bug on onion packet decode

    Pre-existing to this PR, we were reading next packet bytes with io::Read::read,
    which is not guaranteed to read all the bytes we need, only guaranteed to read
    *some* bytes.
    
    We fix this to be read_exact, which is guaranteed to read all the next hop
    packet bytes.
    valentinewallace committed Aug 2, 2022
    Configuration menu
    Copy the full SHA
    17ec697 View commit details
    Browse the repository at this point in the history