Skip to content

Commit a0d38d7

Browse files
committed
Rename blinded_route variables and module to blinded_path
Following up on the previous commit, this also renames variables and the module used to `blinded_path`.
1 parent 9b6de78 commit a0d38d7

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

lightning/src/onion_message/blinded_route.rs renamed to lightning/src/onion_message/blinded_path.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
//! Creating blinded routes and related utilities live here.
10+
//! Creating blinded paths and related utilities live here.
1111
1212
use bitcoin::hashes::{Hash, HashEngine};
1313
use bitcoin::hashes::sha256::Hash as Sha256;
@@ -26,11 +26,11 @@ use core::ops::Deref;
2626
use crate::io::{self, Cursor};
2727
use crate::prelude::*;
2828

29-
/// Onion messages can be sent and received to blinded routes, which serve to hide the identity of
29+
/// Onion messages can be sent and received to blinded paths, which serve to hide the identity of
3030
/// the recipient.
3131
#[derive(Clone, Debug, PartialEq)]
3232
pub struct BlindedPath {
33-
/// To send to a blinded route, the sender first finds a route to the unblinded
33+
/// To send to a blinded path, the sender first finds a route to the unblinded
3434
/// `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion
3535
/// message's next hop and forward it along.
3636
///
@@ -41,24 +41,24 @@ pub struct BlindedPath {
4141
///
4242
/// [`encrypted_payload`]: BlindedHop::encrypted_payload
4343
pub(crate) blinding_point: PublicKey,
44-
/// The hops composing the blinded route.
44+
/// The hops composing the blinded path.
4545
pub(crate) blinded_hops: Vec<BlindedHop>,
4646
}
4747

48-
/// Used to construct the blinded hops portion of a blinded route. These hops cannot be identified
48+
/// Used to construct the blinded hops portion of a blinded path. These hops cannot be identified
4949
/// by outside observers and thus can be used to hide the identity of the recipient.
5050
#[derive(Clone, Debug, PartialEq)]
5151
pub struct BlindedHop {
52-
/// The blinded node id of this hop in a blinded route.
52+
/// The blinded node id of this hop in a blinded path.
5353
pub(crate) blinded_node_id: PublicKey,
54-
/// The encrypted payload intended for this hop in a blinded route.
55-
// The node sending to this blinded route will later encode this payload into the onion packet for
54+
/// The encrypted payload intended for this hop in a blinded path.
55+
// The node sending to this blinded path will later encode this payload into the onion packet for
5656
// this hop.
5757
pub(crate) encrypted_payload: Vec<u8>,
5858
}
5959

6060
impl BlindedPath {
61-
/// Create a blinded route to be forwarded along `node_pks`. The last node pubkey in `node_pks`
61+
/// Create a blinded path to be forwarded along `node_pks`. The last node pubkey in `node_pks`
6262
/// will be the destination node.
6363
///
6464
/// Errors if less than two hops are provided or if `node_pk`(s) are invalid.
@@ -78,7 +78,7 @@ impl BlindedPath {
7878
})
7979
}
8080

81-
// Advance the blinded route by one hop, so make the second hop into the new introduction node.
81+
// Advance the blinded path by one hop, so make the second hop into the new introduction node.
8282
pub(super) fn advance_by_one<K: Deref, T: secp256k1::Signing + secp256k1::Verification>
8383
(&mut self, keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<(), ()>
8484
where K::Target: KeysInterface
@@ -196,15 +196,15 @@ impl_writeable!(BlindedHop, {
196196
pub(crate) struct ForwardTlvs {
197197
/// The node id of the next hop in the onion message's path.
198198
pub(super) next_node_id: PublicKey,
199-
/// Senders to a blinded route use this value to concatenate the route they find to the
200-
/// introduction node with the blinded route.
199+
/// Senders to a blinded path use this value to concatenate the route they find to the
200+
/// introduction node with the blinded path.
201201
pub(super) next_blinding_override: Option<PublicKey>,
202202
}
203203

204204
/// Similar to [`ForwardTlvs`], but these TLVs are for the final node.
205205
pub(crate) struct ReceiveTlvs {
206-
/// If `path_id` is `Some`, it is used to identify the blinded route that this onion message is
207-
/// sending to. This is useful for receivers to check that said blinded route is being used in
206+
/// If `path_id` is `Some`, it is used to identify the blinded path that this onion message is
207+
/// sending to. This is useful for receivers to check that said blinded path is being used in
208208
/// the right context.
209209
pub(super) path_id: Option<[u8; 32]>,
210210
}

lightning/src/onion_message/functional_tests.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ fn two_unblinded_two_blinded() {
136136
let test_msg = OnionMessageContents::Custom(TestCustomMessage {});
137137

138138
let secp_ctx = Secp256k1::new();
139-
let blinded_route = BlindedPath::new(&[nodes[3].get_node_pk(), nodes[4].get_node_pk()], &*nodes[4].keys_manager, &secp_ctx).unwrap();
139+
let blinded_path = BlindedPath::new(&[nodes[3].get_node_pk(), nodes[4].get_node_pk()], &*nodes[4].keys_manager, &secp_ctx).unwrap();
140140

141-
nodes[0].messenger.send_onion_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], Destination::BlindedPath(blinded_route), test_msg, None).unwrap();
141+
nodes[0].messenger.send_onion_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], Destination::BlindedPath(blinded_path), test_msg, None).unwrap();
142142
pass_along_path(&nodes, None);
143143
}
144144

@@ -148,9 +148,9 @@ fn three_blinded_hops() {
148148
let test_msg = OnionMessageContents::Custom(TestCustomMessage {});
149149

150150
let secp_ctx = Secp256k1::new();
151-
let blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
151+
let blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
152152

153-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), test_msg, None).unwrap();
153+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), test_msg, None).unwrap();
154154
pass_along_path(&nodes, None);
155155
}
156156

@@ -174,36 +174,36 @@ fn we_are_intro_node() {
174174
let test_msg = TestCustomMessage {};
175175

176176
let secp_ctx = Secp256k1::new();
177-
let blinded_route = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
177+
let blinded_path = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
178178

179-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg.clone()), None).unwrap();
179+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg.clone()), None).unwrap();
180180
pass_along_path(&nodes, None);
181181

182182
// Try with a two-hop blinded route where we are the introduction node.
183-
let blinded_route = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk()], &*nodes[1].keys_manager, &secp_ctx).unwrap();
184-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg), None).unwrap();
183+
let blinded_path = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk()], &*nodes[1].keys_manager, &secp_ctx).unwrap();
184+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), None).unwrap();
185185
nodes.remove(2);
186186
pass_along_path(&nodes, None);
187187
}
188188

189189
#[test]
190-
fn invalid_blinded_route_error() {
190+
fn invalid_blinded_path_error() {
191191
// Make sure we error as expected if a provided blinded route has 0 or 1 hops.
192192
let nodes = create_nodes(3);
193193
let test_msg = TestCustomMessage {};
194194

195195
// 0 hops
196196
let secp_ctx = Secp256k1::new();
197-
let mut blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
198-
blinded_route.blinded_hops.clear();
199-
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg.clone()), None).unwrap_err();
197+
let mut blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
198+
blinded_path.blinded_hops.clear();
199+
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg.clone()), None).unwrap_err();
200200
assert_eq!(err, SendError::TooFewBlindedHops);
201201

202202
// 1 hop
203-
let mut blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
204-
blinded_route.blinded_hops.remove(0);
205-
assert_eq!(blinded_route.blinded_hops.len(), 1);
206-
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg), None).unwrap_err();
203+
let mut blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
204+
blinded_path.blinded_hops.remove(0);
205+
assert_eq!(blinded_path.blinded_hops.len(), 1);
206+
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), None).unwrap_err();
207207
assert_eq!(err, SendError::TooFewBlindedHops);
208208
}
209209

@@ -223,10 +223,10 @@ fn reply_path() {
223223
format!("Received an onion message with path_id None and a reply_path").to_string(), 1);
224224

225225
// Destination::BlindedPath
226-
let blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
226+
let blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
227227
let reply_path = BlindedPath::new(&[nodes[2].get_node_pk(), nodes[1].get_node_pk(), nodes[0].get_node_pk()], &*nodes[0].keys_manager, &secp_ctx).unwrap();
228228

229-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg), Some(reply_path)).unwrap();
229+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), Some(reply_path)).unwrap();
230230
pass_along_path(&nodes, None);
231231
nodes[3].logger.assert_log_contains(
232232
"lightning::onion_message::messenger".to_string(),

lightning/src/onion_message/messenger.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::ln::features::{InitFeatures, NodeFeatures};
2020
use crate::ln::msgs::{self, OnionMessageHandler};
2121
use crate::ln::onion_utils;
2222
use crate::ln::peer_handler::IgnoringMessageHandler;
23-
use super::blinded_route::{BlindedPath, ForwardTlvs, ReceiveTlvs};
23+
use super::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs};
2424
pub use super::packet::{CustomOnionMessageContents, OnionMessageContents};
2525
use super::packet::{BIG_PACKET_HOP_DATA_LEN, ForwardControlTlvs, Packet, Payload, ReceiveControlTlvs, SMALL_PACKET_HOP_DATA_LEN};
2626
use super::utils;
@@ -92,14 +92,14 @@ use crate::prelude::*;
9292
/// // Create a blinded route to yourself, for someone to send an onion message to.
9393
/// # let your_node_id = hop_node_id1;
9494
/// let hops = [hop_node_id3, hop_node_id4, your_node_id];
95-
/// let blinded_route = BlindedPath::new(&hops, &keys_manager, &secp_ctx).unwrap();
95+
/// let blinded_path = BlindedPath::new(&hops, &keys_manager, &secp_ctx).unwrap();
9696
///
9797
/// // Send a custom onion message to a blinded route.
9898
/// # let intermediate_hops = [hop_node_id1, hop_node_id2];
9999
/// let reply_path = None;
100100
/// # let your_custom_message = YourCustomMessage {};
101101
/// let message = OnionMessageContents::Custom(your_custom_message);
102-
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_route), message, reply_path);
102+
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_path), message, reply_path);
103103
/// ```
104104
///
105105
/// [offers]: <https://github.com/lightning/bolts/pull/798>
@@ -219,11 +219,11 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
219219
// If we are sending straight to a blinded route and we are the introduction node, we need to
220220
// advance the blinded route by 1 hop so the second hop is the new introduction node.
221221
if intermediate_nodes.len() == 0 {
222-
if let Destination::BlindedPath(ref mut blinded_route) = destination {
222+
if let Destination::BlindedPath(ref mut blinded_path) = destination {
223223
let our_node_id = self.keys_manager.get_node_id(Recipient::Node)
224224
.map_err(|()| SendError::GetNodeIdFailed)?;
225-
if blinded_route.introduction_node_id == our_node_id {
226-
blinded_route.advance_by_one(&self.keys_manager, &self.secp_ctx)
225+
if blinded_path.introduction_node_id == our_node_id {
226+
blinded_path.advance_by_one(&self.keys_manager, &self.secp_ctx)
227227
.map_err(|()| SendError::BlindedPathAdvanceFailed)?;
228228
}
229229
}

lightning/src/onion_message/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
//! [offers]: <https://github.com/lightning/bolts/pull/798>
2121
//! [blinded routes]: crate::onion_message::BlindedPath
2222
23-
mod blinded_route;
23+
mod blinded_path;
2424
mod messenger;
2525
mod packet;
2626
mod utils;
2727
#[cfg(test)]
2828
mod functional_tests;
2929

3030
// Re-export structs so they can be imported with just the `onion_message::` module prefix.
31-
pub use self::blinded_route::{BlindedPath, BlindedHop};
31+
pub use self::blinded_path::{BlindedPath, BlindedHop};
3232
pub use self::messenger::{CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError, SimpleArcOnionMessenger, SimpleRefOnionMessenger};
3333
pub(crate) use self::packet::Packet;

lightning/src/onion_message/packet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
1414

1515
use crate::ln::msgs::DecodeError;
1616
use crate::ln::onion_utils;
17-
use super::blinded_route::{BlindedPath, ForwardTlvs, ReceiveTlvs};
17+
use super::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs};
1818
use super::messenger::CustomOnionMessageHandler;
1919
use crate::util::chacha20poly1305rfc::{ChaChaPolyReadAdapter, ChaChaPolyWriteAdapter};
2020
use crate::util::ser::{BigSize, FixedLengthReader, LengthRead, LengthReadable, LengthReadableArgs, Readable, ReadableArgs, Writeable, Writer};
@@ -146,15 +146,15 @@ pub(super) enum ForwardControlTlvs {
146146
Blinded(Vec<u8>),
147147
/// If we're constructing an onion message hop through an intermediate unblinded node, we'll need
148148
/// to construct the intermediate hop's control TLVs in their unblinded state to avoid encoding
149-
/// them into an intermediate Vec. See [`super::blinded_route::ForwardTlvs`] for more info.
149+
/// them into an intermediate Vec. See [`super::blinded_path::ForwardTlvs`] for more info.
150150
Unblinded(ForwardTlvs),
151151
}
152152

153153
/// Receive control TLVs in their blinded and unblinded form.
154154
pub(super) enum ReceiveControlTlvs {
155155
/// See [`ForwardControlTlvs::Blinded`].
156156
Blinded(Vec<u8>),
157-
/// See [`ForwardControlTlvs::Unblinded`] and [`super::blinded_route::ReceiveTlvs`].
157+
/// See [`ForwardControlTlvs::Unblinded`] and [`super::blinded_path::ReceiveTlvs`].
158158
Unblinded(ReceiveTlvs),
159159
}
160160

lightning/src/onion_message/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey, Scalar};
1616
use bitcoin::secp256k1::ecdh::SharedSecret;
1717

1818
use crate::ln::onion_utils;
19-
use super::blinded_route::BlindedPath;
19+
use super::blinded_path::BlindedPath;
2020
use super::messenger::Destination;
2121

2222
use crate::prelude::*;

0 commit comments

Comments
 (0)