Skip to content

Commit 8980bc3

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 43fa49e commit 8980bc3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,15 @@ where
570570
// recipient's node_id.
571571
const MIN_PEER_CHANNELS: usize = 3;
572572

573+
// Number of dummy hops added to each non-compact blinded path
574+
// to obscure the recipient’s position.
575+
//
576+
// Compact paths are optimized for minimal size. Adding dummy hops
577+
// would bloat them and defeat that purpose, so we skip them.
578+
const DUMMY_HOPS_COUNT: usize = 3;
579+
580+
let dummy_hops_count = if compact_paths { 0 } else { DUMMY_HOPS_COUNT };
581+
573582
let network_graph = network_graph.deref().read_only();
574583
let is_recipient_announced =
575584
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -604,9 +613,10 @@ where
604613
let paths = peer_info
605614
.into_iter()
606615
.map(|(peer, _, _)| {
607-
BlindedMessagePath::new(
616+
BlindedMessagePath::new_with_dummy_hops(
608617
&[peer],
609618
recipient,
619+
dummy_hops_count,
610620
local_node_receive_key,
611621
context.clone(),
612622
entropy,
@@ -620,9 +630,10 @@ where
620630
Ok(paths) if !paths.is_empty() => Ok(paths),
621631
_ => {
622632
if is_recipient_announced {
623-
BlindedMessagePath::new(
633+
BlindedMessagePath::new_with_dummy_hops(
624634
&[],
625635
recipient,
636+
dummy_hops_count,
626637
local_node_receive_key,
627638
context,
628639
&**entropy_source,

0 commit comments

Comments
 (0)