A hardened security fork of BitChat with production-ready security enhancements and private room support.
SecureBitchat is a security-hardened version of the decentralized Bluetooth mesh chat app BitChat. It maintains the core principles of offline BLE mesh communication, decentralized architecture, and P2P networking while implementing significant security improvements.
- Signature validation ensures data is at least 64 bytes before processing
- Safe null byte trimming prevents memory corruption
- Length validation on all variable-size fields
- Maximum payload size capped at 65,535 bytes
- Rejects packets exceeding the limit during encoding/decoding
- Prevents resource exhaustion attacks
- Maximum 10 mentions per message
- Maximum 256 characters per mention
- Parsing with strict limits prevents algorithmic complexity attacks
- Timestamp validation within 24-hour window
- Nonce tracking for message uniqueness
- Ratchet key rotation prevents message replay
- QR code based out-of-band fingerprint verification
- Biometric/PIN gate for sensitive operations
- Fingerprint verification before key exchange
- Keys rotate every 1 hour or per session
- Forward secrecy maintained via Double Ratchet
- Automatic key rotation without user intervention
- libsodium-style Double Ratchet implementation
- Each message uses a unique encryption key
- Compromised keys don't affect past messages
- Fixed-padding LZ4 compression
- Padding ensures uniform compressed output size
- Prevents traffic analysis via compression ratios
- XChaCha20-Poly1305 for all packet encryption
- Authenticated encryption with additional data
- Nonce-based encryption prevents pattern detection
- Invite via Signed QR: Ed25519 signed invitations with expiration
- Argon2id Key Derivation: Password + room ID → encryption key
- MLS-style Ratchet: Group rekey when members join/leave
- Biometric/PIN Gate: Extra authentication for room access
- Traffic Padding: Uniform packet sizes hide metadata
┌─────────────────────────────────────────────────────────────┐
│ Private Room Manager │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Create │ │ Join │ │ Rekey │ │
│ │ Room │ │ via QR │ │ (on member change) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ AES-GCM Encryption Layer ││
│ └─────────────────────────────────────────────────────────┘│
│ │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ Argon2id Key Derivation ││
│ │ password + roomId → 32-byte encryption key ││
│ └─────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────┘
- Xcode 15+
- CocoaPods or Swift Package Manager
- iOS 16.0+ / macOS 13.0+
cd SecureBitchat
pod install
xed .The project includes Swift Package Manager support for dependencies.
Run the test suite:
swift testOr via Xcode:
xcodebuild test -scheme SecureBitchat -destination 'platform=iOS Simulator,name=iPhone 15'SecureBitchat/
├── Sources/
│ └── SecureBitchat/
│ ├── Protocols/
│ │ └── SecureBinaryProtocol.swift # Hardened protocol
│ ├── Security/
│ │ ├── SecureIdentityManager.swift # Identity + MITM protection
│ │ └── SecureKeychainManager.swift # Secure storage
│ ├── Ratchet/
│ │ └── RatchetService.swift # Double Ratchet
│ ├── Rooms/
│ │ └── PrivateRoomManager.swift # Private rooms
│ └── Crypto/
│ └── XChaCha20Poly1305AEAD.swift # AEAD encryption
├── Tests/
│ └── SecureBitchatTests/
│ ├── SecureBinaryProtocolTests.swift
│ ├── PrivateRoomTests.swift
│ ├── RatchetServiceTests.swift
│ └── XChaCha20Poly1305Tests.swift
├── Docs/
│ └── diagrams.md # Flow diagrams
├── Podfile # CocoaPods deps
└── README.md
| Feature | BitChat | SecureBitchat |
|---|---|---|
| Signature Validation | Basic | 64-byte check |
| Payload Limit | 4GB | 65535 bytes |
| Timestamp Window | 2 minutes | 24 hours |
| Mentions Limit | None | 10 max |
| Forward Secrecy | Noise only | Double Ratchet |
| Room Encryption | None | AES-GCM |
| Key Derivation | None | Argon2id |
| Biometric Auth | No | Yes |
| Traffic Padding | Optional | Always |
This project is released into the public domain. See the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
See diagrams.md for Mermaid flowcharts showing:
- Secure room join flow
- Message encryption flow
- Key rotation sequence