Skip to main content

Keys and verification

This guide walks the full signer lifecycle with real captured output: create a persistent key, run a mission with it, verify the result, publish a head attestation, share a bundle, rotate the key, run again, and revoke it, showing what writ verify checks at each step. Run the commands from one empty directory. The samples shorten absolute paths, and shorten a public key where writ keys prints it on its own line; the full key appears in the verify commands.

Verify the run directory

Verify a run directory or an exported bundle, not a bare work-record.jsonl. On its own, with no run.json, --expect-head, or --pinned-head, a work-record.jsonl reports INCOMPLETE (exit 8): the receipts check out, but nothing binds the end of the chain, so a shortened export would look identical. --allow-no-terminal-commitment accepts such a record anyway.

The signing modes​

work_record.signingWhat it doesWhen to use it
dev-ephemeral (default)Generates a throwaway signing key in memory only for the run, then discards it. Receipts are stamped signerMode: dev-ephemeral and writ verify warns that they aren't production evidence.Trying Writ out, demos, CI smoke tests.
key-fileSigns with a persistent key at work_record.key_file, created by writ keys init. The public key and a self-signed operator identity record ship with every run.Any evidence you intend to keep, share, or stand behind.
envThe same persistent-identity behavior as key-file, with the key read from the WRIT_RECEIPT_KEY environment variable.A service host that takes its secrets from the environment.

Create a persistent key​

$ writ keys init --operator-name "Example Operator" --operator-url https://operator.example --operator-contact ops@operator.example
Created receipt signing key: keys/receipt.key (private; no other account is granted access)
Created signer identity: <your directory>/keys/signer-identity.json (public; ships with every run)
key_id: 48d196ae736139f2
pubkey: 1f9a2598...82b214ca
operator: Example Operator (https://operator.example) <ops@operator.example>

Next: in mission.yaml set
work_record:
signing: key-file
key_file: keys/receipt.key
and share the pubkey with anyone who will run `writ verify`.

The private key never appears in any command's output. On disk, keys/receipt.key is created private: POSIX mode 0600, or on Windows a protected ACL (nothing inherited from the folder) that grants full control to the account that ran keys init and to no other account, set as the file is created. From an elevated Windows shell the file's owner is BUILTIN\Administrators, not your account, and administrators and SYSTEM can take over any file; keys init grants no other account access. keys/signer-identity.json is the public, self-signed identity record it wrote beside the key:

{
"protocol": "writ.signer-identity/1",
"algorithm": "bip340-secp256k1",
"pubkey": "1f9a2598...82b214ca",
"key_id": "48d196ae736139f2",
"operator": {
"name": "Example Operator",
"url": "https://operator.example",
"contact": "ops@operator.example"
},
"created_at": "2026-11-17T00:21:48.8562729+00:00",
"signature": "e35897bc742bb94326594a399f7825b0193c3b68140aabf776223065709a1bcca3b8b4a61ae2b391d57c735e77c52a2c6caf0660093e96643dbca1a83b05fd68"
}

writ keys init refuses to overwrite an existing key or identity (exit 2); use --out <path> to create a second key elsewhere. writ keys show reprints the public facts, and cross-checks the key file against the identity record:

$ writ keys show
Signer identity: <your directory>/keys/signer-identity.json
key_id: 48d196ae736139f2
pubkey: 1f9a2598...82b214ca
algorithm: bip340-secp256k1
operator: Example Operator (https://operator.example) <ops@operator.example>
created_at: 2026-11-17T00:21:48Z
identity_hash: 02a5d571a02b3aad2fff15b873613ea78945f728ec41a8a089f42e5bd7dce3e8
self-signature: valid
key file: keys/receipt.key (matches this identity)

key_file is resolved from the directory you run writ in, like the rest of the manifest's relative paths. Run your missions from the directory that holds keys/, or give key_file an absolute path.

Who may read the key file​

Every command that reads a receipt key file applies the same custody rule before it reads a byte: writ run (the manifest's key_file), the service hosts' WRIT_RECEIPT_KEY_FILE, keys show, keys rotate, keys revoke, record publish-head, and the coding commands that sign with the key. A key another account can read is a key another account can sign receipts with, so such a file is refused, and no other key is used in its place.

  • Windows: every entry that grants read (or the right to change permissions or take ownership) must name the file's owner, SYSTEM, or BUILTIN\Administrators, or the account running Writ when the file is owned by that account, Administrators, or SYSTEM. Entries inherited from the folder count.
  • Linux and macOS: the mode is 0600 or stricter, and Writ is not running as root.
  • Everywhere: the key path must name the key file itself. A path that is a symbolic link, junction, or other reparse point is refused, whatever it points at. Linked parent folders are followed, and the file they lead to must still pass the rule.

Writ opens the key file once, applies the rule to that open file, and reads the key from it, so a file swapped in after the check is never the one read.

writ run and the service hosts name the file, the account or mode that makes it too open, and the fix. The other commands print KeyFileTooOpen and the rule. --allow-open-key-file lets those other CLI commands read an open key file on a test host. It never admits a linked key path, and it doesn't apply to writ run or the service hosts.

An existing key file: if writ run refuses yours, restrict it (chmod 600 keys/receipt.key, or on Windows icacls keys\receipt.key /inheritance:r /grant:r "<DOMAIN>\<you>:F" and remove any other account it still lists). If another account may have read it, rotate the key with writ keys rotate and revoke the old one.

WRIT_RECEIPT_KEY is a different channel. A key passed in the environment (signing: env) is not a file, and this rule does not judge it; it is protected only as well as the process environment and wherever you set it. Prefer key-file on a host shared with other accounts.

Run a mission signed with that key​

Save this manifest as mission.yaml beside the keys/ directory. It is the install page's smoke mission with work_record pointed at the key:

mission.yaml
mission:
name: keyed-demo
goal: "One paid capability call, signed with a persistent key."

budget:
total_sats: 100
per_call_max_sats: 25

settlement:
mode: simulated

capabilities:
- id: data.lookup
kind: l402-http
base_url: https://api.example.test/data
path: /lookup
method: GET
max_sats_per_call: 5

workers:
- name: probe
scope: [data.lookup]
budget_sats: 40
steps:
- type: call
capability: data.lookup
input: { q: smoke }
output: lookup.json

work_record:
signing: key-file
key_file: keys/receipt.key
output_dir: runs/
$ writ run mission.yaml
Running mission 'keyed-demo' (run keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32)...
19:21:51 warn: Writ.Engine.Runner.MissionRunner[0] No WRIT_ROOT_KEY is set — using an EPHEMERAL per-run authority root key. Credentials minted this run cannot be re-verified after the process exits, so this run cannot be resumed. Never rely on this for production authority.
· probe/mission.data.lookup 5 sats Executed (simulated)

Run keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32: Completed
Spent 5 / 100 sats · settlement simulated · 1 receipt(s)
Outputs:
- runs/keyed-demo-20261117-002151-.../lookup.json
- runs/keyed-demo-20261117-002151-.../work-record.jsonl
- runs/keyed-demo-20261117-002151-.../usage.json
- runs/keyed-demo-20261117-002151-.../run.json
- runs/keyed-demo-20261117-002151-.../report.html
Verify: writ verify runs/keyed-demo-20261117-002151-... --pubkey 1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca

The warn: line is about the authority key, not the signing key: the receipts are signed with your persistent key, and the run cannot be resumed later. To make runs resumable, set WRIT_ROOT_KEY as shown in Approve and resume a run, end to end. The CLI prints absolute paths; the samples on this page shorten them.

The run directory carries the identity record alongside the usual artifacts:

lookup.json
progress.jsonl
report.html
run.json
run.lock
signer-identity.json
usage.json
work-record.jsonl
writ.db

Verify, and what it shows​

$ writ verify runs/keyed-demo-... --pubkey 1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca --require-identity
OK — verified 1 receipt(s).
Chain head: 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a
Terminal commitment verified — this export cannot be truncated undetected.
Signed by Example Operator (https://operator.example) <ops@operator.example>, key 48d196ae736139f2 — identity record verified and bound to the chain.

writ verify checks, offline, from the public key you supply:

  • Every receipt's signature. Each receipt is BIP-340-signed; a forged or altered receipt fails signature verification.
  • The hash chain. Each receipt commits to the hash of the one before it (previousReceiptHash); reordering, deleting, or inserting a receipt breaks the chain.
  • The terminal commitment. When run.json carries a signed commitment over the chain's final (sequence, hash), verify requires the chain to end exactly there, so dropping the last few receipts of an export fails verification.
  • Signer identity, when --require-identity is set or an identity record is present: the record's self-signature is valid and the first receipt commits to its hash, so verify can print the operator the key belongs to.

A clean verify shows that the recorded steps were attested by the holder of this key, and that the chain is intact and complete. It does not independently establish authorization, payment, completion, or quality: those are the signer's attestations. See Security model and preview limitations.

A wrong public key fails​

$ writ verify runs/keyed-demo-... --pubkey 0000000000000000000000000000000000000000000000000000000000000000
FAILED — 3 problem(s) across 1 receipt(s):
[row 0] 5fab3d822eb24a29a5d95e21375e94d1: signature verification failed
the run summary's terminal commitment signature does not verify under the supplied public key — refusing to trust it (the run summary may have been tampered with).
the signer identity record describes key 48d196ae736139f2 (1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca), which is not the --pubkey you pinned and is not reachable from it: key 48d196ae736139f2 is not reachable from the trusted anchor 66687aadf862bd77: no rotation record continues from key 66687aadf862bd77. — the record does not belong to a key you trust.

Exit 5.

Tampering names the row​

A copy of the run directory with one field of work-record.jsonl edited (resultCode changed from completed) gives:

FAILED — 1 problem(s) across 1 receipt(s):
[row 0] 5fab3d822eb24a29a5d95e21375e94d1: receiptHash does not match the recomputed canonical hash (tampered field)

Exit 5. The failure names the row and the reason.

Share a run with a counterparty​

writ record export --out <dir> writes a bundle with ordinary file permissions: the work record, run.json, the report, usage.json, the signer identity record, and the rotation and revocation records when the run has them. It never includes writ.db, key material, or step outputs:

$ writ record export keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32 --out share-bundle
Exported run 'keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32' to <your directory>/share-bundle
work-record.jsonl (1504 bytes, sha256 fa86bd0a321fab11f05de3add6c78c3c1837d2091ffa89ad200ee651ed8cd8c8)
run.json (2115 bytes, sha256 75baefa915634c7c24bde4744ad36123eed0f76c867b17df02f2a255f45f6ea5)
report.html (3776 bytes, sha256 b17704f88a3431762f97ae5219c1a28cb6d5330c0f39936a2ec9b67e40f18b38)
usage.json (182 bytes, sha256 e230184836060050d94f7016905ac25349993f830db241a16e2379a6737d2cae)
signer-identity.json (531 bytes, sha256 a7e7fefe3d966d03e2e2685516f1376bb3248600245affa9364bdb46231d2a07)
manifest.json
Chain head: 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a (1 receipts).
Not included (never exported): writ.db and its sidecars, key material, and step outputs.
Recipient check: writ verify <this directory> --pubkey <signer pubkey hex> --expect-head 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a

Give the recipient your public key separately, through a channel they already trust, not inside the bundle. They verify the bundle directory with it:

$ writ verify share-bundle --pubkey 1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca
OK — verified 1 receipt(s).
Chain head: 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a
Terminal commitment verified — this export cannot be truncated undetected.
Signed by Example Operator (https://operator.example) <ops@operator.example>, key 48d196ae736139f2 — identity record verified and bound to the chain.

Head attestations​

writ record publish-head signs a small attestation over a run's terminal receipt with the run's key. A counterparty who keeps it and passes it to --pinned-head detects any later shortening of the record without having to type in the head themselves.

$ writ record publish-head keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32
Head attestation for run keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32: seq 0, head 526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a
signed by key 48d196ae736139f2 at 2026-11-17T00:22:09.1117481Z
written to runs/keyed-demo-.../head-attestation.json
Counterparties verify with: writ verify <run-dir> --pubkey <anchor> --pinned-head head-attestation.json
head-attestation.json
{
"protocol": "writ.head-attestation/1",
"run_id": "keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32",
"seq": 0,
"head_hash": "526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a",
"signer_key_id": "48d196ae736139f2",
"attested_at": "2026-11-17T00:22:09.1117481+00:00",
"signature": "ba3d2837b8793d73e1064f37aee0e15ed67963c7483dbd6a41ea5c6f3efcadb1b9e688202a7dc9ae5513cfcede5b1993c3a9f114cbb6dc28b8398006fc4b3a5c"
}
$ writ verify runs/keyed-demo-... --pubkey 1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca --pinned-head runs/keyed-demo-.../head-attestation.json
OK — verified 1 receipt(s).
Chain head: 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a
Terminal commitment verified — this export cannot be truncated undetected.
Signed by Example Operator (https://operator.example) <ops@operator.example>, key 48d196ae736139f2 — identity record verified and bound to the chain.
Pinned head verified — attested by key 48d196ae736139f2 at 2026-11-17T00:22:09.1117481Z: the chain ends exactly at 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a.

An attestation names the signer by signer_key_id, not by public key: the verifier still supplies the public key out of band. publish-head needs the private key on disk, so it can't attest a dev-ephemeral run (exit 2):

Run 'smoke-20261117-002246-a33f66e03fa5434ebd1e0279df95a1ed' was signed with a dev-ephemeral key, which existed only in the process that ran it, so no key can attest its head. Use work_record.signing: env or key-file for runs whose head you publish. Nothing was written.

--post <url> also sends the attestation JSON in an HTTP POST to a URL you choose. --relay <wss-url> also publishes it as a signed Nostr event (kind 38410) to a relay you choose; wss://agents.lightningenable.com accepts these events. writ record verify-head <run-id> --relay <wss-url> --pubkey <anchor> later checks every head the relay returns against the local record. A relay is not a transparency log: it can withhold a later head, so publish to and check more than one relay to detect a withheld head. The relay is public and learns the run id, receipt count, head hash and the signer's public key. See record publish-head and record verify-head.

Rotation: keep working with a new key​

$ writ keys rotate
Rotated receipt signing key: 48d196ae736139f2 -> 7c3e2347e1046914
new pubkey: c98f986f...a8df5401
new key: keys/receipt.key (old key archived as receipt.48d196ae736139f2.key)
new identity: <your directory>/keys/signer-identity.json (predecessor_key_id 48d196ae736139f2)
rotation: appended to <your directory>/keys/rotations.jsonl (signed by the old key)
Verifiers pinned to the OLD pubkey keep working: `writ verify --pubkey <old>` walks the rotation to the new key.

The mission's key_file: keys/receipt.key path stays the same; the file now holds the new key. A run made after rotation is signed by the new key, and the runner copies rotations.jsonl into the run directory beside the identity record, and record export copies it into the bundle. Verifying that run with the old public key works with no extra flag:

$ writ verify runs/keyed-demo-<after-rotation>-... --pubkey 1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca
OK — verified 1 receipt(s).
Chain head: 0:8ff7d89d3be8e4d659d7cc861615b85237484c9bda4ca6daa190e69d228a60af
Terminal commitment verified — this export cannot be truncated undetected.
Signed by Example Operator (https://operator.example) <ops@operator.example>, key 7c3e2347e1046914 — identity record verified and bound to the chain.
Key chain: reached the signer from the pinned anchor through 1 verified rotation(s).

--rotations <file> names a rotation record explicitly, for evidence that doesn't carry its own copy.

Revocation: a lost or compromised key stops producing evidence​

The right order is to rotate first, then revoke the old key, signed by its successor. This example revokes the current key to show what a revoked key does to later evidence:

$ writ keys revoke --key-id 7c3e2347e1046914 --reason "key retired"
Revoked key 7c3e2347e1046914 as of 2026-11-17T00:22:33Z (signed by 7c3e2347e1046914).
appended to <your directory>/keys/revocations.jsonl
Receipts that key signed after this instant fail `writ verify`; earlier evidence stays valid. Share the revocations file with your verifiers.
WARNING: you revoked the CURRENT key. It can no longer sign receipts or a rotation verifiers will honour — the right order is `writ keys rotate` FIRST, then revoke the old key with the successor. From here, create a fresh key with `writ keys init --out <new path>` and have verifiers pin its pubkey.

Revoking a key that isn't the current signer and isn't reachable from it is refused, so a stranger can never revoke your key (exit 2):

$ writ keys revoke --key-id deadbeefdeadbeef --reason "unrelated key id"
Key deadbeefdeadbeef is not the current key (7c3e2347e1046914), and the current key is not a successor of it per '<your directory>/keys/rotations.jsonl' (no valid forward rotation chain leads from that key to this one); a revocation must be signed by the revoked key or a successor of it.

writ run does not check revocation when it signs: a run made with a revoked key still completes. Revocation is enforced when the evidence is verified:

$ writ verify runs/keyed-demo-<signed-after-revocation>-... --pubkey c98f986f72c4fe8716b1b13330025ef900a568d8fbac4cd086c2a686a8df5401
FAILED — 1 problem(s) across 1 receipt(s):
key 7c3e2347e1046914 was revoked at 2026-11-17T00:22:33.5412252Z but 1 receipt(s) (first: sequence 0, occurred 2026-11-17T00:22:40.6554204Z) were signed at/after that instant — not evidence.

Exit 5. revocations.jsonl is copied into every run directory made while it exists on disk, and into exported bundles, so this fails without an explicit --revocations flag. A verifier who keeps their own copy of your revocations file passes it with --revocations <file>.

After revoking the current key, create a new one with writ keys init --out <new path> and give its public key to your verifiers.

Trust-anchor summary​

You pin (--pubkey)What verify does
The run's signer keyDirect signature check. No rotation walk needed.
An earlier key in the operator's rotation chainWalks rotations.jsonl forward, hop by hop, each signed by the previous key, until it reaches the run's signer, or fails if it can't.
A key that was later revokedFails, if any receipt in the chain was signed at or after that key's recorded revocation instant.

--require-identity turns "no identity record present" from a warning into a failure (exit 5). Use it whenever you need to know which operator signed, not only that a valid signature exists.

Next steps​