CipherChat is a professional-grade encrypted chat system featuring Signal Protocol security (X3DH + Double Ratchet), TLS transport encryption, and dual IPv4/IPv6 support. Messages are protected with perfect forward secrecy, future secrecy, and zero-knowledge messaging — ensuring that even the server cannot read user messages.
- X3DH handshake for key exchange
- Double Ratchet for per-message forward secrecy
- X25519 ECDH key agreement
- AES-256-GCM authenticated encryption
- TOFU (Trust-On-First-Use) key pinning
- Key fingerprints & safety numbers
- Key change warnings and verification prompts
- TLS 1.2+ encrypted transport layer
- Dual IPv4/IPv6 support with fallback
- Real-time delivery (TCP_NODELAY)
- Zero-knowledge server design
- Multi-user secure messaging
- Broadcast encrypted messages
- Identity verification guidance
- Presence updates (join/leave)
- Python 3.8 or higher
- OpenSSL (recommended for certificate generation)
pip install -r requirements.txtpython generate_certs.pypython server.pypython client_v2.pyEnter:
- Server address:
localhostor IP - Port:
5000(default) - Username: any name
============================================================
[TOFU] First contact with Bob
============================================================
Identity fingerprint:
SHA256:abcd1234...ef567890
Verify this fingerprint with Bob out-of-band (phone, in person)
============================================================
⚠️ SECURITY WARNING: Bob's key changed!
Do NOT accept unless verified with Bob!
Alice → Server → Bob (key bundle)
│ │
└── Performs DH ops ┘
→ shared secret
- New keys on every message
- Past messages safe even if keys leak
CipherChat/
├── server.py # Secure chat server (TLS + bundle relay)
├── client_v2.py # Signal client with TOFU + Ratchet
├── x3dh.py # X3DH key agreement
├── double_ratchet.py # Double Ratchet protocol
├── x25519_utils.py # X25519 ECDH + fingerprints
├── crypto_utils.py # AES-GCM encryption
├── generate_certs.py # TLS certificate generator
├── config.py # Configuration options
└── certs/ # 🔒 (ignored) Local TLS keys
✔ Message content (E2E)
✔ Transport layer (TLS)
✔ Forward secrecy
✔ MITM (with user verification)
❌ Metadata (who talks to whom)
❌ Timing/traffic analysis
❌ First-contact MITM if user ignores fingerprint verification
This project is licensed under the MIT License.
See LICENSE for details.
Contributions, audits, and improvements are welcome!
Secure coding tips or vulnerability reports are especially appreciated.