A secure, end-to-end encrypted group chat application with real-time communication and access-controlled channels. Built entirely in Go, with a lightweight HTML/JS frontend leveraging hybrid RSA + AES encryption.
Note: This is not intended for production use.
CryptCord demonstrates secure messaging and group chat functionality in a browser client, where:
- Only authorized users can access specific channels.
- Messages can be sent, edited, and deleted in real time.
- Communication remains confidential and tamper-resistant against a semi-honest server. Messages are encrypted client-side using AES-GCM, while RSA-OAEP is used to distribute channel AES keys.
| Component | Description |
|---|---|
| Backend (Go) | HTTP + WebSocket server (cmd/server/) handling authentication, message routing, and database operations. |
| Frontend (HTML/JS) | Pure JS client (public/) for login, chat UI, and cryptographic operations via Web Crypto API. |
| Database | SQLite database for users, channels, and encrypted message records. |
| Communication | REST API for registration/login; WebSocket (/ws/{token}) for dynamic updates (message edits, deletes, user/channel changes). |
| Encryption | AES-GCM (symmetric) for data; RSA (asymmetric) for key exchange; PBKDF2-derived keys for password-based private-key protection. |
- Go 1.21+
- SQLite 3
- Modern browser supporting Web Crypto API
git clone https://github.com/xuvi7/cryptcord.git
cd cryptcord
go build -o cryptcord ./cmd/server
./cryptcordAlternatively, you can use the MakeFile:
make build
make run
make cleanDefault address:
http://localhost:8080
Visit:
/auth→ login/register/chat→ main chat interface (after authentication)
-
Registration
-
Client generates:
- Salt
- RSA public/private keypair
-
AES key derived from password + salt (PBKDF2)
-
Private key encrypted locally with password-derived AES key.
-
Server stores public key, salt, and encrypted private key.
-
-
Login
-
Server returns stored salt and encrypted private key.
-
Client decrypts locally and proves identity via challenge:
- Server sends random code encrypted with user’s public key.
- Client decrypts with private key and returns plaintext to server.
-
-
Channel creation
- Channel owner generates a random AES key.
- Key is RSA-encrypted for the creator first; additional members are added later by re-encrypting the same channel key for the invitee and sending it via the server.
-
Messaging
- Each message encrypted with channel’s AES key.
- Server relays ciphertext; clients decrypt with their local AES key.
CryptCord is designed to be secure against semi-honest servers and external attackers:
- The server may relay or store data but cannot decrypt messages.
- Only clients possess plaintext AES keys or private RSA keys.
- Private RSA keys are encrypted client-side with a key derived from the password + salt. Even if the database leaks, attackers cannot decrypt private keys without knowing the password.
- Channel AES keys are encrypted using recipients’ public keys before storage or transmission.
- Login uses a challenge-response protocol: the server encrypts a random code with the user’s public key, requiring the private key to decrypt and respond.
- After successful authentication, a random 64-byte session token is issued as a cookie; this token authenticates subsequent API and WebSocket requests.
- Tokens are stored in-memory only and invalidated on server restart, preventing long-term hijacking.
- AES-GCM provides built-in authentication tags ensuring ciphertexts cannot be modified without detection.
- All cryptographic operations occur client-side; the server only forwards ciphertexts.
- WebSocket messages are authenticated through the active session token.
- WebSocket access is gated by the session token, and AES-GCM provides integrity for ciphertexts in transit.
- Without the private key or symmetric key, intercepted packets remain undecipherable.
- Password recovery is not supported (loss of password = loss of private key).
- Server restarts invalidate sessions (no persistent token storage).
- No formal audit; this is a proof-of-concept educational implementation.
| Endpoint | Method | Description |
|---|---|---|
/api/register |
POST | Register new user, store encrypted keys |
/api/login |
POST | Verify user and issue session token |
/api/getData |
GET | Fetch user’s channels and messages |
/ws/{token} |
WebSocket | Real-time chat, edit, and delete events |