A secure, peer-to-peer terminal chat application built with Bun, TypeScript, and raw TCP/UDP sockets.
- 🔒 End-to-End Encryption: Uses ECDH (secp256k1) key exchange and AES-256-CBC encryption for all Direct Messages.
- 📡 Zero-Config Discovery: Automatically finds peers on your local network using UDP Multicast.
- 💬 Real-time Messaging: Instant broadcast messages and private DMs.
- ⌨️ Rich Terminal UI: Beautiful interface with typing indicators, user presence, and command autocomplete.
- 🚀 High Performance: Built on Bun for lightning-fast startup and execution.
You can install the latest binary release with a single command:
curl -fsSL https://raw.githubusercontent.com/nabwinsaud/terminal-chat/main/install.sh | shiwr -useb https://raw.githubusercontent.com/Nabwinsaud/terminal-chat/main/install.ps1 | iexIf you prefer to build from source:
- Install Bun
- Clone the repository:
git clone https://github.com/nabwinsaud/terminal-chat.git cd terminal-chat - Install dependencies:
bun install
- Run the chat:
bun run chat.ts
Start the application:
terminal-chat
# or if running from source
bun run chat.ts/help- Show available commands/users- List all connected peers/dm <username> <message>- Send an encrypted private message- Tip: Press Tab to autocomplete usernames!
/quit- Exit the chat
The application uses UDP Multicast on port 54321 to announce presence and query for other peers. When a peer is found, a direct WebSocket connection is established.
- Key Generation: On startup, each client generates an ephemeral ECDH key pair (secp256k1).
- Key Exchange: Public keys are exchanged during the initial handshake.
- Shared Secret: When sending a DM, a shared secret is derived using ECDH.
- Encryption: Messages are encrypted using AES-256-CBC with a unique IV for each message.
- Server: Each client runs a WebSocket server to accept incoming connections.
- Client: Connects to other peers' WebSocket servers.
- UI: Handles input/output using raw terminal mode for a responsive experience.
MIT
