-
Notifications
You must be signed in to change notification settings - Fork 405
Pub make onion #2583
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
Pub make onion #2583
Conversation
reply_path: Option<BlindedPath> | ||
) -> Result<Vec<u8>, SendError> { | ||
let (_, onion_routing_packet) = self.make_onion_message(path, message, reply_path)?; | ||
Ok(onion_routing_packet.onion_routing_packet.hop_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we return the full OnionMessage
? Presumably whatever is handling it needs the blinding_point
as well to send.
} | ||
|
||
/// Construct an onion message with contents `message` to the destination of `path`. | ||
pub fn construct_onion_message<T: CustomOnionMessageContents>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this method really wants to be static - IIUC your use-case is that you want to do the onion message construction on an edge node but then pass it to the first hop via some out-of-band protocol. Using an OnionMessenger
could work for that, but seems a bit awkward to expose a method to return the message on a struct that's all about passing messages to peers. If we want a method that generates messages in a free-standing way, it probably should be a utility method, rather than a struct method taking &self
. OTOH, if you want to use the struct, you could probably just intercept on the other send, calling send_onion_message
then immediately calling next_onion_message_for_peer
on the messenger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see what you mean, its much cleaner as a static method. And u can use it just like SimpleRefOnionMessenger::make_onion_message
. Thanks for taking a look!
@@ -631,7 +631,8 @@ pub struct UpdateAddHTLC { | |||
pub struct OnionMessage { | |||
/// Used in decrypting the onion packet's payload. | |||
pub blinding_point: PublicKey, | |||
pub(crate) onion_routing_packet: onion_message::Packet, | |||
/// The full onion packet including hop data, pubkey, and hmac | |||
pub onion_routing_packet: onion_message::Packet, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't (actually) public because Packet
isn't pub (its only pub from a private module). You'll need to make the packet
module pub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packet
was already exported from the mod.rs as pub(crate)
, so I just made it pub
and added doc comments
pub version: u8, | ||
/// The PublicKey used during shared secret generation | ||
pub public_key: PublicKey, | ||
/// 1300 bytes payload for the next hop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1300 bytes is for payment onions, not onion messages. This is arbitrary length.
pub struct Packet { | ||
/// Bolt 04 version number | ||
pub version: u8, | ||
/// The PublicKey used during shared secret generation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit more info would be nice, something like just "a random secp256k1 point which is ECDH'd to build a shared secret used to decrypt the hop_data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thanks for the feedback
This LGTM, can you squash the fixup commits down so that each commit stands on its own and no commit cleans up or fixes code introduced in a previous commit? |
70acdbc
to
a109c72
Compare
Codecov ReportPatch coverage:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2583 +/- ##
==========================================
- Coverage 90.63% 88.77% -1.86%
==========================================
Files 113 113
Lines 59057 84510 +25453
Branches 59057 84510 +25453
==========================================
+ Hits 53524 75027 +21503
- Misses 5533 7247 +1714
- Partials 0 2236 +2236
☔ View full report in Codecov by Sentry. |
ok done! |
e115aa5
to
30b74a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -631,7 +631,8 @@ pub struct UpdateAddHTLC { | |||
pub struct OnionMessage { | |||
/// Used in decrypting the onion packet's payload. | |||
pub blinding_point: PublicKey, | |||
pub(crate) onion_routing_packet: onion_message::Packet, | |||
/// The full onion packet including hop data, pubkey, and hmac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, docs should end in periods (particularly public docs)
@@ -283,6 +283,36 @@ where | |||
&self, path: OnionMessagePath, message: OnionMessageContents<T>, | |||
reply_path: Option<BlindedPath> | |||
) -> Result<(), SendError> { | |||
let (introduction_node_id, onion_msg) = Self::create_onion_message( | |||
&self.entropy_source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: You have whitespace hanging off the end of line here and a few other places. This should be highlighted by a local git show
depending on your terminal settings.
Adds a public
construct_onion_message
method on OnionMessenger. At sphinx chat we are experimenting with client-side onion route creation, and would like to use a method like this