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.

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:

ChoiceWhyCost
Web app, no app storeAnyone can run their own instance; works on every phone and computerThe code is delivered by the server (section 8.1)
Invite-only membershipNo spam, no strangers, a small known groupLosing the admin key is permanent
Key-based accountsNo phone number or email to leak or subpoenaLosing every device and backup loses the account
One shared chain of daily keys per accountAll devices of an account stay in step with no sync protocolForward secrecy per day, no recovery after theft (section 5.4)
Signed envelopesA stolen key can't forge your contacts' messages to you; the server can check sendersNo deniability (section 8)
Sender visible to the serverRate limits, blocks, stranger caps, member checksThe social graph is visible to the server (section 7)
Pairwise group fan-outRemoving a member is real; no group key to leak; the server has no group objectA group message costs one request per member
Cloudflare free planAnyone can host it for nothingCloudflare is in the path and sees traffic metadata

3. Threat model

3.1 What is protected

  1. Message content (all kinds listed in section 1) against everyone but the sender's and recipients' devices.
  2. 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).
  3. 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).
  4. Membership: only invited people can send anything to anyone.
  5. 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

AdversaryCanCan'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 / CloudflareSee 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 memberMessage you (as a request until you accept), see what you send themRead others' messages, join your groups without your consent, spoof another member
A stranger on the internetSend 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 replacedRead 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 fileWith the passphrase: what a device thief gets, as of that dayWithout the passphrase: nothing (scrypt, section 6.3)

3.3 Out of scope

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  │               └──────────────────────────────────┘
 └──────────────────────┘

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.

PurposePrimitive
Identity, signaturesEd25519 (strict RFC 8032 checks, zip215: false)
Key agreementX25519
Key derivationHKDF-SHA256
EncryptionXChaCha20-Poly1305 (24-byte nonces)
Passphrases, link codes, PINsscrypt (N = 2^17 for backups and device links, 2^15 for the app lock PIN; r = 8, p = 1)
Safety numbersSHA-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

5.3 Messages: key, envelope, signature

A message's path: sealed on your device, an envelope on the server, opened on theirs

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)

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.

5.5 Groups

A group message: one sealed copy per member

(Details.)

5.6 Files, view once, disappearing messages

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.

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:

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

Who can see what

(Details.) "The server" means whoever runs the instance (with access to its Cloudflare account) and Cloudflare itself.

SeesNever sees
Which account sends to which, and whenMessage text, captions, reactions, receipts' content
Envelope and file sizes (not padded)Photos, voice, video, files (encrypted chunks only)
IP addresses of connecting devicesNames (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 onlineDisappearing 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 readersCall audio and P2P chat data (TURN relays see encrypted packets and IPs)
Whether a push is a message or a callThe account key or any message key

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

8.3 Operational limits

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.

cha7WhatsAppTelegramSignal
Account needsAn inviteA phone numberA phone numberA phone number (usernames can hide it)
Self-hostingYes, free on CloudflareNoNoNo: server code is open, but there is no federation and the official apps only talk to Signal's servers
Who can contact youMembers of your instance; strangers only as limited requestsAnyone with your numberAnyone (privacy settings limit it)Anyone with your number or username
Message storage on serverUntil delivered (≤ 30 days)Until delivered; optional cloud backupsCloud chats kept until deletedUntil delivered
Server knows group membershipNo group object; can infer from trafficYesYesNo (private group credentials)
End-to-end encrypted by defaultYes, everythingYes (chats and calls)No. Only "secret chats" (1:1, opt-in, one device); groups and cloud chats are readable by TelegramYes, everything
Open sourceClient and server (AGPL-3.0)NoClients onlyClient and server
ProtocolOwn: X25519 + daily key chain, Ed25519-signed envelopesSignal Protocol (classical: X3DH-style setup, Double Ratchet)MTProto 2.0 (secret chats)Signal Protocol: PQXDH + Double Ratchet + SPQR ("Triple Ratchet")
Forward secrecyPer day, ~40-day windowPer messageSecret chats onlyPer message
Recovery after key theftNoYes (ratchet)Secret chats onlyYes (ratchet)
Post-quantum key exchangeNoNo (whitepaper v10, Oct 2026: classical only; Meta's post-quantum work so far covers its own TLS, not chats)NoYes (PQXDH since 2023; SPQR ratchet since Oct 2025, with fallback for older peers)
Server sees who talks to whomYesYes, and Meta's policy allows using metadataYes, and the content of non-secret chatsMostly not (sealed sender), still sees IPs and timing
DeniabilityNo (signed envelopes)YesSecret chats: no signatures, shared-key authentication, so deniable in principle (not claimed or analysed by Telegram). Cloud chats: moot, Telegram stores the textYes
Client deliveryWeb app from the instance (section 8.1)Signed native apps; web client with an optional code-verify extensionSigned native apps; open-source clientsSigned 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

TopicCodeTests
Envelopes, message keysweb/src/lib/e2e.ts, shared/src/protocol.tsnpm run test:e2e
Rotating keysshared/src/rkey.ts, web/src/lib/keys.ts, worker/src/inbox.tsnpm run test:fs
Payload parsingshared/src/payload.ts, web/src/lib/batch.tsnpm run test:batch
Groupsshared/src/groups.ts, web/src/lib/groups.tsnpm run test:groups
View once / disappearingweb/src/lib/once.ts, web/src/lib/expire.tsnpm run test:once, test:batch
Backups, device linksweb/src/lib/backup.ts, web/src/lib/link.tsnpm run test:backup, test:link
App lockweb/src/lib/lockcrypto.ts, web/src/lib/lock.svelte.ts, shared/src/lock.tsnpm run test:lock
Safety numbersweb/src/lib/safety.ts, web/src/lib/safetyqr.tsnpm run test:safety
Serverworker/src/inbox.ts, worker/src/registry.tsnpm run smoke
Headers, CSPweb/public/_headers—

Corrections and questions: open an issue at https://github.com/t0ma5/cha7.