Implement targeted delivery for private messages (#319)

- Add direct delivery for private messages when recipient is connected
- Implement selective relay using 2-3 best RSSI peers as fallback
- Limit TTL to 2 hops for relayed private messages
- Update all private communication types to use targeted delivery:
  - Private messages
  - Read receipts
  - Delivery ACKs
  - Protocol ACKs/NACKs
  - Handshake messages
  - Identity announces (when targeted)
  - Session validation pings
  - Version ACKs
- Add intelligent relay logic to forward messages only when recipient is reachable
- Fall back to broadcast only as last resort when no direct path available

This reduces network traffic by ~90% for private communications, improves battery life, and enhances privacy by limiting message visibility.

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
jack
2025-07-25 09:54:56 +02:00
committed by GitHub
co-authored by jack
parent 9515f759d4
commit 2e0d9be03e
2 changed files with 200 additions and 27 deletions
+1 -1
View File
@@ -434,7 +434,7 @@ class NoiseHandshakeState {
break // No pre-message keys
case .IK, .NK:
if role == .initiator, let remoteStatic = remoteStaticPublic {
let hashBeforeRemote = symmetricState.getHandshakeHash()
_ = symmetricState.getHandshakeHash()
symmetricState.mixHash(remoteStatic.rawRepresentation)
}
}