Skip to content

Commit 1e2c79f

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 499aa35 commit 1e2c79f

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
@@ -572,6 +572,13 @@ where
572572
// recipient's node_id.
573573
const MIN_PEER_CHANNELS: usize = 3;
574574

575+
// Add a random number (1 to 5) of dummy hops to each non-compact blinded path
576+
// to make it harder to infer the recipient's position.
577+
let dummy_hops_count = compact_paths.then_some(0).unwrap_or_else(|| {
578+
let random_byte = entropy_source.get_secure_random_bytes()[0];
579+
(random_byte % 5) + 1
580+
});
581+
575582
let network_graph = network_graph.deref().read_only();
576583
let is_recipient_announced =
577584
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -602,8 +609,9 @@ where
602609
let paths = peer_info
603610
.into_iter()
604611
.map(|(peer, _, _)| {
605-
BlindedMessagePath::new(
612+
BlindedMessagePath::new_with_dummy_hops(
606613
&[peer],
614+
dummy_hops_count,
607615
recipient,
608616
context.clone(),
609617
entropy,

0 commit comments

Comments
 (0)