Skip to content

Commit

Permalink
fix(dht): optimisation, no decrypt if public key dest doesn't match
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed May 24, 2022
1 parent 331751d commit 99158bb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions comms/dht/src/inbound/decryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ where S: Service<DecryptedDhtMessage, Response = (), Error = PipelineError>
return Err(DecryptionError::EncryptedMessageNoDestination);
}

if !message.dht_header.destination.is_unknown() {
if message
.dht_header
.destination
.public_key()
.map(|pk| pk != node_identity.public_key())
.unwrap_or(false)
{
debug!(
target: LOG_TARGET,
"Encrypted message (source={}, {}) not destined for this peer. Passing to next service (Trace: {})",
message.source_peer.node_id,
message.dht_header.message_tag,
message.tag
);
return Ok(DecryptedDhtMessage::failed(message));
}
}

let e_pk = dht_header
.ephemeral_public_key
.as_ref()
Expand Down

0 comments on commit 99158bb

Please sign in to comment.