---
title: "Operator lesson 1: The vault and its keys"
description: "See how a forge keeps its keys, rotate the cluster's key, and serve your organization's own keys for encryption and signing."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.forge.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Operator lesson 1: The vault and its keys

**Time:** 25 minutes. **Track:** [operator](https://docs.forge.workreef.dev/learn/#operator). **Before this:** [developer lesson 1](https://docs.forge.workreef.dev/learn/developer/first-landing/).

By the end of this lesson you will be able to:

- say where a forge's keys live, and what unseals it after every node has stopped;
- rotate the cluster's key, and read the keyring's status;
- create an organization key, encrypt and decrypt with it, and sign with a post-quantum key.

## Where the keys live

Every key the forge holds is sealed under one key, the cluster's, which lives only in the nodes' memory. On a production forge, if every node stops, it comes back from recovery shares that people hold; see [The vault and recovery keys](https://docs.forge.workreef.dev/server/vault/). A development forge keeps its key in a file instead, so it starts on its own:

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
$ af vault status
unsealed: its key is kept in a development file
$ af vault rekey status
Error: InvalidState: this cluster keeps its key in a development file: it has no recovery rule to rekey
[1]
```

## Rotate the cluster's key

The cluster's key is the root of a keyring. Each term of the keyring is a key of its own; the latest seals everything new, and every earlier term still opens what it sealed. A rotation adds a term. On a forge with one administrator it takes effect at once:

```console check
$ af vault rotate --reason "the lesson's rotation"
done: it took effect at once, on your word as an administrator
$ af vault key-status
term 1: installed 2026-11-25T06:33:45.93Z, 5 keys sealed
term 2: installed 2026-11-25T06:33:46.427Z, 0 keys sealed, seals now
```

Term 1 sealed the forge's own keys as it started; term 2 seals from now on. Nothing is sealed again under the new term, and a term that has sealed as many keys as one may gives way to the next on its own.

## Your organization's keys

On top of its own keys, the forge is a key management service for your organization. Each key names who may use it; creating one takes effect at once, on your word as an administrator:

```console check
$ af kms create app-secrets --use-person dev@localhost
done: it took effect at once, on your word as an administrator
$ printf 'hunter2' | af kms encrypt app-secrets --context env=prod > token.enc
$ af kms decrypt --context env=prod < token.enc
hunter2
```

The context is bound to the ciphertext: decrypting with another fails.

```console check
$ af kms decrypt --context env=test < token.enc
Error: InvalidState: the ciphertext does not open: another key, version or context, or changed
[1]
```

## Sign with a post-quantum key

A signing key can be Ed25519 or ML-DSA-65, the post-quantum signature of FIPS 204:

```console check
$ af kms create releases --spec ml-dsa-65 --use-person dev@localhost
done: it took effect at once, on your word as an administrator
$ printf 'v1.0' | af kms sign releases > v1.sig
$ printf 'v1.0' | af kms verify releases --signature "$(cat v1.sig)"
valid
$ printf 'v1.1' | af kms verify releases --signature "$(cat v1.sig)"
Error: the signature does not verify
[1]
```

## Exercises

1. Rotate the cluster's key once more, and read the keyring. How many terms are there, and which one seals now?

   ```console check
   $ af vault rotate --reason "a second rotation"
   done: it took effect at once, on your word as an administrator
   $ af vault key-status
   term 1: installed 2026-11-25T06:33:45.93Z, 5 keys sealed
   term 2: installed 2026-11-25T06:33:46.427Z, 2 keys sealed
   term 3: installed 2026-11-25T06:33:46.695Z, 0 keys sealed, seals now
   ```

   Term 2 sealed the two keys you made in this lesson; term 3 seals from now on.

2. Encrypt a second secret under `app-secrets` with no context, and decrypt it.

   ```console check
   $ printf 'correct horse' | af kms encrypt app-secrets > other.enc
   $ af kms decrypt < other.enc
   correct horse
   ```

## Check your understanding

<details>
<summary>After a rotation, can the forge still open what the old term sealed?</summary>

Yes. A rotation adds a term; every earlier term stays in the keyring and still opens what it sealed. Nothing is sealed again under the new term.

</details>

<details>

<summary>

Why did decrypting with `env=test` fail?

</summary>

The context is bound to the ciphertext when it is encrypted, so only the same context opens it. A token for production cannot be read as a test token, even by someone who may use the key.

</details>

## Next

[Operator lesson 2: Repositories, folders and runners](https://docs.forge.workreef.dev/learn/operators/repositories-folders-runners/).

Source: https://docs.forge.workreef.dev/learn/operators/vault-and-keys/index.mdx
