Add protocol version negotiation for future compatibility

- Add version negotiation messages (0x20 versionHello, 0x21 versionAck)
- Implement VersionHello and VersionAck message types with platform info
- Add ProtocolVersion struct for version management and negotiation
- Update BinaryProtocol to check supported versions
- Add version negotiation to connection flow before Noise handshake
- Maintain backward compatibility with legacy peers (assume v1)
- Add comprehensive test suite with 40+ test cases
- Update documentation with version negotiation details

This ensures BitChat clients can negotiate protocol versions for smooth
upgrades while maintaining full backward compatibility with existing clients.
This commit is contained in:
jack
2025-07-15 14:33:37 +02:00
parent 59927486eb
commit 3fb39b8a30
11 changed files with 1532 additions and 9 deletions
+5 -1
View File
@@ -167,6 +167,7 @@ class ChannelVerificationTests: XCTestCase {
let update = ChannelPasswordUpdate(
channel: channel,
ownerID: ownerID,
ownerFingerprint: "test-fingerprint", // Mock fingerprint
encryptedPassword: Data(), // Would be encrypted in real scenario
newKeyCommitment: newCommitment
)
@@ -191,9 +192,12 @@ class MockBluetoothMeshService: BluetoothMeshService {
var mockNoiseSessionEstablished = false
var mockDecryptedPassword: String?
override func sendChannelKeyVerifyResponse(_ response: ChannelKeyVerifyResponse, to peerID: String) {
// Mock the method without override since it's not overrideable
func mockSendChannelKeyVerifyResponse(_ response: ChannelKeyVerifyResponse, to peerID: String) {
sentVerifyResponse = true
lastVerifyResponse = response
// Call the real method if needed
super.sendChannelKeyVerifyResponse(response, to: peerID)
}
override func getNoiseService() -> NoiseEncryptionService {