Encryption
There are two encryption boundaries, and between them nothing is in the clear: in transit, every request and response travels in a sealed session bound to an attested key; at rest, a node’s data directory is on a data disk the TD encrypts itself (LUKS2 with integrity, its key from mero-kms, opened inside the TD), and what leaves that disk (a snapshot or backup file) is sealed under the cluster key K_c, which the node keeps wrapped under its release’s storage key K_r. In between, data exists in plaintext only inside the TD’s memory.
In transit
Section titled “In transit”| Hop | Protection |
|---|---|
| Client → node | Sealed session (Noise NK to the attested transport key, AES-256-GCM per request and per response frame) |
| Node → node | The same sealed session, identified (Noise IK: the caller proves its own attested transport key), plus the cluster secret on every internal route |
| Anything unsealed | Only /attestation, /health, the consent page, app frontends’ static files, and a refused oversized envelope’s 413 |
The session keys come from ephemeral keys on both sides, so a session that has ended (after an hour at most) cannot be opened later, not even with the node’s transport key. See Networking & sealed channels.
At rest: the storage key K_r and the cluster key K_c
Section titled “At rest: the storage key K_r and the cluster key K_c”Attestation comes before any key: a node gets nothing from mero-kms until its quote matches a release the KMS’s policy accepts, and everything it writes is sealed under keys that the key it got unwraps. Every node of a cluster holds the same K_c, whatever release it runs, so a follower opens a leader’s snapshot as it is; a different cluster name gives a different K_r from the same KMS key. The keys that identify a node to clients — its transport and receipt keys — are attested on their own, never derived from K_r. The transport key is made in memory at start; the receipt key, which also signs sessions, is made on the node’s first start and kept in its data directory wrapped under K_r, so it survives a restart and only the release that holds that K_r opens it.
Each node’s snapshot frames and backups, and the node rows that mark its store,
are sealed under one 32-byte cluster key, K_c, which the node keeps on disk
wrapped under its storage key, K_r, from mero-kms. Its Raft entries, votes,
state rows and blobs are kept as they are (store formats 2 and 3) on the data disk the TD
encrypts with a key from mero-kms: merod kms disk-key fetches it for the image’s
boot script under the same signed release policy, and the boot script opens the
LUKS2 volume (aes-xts-plain64, hmac-sha256 integrity) inside the TD. A node
that takes its storage key from mero-kms refuses to start without that disk’s
record (--kms-disk-evidence) unless its data directory is in memory (tmpfs).
Store format 1 sealed each of those values under K_c as well, encrypting the same
bytes twice; format 2 dropped that and reads no earlier store (a rollout’s new
nodes start empty and receive their data by snapshot).
Search indexes, derived data tantivy writes as it is, are kept the same way: on
that disk when the node has its record, and in memory otherwise.
K_r = HKDF-SHA256(ikm = KMS key, salt = "calimero.cloud.storage.v1", info = cluster name)- From mero-kms, after attestation. A TDX node fetches the KMS key itself
(
--kms-urlwith--kms-identity) throughcalimero-kms-client. The client trusts the KMS only if the KMS’s own quote matches the signed mero-tee release the environment names (MERO_TEE_VERSION,MERO_KMS_VERSION,MERO_KMS_RELEASE_TAG); its request carries this TD’s quote over the KMS’s challenge, and the key comes back sealed to that request. - Never from the host. Without
--dev,--storage-keyand--storage-key-fileare refused (kms::key_source): a key the host could hand the node would let whoever runs the host read the disks.merod kms disk-keyfetches the same key for a boot script and writes it only to tmpfs or ramfs;merod runaccepts such a file only with--devtoday. A--devnode without a key derives a development key from the cluster name. - Shared by the cluster’s nodes of one release. mero-kms derives a key per identity, and the nodes of one cluster share one disk identity, so they derive the same K_r.
- Bound to the cluster. The cluster name is the HKDF info, so the same KMS key gives another cluster a different K_r.
- Bound to the release. Each mero-tee release has a mero-kms cluster of
its own whose random root lives only in its replicas’ memory (mero-tee
docs/design/gcp-tdx-kms.md, “Lifecycle”), so a node of the next release gets another K_r, and once a release’s KMS is retired its K_r is gone for good.
The cluster key K_c
Section titled “The cluster key K_c”K_r changes with every release, but a cluster’s data outlives releases: a
release upgrade starts nodes on the new image, moves every app onto them and
retires the old ones (Upgrade the cluster’s release).
So nothing the nodes share is keyed by K_r itself (calimero_node::cluster_key):
-
Minted once. The founding node (
--bootstrap) takes its own K_r as K_c. A node whose store was written before K_c existed does the same: its data is sealed under K_r, which was then the cluster’s only key, so nothing on disk changes. -
Wrapped per release. Every node keeps K_c in
<data-dir>/cluster-key, AES-256-GCM underHMAC-SHA256(K_r, "calimero.cluster-key.wrap.v1"), and unwraps it at each start. A K_r that does not open it (the same disk booted on another release’s KMS) stops the node: a node does not move to a new release in place. The node’s signing key (receipts and sessions) is kept beside it the same way, in<data-dir>/signing-keyunderHMAC-SHA256(K_r, "calimero.signing-key.wrap.v1"), made on the first start. -
Delivered to new nodes by attestation. A node starting on an empty data directory without
--bootstrapserves only/health(with awaitingfield),/attestationand a delivery route, and asks its--peersfor K_c (POST /internal/cluster-key { cluster, node, token }, inside the sealed channel to a peer whose quote it verified), every second for up to 10 minutes (cluster_key::WAIT). The peer never answers with the key. It delivers it to the address the cluster has for that node id: the one registered with/ops/nodes(the founding--peersare registered at genesis), else the system group’s membership; a node id only the peer’s own--peersnames is served only before genesis, while the cluster is being founded, and a removed node never, inside a sealed channel to the key the TD at that address attests, judged like any peer (--peer-profiles,--peer-min-release) (POST /internal/cluster-key/deliver { token, key }). The waiting node takes it only with its own random token, which travelled only to an attested peer. So K_c reaches only a genuine TD at an address the operator chose, the same bar the shared disk identity sets for K_r (mdma stamps it only after attesting the instance). At mostMAX_CONCURRENT_KEY_RELEASES(4) requests are handled at once. -
Kept with backups, per release. A node with
--backup-dirwrites K_c there wrapped under its own K_r (cluster-key/{release}, the same wrapping as<data-dir>/cluster-key), once per release. A cluster founded again from its backups (--restore-from) takes K_c from the copy its founder’s K_r opens, so it is the same cluster; no other key opens any copy, and a copy dies with its release’s mero-kms (Found a cluster again).
The route takes no cluster secret, since the new node has none yet. Release
approvals still decide which apps’ data reaches the new node
(Node::may_send): K_c opens what a node holds, not what it may receive.
How a value is sealed
Section titled “How a value is sealed”calimero-log seals what leaves the data disk, and the node’s own rows, with
AES-256-GCM under K_c, with a fresh random nonce, bound (as associated data) to
its column, its group and its key: a snapshot file’s rows, and the node rows that
name the store’s format and hold its rollback counter, so a store opened under
another key is refused at once. Every other row is stored as it is, on the
encrypted data disk. A state machine can also hide a key: the row is then
keyed by an HMAC of the key and the key itself travels inside the value, so even
a snapshot does not show which keys an app uses. App state rows and idempotency
records are hidden this way. See Storage schema.
Snapshots are files of sealed frames, each frame’s associated data naming its
group, snapshot, position and whether it is the last, so frames cannot be
reordered or truncated unnoticed. Backups are copies of those files, each with
a manifest sealed under HMAC-SHA256(K_c, "calimero.backup.manifest.v1") and
bound to its app and file name, so a backup opens and restores only where K_c
is: on the cluster that wrote it, whatever release its nodes run.
Keys derived from K_c
Section titled “Keys derived from K_c”| Key | Derivation | Used for |
|---|---|---|
| Cluster secret | HMAC-SHA256(K_c, "calimero.cluster.v1|" ‖ cluster) |
x-cluster-auth on internal routes |
| App TEE key | HMAC-SHA256(K_c, "calimero.tee.v1|" ‖ app) |
Values sealed to the app’s TEE (TeeSecret, a timer’s own state) |
| Member key | HMAC-SHA256(K_c, "calimero.member.v1|" ‖ app ‖ "|" ‖ account) |
A member’s sealed share, opened only in that member’s own runs |
| Hidden-key HMAC key | HMAC-SHA256(K_c, "calimero.log.hidden-keys.v1") |
Hiding row keys in the store |
| Snapshot key | HMAC-SHA256(K_c, "calimero.log.snapshot.v1") |
Sealing snapshot frames (streamed to followers as they are) |
| Backup manifest key | HMAC-SHA256(K_c, "calimero.backup.manifest.v1") |
Sealing a backup’s manifest, bound to its app and file name |
| App file key | HMAC-SHA256(K_c, "calimero.files.v1|" ‖ app) |
Wrapping each sealed file’s random data key; a compute run’s seed and token |
| Cluster identity | Ed25519 seed HMAC-SHA256(K_c, "calimero.cluster-identity.v1") |
Signing job nodes’ assignments and bundles; named in purpose=orchestrator quotes |
| Backup code key | HMAC-SHA256(K_c, "calimero.backup.code.v1") |
Sealing the code a system backup names |
| Component cache key | HMAC-SHA256(K_c, "calimero.components.v1") (component_cache_key) |
The MAC on compiled components in <data-dir>/components |
Every node, of every release, derives the same keys, and nothing outside the
cluster can. These derivations are the ones K_r fed before K_c existed, so a
cluster founded earlier keeps every value, and a next-release node opens them
(regression: nodes_on_the_next_release_keep_the_data_of_the_ones_before).
There are no keys per app: one K_c covers every app on the cluster, so an
app’s data opens on any node of the cluster, not only where that app is placed.
What an observer can still see
Section titled “What an observer can still see”| Position | Sees | Does not see |
|---|---|---|
| The network or a TLS-terminating proxy | That a client talks to a node; request sizes and timing; unsealed attestation documents | Paths, tokens, arguments, results, events |
| The host, reading the disks | Sizes of sealed values, row counts per column; which groups exist | Keys of hidden rows, values, entries, snapshots, blobs |
| The operator, through the Ops API | Counts, Raft status, node list, governance, quotas, Prometheus metrics | App names, state, events, accounts’ details, credentials |
The host also controls availability: it can stop, freeze or restart a node, or withhold the network. Raft keeps an app available while a majority of its replicas run. Sealing hides what a copy of a disk holds but not its age, so a restored older copy is caught another way: mero-kms keeps, per node, a counter the node also keeps in its sealed store and raises about once a second, and a node whose store is behind it does not start (below).
Rollback protection
Section titled “Rollback protection”A host can stop a TD, copy its encrypted disk, and start it later on that copy.
K_r and K_c open an old copy as well as a new one, so the node would forget the
votes it cast and serve stale state, and a host that restarts every node on
copies of one moment would erase everything committed since without any
replica noticing. The rollback counter (crates/node/src/rollback.rs, its
mero-kms side in calimero-kms-client’s kms::rollback) refuses such a start.
-
Two copies of one counter. mero-kms keeps, per node id of the cluster’s key path, an entry
(generation, mark), and a cluster epoch: the number of rollbacks an operator has forced. The node keeps the same entry in its sealed store, in the node rowrollback({ node, entry, epoch }, bound to its node id). Entries compare as pairs, so a forced rollback, which starts a new generation, is above every mark of the generation before. mero-kms keeps the counters in its replicas’ memory, as it keeps its root, and answers a change once a majority of itsMERO_KMS_REPLICAShold it. -
Delivered with the key. The node asks
/attestforcapabilities; a mero-kms that keeps counters answers["rollback/v1"], and its quote commits to that list (mero-kms/attest-transport-key/v2), so a relay that strips it breaks the quote. The node’s/get-keythen names its node id (rollbackNodeId, committed to in its own quote undermero-kms/sealed-get-key/v2), and the answer, sealed to the TD undermero-kms/sealed-key/v2, carries the key, the epoch, the node’s entry (none if mero-kms never saw this node id) and a session id and key that only that TD and mero-kms hold. A mero-kms that answers no capabilities gets the request it always did. -
Raised every second, store first. A running node writes
mark + 1to its store (synced), then to mero-kms (POST /rollback/raise), everyCHECKPOINT_EVERY(1 s). The store goes first so that a crash between the two leaves the store ahead, which starts. A raise and its answer are HMAC-SHA256 under the session key, the answer bound to the node’s fresh nonce, so a relay can neither move the counter nor fake an acknowledgement, and no checkpoint needs a quote. The first checkpoint is part of the start: unacknowledged, the node does not start. After that a mero-kms that does not answer is logged and retried each second; the node keeps serving and reports the seconds since the last acknowledgement (sinceCheckpointSecsin/ops/status’srollback). -
Judged before any group starts (
rollback::judge, inNode::start). “Rolled back” refuses the start unless the node runs with--accept-rollback; “never” refuses it whatever the flags.mero-kms’s entry The store’s Outcome none (a KMS without counters) none Starts unprotected (an older mero-kms); logged, and rollbackisnullnone (a KMS without counters) some Never: this store was protected, and the answer may have been stripped any another node id Never: a store does not move to another id none none First start, or the first since mero-kms keeps counters: starts at the epoch, mark 0 some none Rolled back: an empty or older store under a used id none some Rolled back: mero-kms lost its counters (g, m)below (g, m)Rolled back (g, m)at or above (g, m)Starts -
Recovery is explicit. One node rolled back: wipe it, remove it, and register it again under a new node id; it joins as a learner and catches up (A node refuses to start as rolled back). Every node rolled back, or the newest disks lost: the operator starts each node with
merod run --accept-rollback; the node asks mero-kms (POST /rollback/reset) to set its entry to its store’s mark in a new generation, mero-kms raises the cluster epoch, and every node reports the epoch (rollbackEpochin/health,rollbackin/ops/status, withforced: trueon the node that forced it). The flag is the host’s decision, as restoring an old disk is: a forced rollback is visible, not impossible. The attested KMS evidence does not carry the epoch. -
One release, one set of counters. Each mero-tee release has its own mero-kms cluster, so its own counters, and a node does not move to a new release in place: a node of the next release is a new node with a new store, and a counter never crosses releases.
--dev nodes and nodes given --storage-key* take no counters. A rollback
shorter than one checkpoint looks like a crash, and Raft still holds those
writes on the other replicas. Rows are sealed one by one, so a store spliced
from rows of different ages is not caught by the counter; on a TDX node the
store sits on a disk encrypted with the KMS disk key, so splicing means
swapping encrypted blocks blind.
The recovery disk
Section titled “The recovery disk”K_c dies with the last mero-kms that can unwrap it. The recovery disk
(merod --recovery-dir DIR) keeps a second set of backups that does not
depend on any mero-kms: every 5 minutes each node writes, for every app it
holds, the app’s state, the code it runs and its holder’s slice of the system
state, each sealed to the backup key of whoever upgrades the app
(SystemState::backup_holder: the operator where it holds app upgrades, else
the app’s organization or owner account).
- A backup key is an X25519 key pair made on the holder’s own machine
(
meroctl ops recovery-keygenfor the operator; mero-js’s and calimero-client-py’srecoverymodules for an organization or account). Only the public half reaches the cluster, logged bySetBackupKey(POST /ops/backup-key, operator-signed;POST /orgs/{org}/backup-keyandPOST /auth/backup-key, passkey; thebackupKeysfeature, 1.0.0-rc.20). - Each file’s body is sealed under a fresh data key, as a sealed file is (64 KiB AES-256-GCM chunks), and the data key is sealed to the holder’s key with HPKE (RFC 9180, base mode, DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-256-GCM). The node’s receipt key signs the header, which carries its attestation (Attestation).
- To recover, the holder opens the data keys on its own device and sends only
those over the sealed channel (
POST /ops/recoverandPOST /ops/apps/{app}/restore { recovery }for the operator,POST /recover/holderfor an organization or account). The state comes back under the new cluster’s K_c: rows are sealed again, hidden keys hidden again, and each sealed file’s data key is wrapped again under the new cluster’s file key. No node ever holds a holder’s private key.
The file format is in Storage schema; the procedure in Recover after every key service is gone.
In calimero-node
Section titled “In calimero-node”Where the node implements this chapter, by the names in its code: paths are under crates/node/src
unless another crate is named. The design and its reasons are above; a module’s own detail is in its
//! doc, and the node’s mental model is crates/node/AGENTS.md.
Storage key
Section titled “Storage key”Code: kms.rs.
K_r = HKDF(KMS key, cluster).
A TDX node takes it from mero-kms only (kms::key_source: --storage-key/--storage-key-file need
--dev), fetched by merod itself (--kms-url --kms-identity; calimero-kms-client:
release-policy-verified KMS, key sealed to the TD).
The boot script uses the same client for the data disk’s key (merod kms disk-key).
The cluster’s nodes share the disk identity, so the nodes of one release share K_r; every release
has its own mero-kms root, so K_r changes at each release upgrade.
Cluster key
Section titled “Cluster key”Code: cluster_key.rs.
K_c seals the store, snapshots, backups and feeds the cluster secret, TEE, member and
component-cache keys, so data outlives a release.
Kept in <data_dir>/cluster-key, wrapped under K_r.
The founder (--bootstrap) and a store from before K_c take K_c = K_r (nothing on disk changes).
A node on an empty data directory (run, before Node::start) serves only /health (waiting),
/attestation and /internal/cluster-key/deliver while it asks its --peers (POST /internal/cluster-key { cluster, node, token }, no cluster secret); a peer never answers with K_c
but delivers it (cluster_key::deliver) to the address registered for that node id, else the system
group’s membership’s (cluster_key::recipient_addr; its own --peers only before genesis, while
the founding nodes ask the founder; never a removed or job node), over a fresh sealed channel
attested under the peer policy, with the token (MAX_CONCURRENT_KEY_RELEASES).
A K_r that does not unwrap the file stops the node: no in-place move to a new release.