-
Notifications
You must be signed in to change notification settings - Fork 382
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
Move shared secret calculation into decode_next_payment_hop #3607
Move shared secret calculation into decode_next_payment_hop #3607
Conversation
Makes sense to me, care to clean up the commits? |
8c9f53b
to
49f9ba9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3607 +/- ##
==========================================
+ Coverage 88.69% 89.48% +0.79%
==========================================
Files 149 149
Lines 117505 123481 +5976
Branches 117505 123481 +5976
==========================================
+ Hits 104219 110496 +6277
+ Misses 10794 10423 -371
- Partials 2492 2562 +70 ☔ View full report in Codecov by Sentry. |
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, one small nit on commits but otherwise happy
}, | ||
onion_utils::Hop::BlindedReceive(next_hop_data) => { | ||
onion_utils::Hop::Receive { .. } | onion_utils::Hop::BlindedReceive { .. } => { | ||
let inbound_onion_payload = match decoded_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.
This kinda thing could probably go in a separate commit since its just a cleanup.
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.
good point, done
49f9ba9
to
a0ce434
Compare
a0ce434
to
912a5dd
Compare
Essentially a follow-up to 38284a0, deduplicating some additional code.
912a5dd
to
78ddff5
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.
Nothing blocking!
lightning/src/ln/onion_payment.rs
Outdated
Some(next_packet_pubkey), | ||
)? | ||
}, | ||
onion_utils::Hop::Receive(received_data) => { | ||
onion_utils::Hop::Receive{hop_data, shared_secret} => { |
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:
onion_utils::Hop::Receive{hop_data, shared_secret} => { | |
onion_utils::Hop::Receive { hop_data, shared_secret } => { |
lightning/src/ln/onion_payment.rs
Outdated
None, allow_skimmed_fees, msg.skimmed_fee_msat, cur_height, | ||
)? | ||
}, | ||
onion_utils::Hop::BlindedReceive(received_data) => { | ||
onion_utils::Hop::BlindedReceive{hop_data, shared_secret} => { |
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:
onion_utils::Hop::BlindedReceive{hop_data, shared_secret} => { | |
onion_utils::Hop::BlindedReceive { hop_data, shared_secret } => { |
lightning/src/ln/onion_utils.rs
Outdated
let shared_secret = node_signer | ||
.ecdh(recipient, hop_pubkey, blinded_node_id_tweak.as_ref()) | ||
.unwrap() | ||
.secret_bytes(); |
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.
Can we avoid calling secret_bytes
here and only call it below for decode_next_hop
instead? Avoids doing SharedSecret::from_bytes
in a bunch of places
lightning/src/ln/onion_utils.rs
Outdated
Hop::Forward { shared_secret, .. } => shared_secret.clone(), | ||
Hop::BlindedForward { shared_secret, .. } => shared_secret.clone(), | ||
Hop::Receive { shared_secret, .. } => shared_secret.clone(), | ||
Hop::BlindedReceive { shared_secret, .. } => shared_secret.clone(), |
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: doesn't matter much but could return a reference (or dereference) instead of cloning
yup, will squash as soon as CI passes on my fork |
2cce8d7
to
5afe97f
Compare
For Trampoline, we'll need to keep track of both the outer and inner onion's shared secrets. To this end, we're moving the secret calculation inside `decode_next_payment_hop` such that, when applicable, it can return both.
5afe97f
to
5291445
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.
Thanks
For Trampoline, we'll need to keep track of both the outer and inner onion's shared secrets. To this end, we're moving the secret calculation inside the hop decoding method such that, when applicable, it can return both.
This might end up being just one commit, but the primary consideration in this PR is whether to make the relay error return the shared secret, or do the
HTLCFailReason
within. I opted for the former due to the awkwardness the latter seemed to entail, but open to undoing it, or passing the channel/HTLC details into the decode method to be able to return anHTLCFailureMsg
.