Fix asymmetric voice/media delivery in private chats

When selectedPrivateChatPeer was migrated to a 64-hex stable Noise key
after session establishment, file transfers would silently fail because:

1. Sender used raw 64-hex key, truncated to first 8 bytes by BinaryProtocol
2. Receiver's myPeerID is SHA256-fingerprint-derived (different value)
3. Recipient check failed, causing silent packet drop

The fix normalizes peerID to short form (SHA256-derived 16-hex) in
sendFilePrivate before constructing recipientData, ensuring the wire
format matches what receivers expect.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jack
2026-01-12 16:17:50 -10:00
co-authored by Claude Opus 4.5
parent 7cfdcfe174
commit b47fb736f4
2 changed files with 70 additions and 1 deletions
+4 -1
View File
@@ -728,7 +728,10 @@ final class BLEService: NSObject {
SecureLogger.error("❌ Failed to encode file packet for private send", category: .session)
return
}
guard let recipientData = Data(hexString: peerID.id) else {
// Normalize to short form (SHA256-derived 16-hex) for wire protocol compatibility
// This ensures 64-hex Noise keys are converted to the canonical routing format
let targetID = peerID.toShort()
guard let recipientData = Data(hexString: targetID.id) else {
SecureLogger.error("❌ Invalid recipient peer ID for file transfer: \(peerID)", category: .session)
return
}