cha7 white paper
Security design, threat model and honest limits Version 1, November 2026. Describes the code in this repository (main); where this paper and the code disagree, the code wins. The full technical reference is DOCS.md; section links below point into it.
1. Summary
cha7 is a small, invite-only messenger for people who know each other. It runs in the browser (an installable web app), and one server instance (a Cloudflare Worker with Durable Objects, on the free plan) serves one community.
- Content is end-to-end encrypted, always: 1:1 chats, groups, photos, voice, video, files, reactions, receipts, edits, deletes, view-once messages, disappearing-message timers, pins, and the copies a user's own devices exchange. There is no unencrypted mode.
- The server is a mailbox, not an archive: it holds sealed envelopes until every device of the recipient has them, then deletes them. Undelivered ones are deleted after the retention time (30 days by default).
- An account is a key on the device. No phone number, no email, no password at the server.
- What it does not hide: who writes to whom and when, from the server and from Cloudflare. And as with any web app, the code itself comes from the server on each visit (section 8.1).
- What it does less well than Signal: forward secrecy is a light version (days, not messages), there is no recovery after a key theft, no deniability, no hidden sender, and no post-quantum key exchange.
- What Signal doesn't do: let a group run its own server. Signal is one network run by one organisation; cha7 is built to be self-hosted, for free.
The rest of this paper says exactly what is protected, against whom, and where the edges are.
2. Scope and design choices
cha7 is built for a small community of people who already trust each other enough to share invites, on a server one of them runs. That shapes most decisions:
| Choice | Why | Cost |
|---|---|---|
| Web app, no app store | Anyone can run their own instance; works on every phone and computer | The code is delivered by the server (section 8.1) |
| Invite-only membership | No spam, no strangers, a small known group | Losing the admin key is permanent |
| Key-based accounts | No phone number or email to leak or subpoena | Losing every device and backup loses the account |
| One shared chain of daily keys per account | All devices of an account stay in step with no sync protocol | Forward secrecy per day, no recovery after theft (section 5.4) |
| Signed envelopes | A stolen key can't forge your contacts' messages to you; the server can check senders | No deniability (section 8) |
| Sender visible to the server | Rate limits, blocks, stranger caps, member checks | The social graph is visible to the server (section 7) |
| Pairwise group fan-out | Removing a member is real; no group key to leak; the server has no group object | A group message costs one request per member |
| Cloudflare free plan | Anyone can host it for nothing | Cloudflare is in the path and sees traffic metadata |
3. Threat model
3.1 What is protected
- Message content (all kinds listed in section 1) against everyone but the sender's and recipients' devices.
- Past content against someone who later steals a device, a key or a backup: protected once it is older than the forward-secrecy window (about 40 days by default, section 5.4).
- Stored data on a device against someone who holds the device or a copy of its storage, when the app lock is on (section 6.4).
- Membership: only invited people can send anything to anyone.
- Authenticity: a message that shows a contact's name was sent with that contact's key; nobody (the server included) can forge, replay, reorder into another chat, or edit it.
3.2 Adversaries
| Adversary | Can | Can't |
|---|---|---|
| Network attacker (Wi-Fi, ISP, state on the wire) | See that you talk to the cha7 server, when, how much (TLS hides the rest) | Read or change anything (HTTPS/WSS, and the content is sealed anyway) |
| Server operator / Cloudflare | See who sends to whom, when, sizes, IP addresses, devices, contact states; delay, drop or refuse delivery; serve a modified app (section 8.1) | Read content of messages, files or calls from the stored or passing data; forge messages; swap keys unnoticed by people who compare safety numbers |
| Another member | Message you (as a request until you accept), see what you send them | Read others' messages, join your groups without your consent, spoof another member |
| A stranger on the internet | Send requests that cost the instance quota (section 8) | Become a member without an invite, send to anyone |
| Device thief (unlocked phone, or a disk copy) | Read what the device holds; with the account key, read new messages until the account is replaced | Read messages older than the window; with the app lock on, open the stored data without the PIN (counted guesses) or the biometric |
| Someone with a backup file | With the passphrase: what a device thief gets, as of that day | Without the passphrase: nothing (scrypt, section 6.3) |
3.3 Out of scope
- A compromised operating system, browser or browser extension on a user's device. It sees what the user sees.
- A recipient who copies, screenshots or forwards what they receive (view once and disappearing messages are a courtesy, not a control).
- Traffic analysis by someone who can watch the server's traffic, beyond what section 7 lists.
- Denial of service: anyone can use up the free plan's daily quota with enough requests (section 8).
4. Architecture in brief
browser (installable web app) Cloudflare
┌──────────────────────┐ HTTPS / WSS ┌──────────────────────────────────┐
│ keys, contacts, │ ────────────▶ │ Pages: static app + Functions │
│ history, files │ │ /inbox/* ─▶ InboxDO (per member)│
│ (IndexedDB) │ │ /api/* ─▶ RegistryDO (one) │
│ all encryption here │ └──────────────────────────────────┘
└──────────────────────┘
- The device is the source of truth. Contacts, history and files live in the browser's IndexedDB. Nothing readable is stored on the server.
- InboxDO, one per member, keyed by the member's public key: accepts envelopes for its owner, delivers them over a WebSocket, deletes them once every device acknowledged them, stores encrypted file chunks, sends Web Push.
- RegistryDO, one per instance: the admin, invites, members, removals, device-link drops.
- Web Push wakes a closed app. A message push carries no payload; the app fetches the envelope itself. The one exception, a voice call, carries the 12 encrypted bytes
{"t":"call"}so the phone can show "Incoming call" (no caller, no key).
Details: How it works, Delivery.
5. Cryptography
5.1 Primitives
All client cryptography is the open-source noble libraries (@noble/curves, @noble/hashes, @noble/ciphers; pure TypeScript, no native code), plus the browser's WebCrypto for SHA-256/512 where convenient.
| Purpose | Primitive |
|---|---|
| Identity, signatures | Ed25519 (strict RFC 8032 checks, zip215: false) |
| Key agreement | X25519 |
| Key derivation | HKDF-SHA256 |
| Encryption | XChaCha20-Poly1305 (24-byte nonces) |
| Passphrases, link codes, PINs | scrypt (N = 2^17 for backups and device links, 2^15 for the app lock PIN; r = 8, p = 1) |
| Safety numbers | SHA-512 |
| Membership certificate (server side) | HMAC-SHA256 |
Every signature has its own context string (envelopes, socket login, rotating keys, admin actions, joins, uploads, group states, device links, forget-device proofs, lock requests), over canonical, length-prefixed bytes, so a signature made for one purpose can never be replayed as another.
5.2 Identity and membership
- An account is a 32-byte seed on the device. Ed25519 from it signs; the X25519 form of the same key is one input of every message key. The public key (base64url) is the account's address and its inbox id.
- Invites (details): the inviting app makes a random token; the server stores only
SHA-256(SHA-256("cha7-invite-redeem-v1:" + token)). The link (with the token) never reaches the server: it is in the URL fragment, read once and wiped from the address bar. Single use, 7 days. Joining proves the redeem value and signs with the new key. - The new member and the inviter connect with a second value derived from the token (
invite-proof) that the server can't compute, so the server can't fake that introduction. - Every send carries a membership certificate (HMAC by a server secret), and inboxes ask the registry (cached for a day) whether the sender is still a member. A removed member is refused at once and gets the same answers as anyone else, so they can't probe who is still in.
5.3 Messages: key, envelope, signature
For each envelope (details) the sender makes a one-time X25519 key and derives:
key (32) || nonce (24) = HKDF-SHA256(
X25519(one-time secret, recipient's rotating key for day k)
|| X25519(sender's account key, recipient's account key),
info = "cha7-msgkey-v3" | from | to | k | one-time public | rotating public)
- The one-time secret is deleted right after sealing: not even the sender can open the envelope again.
- The account-key part ties every message key to both identities: a leaked rotating key alone neither opens nor creates a message.
- Envelope
{v, id, from, to, ts, k, ek, re, rk, ct, sig};ctis XChaCha20-Poly1305 with every header field as associated data;sigis Ed25519 by the sender's account key over every field. The server checks the signature (and refuses envelopes sealed to an expired or future key), the recipient checks it again. - Payloads inside
ctare typed and parsed strictly; unknown or malformed ones are dropped. A received message can never overwrite an existing one, and edits and deletes are accepted only from the author, within their time windows, judged by clocks the sender doesn't control. - Everything is sealed the same way, including receipts, reactions, group state changes, and the
syncenvelopes a user's own devices exchange (what I sent, read, pinned, verified…).
5.4 Rotating keys: forward secrecy, light version
(Details.) Each account has one X25519 key per UTC day, taken from a one-way chain: chain(e+1) = HKDF(chain(e)), secret(e) = HKDF(chain(e)). The chain starts from random bytes, not from the account key.
- Why a chain: all devices of an account get the same keys with no sync messages; a device that was offline for weeks, or a restored backup, works out today's key alone; keys can be published weeks ahead.
- Published keys are signed by the account key with their day inside the signature, so the server can withhold a key but can't make, swap or extend one.
- Most senders never ask the server: every envelope carries the sender's current rotating key (signed), so people who talk regularly always hold a fresh key for the reply.
Deletion: a device moves its chain forward and overwrites the old chain key once no message sealed to that day can still arrive:
Part Default Rotation 1 day A sender may still use a key it holds 7 days Server retention of undelivered messages (admin setting, ≤ 30) 30 days Clock margin 2 days Window 40 days (17 with 7-day retention)
- What a thief gets with a device, or with a backup and its passphrase: everything sealed to the account during the last ~40 days before the theft (or before the backup), and everything after it, until the account is replaced. Not what is older.
- Not provided: a new key agreed with the other side for each message, and recovery after a compromise (the Double Ratchet's "self-healing"). All devices share one forward-only chain, so a thief who has it follows it. After a theft: make a new account.
5.5 Groups
(Details.)
- Pairwise fan-out, no shared group key: a group message is the same payload sealed separately for each member (each with its own one-time key and that member's rotating key), plus a
synccopy for the sender's devices. Removing a member is real: they get no further copies and hold no key that opens them. - The group state
{id, name, members, owner, ver, sig}is signed by the owner and versioned; every device checks owner, signature and version. It is encrypted like any payload: the server has no group object, no group name, no member list. - Consent: you are put into an existing group only after you tap Join, and only by an owner you accepted as a contact.
- Group files are uploaded once, encrypted with a per-file key, to the sender's inbox; each member's envelope carries that key. The sender's inbox learns the reader accounts (it must, to delete the file once all have it).
5.6 Files, view once, disappearing messages
- Files (photos, voice, video, files): a fresh random key per file, XChaCha20-Poly1305 in 1.5 MB chunks, uploaded to the recipient's inbox (or the sender's for groups). The key travels only inside the sealed message, so files have the same forward secrecy. Chunks are deleted once every device has them. Photos and videos are re-encoded on the device first, which drops metadata such as GPS; any other file type is sent as opaque bytes and never displayed.
- View once (details): the receiving app deletes the content from its database before showing it (a crash or reload can't give a second view), tells the sender ("opened"), and never puts it in backups, device links, exports, search or reply quotes.
- Disappearing messages (details): the timer and every expiry are inside encrypted payloads; the server can't tell such a message from any other. Each device deletes the row and its file at the time, computed from the sender's stamp.
- Both are honest about their limit: a recipient's screenshot, camera or modified app keeps what it was shown.
5.7 P2P chat and voice calls
The WebRTC session description (with its DTLS certificate fingerprint) travels inside a normal sealed, signed envelope, so the direct connection is authenticated by the contacts' keys and nobody in between (the cha7 server, the TURN relay) can insert itself. P2P chat data and call audio (DTLS-SRTP) are end-to-end encrypted by WebRTC itself. A direct connection shows each side's IP address to the other; a "relay only" setting routes through TURN instead.
5.8 Verifying a contact
The safety number is SHA-512 over both account keys, shown as 60 digits, the same on both phones; it can also be compared by scanning a QR code. A contact's key never changes (the key is the contact), so there are no "safety number changed" events to train people to ignore. Whoever connects two people (an invite link, a shared contact card) is trusted to pass the right key; comparing the number removes that trust.
6. On the device
6.1 Storage
Everything lives in the browser's IndexedDB under the app's origin. The strict Content Security Policy allows scripts only from the app's own origin (no inline scripts, no third-party code, no remote fonts), and no untrusted HTML is ever rendered: message text is drawn as text nodes.
6.2 Several devices
All devices of an account hold the same account key and key chain. They keep each other in step with sync envelopes through the account's own inbox, sealed like any message.
- Linking a device (details): the old device encrypts the account under a key derived (scrypt) from a random secret in the QR code and an 8-character code typed by hand, and leaves it in a 10-minute, download-once drop.
- Forgetting a device is signed by the account key, and a forgotten device wipes itself only on that signed statement, never on the server's word alone.
6.3 Backups
A backup file is the account, the key chain, contacts and groups and (optionally) history, encrypted with XChaCha20-Poly1305 under scrypt(passphrase, N = 2^17). Files and view-once content are never in it. It opens everything a device thief would get (section 5.4) as of the day it was made, for as long as the account is used: keep only the newest.
6.4 App lock
(Details.) With the lock on, every stored row (messages, contacts, settings, keys, files) is sealed under a random database key. That key is wrapped two ways:
- PIN: the wrapping key needs both
scrypt(PIN)and a 32-byte secret held by the account's inbox, which hands it out only for the right PIN proof and counts wrong tries: 10 wrong in a row and the secret is deleted for good. A rotating unlock token means a copy of the data taken before the owner's last unlock can't even make a guess. - Biometric: a WebAuthn passkey with the PRF extension; the secret never leaves the device's authenticator.
- A panic PIN wipes the device (recognised locally, so it works offline).
What stays readable in a copy of a locked device: who the chats are with (keys, not names), message times and counts, file sizes. The server operator, holding the server half, can brute-force a short PIN against a copy of the device's data; a long PIN or biometrics avoid that.
7. What the server and Cloudflare can and cannot see
(Details.) "The server" means whoever runs the instance (with access to its Cloudflare account) and Cloudflare itself.
| Sees | Never sees |
|---|---|
| Which account sends to which, and when | Message text, captions, reactions, receipts' content |
| Envelope and file sizes (not padded) | Photos, voice, video, files (encrypted chunks only) |
| IP addresses of connecting devices | Names (of people, chats or groups) |
| Each member's devices, and their contact states (accepted, blocked, shares a group) | Group names, member lists, who owns a group |
| When a device is online | Disappearing timers, view-once flags, pins, verified marks |
| Who invited whom (shown to the admin) | Invite tokens, link codes, backup passphrases |
| Group traffic patterns (one sender to M − 1 inboxes at once) and group-file readers | Call audio and P2P chat data (TURN relays see encrypted packets and IPs) |
| Whether a push is a message or a call | The account key or any message key |
- Stored: only envelopes still waiting for a device, encrypted file chunks still waiting, public keys, signed rotating keys, membership and invites, contact states, push subscriptions, lock secrets. Persisted Worker logs are off; live traffic can still be watched by the account owner.
- Push services (Apple, Google, Mozilla) learn that a device got a push and when, never what (no payload for messages).
- Hiding your IP: a VPN or Tor helps against the server, not against who-talks-to-whom.
8. Honest limits
8.1 The code comes from the server
cha7 is a web app. Each time it starts with a network, the browser loads its code from the instance (Cloudflare Pages); the service worker only keeps a copy for offline use. So whoever controls what the instance serves (the operator, someone who takes over its Cloudflare or GitHub account, or Cloudflare) could serve a modified app that sends keys or messages elsewhere, to everyone or to one person, and users would not notice. End-to-end encryption protects against a server that stores and relays data; it can't protect against a server that also writes the client. Native apps narrow this (app-store signing, the same build for everyone), and WhatsApp offers a browser extension that checks its web code; cha7 has neither yet. What helps today: run your own instance, or trust the person who does. The code is open source (AGPL-3.0), but nothing makes the browser check that the code it got is the code in this repository.
8.2 Cryptographic limits
- Forward secrecy per day, not per message; a ~40-day window (section 5.4).
- No post-compromise security: a stolen key chain keeps working until the account is replaced.
- No deniability: envelopes are signed. The app drops the signature after checking, so stored history is plain text anyone could have typed, but a modified recipient app (or someone who logged envelopes on the server and later gets the recipient's keys) can prove authorship.
- No post-quantum key exchange: X25519 only. Traffic recorded today could be opened by a future quantum computer ("harvest now, decrypt later"). Signal has post-quantum key agreement (PQXDH, 2023) and a post-quantum ratchet (SPQR, 2025); WhatsApp's security whitepaper (version 10, October 2026) still describes a classical key exchange; cha7 has neither.
- No sealed sender: the server sees the sender of each envelope (it needs it for rate limits, blocks and member checks, and timing would reveal it anyway on a small server).
- Sizes are not padded.
8.3 Operational limits
- Availability: anyone can send junk requests to the public endpoints; about 100,000 a day stop a free-plan instance until midnight UTC. A custom domain with a rate-limiting rule (or the paid plan) closes that.
- The admin key can't be transferred or recovered.
- The browser's storage engine may keep deleted bytes (old keys, rows from before the app lock) on disk for a while.
- Multi-device trust is flat: every device holds the full account key. Forgetting a device stops the server from serving it, but a thief with that device's data can still act as the account. After a theft: new account.
The complete list, feature by feature: Known limits.
9. Comparison
Where cha7 is ahead comes first, where it is behind after. Signal, WhatsApp and Telegram as their makers publicly describe them, checked at the end of November 2026 (sources below the table); check their current documentation for changes.
| cha7 | Telegram | Signal | ||
|---|---|---|---|---|
| Account needs | An invite | A phone number | A phone number | A phone number (usernames can hide it) |
| Self-hosting | Yes, free on Cloudflare | No | No | No: server code is open, but there is no federation and the official apps only talk to Signal's servers |
| Who can contact you | Members of your instance; strangers only as limited requests | Anyone with your number | Anyone (privacy settings limit it) | Anyone with your number or username |
| Message storage on server | Until delivered (≤ 30 days) | Until delivered; optional cloud backups | Cloud chats kept until deleted | Until delivered |
| Server knows group membership | No group object; can infer from traffic | Yes | Yes | No (private group credentials) |
| End-to-end encrypted by default | Yes, everything | Yes (chats and calls) | No. Only "secret chats" (1:1, opt-in, one device); groups and cloud chats are readable by Telegram | Yes, everything |
| Open source | Client and server (AGPL-3.0) | No | Clients only | Client and server |
| Protocol | Own: X25519 + daily key chain, Ed25519-signed envelopes | Signal Protocol (classical: X3DH-style setup, Double Ratchet) | MTProto 2.0 (secret chats) | Signal Protocol: PQXDH + Double Ratchet + SPQR ("Triple Ratchet") |
| Forward secrecy | Per day, ~40-day window | Per message | Secret chats only | Per message |
| Recovery after key theft | No | Yes (ratchet) | Secret chats only | Yes (ratchet) |
| Post-quantum key exchange | No | No (whitepaper v10, Oct 2026: classical only; Meta's post-quantum work so far covers its own TLS, not chats) | No | Yes (PQXDH since 2023; SPQR ratchet since Oct 2025, with fallback for older peers) |
| Server sees who talks to whom | Yes | Yes, and Meta's policy allows using metadata | Yes, and the content of non-secret chats | Mostly not (sealed sender), still sees IPs and timing |
| Deniability | No (signed envelopes) | Yes | Secret chats: no signatures, shared-key authentication, so deniable in principle (not claimed or analysed by Telegram). Cloud chats: moot, Telegram stores the text | Yes |
| Client delivery | Web app from the instance (section 8.1) | Signed native apps; web client with an optional code-verify extension | Signed native apps; open-source clients | Signed native apps; desktop app |
Where cha7 is stronger: no phone number or email anywhere; invite-only with no way for strangers in; no server-side group object; nothing kept after delivery; anyone can run their own instance, so the operator can be someone the group knows rather than a company.
Where it is weaker: Signal's cryptography is stronger on every axis listed in section 8.2 (per-message forward secrecy, self-healing, deniability, post-quantum, sealed sender), Signal and WhatsApp ship signed native apps, and Signal has had years of public review. cha7's design has had no independent review yet, only its own tests and internal audits: treat it as a carefully documented design, not a proven one.
But Signal can't be self-hosted. Its server code is open source, yet the official apps talk only to Signal's own servers and there is no federation: a group that wants its own server would have to build and ship its own modified apps, cut off from the Signal network. So with Signal, as with WhatsApp and Telegram, everyone's metadata sits with one organisation. With cha7 the operator is whoever the group chooses, often one of its own members, and every community's traffic is on its own instance.
Against Telegram: cha7 encrypts everything end to end, groups included; Telegram's default and group chats are not end-to-end encrypted at all.
Sources for the comparison (checked November 2026): Signal: PQXDH, Signal: SPQR (Oct 2025), Signal: on federation, WhatsApp Encryption Overview, v10 (Oct 2026), Meta: post-quantum TLS, Telegram: end-to-end encryption, Albrecht et al., Four Attacks and a Proof for Telegram (IEEE S&P 2022).
10. Where to check the claims
| Topic | Code | Tests |
|---|---|---|
| Envelopes, message keys | web/src/lib/e2e.ts, shared/src/protocol.ts | npm run test:e2e |
| Rotating keys | shared/src/rkey.ts, web/src/lib/keys.ts, worker/src/inbox.ts | npm run test:fs |
| Payload parsing | shared/src/payload.ts, web/src/lib/batch.ts | npm run test:batch |
| Groups | shared/src/groups.ts, web/src/lib/groups.ts | npm run test:groups |
| View once / disappearing | web/src/lib/once.ts, web/src/lib/expire.ts | npm run test:once, test:batch |
| Backups, device links | web/src/lib/backup.ts, web/src/lib/link.ts | npm run test:backup, test:link |
| App lock | web/src/lib/lockcrypto.ts, web/src/lib/lock.svelte.ts, shared/src/lock.ts | npm run test:lock |
| Safety numbers | web/src/lib/safety.ts, web/src/lib/safetyqr.ts | npm run test:safety |
| Server | worker/src/inbox.ts, worker/src/registry.ts | npm run smoke |
| Headers, CSP | web/public/_headers | — |
Corrections and questions: open an issue at https://github.com/t0ma5/cha7.