CRT CKB Revocable Timelock

How it works

A switch is a handful of cells on the CKB chain, one small program running inside each chosen node, and one file in your hands. This page walks through them in the order they come into being.

Three kinds of cell [§3]

Alive Cell
One per switch. Its type script is CKB’s type-id, so its 32-byte argument T is unique on the chain and can never be recreated once the cell is consumed. It is locked by your wallet and never updated. Consuming it without a replacement is cancellation.
Node Cell
One per chosen runner. Locked by CRT’s own script with T and the runner’s identity in the arguments. Holds the deadline, your wallet’s lock hash, the hash of the descriptor, and — written by the runner — first the public key, later the private key.
Job cells
Standard CSR job cells, two per runner: one “run now” job that triggers key generation within minutes, and one job that fires every day for the term and pays the runner a tip each time. Both name the runner-specific service ID, so only that runner can run them.

Creating a switch is one wallet transaction with all of these as outputs. Nothing in it depends on the runners; their keys arrive afterwards into cells that already exist.

The lock script [§4]

The Node Cell lock has two paths. On the owner path — any input signed by your wallet — everything is allowed: change the deadline, write the descriptor hash, destroy the cell. On the node path — the runner’s own CSR transaction — exactly two transitions exist:

  1. Commit. From “created” to “armed”: a valid compressed public key is written, nothing else changes, capacity is preserved.
  2. Release. From “armed” to “released”: a private key is written and the script checks three things — pubkey(privkey) equals the committed public key; the input’s since is an absolute timestamp of at least deadline + 24 h, which CKB consensus compares against the median time of the last 37 blocks; and the Alive Cell with T is present as a cell dependency, which a dead cell cannot be.

Those three checks are the whole security argument on chain: a release cannot be committed early, cannot be committed after a cancel, and cannot be faked.

The service in the sandbox [§5]

Each runner executes CRT as a CSR service: a RISC-V program running in CKB-VM with no network, no filesystem and no clock, talking to the host through a small set of calls. Every job run executes the same decision table against chain state:

no Alive Cell            → delete key, do nothing          (cancelled)
no Node Cell for me      → delete key, do nothing          (dropped at rewrap)
Node Cell created        → draw 32 random bytes from the host CSPRNG,
                           store them encrypted, mark secret,
                           bind deletion to the Alive Cell,
                           commit the public key on chain
Node Cell armed, early   → do nothing                      (heartbeat)
Node Cell armed, due     → write the private key on chain  (release)
Node Cell released       → delete key                      (done)

Two properties matter. The key is drawn from randomness, never derived from anything the runner could recompute later — a derived key cannot be deleted. And deletion on cancel is done by the CSR host itself, through a rule the service registers at key generation, so it happens even if the operator has since disabled the service.

Your secret, split [§7]

Runners know nothing about each other or about how many of them you chose. Your application generates a 32-byte secret K, splits it with Shamir’s scheme into n shares of which any t suffice, and seals one share to each runner’s public key (secp256k1 ECDH, HKDF, AES-GCM). A mandatory node — your own, say — is a second branch combined by XOR: without it, no number of other runners can recover K.

Every mandatory node makes the secret harder to steal and easier to lose, one for one. The app says this at the moment you choose, not in a footnote.

Each share also gets a public commitment hash, so a node that releases garbage is identified immediately rather than silently breaking the reconstruction.

The recovery file [§8]

Everything a future reader needs lives in one HTML file: a printable certificate (deadline, nodes, hashes, plain-language instructions), the descriptor, the sealed shares, and the code to recover. Opened in a browser — online or offline, from a USB stick — it recomputes the descriptor hash and shows MATCH or MISMATCH before anything else. Online, it reads the released keys straight from any CKB node; offline, you paste them. Applications add their own payload and a decrypt step, which is how dead-man-switch turns the recovery file into a sealed letter.

The descriptor itself never goes on chain — it would name the nodes that hold your shares and which of them is mandatory. Only its hash does, in every Node Cell.

Renew, rewrap, cancel [§6]

Renew
One wallet transaction updates the deadline in the Node Cells and posts new heartbeat jobs. The Alive Cell, the keys and the recovery file do not change.
Rewrap
Change the node set: destroy the Node Cells of runners you drop, create new ones, wait for new commits, seal a fresh K, download a new file. Dropped runners find their cell gone and delete their key.
Cancel
Consume the Alive Cell with no replacement. The Node Cells can be reclaimed in the same transaction. No fee of any kind, ever — and in the app, never more clicks than creating.
Reclaim
After release or cancel, take the parked capacity of the cells back. The release values stay in chain history.

Limits, stated plainly [§12]