Skip to content

Latest commit

 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E2EE-Chat

A High-Security, Desktop-Native End-to-End Encrypted Chat Client & Relay Server

Language Framework Security License

FeaturesHow It WorksCryptographyWire ProtocolSetup


Overview

E2EE-Chat is a local, zero-knowledge, end-to-end encrypted messaging application comprising a sleek desktop client GUI and a dedicated administrative relay server dashboard. Built natively using PySide6 (Qt) and hardened with modern asymmetric/symmetric primitives, the server serves exclusively as a blind packet dispatcher.

The server architecture cannot access, log, or read any unencrypted conversation payloads, cryptographic keys, or identity fingerprints.


Features

  • State-of-the-Art E2EE: Combines X25519 Ephemeral Key Exchanges and AES-256-GCM authenticated symmetric encryption executed locally in browser/client memory.
  • Native Desktop Dashboards: High-fidelity dark-mode user interfaces for both the Client application and the Server Management Console.
  • Enterprise Tunneling Out-of-the-Box: Auto-detects remote domain endpoints and seamlessly spins up local isolated reverse Cloudflare TCP Access Tunnels (cloudflared).
  • Live Server Analytics: Graphical server console to monitor registered socket connections, tracking nodes, and localized system logs without compromising message content privacy.
  • Passive Notifications: Full Windows/Linux system tray integration with message truncation previews and native system alerts.

How It Works (Step-by-Step)

The underlying core protocol relies on a tight coordination loop between the clients and the server instance:

[ Client A (Alice) ]             [ Relay Server ]             [ Client B (Bob) ]
        |                               |                               |
        |------ 1. Register Name ------>|                               |
        |                               |<------ 2. Register Name ------|
        |                               |                               |
        |========== 3. X25519 Ephemeral Key Handshake ==========|       |
        |---- message-key-1 (PubA) ---->|------------------------------>|
        |<--- message-key-1 (PubB) -----|<------------------------------|
        |---- shared-key-ready -------->|------------------------------>|
        |<--- shared-key-ready ---------|<------------------------------|
        |                               |                               |
        |==== 4. Derive Shared Session Key via HKDF-SHA256 ====|       |
        |                               |                               |
        |== 5. Encrypt with AES-GCM and Send Blind Ciphertext ==|       |
        |--- [Nonce + Ciphertext] ----->|------------------------------>|

1. Client Connection & Registration

When a client initializes, it opens a raw TCP socket connection to the relay server. It sends an unencrypted register packet containing the chosen username. The server keeps a memory-bound registry mapping names to active network sockets.

2. Ephemeral Key Exchange (X25519)

Before any text messages can travel, the client demands the target peer's identity and initializes a secure key handshake:

  • Alice's client generates a random, cryptographically secure X25519 Private Key and computes its corresponding Public Key.
  • Alice packages her public key inside a message-key-1 packet targeted for Bob. The server receives this and passes it to Bob blindly.
  • Bob responds with his own message-key-1 containing his public key.
  • Both parties issue a shared-key-ready command confirmation to verify completion.

3. Key Derivation (HKDF)

Both clients extract the peer's public key material and perform a Diffie-Hellman exchange against their own private parameters to output a shared master secret. This master secret is passed through a Hash-based Key Derivation Function (HKDF) using SHA-256 to create a static, unique 32-byte Symmetric Chat Key.

4. Authenticated Transmission (AES-GCM)

When Alice types a message and hits send:

  • The client generates a random 12-byte initialization vector (Nonce).
  • The raw string is encrypted using AES-GCM (Galois/Counter Mode) with the derived session key, producing ciphertext and an authentication tag.
  • The client binds the Nonce + Ciphertext into an encrypted-chat structural payload.
  • The server processes the envelope header, sees the destination username, and passes the payload along. It can never decode the message body since it lacks the private keys.

Cryptography Architecture

The implementation rejects legacy, insecure cryptography and opts strictly for modern performance:

Component Primitive Details
Key Exchange X25519 High-speed ECDH key agreement over Curve25519
Key Derivation HKDF-SHA256 Derives 32-byte keys using unique context tags
Symmetric Cipher AES-256-GCM Authenticated encryption preventing chosen-ciphertext attacks
Entropy Engine os.urandom() OS-level cryptographically secure random generation

Wire Protocol (Packet Format)

Network data frames traveling through sockets use explicit, predictable binary packing sizes structural headers via the Python struct format specifier !.

1. Registration Packet Structure

+----------------------------------+--------------------------+
|      Command (32 Bytes Char)     |  Payload Length (UInt32) |
+----------------------------------+--------------------------+

2. Chat / Key Exchange Structure

+----------------------------+----------------------------+--------------------------+
|   Command (32 Bytes Char)  |  Recipient (64 Bytes Char) |  Payload Length (UInt32) |
+----------------------------+----------------------------+--------------------------+

Installation & Setup

Prerequisites

  • Python 3.10 or higher installed on your pathing layout.
  • Optional: cloudflared installed system-wide if attempting to map local environments across active web domains.

1. Clone the Codebase

git clone [https://github.com/CBHELEC/e2ee-chat.git](https://github.com/CBHELEC/e2ee-chat.git)
cd e2ee-chat

2. Install Dependencies

pip install PySide6 cryptography

3. Run the Relay Dashboard Server

Launch the central communication controller node first:

python server_gui.py

Input your preferred local host interface (e.g., 127.0.0.1 or 0.0.0.0 for all interfaces) along with the default target Port (724), and click Start Server.

4. Launch Chat Clients

Open two individual shell client terminal frameworks to simulate user interactions:

python client_gui.py

Ensure your Server targeting fields match the running instance.

Enter your distinct handle inside Username.

Target your peer's handle inside Chat With.

Hit Connect to run the handshake automatically and begin chatting securely!

Contributing

Fork the Project

Create your Feature Branch (git checkout -b feature/AmazingFeature)

Commit your Changes (git commit -m 'Add some AmazingFeature')

Push to the Branch (git push origin feature/AmazingFeature)

Open a Pull Request

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages