Design and Implementation of a Secure Encrypted Chat Application Using Diffie-Hellman Key Exchange and AES Encryption
Abstract
The increasing popularity of digital messaging has resulted in heightened security concerns regarding user data, leading to numerous cases of interception, data leaks, and unauthorized access. Although many solutions have been proposed, including end-to-end encryption (E2EE), some systems utilize only one cryptographic primitive or do not adequately address key management. This paper presents the design, implementation, and evaluation of a web-based chat application implementing E2EE using AES and the Diffie-Hellman key exchange algorithm. In contrast to common approaches where encryption is optional, the proposed platform is centered on cryptographic security: each message is encrypted before transmission, and the symmetric session key is generated independently by both users without server involvement in key distribution. The application supports user registration, JWT-based authentication, consent-based per-session key negotiation, and storage of encrypted chat histories in MongoDB Atlas. The solution is deployed on Render and accessible through standard web browsers. Experimental evaluation including WebSocket payload overhead analysis, latency measurements with 95% confidence intervals, computational complexity analysis, and message size scalability tests demonstrates that the hybrid approach achieves low cryptographic overhead while maintaining real-time messaging performance in both local and cloud-hosted environments.