rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Implement route blinding test vectors

Open valentinewallace opened this issue 1 year ago • 1 comments

See https://github.com/lightning/bolts/blob/3fffab3b889c9a6818130b56fb6dcfdf6906f90e/bolt04/route-blinding-test.json for test vectors.

This also adds support for next_blinding_override in blinded payment paths, and fixes a ser bug for blinded hop features.

  • [ ] Release note

valentinewallace avatar Jul 24 '24 19:07 valentinewallace

Codecov Report

Attention: Patch coverage is 92.08633% with 22 lines in your changes missing coverage. Please review.

Project coverage is 90.21%. Comparing base (8fe3a56) to head (6f6115f). Report is 44 commits behind head on main.

Files Patch % Lines
lightning/src/ln/blinded_payment_tests.rs 91.34% 7 Missing and 13 partials :warning:
lightning/src/blinded_path/payment.rs 90.00% 1 Missing :warning:
lightning/src/ln/channelmanager.rs 91.66% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3204      +/-   ##
==========================================
+ Coverage   89.73%   90.21%   +0.48%     
==========================================
  Files         123      124       +1     
  Lines      102287   106656    +4369     
  Branches   102287   106656    +4369     
==========================================
+ Hits        91784    96223    +4439     
+ Misses       7807     7759      -48     
+ Partials     2696     2674      -22     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 24 '24 19:07 codecov[bot]

Rebased due to conflicts.

valentinewallace avatar Aug 16 '24 18:08 valentinewallace

error: public documentation for `next_blinding_override` links to private item `BlindedPath`
   --> lightning/src/blinded_path/payment.rs:204:20
    |
204 |     /// Set if this [`BlindedPath`] is concatenated to another, to indicate the
    |                       ^^^^^^^^^^^ this item is private

TheBlueMatt avatar Aug 19 '24 14:08 TheBlueMatt

Had a rebase error, squashed change with the following diff:

diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs
index 10d5d8de0..ca937c57d 100644
--- a/lightning/src/blinded_path/payment.rs
+++ b/lightning/src/blinded_path/payment.rs
@@ -201,8 +201,8 @@ pub struct ForwardTlvs {
        ///
        /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
        pub features: BlindedHopFeatures,
-       /// Set if this [`BlindedPath`] is concatenated to another, to indicate the
-       /// [`BlindedPath::blinding_point`] of the appended blinded path.
+       /// Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the
+       /// [`BlindedPaymentPath::blinding_point`] of the appended blinded path.
        pub next_blinding_override: Option<PublicKey>,
 }

diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 2054e4e8e..e08b45558 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -227,8 +227,8 @@ pub struct BlindedForward {
        /// the introduction node.
        pub failure: BlindedFailure,
        /// Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being
-       /// forwarded within a [`BlindedPath`] that was concatenated to another blinded path that starts
-       /// at the next hop.
+       /// forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that
+       /// starts at the next hop.
        pub next_blinding_override: Option<PublicKey>,
 }

valentinewallace avatar Aug 19 '24 14:08 valentinewallace

 error[E0063]: missing field `next_blinding_override` in initializer of `ForwardTlvs`
   --> src/invoice_request_deser.rs:104:9
    |
104 |         tlvs: ForwardTlvs {
    |               ^^^^^^^^^^^ missing `next_blinding_override`

error[E0063]: missing field `next_blinding_override` in initializer of `ForwardTlvs`
  --> src/refund_deser.rs:82:9
   |
82 |         tlvs: ForwardTlvs {
   |               ^^^^^^^^^^^ missing `next_blinding_override

TheBlueMatt avatar Aug 19 '24 16:08 TheBlueMatt

diff --git a/fuzz/src/invoice_request_deser.rs b/fuzz/src/invoice_request_deser.rs
index a5db1c4be..3abb0974e 100644
--- a/fuzz/src/invoice_request_deser.rs
+++ b/fuzz/src/invoice_request_deser.rs
@@ -113,6 +113,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
                                htlc_minimum_msat: 100,
                        },
                        features: BlindedHopFeatures::empty(),
+                       next_blinding_override: None,
                },
                node_id: pubkey(43),
                htlc_maximum_msat: 1_000_000_000_000,
diff --git a/fuzz/src/refund_deser.rs b/fuzz/src/refund_deser.rs
index 58dc68eed..17f255081 100644
--- a/fuzz/src/refund_deser.rs
+++ b/fuzz/src/refund_deser.rs
@@ -91,6 +91,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
                                htlc_minimum_msat: 100,
                        },
                        features: BlindedHopFeatures::empty(),
+                       next_blinding_override: None,
                },
                node_id: pubkey(43),
                htlc_maximum_msat: 1_000_000_000_000,

valentinewallace avatar Aug 19 '24 16:08 valentinewallace