mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 23:25:20 +00:00
Remove dead code and placeholders
- Remove NoisePostQuantum.swift entirely (placeholder with no implementation) - Remove Double Ratchet placeholder code from NoiseChannelKeyRotation.swift - Remove NoisePostQuantumTests that tested mock implementations - Handle TODO for version negotiation rejection (now properly disconnects) - Remove legacy comment about removed message type 0x02 - Keep deprecated ownerID field as it's still used for compatibility This cleanup removes ~400 lines of placeholder code that was not being used and unlikely to be implemented in the near future.
This commit is contained in:
@@ -307,80 +307,4 @@ class NoiseKeyRotationTests: XCTestCase {
|
||||
|
||||
XCTAssertTrue(decrypted, "Failed to decrypt with any valid key")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Post-Quantum Framework Tests
|
||||
|
||||
class NoisePostQuantumTests: XCTestCase {
|
||||
|
||||
func testHybridKeyGeneration() throws {
|
||||
let (publicKey, privateKey) = try HybridNoiseKeyExchange.generateKeyPair(algorithm: .classicalOnly)
|
||||
|
||||
XCTAssertNotNil(publicKey.classical)
|
||||
XCTAssertNil(publicKey.postQuantum) // No PQ component yet
|
||||
XCTAssertEqual(publicKey.serialized.count, 32) // Just Curve25519
|
||||
|
||||
XCTAssertNotNil(privateKey.classical)
|
||||
XCTAssertNil(privateKey.postQuantum)
|
||||
}
|
||||
|
||||
func testHybridKeyAgreement() throws {
|
||||
// Generate two keypairs
|
||||
let (alicePub, alicePriv) = try HybridNoiseKeyExchange.generateKeyPair(algorithm: .classicalOnly)
|
||||
let (bobPub, bobPriv) = try HybridNoiseKeyExchange.generateKeyPair(algorithm: .classicalOnly)
|
||||
|
||||
// Perform key agreement
|
||||
let aliceShared = try HybridNoiseKeyExchange.performKeyAgreement(
|
||||
localPrivate: alicePriv,
|
||||
remotePublic: bobPub,
|
||||
algorithm: .classicalOnly
|
||||
)
|
||||
|
||||
let bobShared = try HybridNoiseKeyExchange.performKeyAgreement(
|
||||
localPrivate: bobPriv,
|
||||
remotePublic: alicePub,
|
||||
algorithm: .classicalOnly
|
||||
)
|
||||
|
||||
// Shared secrets should match
|
||||
XCTAssertEqual(
|
||||
aliceShared.combinedSecret().withUnsafeBytes { Data($0) },
|
||||
bobShared.combinedSecret().withUnsafeBytes { Data($0) }
|
||||
)
|
||||
}
|
||||
|
||||
func testMigrationConfig() {
|
||||
let config = NoiseProtocolMigration.getMigrationConfig()
|
||||
|
||||
XCTAssertEqual(config.currentPhase, .classicalOnly)
|
||||
XCTAssertEqual(config.preferredAlgorithm, .classicalOnly)
|
||||
XCTAssertTrue(config.acceptedAlgorithms.contains(.classicalOnly))
|
||||
XCTAssertNil(config.migrationDeadline)
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
func testMockPostQuantum() throws {
|
||||
// Test mock PQ implementation
|
||||
let (publicKey, privateKey) = try MockPostQuantumKeyExchange.generateKeyPair()
|
||||
|
||||
XCTAssertEqual(publicKey.count, MockPostQuantumKeyExchange.publicKeySize)
|
||||
XCTAssertEqual(privateKey.count, 32) // Mock uses smaller private key
|
||||
|
||||
let (sharedSecret, ciphertext) = try MockPostQuantumKeyExchange.encapsulate(
|
||||
remotePublicKey: publicKey
|
||||
)
|
||||
|
||||
XCTAssertEqual(ciphertext.count, MockPostQuantumKeyExchange.ciphertextSize)
|
||||
XCTAssertEqual(sharedSecret.count, MockPostQuantumKeyExchange.sharedSecretSize)
|
||||
|
||||
let decapsulatedSecret = try MockPostQuantumKeyExchange.decapsulate(
|
||||
ciphertext: ciphertext,
|
||||
privateKey: privateKey
|
||||
)
|
||||
|
||||
// In real implementation, these would match
|
||||
// Mock just returns deterministic values
|
||||
XCTAssertEqual(decapsulatedSecret.count, 32)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user