Protocol v2
This page describes receipts and key changes as of v0.11. The C2SP checkpoint format replaces the v0.10 checkpoint format.
v2 makes three changes:
- Signer-attested time. Each signer signs its own clock reading
(
signed_at) along with the record. A receipt therefore says when each signer saw it, not only what time the gateway proposed. - Stateful checkpoint signing. Signers remember the last log checkpoint they signed and only sign a new one that provably extends it. Log leaves commit to the full receipt record, not just the submitted hash.
- Key epochs and authenticated key transitions. Receipts name the key set (epoch) they were signed under. A key change is a signed document that clients can verify starting from a key file they pinned earlier.
It also removes the federation and external-anchor code paths, which were inert since v0.9.
Records and signing messages
All integers are little-endian. str(x) is u32 length || UTF-8 bytes.
Receipt record (Attestation)
| Field | Type | Meaning |
|---|---|---|
hash |
32 bytes | SHA-256 submitted by the client |
timestamp |
u64 | Gateway-assigned time label (Unix seconds) |
network_id |
string | Network identifier |
sequence |
u64 | Gateway sequence number |
key_epoch |
u64 | Key set the receipt is signed under |
Attestation::to_bytes() = hash || timestamp || str(network_id) || sequence || key_epoch
Checkpoints
The log signs a C2SP checkpoint, which contains the log origin, tree size, and root. Signers add signatures with their own clock readings. The note has no gateway timestamp or explicit key epoch.
Signatures
WitnessSignature { witness_id: string, signed_at: u64, signature: 64 bytes hex }
Each signature covers a domain-separated message:
| Object | Message |
|---|---|
| Receipt | "witness/v2/receipt\0" || signed_at || Attestation::to_bytes() |
| Key transition | "witness/v2/key-transition\0" || signed_at || KeyTransitionBody::to_bytes() |
Domain separation means a signature on one kind of object can never be
replayed as another kind (v1 signed checkpoints through the receipt path).
Signatures use Ed25519 verify_strict; weak public keys are rejected.
SignedAttestation { attestation, signatures: Vec<WitnessSignature> } carries
a flat signature list. Checkpoints use the separate C2SP signature format.
Log leaves
receipt_leaf(a) = SHA-256("witness/v2/leaf\0" || a.to_bytes()). The Merkle
log (and batches) use these leaves, so an inclusion proof commits to the exact
hash, gateway timestamp, sequence, network and epoch of a receipt.
Verification config
{
"id": "example-network",
"key_epoch": 1,
"log": {"origin": "example.org/witness/example-network", "public_key": "<hex>"},
"witnesses": [
{"id": "example.org/witness/w1", "pubkey": "<hex>"},
{"id": "example.org/witness/w2", "pubkey": "<hex>"},
{"id": "example.org/witness/w3", "pubkey": "<hex>"}
],
"threshold": 2,
"signature_scheme": "ed25519",
"time_policy": {"max_skew_secs": 300}
}
Validation (in addition to v1 rules: nonempty id, unique IDs and keys, valid keys):
threshold * 2 > witnesses.len()— a majority is required. Two conflicting checkpoints would each needthresholdsignatures, so at least2 * threshold - witnesses.len()signers (one or more) would have to sign both, which honest stateful signers refuse.1 <= time_policy.max_skew_secs <= 3600.- The origin and signer IDs are valid C2SP names. The log public key must differ from all signer keys.
The operator network.json is the same shape plus endpoint and
auth_token per witness. federation, external_anchors and
federation_peers no longer exist (unknown keys are ignored).
Receipt verification
verify_signed_attestation(signed, config) -> ReceiptVerification:
network_idandkey_epochmust match the config.- Duplicate or unknown
witness_id→ error. - A signature counts only if it verifies and
|signed_at - attestation.timestamp| <= max_skew_secs. - At least
thresholdcounted signatures, else error.
ReceiptVerification {
verified_signatures, required_signatures,
signed_at_earliest, signed_at_latest // over counted signatures only
}
Time meaning. If at least one counted signer is honest, the hash existed
no later than signed_at_latest (plus that signer's clock error). Colluding
signers can only make this bound later, never earlier, so backdating requires
every counted signer to collude. timestamp is a gateway label within
max_skew_secs of every counted signer's clock.
Signer behaviour
Receipt signing — POST /v1/sign
Request { "attestation": Attestation }, bearer-authenticated. The signer
refuses (4xx/503) unless:
network_idandkey_epochmatch its config;|attestation.timestamp - now| <= max_clock_skew(signer config, must be<=the network'smax_skew_secs);- its clock is healthy (below).
Response { "witness_id", "signed_at": now, "signature" }.
Clock health
- Step detection (always on). The signer tracks wall-clock time against a
monotonic clock. If the wall clock moves more than
1 s + 0.1 %of elapsed monotonic time away from expectation between checks, the signer refuses to sign forclock_recovery_secs(default 60) and then recalibrates. - Kernel sync status (
require_clock_sync, Linux only). When enabled, the signer callsadjtimexand refuses to sign while the kernel reports the clock as unsynchronized. Enabling it on other platforms is a startup error. GET /healthreportsclock: "ok" | "unhealthy"and returns 503 when unhealthy.
Checkpoint signing — POST /add-checkpoint
The signer checks the log's signature and whether the checkpoint extends the
last tree it accepted. It writes the new state and signed note to
checkpoint_state_path before returning its signature. See
Signers are C2SP witnesses for the
request, responses, and monitoring endpoint.
Comparing signers (split-view detection)
witness-auditor --signer <id>=<url> fetches each signer's latest checkpoint
and checks it against the gateway's latest verified checkpoint.
--monitor-witness <vkey>=<url> adds an independent witness to the comparison:
| Signer size vs gateway | Check |
|---|---|
| equal | roots must match |
| smaller | GET /v1/log/consistency-proof?first=<signer>&second=<gateway> must show the gateway's tree extends the signer's root |
| larger (signer ahead) | consistency proof from the gateway's size to the signer's root |
It also compares signers with each other at equal sizes. A failure is recorded
as a split_view anomaly with both signed objects as evidence. /v1/log/consistency-proof
returns a bare ConsistencyProof { first, second, hashes } between any two
sizes, including sizes the gateway never published a checkpoint for, because a
signer may have signed a checkpoint that never reached the threshold.
This turns the 2m - N overlap below from undetectable into detectable: the
honest signers on the two sides of a split each publish a checkpoint, and at
least one of them is inconsistent with whatever history the auditor is shown.
Detection needs an auditor that can reach the signers directly, and it happens
after the fact; it does not stop the split from being signed.
Checkpoint freshness
The gateway asks signers to sign the current tree again (same size and root)
every WITNESS_CHECKPOINT_REFRESH_SECS (default 600; 0 disables) even when
nothing new was logged, and replaces the stored checkpoint for that size.
The log signature is unchanged; each signer supplies a new clock reading.
The auditor reports a stale_checkpoint anomaly when the latest checkpoint is
older than --max-checkpoint-age (default 3600 s). witness verify-proof and
witness log checkpoint --verify accept --max-checkpoint-age to reject
stale checkpoints. Age is measured from fresh_as_of, the oldest reading
among the minimum number of latest valid signer readings. An empty log has
no checkpoint to refresh.
What this buys. To get valid checkpoints for two different histories, the
gateway needs at least 2m - N signers (threshold m of N) to sign both,
which means those signers must be dishonest or have lost their state. That is
only one signer for 2 of 3 or 3 of 5, two for 4 of 6 or 4 of 5, and three
for 5 of 7. The honest signers on each side each see a consistent history and
cannot tell, because signers do not compare state with each other; an auditor
comparing the signers' published checkpoints (above) can. Use a higher
threshold to raise the bar (m = N makes every signer an overlap, at the cost
of availability). Clients can also require signatures from independent
witnesses they choose. None of this proves the log is complete (the gateway can
withhold entries from the log); --require-log-inclusion covers that for a
given receipt, and checkpoint freshness covers a log that stops.
Key epochs and transitions
KeySet { key_epoch, witnesses: Vec<VerificationWitnessInfo>, threshold, log_public_key }
LogCheckpointRef { tree_size, root_hash }
TransitionReason "routine" | "compromise"
KeyTransitionBody { network_id, from_epoch, from_key_set_digest, to: KeySet,
effective_at, reason, final_checkpoint: Option<LogCheckpointRef> }
KeyTransition { body, old_signatures: Vec<WitnessSignature>,
new_signatures: Vec<WitnessSignature> }
KeyHistory { genesis: NetworkVerificationConfig, transitions: Vec<KeyTransition> }
KeyTransitionBody::to_bytes() = str(network_id) || from_epoch ||
from_key_set_digest || to.key_epoch || u32 count || for each witness (str(id) ||
32-byte pubkey) || u64 threshold || 32-byte log public key || effective_at || reason byte (0 routine, 1
compromise) || flag byte (0 none / 1 some) || [tree_size || root_hash].
Encoding fails (rather than producing non-canonical bytes) if a public key is
not valid 32-byte hex.
from_key_set_digest = key_set_digest(old config) = SHA-256("witness/v2/key-set\0"
|| str(network_id) || key_epoch || u32 count || (str(id) || pubkey)* || u64
threshold || str(log.origin) || 32-byte log public key || u64 max_skew_secs ||
u8 scheme). Because the incoming key set
signs a body that names the outgoing set, a client that pins a later epoch
also authenticates every earlier key set and time policy on the chain.
KeyHistory::verify(pinned) -> VerifiedKeyHistory:
genesismust validate.- For each transition, in order:
network_idmatches;from_epochequals the current epoch;to.key_epoch == from_epoch + 1; the new set validates (majority, unique keys);effective_atis non-decreasing;from_key_set_digestequals the digest of the current derived config;old_signaturesmeet the old threshold andnew_signaturesmeet the new threshold over the transition message (no skew rule; duplicates and unknown IDs rejected);reason = compromiserequiresfinal_checkpoint. - The config derived for
pinned.key_epochmust equalpinnedexactly (id, epoch, log origin and key, witnesses, threshold, scheme, time policy). Otherwise the history is rejected: it does not lead through the key set you trust.
Derived configs keep the genesis id, log.origin, signature_scheme and
time_policy; they replace log.public_key, key_epoch, witnesses and
threshold.
VerifiedKeyHistory exposes config_for_epoch(e), current(), and
retirement(e) -> Option<{reason, effective_at, final_checkpoint}>.
Old receipts after a key change
- Routine retirement: receipts signed under the old epoch stay valid with that epoch's keys.
- Compromise retirement: the old keys may be in an attacker's hands, so a
receipt from that epoch is accepted only with a log inclusion proof at
exactly
final_checkpoint.tree_sizewhose path leads tofinal_checkpoint.root_hash. That root is authenticated by the new key set through the transition, so the old (compromised) checkpoint signatures are not relied on. Plain signature verification of such a receipt fails withEpochCompromised. The receipt's ownsigned_atvalues came from possibly compromised keys, so the trustworthy time bound for an anchored receipt is the transition'seffective_at(existed_no_later_than), notsigned_at_latest.
Limit. Whoever holds a threshold of an epoch's keys can sign a transition to keys of their choosing, so a history is only as trustworthy as the epoch you pinned. After a compromise, clients must re-pin the new epoch's key file through an out-of-band channel; following the chain from a pin at the compromised epoch is not enough.
Checkpoint verification checks the newest key set whose log and signer signatures satisfy the policy, skipping epochs retired due to compromise. For a receipt verified through a compromise transition, the transition proves the root, not which independent witnesses signed it. Verification therefore rejects that receipt if the client requires a witness policy.
Operating a key change
- Drain in-flight jobs (signers reject requests from another epoch).
- Write the
KeyTransitionBody; for a compromise, setfinal_checkpointto the last checkpoint you trust. - Each old and new signer runs
witness-node sign-key-transition --body body.jsonand returns aWitnessSignature. - Append the assembled
KeyTransitionto the history file the gateway serves (--key-history/WITNESS_KEY_HISTORY), updatenetwork.jsonand signer configs to the new epoch, restart.
Proof bundle
ProofBundle { signed_attestation, log_inclusion: Option<LogInclusionProof> }
LogInclusionProof { leaf_index, tree_size, audit_path: Vec<[u8;32]>, checkpoint: String }
ProofBundleVerification { receipt: ReceiptVerification, log_tree_size, log_leaf_index,
checkpoint_fresh_as_of, existed_no_later_than, anchored_by_key_transition }
existed_no_later_than is receipt.signed_at_latest, or the retirement's
effective_at for a receipt anchored through a compromise transition.
GET /v1/bundle/:hash returns the receipt plus an inclusion proof under the
latest checkpoint once the receipt is logged. Verification fails if a present
inclusion proof is invalid. The leaf is always recomputed from the receipt.
Gateway API changes
- Removed:
/v1/anchors/:hash,/v1/proof/:hash(per-batch proof), federation code and tables. GET /v1/log/proof?hash=&tree_size=returnsLogInclusionProoffor the receipt leaf of that hash.GET /checkpointreturns the latest C2SP note as plain text.GET /v1/log/checkpointand/v1/log/checkpoint/:sizewrap the note in JSON.GET /v1/log/consistency-proof?first=&second=— bare consistency proof between any two log sizes (used by the auditor to check signers' checkpoints).GET /v1/key-history— the gateway'sKeyHistory(a single-entry history derived fromnetwork.jsonif no file is configured). It is safe to fetch from an untrusted gateway because clients verify it against their pin.- Startup refuses
WITNESS_JOB_SIGNING_WINDOW_SECS > time_policy.max_skew_secs(a retried job would carry a timestamp signers reject) and anetwork.jsonepoch that differs from the key history's current epoch.
Clients
witness verify/verify-prooftake a pinned config and always try to load the key history (--key-history <file>, else/v1/key-history), verify it against the pin, and use the config for each object's epoch. This also detects a later compromise retirement of the pinned epoch itself. If the history cannot be fetched, they fall back to the pin alone only when every epoch involved equals the pin's, and report the history as unchecked. A history that does not verify against the pin is a hard failure.- Output includes
signed_at_latestas "existed no later than". - The auditor verifies each checkpoint with its own epoch's config via the verified key history.