Skip to content

multi: implement latest multi-frame EOB proposal #36

Closed
Roasbeef wants to merge 10 commits intolightningnetwork:masterfrom
Roasbeef:eob-frames
Closed

multi: implement latest multi-frame EOB proposal #36
Roasbeef wants to merge 10 commits intolightningnetwork:masterfrom
Roasbeef:eob-frames

Conversation

@Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented May 14, 2019

This takes off where #31 and #33 left off. It implements the latest version of lightning/bolts#593 (4 bits right now, but I think that's heading to 3 bits for the packet type). At the same time with the way the code is implemented right now, it's a short distance away from lightning/bolts#604 if we end up going in that direction (only thing that would change in that case is the new HopData method and the packRealm method).

This PR takes the commits from #33, implements a few bug fixes along the way, and the unifies the external caller API with that of #31. It passes all the tests from #31 as is, but I also plan to port over relevant tests from #33 as they exercise additional end-to-end behavior.

We'll be encoding to and decoding from a variable length byte-slice
once we complete the multi-hop proposal.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
cdecker and others added 9 commits May 13, 2019 20:59
…frames

Since we want to use multiple former per-hop-payloads as a single
payload, we want to differentiate the notion of a frame from a
payload, since the latter can be now be made up of multiple frames.

Signed-off-by: Christian Decker <@cdecker>
HopPayload represents the raw, unparsed payload, from which the
HopData can be parsed. The sphinx code internally only handles
HopPayload, and the `HopData()` method can be used to parse and return
the HopData. This completes the transition to HopPayload.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This is the central commit in this whole series, it modifies the
right- and left- shifts to account for multi-frame payloads and it
modifies the filler generation code to generate multi-frame fillers if
the payload requires it.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This is a simple test that create a 5 hop onion, and the third hop
gets a payload that spans 2 frames.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This should make testing a lot easier, since we can just have a bunch of these
sitting in the repo and test them.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
In this commit, we move the HopData struct back into path.go. Along the
way, we remove its old HMAC field (since it's now in the hop payload),
and also restore its Decode method for later use.
In this commit, we add a new constructor to abstract away the details of
the hop payload framing from the caller. This new function accepts the
hop data, as well as optional EOB bytes. We'll then map these two pieces
of data into a single hop payload by appending the EOB bytes to the
serialized hop data.
Rather than mutate the underlying realm byte, we'll now expose two
methods to the caller: one for the "external" realm, and one of the
realm that we'll encode in the payload.
In this commit, we remove the HopData field from the OnionHop struct as
it's no longer needed since we can obtain the HopData via the HopData()
method of the HopPayload struct. Additinoally, we also now return the
set of unused payload bytes after the HopData encoding, we call these
the EOB or extra onion blobs.

With this distinction we now provide the caller of ProcessOnionPacket
with the forwarding instructions, then the left over EOB bytes. These
EOB bytes will then be interpreted using a TLV format or any other
arbitrary framing system.
HopDataSize = (RealmByteSize + AddressSize + AmtForwardSize +
OutgoingCLTVSize + NumPaddingBytes + HMACSize)

// FramSize is the size of a frame in the packet. A frame is a region

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be FrameSize

privkey, _ := btcec.PrivKeyFromBytes(btcec.S256(), binKey)
s := sphinx.NewRouter(privkey, &chaincfg.TestNet3Params,
sphinx.NewMemoryReplayLog())
replay_log := sphinx.NewMemoryReplayLog()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not camel case for consistency?

@Roasbeef
Copy link
Member Author

Roasbeef commented Jul 4, 2019

Superseded by #38.

@Roasbeef Roasbeef closed this Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants