Specification
Normative source · v1
This page is a shortened reference for implementers who already understand the protocol. The complete text — notation, test vectors, compliance checklist — lives in the spec repo.
Envelope familyLink to this section
| Envelope | kind | Nostr kind | d-tag prefix | File ext |
|---|---|---|---|---|
| Delegation | agent- | 30083 (co-claimed with OC Stamp via disjoint d-tags) | oc- | . |
| Agent-action | agent- | 30084 (claimed exclusively; reuses OC Stamp env shape) | oc- | . |
| Revocation | agent- | 30085 (claimed exclusively) | oc- | . |
| Sub-delegation (v1.1) | agent- | 30086 (claimed exclusively) | oc- | . |
Delegation canonical message (§SPEC 4.1)Link to this section
oc-agent:delegation:v1
principal: <btc_address>
agent: <btc_address>
scopes: <scope_1>,<scope_2>,…
bond_sats: <non-negative integer>
bond_attestation: <64-hex | "none">
issued_at: <ISO 8601 UTC>
expires_at: <ISO 8601 UTC>
nonce: <32-hex>
Each line LF-terminated; no trailing LF after nonce. Scopes are serialized in
sorted order (lexicographic byte order) and joined by a single ASCII comma.
Envelope id = sha256(canonical_message_bytes) rendered as lowercase hex.
A delegation lasts at most 365 days: expires_at - issued_at is at most
31,536,000 seconds (§SPEC 4.4). A longer one is malformed whatever the clock
says.
Agent-action canonical message (§SPEC 5.1)Link to this section
oc-agent:action:v1
address: <agent_btc_address>
content_hash: sha256:<64-hex>
content_length: <positive integer>
content_mime: <RFC 6838 media type>
signed_at: <ISO 8601 UTC>
delegation_id: <64-hex>
scope_exercised: <scope string>
A strict extension of OC Stamp's canonical message. OC Stamp verifiers that treat unknown-field additions tolerantly (as the spec requires) correctly verify authorship and priority; authority verification is additive.
Revocation canonical message (§SPEC 9.1)Link to this section
oc-agent:revocation:v1
address: <signer_btc_address>
delegation_id: <64-hex>
reason: <printable ASCII, at most 128 bytes, "" if omitted>
signed_at: <ISO 8601 UTC>
A signer writes the reason as printable ASCII of at most 128 bytes. A verifier
decides a revocation on its signed bytes only: it computes the id from the
signed fields and checks the signature against that id and signer.address. The
reason's content and the envelope's v, id, kind, sig.pubkey and
sig.alg never stop a validly signed revocation from revoking; a reason left
out or null is "". A reason shown to a person has its control, bidi and
invisible characters escaped (agent-core shownReason).
SigningLink to this section
All three envelopes sign the hex-encoded ASCII id (64 bytes) via BIP-322 under the appropriate signer's Bitcoin address:
- Delegation → principal's address.
- Agent-action → agent's address.
- Revocation → the delegation's principal or agent. Either may always revoke
(SPEC §9.5);
revocation.holdersdecides nothing.
Scope grammarLink to this section
See scope grammar for the detailed walkthrough.
scope := product ":" verb [ "(" constraint-list ")" ]
constraint := key op value
op := "=" | "!=" | "<" | "<=" | ">" | ">=" | "*"
Registry: lock:seal, lock:chat, stamp:sign, vote:cast, nostr:publish,
http:request, ln:send, mcp:invoke, pledge:create, and the adapter scopes
anthropic:tool, openai:function, vercel:tool and langgraph:tool. Keys
per scope are on Scopes.
Verification algorithm (§SPEC 8)Link to this section
Verification runs at a time, now. Live verification decides whether to act
on A now, and is what the steps below mean. An audit checks a past action
as of its own A.signed_at (below). A verifier deciding whether to act MUST
verify live.
verify(D):
1. v == 1 else E_UNSUPPORTED_VERSION
2. shape check, incl. issued_at < expires_at ≤ issued_at + 365 days, else E_MALFORMED
3. reconstruct canonical → id' == D.id else E_BAD_ID
4. scopes parse + validate else E_BAD_SCOPE_GRAMMAR
5. BIP-322(D.principal, D.id) verifies else E_BAD_SIG
6. now ∈ [issued_at, expires_at), for D and every link of a chain,
else E_NOT_YET_VALID / E_EXPIRED
7. no revocation targeting D.id in effect at or before now, and none
effective before A.signed_at, else E_REVOKED
verify(A, D):
verify(D) clean, at now
8. base stamp checks on A else E_BAD_ACTION_STAMP
9. A.delegation_id == D.id else E_DELEGATION_MISMATCH
10. A.signer.address == D.agent.address else E_AGENT_MISMATCH
11. A.signed_at ∈ [D.issued_at, D.expires_at) else E_OUT_OF_WINDOW
11a. |now − A.signed_at| ≤ the verifier's bound (120 s recommended) else E_STALE
11b. act on each A.id once: keep accepted ids until A.signed_at + the bound
12. A.scope_exercised ⊆ some scope in D.scopes else E_SCOPE_DENIED
12a. content-bound keys (stamp:sign mime, max_bytes, content_hash_prefix)
are derived from A.content, not the agent's claim, and must still fit
the grant, else E_SCOPE_DENIED
optional bond check:
13. D.bond non-null else E_NO_BOND
14. D.bond.sats >= threshold else E_BOND_UNMET
15. resolve(D.bond.attestation_id) still valid else E_BOND_UNVERIFIED
A.signed_at is chosen by the agent. Live, steps 6, 7 and 11a make it
irrelevant to whether the delegation is in force or revoked. An audit (§SPEC
8.6) skips steps 6, 11a and 11b, refuses only a revocation effective before
A.signed_at, and MUST report that time as the agent's claim unless a checked
OTS anchor fixes it. An audit never decides whether to act now. In
@orangecheck/agent-core, verifyAction is the live check and
verifyActionAsOfSignedAt the audit.
Error codes (§SPEC 11)Link to this section
E_UNSUPPORTED_VERSION · E_MALFORMED · E_BAD_ID · E_BAD_SIG ·
E_BAD_SCOPE_GRAMMAR · E_NOT_YET_VALID · E_EXPIRED · E_REVOKED ·
E_STALE · E_DELEGATION_MISMATCH · E_AGENT_MISMATCH · E_OUT_OF_WINDOW ·
E_SCOPE_DENIED · E_BAD_ACTION_STAMP · E_NO_BOND · E_BOND_UNMET ·
E_BOND_UNVERIFIED · E_REVOKER_UNAUTHORIZED · E_CALENDAR_UNREACHABLE
v1.1 (sub-delegation): E_SUBDELEGATION_DEPTH_EXCEEDED ·
E_SUBDELEGATION_PRINCIPAL_MISMATCH · E_SUBDELEGATION_EXPIRES_EXTENDED ·
E_SUBDELEGATION_SCOPE_ESCALATED. See sub-delegation
for the chain-walking algorithm.
v1.2 (private scope): E_SCOPES_BOTH_PROVIDED · E_SCOPES_NEITHER_PROVIDED
· E_SCOPES_UNREADABLE · E_BAD_LOCK_ENVELOPE. See
private scope for the confidential-mode verifier
extension.
Canonicalization (§SPEC 6)Link to this section
- RFC 8785 JSON canonicalization (lexicographic key sort; no insignificant
whitespace;
\uXXXXonly for control chars and"/\). - Arrays preserve order except the top-level
scopesfield of a delegation, which MUST be sorted lexicographically to match the canonical-message serialization. - Constraints within a scope string MUST be sorted by key for canonical form.
VersioningLink to this section
envelope.v is an integer. Future incompatible changes increment it.
Unknown-field tolerance handles minor additions.
Where to go from hereLink to this section
- Scope grammar for the full BNF and the sub-scope decision procedure.
- Test vectors (opens in a new tab) for cross-implementation conformance.
@orangecheck/agent-core(opens in a new tab) for the reference TypeScript implementation.