# How encryption works

Check what the client encrypts, what a command can read and how recovery changes who can open a saved value.

## On your machine

`asecret connect` creates your encryption key locally. aSecret never has it. Each secret gets its own key, and that key is wrapped with your local key. The secret's value, and its name and fingerprint, are encrypted with AES-256-GCM before anything is uploaded. `asecret run` and `asecret get` check the fingerprint before they use a value.

## In your browser

My details is encrypted in your browser with a key that only your passkey, your passphrase or your recovery key opens. asecret.sh keeps none of them. An account backup is encrypted in your browser too, with a backup passphrase asecret.sh never sees. When an agent asks you to save a detail or set up your details, your answer tells it "saved" or "ready", never the detail.

When an agent asks to use a detail, it sends a public key it made for that ask alone. If you share one, your browser encrypts it to that key, with X25519, HKDF-SHA-256 and AES-256-GCM, so only that agent can open it. asecret.sh passes it on and can't read it. The agent opens it on its own machine and keeps it as one of its secrets, encrypted like the rest.

## Agent recovery

If an agent's machine is lost, its key goes with it. At [asecret.sh/recovery](https://asecret.sh/recovery) you can turn on agent recovery with one click: your browser makes an X25519 key pair and gives asecret.sh only the public half. The private half, your agent recovery key, is kept inside your encrypted details, so whatever unlocks aSecret opens it and your account backup carries it to another browser. Or you keep the key yourself. Each linked agent then seals its key to the public half, with X25519, HKDF-SHA-256 and AES-256-GCM, and sends it on its next `asecret` command. Only your browser can open it: to show your agents' secrets by name, and to reveal a value when you click **Reveal**. A revealed value is decrypted in the page and forgotten when you hide it or leave. Without the agent recovery key, the escrow can't be opened, by anyone.

## What aSecret can see

aSecret can't see a secret's name or value, or any of your details. It can see:

- **Agents.** A random id for each agent, the name it gives itself, a hash of its token (never the token), when it was created and last used, and whether it's linked to a person.
- **Secrets.** That a secret exists and which agent it belongs to, its encrypted size, its version, and when it was created, changed and will expire.
- **Asks.** Which agent asked which person for which kind of detail, when, how it ended, and the reason an agent gave to use one.
- **Shared details.** A detail you share, sealed to the key the agent made for that ask, until the agent collects it, for a day at most. asecret.sh can't open it.
- **Requests.** The address a request comes from, to rate-limit it.

The [Privacy Policy](https://asecret.sh/privacy) says how long each is kept.

## What you keep

Without your local key, nobody can open its secrets again, aSecret included, unless you turned on agent recovery for it. Export it once with `asecret key --export --out asecret-key.json` and keep the file safe. The export also holds the token, so treat it like a password.

The code that encrypts an agent's secrets is open: [asecret-org/cli](https://github.com/asecret-org/cli) and [asecret-org/protocol](https://github.com/asecret-org/protocol). The browser code that encrypts your details at asecret.sh is not open source.
