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
- 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.
- 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.
- 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.
- 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).
- 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.
- You close the tab and it's gone. There is no history to recover.
Who can see what
| Party | Can see | Cannot see |
|---|---|---|
| The other person | Your nickname, your messages, your IP address | Anything outside the chat |
| The site's host | That someone downloaded this page (IP, time) | Phrases, nicknames, messages |
| Nostr relays | Your IP, the hashed room ID, encrypted signaling data | The phrase, nicknames, messages |
| STUN servers | Your IP, to help work out your public address | Phrases, nicknames, messages |
| The CDN | That the Trystero library was loaded (IP, time) | Phrases, nicknames, messages |
| Your network provider | That you connected to the peer and to relays, and how much data moved | Message contents |
Known limits
- The phrase is the only lock. Anyone who guesses it can join with any nickname. Use something long and random, such as three unrelated words, and share it in person or over a channel you trust. Avoid "test" or "chat".
- No identity check. A nickname is just text. Nothing proves who is behind it.
- Your IP is visible to the other person. That is how direct connections work. If that matters, this tool is not the right one.
- Both people must be online at the same time. Messages can't wait for someone who isn't there.
- Some networks block it. There is no TURN relay, so strict firewalls, some mobile networks and some corporate Wi-Fi can stop the connection. Try another network.
- Built for small rooms. Every person connects to every other person, so it works best with two to a handful of people.
- It trusts the code you load. If the host or the CDN were compromised, the page could be altered. That is why the source is public and small.
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