mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 15:45:23 +00:00
Implement Noise Protocol Framework and peer ID rotation for enhanced security and privacy
This major update replaces the basic encryption with the Noise Protocol Framework and adds ephemeral peer ID rotation for enhanced privacy. Key Changes: Security Infrastructure: - Implemented Noise Protocol Framework (XX handshake pattern) - End-to-end encryption with forward secrecy and identity hiding - Session management with automatic rekey support - Channel encryption with password-derived keys Privacy Enhancements: - Ephemeral peer ID rotation (5-15 minute random intervals) - Persistent identity through public key fingerprints - Favorites and verification persist across ID rotations - Block list based on fingerprints, not ephemeral IDs Core Components Added: - NoiseEncryptionService: Main encryption service - NoiseSession: Individual peer session management - NoiseChannelEncryption: Password-protected channel support - SecureIdentityStateManager: Persistent identity storage - FingerprintView: Visual fingerprint verification UI Bug Fixes: - Fixed handshake storm with tie-breaker mechanism - Fixed missing connect messages during peer rotation - Fixed delivery ACK compression issues - Fixed race conditions in message queue - Fixed nickname resolution for rotated peer IDs Testing: - Comprehensive test suite for Noise implementation - Security validator tests - Channel encryption tests - Identity persistence tests - Rate limiter tests Documentation: - BRING_THE_NOISE.md: Technical implementation details - Updated WHITEPAPER.md: Simplified and focused on core innovations - Removed temporary debug documentation The implementation maintains backward compatibility while significantly improving security and privacy. All existing features (channels, private messages, favorites, blocking) work seamlessly with the new system.
This commit is contained in:
@@ -198,4 +198,45 @@ class BitchatMessageTests: XCTestCase {
|
||||
|
||||
XCTAssertEqual(decoded.content, longContent)
|
||||
}
|
||||
|
||||
func testPrivateMessageWithAllFieldsForNoise() {
|
||||
// Test that private messages with ID field (used by Noise) are encoded/decoded correctly
|
||||
let messageID = UUID().uuidString
|
||||
let privateMessage = BitchatMessage(
|
||||
id: messageID,
|
||||
sender: "alice",
|
||||
content: "Hello Bob, this is a private message via Noise",
|
||||
timestamp: Date(),
|
||||
isRelay: false,
|
||||
originalSender: nil,
|
||||
isPrivate: true,
|
||||
recipientNickname: "bob",
|
||||
senderPeerID: "alice-peer-id-123",
|
||||
mentions: nil,
|
||||
channel: nil
|
||||
)
|
||||
|
||||
// Encode to binary payload (as used by Noise encryption)
|
||||
guard let encoded = privateMessage.toBinaryPayload() else {
|
||||
XCTFail("Failed to encode private message with ID to binary payload")
|
||||
return
|
||||
}
|
||||
|
||||
// Decode from binary payload (as received from Noise decryption)
|
||||
guard let decoded = BitchatMessage.fromBinaryPayload(encoded) else {
|
||||
XCTFail("Failed to decode private message with ID from binary payload")
|
||||
return
|
||||
}
|
||||
|
||||
// Verify all fields match
|
||||
XCTAssertEqual(decoded.id, messageID)
|
||||
XCTAssertEqual(decoded.sender, "alice")
|
||||
XCTAssertEqual(decoded.content, "Hello Bob, this is a private message via Noise")
|
||||
XCTAssertEqual(decoded.isPrivate, true)
|
||||
XCTAssertEqual(decoded.recipientNickname, "bob")
|
||||
XCTAssertEqual(decoded.senderPeerID, "alice-peer-id-123")
|
||||
XCTAssertNil(decoded.channel)
|
||||
XCTAssertFalse(decoded.isRelay)
|
||||
XCTAssertNil(decoded.originalSender)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user