# Accounts and recovery — the full specification The detailed version of [Accounts and recovery](./accounts.md), for auditors and security reviewers: every key an account holds, how the room list reaches each device, the encrypted backup, how the account service checks a restore without learning the recovery code, what changes the account's protection, and exactly what Witbitz sees. > **Status: Production** in the Spaces app (regular and hosted) and in the SDK. New accounts in the Spaces app are kept on > the **Witbitz account service**, which also knows the account's devices; an account still on the older store moves to > it when the app opens if the device has the required recovery material ([below](#older-store)). --- ## What an account is - **An identity: a verified email.** The user proves the address with a one-time email code or with Google (a Gmail or Google Workspace address). The same email is a separate account in each app — an app built on Witbitz cannot see or touch the user's account in another, and a device of one app's account is refused by another's. - **A root: the master secret.** 32 random bytes made on the device when the account is created. Every other account key is derived from it or sealed under it. It never leaves the device in the clear. ## The keys {#keys} | Key | Made | Used for | |---|---|---| | **Master secret** | on the device, at creation | the root: derives the keys below and seals the backup | | **Account store key** | derived from the master | seals the account's own records (the room list) on the device | | **Backup write key** | derived from the master | proves to the account service that a write to the backup comes from the account | | **Device key** | on each device, never exportable | registered with the account service; signs that device's requests to it | | **Possession key** | derived from the recovery code | proves to the account service that a restore holds the code, without sending it | | **Account signing key** | on the device | signs this account's device certificates | | **Invite key** | on the device | lets others invite this account by email: only its public half is published, under a blinded handle | | **Room keys** | on the device, one per Space | open each Space | ## Creating an account 1. **On a computer, secure it first.** Before anything personal is written, the user sets up a passkey that locks this computer's storage ("Secure this computer"). A computer that cannot hold such a passkey uses the phone instead (by QR). The Witbitz apps for the Mac and Linux skip this step: they keep the key that seals the storage in the system's keychain or keyring. 2. **Prove the email.** A one-time code or Google. If the address already has an account, the user is offered to restore it instead of starting a duplicate. 3. **The device makes the account.** The master secret and a **recovery code** — 128 random bits, shown as groups of letters and digits — are made on the device. The device registers itself with the account service and writes the encrypted backup and the recovery entry (below). 4. **Keep the code.** The app shows the recovery code to copy and keep somewhere safe. ## One account on every device {#sync} The account's **room list** — every Space with its key and name — lives in a hidden **index room**, sealed on the device under the account store key before it is written: the server stores it and cannot read it. Two more hidden rooms hold the private assistants' links and messages between the user's own devices. A new device needs only the master secret: from it, the backup gives the index room's address and key, and the index room gives every Space. Changes reach the other devices through the index room as they happen. **Add a device** without the recovery code: the new device shows a code; a device that is already signed in scans it, checks that both screens show the same check code, confirms with an email code (or Google) and registers the new device with the account service. The master, the code and the sign-in are then sealed to the new device's own key and passed through a short-lived relay. ## The account's devices {#devices} The account service keeps the list of the account's registered devices (each by its public key and a label), which the app shows under Your devices. A device the account signed out learns it at its next check and removes the account's keys and data from itself. Verified Spaces also ask for a **room pass** — a ten-minute note that only a device still registered with the account can get — and on the standard tier refuse a request without one, so a signed-out device is refused there. A device that never connects again keeps what is already on it: sign-out cannot reach a lost device's copies. ## The encrypted backup {#backup} | | | |---|---| | **What it holds** | the account's keys (signing, invite), the index room's address and key, the Spaces' keys, contacts, connection handles, the recovery code (so the app can show it again) | | **Sealed with** | AES-GCM under a key derived from the master secret, on the device | | **Stored at** | an id also derived from the master — without the master, nobody can find it or read it | | **Written** | a few seconds after a change, merged with the stored copy, by a registered device signing with its device key and the backup write key; earlier versions are kept | The master itself is stored only **wrapped** under the recovery code. Each signed-in device keeps the master too, so it can keep the backup current without asking for the code. ## Recovering an account {#recovery} A restore needs two things — so neither a leaked recovery code nor a hijacked mailbox opens the account alone. | What the user has | Opens the account? | |---|---| | **Recovery code + the account's email** (a one-time code, or Google for a Gmail or Workspace address) | Yes — the usual way back after losing every device. It also signs the new device in, and every restore is announced by email. | | **Another signed-in device** | Yes — Add a device, above. | | **The recovery code alone** | No. | | **The email alone** | Never. | ### How the service checks the email without learning the code {#restore-check} The account's recovery entry stores only an HMAC of the email under a key derived from the recovery code, and the public half of the possession key. At recovery, the device sends that derived key with the email check and signs with the possession key; the service verifies the proven address against the stored value. The code itself never reaches the server, and decryption always happens on the device. ### Changing what protects the account {#changes} Each of these needs a registered device and an email code (or Google): - **A new recovery code** — the old one stops working, and every other device is signed out at once. - **Sign out all other devices**, or one of them. - **Delete the account** — every device is signed out, the email binding and the recovery entry are deleted, then every backup version and device registration. The address can start a new account at once. ### Lost the recovery code and every device {#lost-address} Whoever controls the address can move it to a new, empty account. It takes a week, the address is emailed when it starts and when it ends, and anyone who can read that inbox can stop it in that time; a device of the old account can stretch the wait to 30 days, once. The old account is not opened: only its recovery code opens it. ### Advanced Backup A restore that also needs one of the account's registered hardware security keys. Built in the account service and not yet switched on in production. ### Accounts on the older store {#older-store} After the first account-index read confirms the device is not signed out, the app attempts a silent move with the same recovery code (`acctSilentMove.js`, `acctV2App.js`); in the hosted app the vault performs it. It requires the retained recovery code, the account signing key and a matching address, and the service must accept silent moves. A missing proof leaves the account on the old service; Settings offers the explicit move, with an email check where needed. It is not a guarantee that every old account moves on its next launch. Until it has moved, the older store's rules apply: its backup opens with the recovery code and an email check (the same HMAC check), or with a backup passkey added to it. The app frame's own diagnostic can say the account service is off because the hosted account lives in the vault, not in that frame. ## What Witbitz sees and can do {#what-witbitz-sees} - **Sees:** ciphertext at opaque ids, their sizes and write times; the account's security record — its registered devices' public keys and labels, the recovery entry's HMAC and public key, the security events; an HMAC of the sign-in address under a service key (so it can tell whether an address it is given has an account, and send that address its codes); notification addresses only sealed to the worker that sends the notices. During a code check, the address it mails. - **Cannot:** read the backup, the room list or any Space; recover an account without the user's recovery code or one of their devices. There is no operator key. - **Can:** refuse service — withhold a backup, or delete one. Availability is ours to break; reading is not. ### Guessing limits {#limits} An emailed code has six digits, expires in ten minutes and allows five tries; codes to one address are capped at one a minute, five an hour and fifteen a day. A recovery code is 128 random bits. ## In your app - **The Spaces app** holds the account in the page (regular app), or in the **vault** (hosted app) — the frame that draws the screen never holds the master or the room keys ([the app as an operating system](./app-os.md)). - **The SDK**: `wb.backup` is the same kind of backup, one per app, with the email check when the user is signed in; `wb.account` is the live room list. In **vault mode** your vault holds the account, and a vault started with your tenant keeps new accounts on the Witbitz account service as your app's own ([SDK — account backup](./sdk-accounts.md#backup), [vault mode](./sdk-keys.md#vault-mode)). ## Read next - [Accounts and recovery](./accounts.md) (the short version) · [The app as an operating system](./app-os.md) · [Identity and admission](./identity-and-admission.md) · [SDK — account backup](./sdk-accounts.md#backup)