lightningnetwork / lightning-onion

Onion Routed Micropayments for the Lightning Network
MIT License
397 stars 126 forks source link

Implement the onion-routing as per spec #2

Closed cdecker closed 7 years ago

cdecker commented 7 years ago

This implementation is compatible with the latest c-lightning implementation of the sphinx onion routing protocol: cdecker/lightning@04ea0c8

The implementation now uses a spec compatible serialization, uses CHACHA20 for exncryption and cipher stream generation, adds per-hop payloads, and includes the payloads into the per-hop HMACs.

Simplified the padding generation and packet construction, and externalized the sessionKey for deterministic testing.

In addition it gets rid of the additional 40 bytes in the routing-info that were unused. It creates a new command line tool to generate and process onions from the command line, that is then used to check compatibility with other implementations. For a simple test including bytewise comparisons and cross encoding/decoding see https://gist.github.com/cdecker/19086ba600de5d6981661fde14e72409

cdecker commented 7 years ago

Let me know if I should squash the PR into one commit.

Roasbeef commented 7 years ago

Also, if you could squash everything into a single commit after fixing the tests, that'd be great. Thanks!

cdecker commented 7 years ago

Ok, I took the liberty of also adding the associated data patch in there and keeping the removal of the e2e payload in a separate commit so we can dig it up should we need it later.

Travis is not updating the build status due to the DNS outage today, but the build passed :-)

cdecker commented 7 years ago

I forgot to mention, the 0.5 release of our lightningd does not yet commit to the payment hash, but it will with the 0.6 :-)