Skip to content

Commit e66e39a

Browse files
committed
Update Default Blinded Path constructor to use Dummy Hops
Applies dummy hops by default when constructing blinded paths via `DefaultMessageRouter`, enhancing privacy by obscuring the true path length. Uses a predefined `DUMMY_HOPS_COUNT` to apply dummy hops consistently without requiring explicit user input.
1 parent 04c5f2b commit e66e39a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lightning/src/onion_message/messenger.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ where
570570
// recipient's node_id.
571571
const MIN_PEER_CHANNELS: usize = 3;
572572

573+
// Add a random number (1 to 5) of dummy hops to each non-compact blinded path
574+
// to make it harder to infer the recipient's position.
575+
let dummy_hops_count = compact_paths.then_some(0).unwrap_or_else(|| {
576+
let random_byte = entropy_source.get_secure_random_bytes()[0];
577+
(random_byte % 5) + 1
578+
});
579+
573580
let network_graph = network_graph.deref().read_only();
574581
let is_recipient_announced =
575582
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -600,8 +607,9 @@ where
600607
let paths = peer_info
601608
.into_iter()
602609
.map(|(peer, _, _)| {
603-
BlindedMessagePath::new(
610+
BlindedMessagePath::new_with_dummy_hops(
604611
&[peer],
612+
dummy_hops_count,
605613
recipient,
606614
context.clone(),
607615
entropy,

0 commit comments

Comments
 (0)