← Back to the chat

Under the hood

How it works

A two-person chat with no chat server. This page explains what that means, and where it stops being true.

In short

This site is one static page. It has no backend, no accounts and no database. When two people open it and type the same phrase, their browsers find each other and open a direct, encrypted connection. Messages travel over that connection and nowhere else.

Step by step

  1. You type a nickname and a phrase. The phrase is your room's password. Nobody checks it against a list, it only has to match.
  2. Your browser hashes the phrase. It computes SHA-256 of the lowercased phrase and keeps the first 32 hex characters. That is the room ID. The phrase itself is never sent anywhere.
  3. Browsers find each other. Using the open-source library Trystero, each browser posts a small signaling note to public Nostr relays, tagged with the room ID. The note is encrypted with your phrase, so relays only see unreadable data.
  4. A direct connection opens. When two browsers read each other's notes they set up a WebRTC connection. WebRTC data channels are encrypted in transit (DTLS).
  5. Messages go browser to browser. Nothing is sent to the site's host or to the relays. Nothing is written to disk or to a database.
  6. You close the tab and it's gone. There is no history to recover.

Who can see what

PartyCan seeCannot see
The other personYour nickname, your messages, your IP addressAnything outside the chat
The site's hostThat someone downloaded this page (IP, time)Phrases, nicknames, messages
Nostr relaysYour IP, the hashed room ID, encrypted signaling dataThe phrase, nicknames, messages
STUN serversYour IP, to help work out your public addressPhrases, nicknames, messages
The CDNThat the Trystero library was loaded (IP, time)Phrases, nicknames, messages
Your network providerThat you connected to the peer and to relays, and how much data movedMessage contents

Known limits

Not for situations where your safety depends on anonymity. This tool keeps messages off servers, not you off the network.

Source code

The whole project is two HTML files. Read it, check it, or host your own copy: github.com/lianshao09/ClosedRoom