Decentralized P2P Messaging
End-to-end encrypted peer-to-peer chat with no central server, built on X25519 key exchange and AES-GCM.
Technologies Used
Motivation
This started as a group project with John Nasitem for my Advanced C# class. The goal was straightforward: build a chat application where messages go directly between peers with no central server relaying traffic. Every message is end-to-end encrypted so even if someone intercepts the connection, they get nothing useful.
What began as a class assignment turned into a deep dive into modern cryptography and how to actually implement it correctly in a real-world application.
How It Works
When two peers connect, they perform an X25519 key exchange to derive a shared secret without ever transmitting it. That shared secret is used to key AES-GCM, which encrypts every message with authenticated encryption - meaning tampering is detected, not just eavesdropping. HMAC provides an additional layer of message authentication.
The architecture is fully decentralized. There is no server in the middle. Peers connect directly to each other over TCP, exchange keys, and start sending encrypted messages. If one peer goes offline, the connection simply drops - no state is stored anywhere else.
What I Learned
ECDH in practice - Understanding the mathematics behind Elliptic Curve Diffie-Hellman and why X25519 is the go-to curve for key agreement. Prior to this I had a foundation in Abstract Algebra and Rings/Modules, but this project made the theory concrete.
Authenticated encryption - Why AES-GCM matters over plain AES-CBC. Encryption without authentication is surprisingly dangerous.
P2P networking - Dealing with NAT traversal, direct TCP connections, and the reality that "just connect two computers" is harder than it sounds.
What's Next
This project is still in active development. More updates to come.