AT Protocol spaces are in development. Expect changes throughout the beta starting on December 1st, 2026.

Chapter 2

Identity and keys

Revised 2026-11-23Markdown

Every identity in atproto has a permanent identifier in the form of a DID, and a DID document that lists the identity’s keys and the services it uses. Anyone can look up a DID’s document. Spaces need a handful of keys to save data into a space and read it back, and most of them live in these documents.

Spaces rely on cryptographic material in DID documents and OAuth client metadata documents. This material is used to verify authorization and to facilitate the exchange of data.

  • #atproto signs tokens. Elena’s PDS uses it to vouch that she asked.

  • #atproto_kem lets a reader derive a secret for one request, which is how the app knows an answer came from Ruth’s PDS.

  • An application’s own key, published in its JSON Web Key Set (JWKS), signs its client attestation, which tells a space host which app is asking.

A DID document with spaces support#

Elena’s DID document is an ordinary atproto DID document with one addition. The #atproto_kem verification method is introduced to support spaces. The #atproto verification method item and #atproto_pds service item are already present and remain untouched.

Reference

Elena’s DID document#

Her identity’s two keys, and the server that acts for her.

JSON
{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/multikey/v1",
    "https://w3id.org/security/suites/secp256k1-2019/v1",
    "https://w3id.org/security/suites/ecdsa-2019/v1"
  ],
  "id": "did:plc:53ni6w7okqrxvjxezmopejoo",
  "alsoKnownAs": [
    "at://elena.example.com"
  ],
  "verificationMethod": [
    {
      "id": "did:plc:53ni6w7okqrxvjxezmopejoo#atproto",
      "type": "Multikey",
      "controller": "did:plc:53ni6w7okqrxvjxezmopejoo",
      "publicKeyMultibase": "zQ3shPWwfJKjriJqb4CsR7KBBHkaffnpZin5NCyAYJzztnuRV"
    },
    {
      "id": "did:plc:53ni6w7okqrxvjxezmopejoo#atproto_kem",
      "type": "Multikey",
      "controller": "did:plc:53ni6w7okqrxvjxezmopejoo",
      "publicKeyMultibase": "zDnaeueFwjSjPA49dvab7bN4VjYDvv7eBVsDSjncdQHsud125"
    }
  ],
  "service": [
    {
      "id": "#atproto_pds",
      "type": "AtprotoPersonalDataServer",
      "serviceEndpoint": "https://pds-a.example.com"
    }
  ]
}
FieldWhat it holdsIn Elena’s document
@contextThe standards the document followsDID Core, Multikey, and two signature suites
idThe DID itselfdid:plc:53ni6w7okqrxvjxezmopejoo
alsoKnownAsThe identity’s handleat://elena.example.com
verificationMethodThe identity’s public keys, each named by a fragment#atproto and #atproto_kem
serviceThe servers that act for the identityHer PDS, as #atproto_pds

These fields come from specifications outside atproto. DID Core defines the document’s structure, and the did:plc and did:web method specifications define how each kind of DID is created, updated, and resolved.

#atproto: the signing key#

This is the identity’s existing signing key (K-256 or P-256). It belongs to the core AT Protocol, and spaces reuse it. The PDS almost always manages it entirely, because the PDS is the service that signs data with it. As a reader, it signs delegation tokens. As a space authority, it signs space credentials and the service auth the authority sends (notifyCredentialsRevoked, checkAccess). When its account writes to a space, the PDS uses it to sign the service auth on notifyRepoUpdate. Every space token header carries kid: "#atproto" exactly spec.

#atproto_kem: the key-encapsulation key#

Each identity whose account holds space repos publishes a P-256 key with id {did}#atproto_kem, its DID as controller, type Multikey, and the key in atproto multikey encoding (the zDna... prefix) spec. The repo host holds the private half and uses it only to derive per-request shared secrets for MACs (Chapter 5). It should be a dedicated keypair rather than a reuse of #atproto, so rotating one leaves the other alone.

A requester needs this key before it can ask for a MAC, and it may cache it. atproto-space-client resolves an author’s DID document once, keeps the key, and resolves again after a failed MAC check or an #identity event crates. An account whose identity publishes no KEM key can’t be read with a space credential, because no requester can derive a secret for it.

#atproto_pds: the space host#

A space authority is resolved like any other identity. Its #atproto_pds service endpoint is the space host, and its #atproto key signs the space’s credentials spec. Tokens addressed to the space host use the service-id form did:plc:ejjl2znzqp3ci25dqaslpkk2#atproto_pds as their aud, the claim that names the service a token is meant for.

Client keys#

A space can limit which apps may read it. To enforce that, the space host has to know which app is asking.

An application proves who it is with a client attestation signed by a key from its own client-metadata.json (jwks or jwks_uri). The space host resolves iss to that document and picks the key by the attestation’s kid, the same machinery an atproto confidential OAuth client already uses for private_key_jwt spec. Public clients have no such key, so they can use only spaces that admit any app.

Reference

The family app’s published key#

The jwks entry in its client metadata, at https://family.example/client-metadata.json.

JSON
{
  "keys": [
    {
      "kty": "EC",
      "crv": "P-256",
      "x": "COmaVfdUzj6QHwm3ZTZgY8KsbNhtJN12EgFWLsm7_pE",
      "y": "G36xIW2qad2tMbOE8zj-pSq39311l313hbZbcAPTxKw",
      "kid": "key-1",
      "alg": "ES256",
      "use": "sig"
    }
  ]
}

Ephemeral keys#

Two more P-256 keys exist only briefly on the syncer. The credential key is generated for each credential, named in authorizeSpaceSync as credentialKey, and used to sign every call that presents that credential. That signature is what stops a repo host that receives the credential from replaying it to another host (Chapter 5).

The KEM ephemeral key is generated for each read that asks a repo host for a MAC: a call to getLatestCommit, getRepo, listRepoOps, or getRecord made with a space credential. Every page and every retry counts as its own read. The key is sent as the keyid of that read’s MAC request, and discarded once the response’s MAC is checked. Neither is published anywhere.

Rotation#

Rotating different keys and key references will have side effects that developers should be aware of.

The #atproto key signs every space credential an authority issues, and any service auth it sends as the authority spec. A repo host has to validate a credential’s signature before it serves a read spec. atproto-pds checks it against the key in the authority’s current DID document crates, so a credential issued before a rotation stops verifying once the host sees the new document. The spec gives no rule for that case. Its key rotation entry covers only #atproto_kem. What bounds the damage is the credential’s lifetime: ten minutes by default and sixty at most spec.

Rotating #atproto_kem leaves every repo’s digest and revision as they were, because the key is not part of repo operations that use cryptographic material. Requests made against the old key may fail MAC verification. A syncer that sees a MAC failure refreshes the author’s DID document and retries with a new ephemeral key spec. Rotation, like every other identity change, arrives as an #identity event on the public firehose (Chapter 10).

A space host fetches an app’s client metadata and JWKS each time it verifies a client attestation, and picks the key by kid crates. Rotating that key takes effect on the next attestation. One signed with a key that isn’t published yet is refused with InvalidClientAttestation, so publish the new key before the app signs with it. Credentials already issued keep working, because they are bound to the credential key.

What should an app do when a user’s signing key rotates?#

For an app, which user rotated matters. When a member’s key rotates, the app holds nothing signed by the old key. Delegation tokens are minted for each exchange and live 60 seconds spec, so the next one carries the new key’s signature, and space repos hold no signatures at all spec.

When the authority’s key rotates, the app’s credential is refused. It calls authorizeSpaceSync again, which the spec calls reauthorizing spec, and retries the read. atproto-space-client does that once after an authorization failure crates. Until the new credential arrives the app still has its own copy of the space, so its users see data that is a little behind.

An app can also act before it is refused, because a signing key change arrives as an #identity event on the firehose spec. The spec asks for reauthorizing when the authority’s #atproto_pds endpoint changes spec. atproto-space-client gives an app a hook to drop a cached #atproto_kem key when an #identity event arrives, and it renews a credential when a read is refused crates.

Common questions#

Are app developers responsible for generating or updating an identity’s #atproto or #atproto_kem keys?#

No. The user’s PDS manages both keys and uses them for the user. Your app reads the public halves from the identity’s DID document.

Does my app need a key of its own?#

A space that lists its allowed apps asks for a client attestation, which your app signs with the key in its client metadata. A public client has no key there, so it is limited to spaces that admit any app. An app that reads spaces also makes short-lived keys as it goes, one for each credential and one for each read that asks for a MAC.

Why does an identity need a second key for spaces?#

#atproto signs tokens. #atproto_kem lets a reader and a repo host agree on a secret for one read, which is how the reader knows who answered (Chapter 5). They are separate keys so that either can be rotated by itself.

What if an identity has no #atproto_kem key?#

Then no reader can derive a secret for its space repos, and reads of them with a space credential fail. Erin reads the family space and has no account, so she has no space repos and needs no such key (Chapter 6).

How does an app find the server for a space?#

It resolves the space authority’s DID document and reads the #atproto_pds entry, which names the space host. It finds each writer’s repo host the same way, from that writer’s document.

What happens when a key is rotated?#

For an app, a rotation shows up as a failed check or a refused credential. It refreshes the DID document or asks for a new credential, and tries again. The Rotation section covers each key.

Chapter 2 of 11 · AT Protocol Spaces: A Field Guide

Search