Skip to content

Commit 67eef37

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 58a0c13 commit 67eef37

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lightning/src/onion_message/messenger.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,15 @@ where
563563
// recipient's node_id.
564564
const MIN_PEER_CHANNELS: usize = 3;
565565

566+
// Add a random number (1 to 5) of dummy hops to each non-compact blinded path
567+
// to make it harder to infer the recipient's position.
568+
let dummy_hops_count = compact_paths
569+
.then_some(0)
570+
.unwrap_or_else(|| {
571+
let random_byte = entropy_source.get_secure_random_bytes()[0];
572+
(random_byte % 5) + 1
573+
});
574+
566575
let network_graph = network_graph.deref().read_only();
567576
let is_recipient_announced =
568577
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -602,8 +611,15 @@ where
602611
Ok(paths) if !paths.is_empty() => Ok(paths),
603612
_ => {
604613
if is_recipient_announced {
605-
BlindedMessagePath::new(&[], recipient, context, &**entropy_source, secp_ctx)
606-
.map(|path| vec![path])
614+
BlindedMessagePath::new_with_dummy_hops(
615+
&[],
616+
dummy_hops_count,
617+
recipient,
618+
context,
619+
&**entropy_source,
620+
secp_ctx,
621+
)
622+
.map(|path| vec![path])
607623
} else {
608624
Err(())
609625
}

0 commit comments

Comments
 (0)