Menu

Building an end-to-end encrypted chat app with libsodium
📰

Building an end-to-end encrypted chat app with libsodium

DEV Community: fastify·Mike Vu·11 days ago
#zfD1sQ0w
#devtofastify#devto#dev#server#chat
Long article (1404 words) — no AI summary yet.
Reading 0:00
15s threshold

End-to-end encryption (E2EE) sounds simple: encrypt on the sender's device, decrypt on the recipient's, and the server in the middle only sees ciphertext. When building E2EE Chat , the harder part wasn't the algorithms but one question: what if the server itself cheats?

This post walks through the app's key design, which libsodium primitive does which job, and the general limits every design of this kind has to accept. If you're learning about E2EE, I hope it helps you see how the pieces fit together.

System overview

Part Stack

Web app (PWA) React 19, TanStack Router and Query, Tailwind CSS 4, libsodium

API Fastify 5, Drizzle ORM on PostgreSQL, Centrifugo, Web Push

Files S3-compatible object storage

Accounts Keycloak, OpenID Connect with PKCE

Reads and writes go through REST, and every change (new messages, typing, read markers…) is pushed in real time over Centrifugo (Socket.IO until November 2026).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.