Skip to content

Omkarth/socp-chat

Repository files navigation

SOCP — Secure Open Chat Protocol

A secure chat system implementing end-to-end encrypted messaging over a federated server network. Built with Python, WebSockets, and RSA-4096.

🔑 Security note: all RSA keypairs are generated locally at runtime — no private keys are stored in this repository.

Features

Security

  • RSA-4096 end-to-end encryption — servers cannot read message contents
  • Message signing and signature verification
  • Public key infrastructure with key request/exchange protocol
  • SHA-256 integrity verification for file transfers

Messaging & files

  • Encrypted direct messages and public channel broadcasts
  • Cross-server message routing across the federated network
  • Encrypted, chunked (4 KB) file transfer with automatic retry

Network

  • Federated server architecture with automatic server discovery
  • Introducer/bootstrap servers for joining the network
  • Heartbeat-based connection monitoring

Quick start

Requires Python 3.8+.

python3 -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -r requirements.txt

Run servers

# Terminal 1 — introducer/bootstrap server (generates its RSA-4096 keypair on startup)
python run_server.py --port 8001 --introducer

# Terminal 2 — a second server that joins the network (optional)
python run_server.py --port 8002

Options: --host, --port, --introducer, --verbose, --key KEYFILE.

Run a client

cd client
python client.py

Enter the server host/port and a username; the client generates its own RSA-4096 keypair and announces its public key to the network.

Client commands

Command Description
/tell <user> <msg> Send an encrypted direct message
/file <user> <path> Send a file (encrypted, SHA-256 verified)
/all <msg> Broadcast to the public channel
/list List all online users across servers
/keys Show known public keys
/request <user> Request a user's public key
/quit Exit

Testing cross-server messaging

Start two servers (ports 8001 and 8002), connect alice to 8001 and bob to 8002, then /tell bob hello from alice — the message routes between servers and only bob can decrypt it.

Project structure

server/
  server.py          # Main server: WebSockets, routing, protocol
  crypto_handler.py  # Cryptography operations
  database.py        # SQLite persistence (aiosqlite)
  routing.py         # Cross-server message routing
  config.py          # Configuration handling
client/
  client.py          # Interactive chat client
  crypto_client.py   # Client-side cryptography
common/
  constants.py       # Protocol constants and enums
key_exchange.py      # Key exchange implementation
run_server.py        # Server entry point
run_client.py        # Client entry point

Credits

Built as a group project (Group 34) for Secure Programming at the University of Adelaide, by Omkar Thombre, Ayush Sahane, Sharvil Kadam, and Yashashree Talele.

About

Secure Open Chat Protocol (SOCP) — WebSocket-based end-to-end encrypted chat with RSA-4096, asyncio, and canonical JSON serialization

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages