# KYA-OS Protocol Specification **Cryptographic identity, delegation, and proof for Model Context Protocol servers** Version: 1.0.0 Status: Stable Editors: Dylan Hobbs ([@H0BB5](https://github.com/H0BB5)), KYA-OS Working Group Repository: https://github.com/decentralized-identity/kya-os-mcp --- ## Abstract KYA-OS (Know Your Agent Operating System) is a protocol extension for the Model Context Protocol (MCP) that adds cryptographic identity, delegation chains, and non-repudiation proofs to AI agent interactions. KYA-OS enables MCP servers to verify *who* is calling (agent DID), *what authority they hold* (a delegation chain rooted at a Responsible Party, expressed as W3C Verifiable Credentials), and *what was done* (signed proof for audit trails). The protocol uses Decentralized Identifiers (DIDs) for agent identity, W3C Verifiable Credentials for delegation, Ed25519 signatures for cryptographic operations, and StatusList2021 for revocation. --- ## Conformance Keywords The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119]. --- ## Status **Stable 1.0.0** — Donated to DIF TAAWG (Decentralized Identity Foundation, Trusted AI Agents Working Group) and ratified as a DIF standard. The wire format is stable: a change that breaks compatibility with this version ships in a major version. A fix for a security weakness may ship in a minor version even when it refuses what this version accepted. [SPEC-CHANGES.md](./SPEC-CHANGES.md) lists every edit since the ratified text, and marks each edit that refuses what that text accepted. --- ## 1. Motivation The Model Context Protocol (MCP) defines a standard interface for AI agents to interact with tools and resources. However, MCP lacks an identity layer, creating several security vulnerabilities: 1. **Agent Impersonation**: Without identity verification, any process can claim to be a particular agent. Malicious actors can impersonate trusted agents to gain unauthorized access to sensitive tools. 2. **Prompt Injection with Forged Identity**: Attackers can inject prompts that include fabricated identity claims. Without cryptographic verification, servers cannot distinguish legitimate identity assertions from forged ones. 3. **No Delegation Chain**: When Agent A delegates to Agent B, there is no standard mechanism to prove the delegation occurred or verify the delegation constraints. This prevents secure hierarchical agent architectures. 4. **No Audit Trail**: Tool calls leave no cryptographic evidence of what was requested, what was returned, or who was responsible. This makes compliance, debugging, and incident response difficult. 5. **Replay Attacks**: Without nonce-based session establishment, captured tool call payloads can be replayed by attackers. DIDs and Verifiable Credentials are the right fit for this problem: - **DIDs** provide decentralized, cryptographically-verifiable identifiers that agents control. They do not require a central authority and support multiple resolution methods (did:key for ephemeral, did:web for persistent organizational identity). - **Verifiable Credentials** provide a W3C standard for expressing cryptographically-signed claims. Delegation credentials can express scope constraints, temporal bounds, budget limits, and revocation status in an interoperable format. - **EdDSA/Ed25519** provides high-performance, deterministic signatures suitable for high-throughput agent interactions with no reliance on hash function collision resistance. --- ## 2. Terminology | Term | Definition | |------|------------| | **Agent DID** | A Decentralized Identifier (DID) that uniquely identifies an AI agent. KYA-OS supports `did:key` (self-certifying, ephemeral) and `did:web` (organization-hosted, persistent). | | **Principal** | The entity that immediately delegates authority to an agent — typically the human operator who launches the agent for a task. The Principal MAY or MAY NOT be the Responsible Party. In personal-use scenarios they are usually the same; in organizational scenarios they differ. | | **Responsible Party** | The entity ultimately accountable for the actions of an agent operating under a delegation chain. The Responsible Party is the root issuer of the chain (`issuerDid` of the root `DelegationCredential`). In personal use, the Responsible Party equals the Principal. In organizational use, the Responsible Party is the employing organization or parent entity while the Principal is the immediate human delegator within that organization. Reputation and accountability signals are scoped primarily to the Responsible Party rather than to an agent's ephemeral identity — "can this be trusted?" is ultimately a question about the accountable party. | | **Delegation Chain** | An ordered sequence of Delegation Credentials from a root delegator (the Responsible Party) to the current agent, where each credential's subject is the next credential's issuer. | | **Delegation Credential** | A W3C Verifiable Credential that grants specific permissions from an issuer (delegator) to a subject (delegate). Contains CRISP constraints defining allowed operations. | | **Detached Proof** | A JWS (JSON Web Signature) that cryptographically binds a tool request and response together, enabling non-repudiation and audit. Attached to responses under the reverse-DNS key `org.kya-os/response-proof` within the MCP `_meta` field (prior keys `org.kya-os/proof` and bare `proof` accepted for backward compatibility; see §7.6). | | **CRISP Constraints** | **C**onstraints, **R**esources, **I**dentity, **S**cope, **P**olicy — a structured envelope defining what operations a delegation permits: allowed scopes, budget caps, temporal bounds, and audience restrictions. | | **Session** | An OPTIONAL, validated, time-bounded convenience context established through the `handshake` action of the `_kyaos` tool (§14). Sessions aid replay prevention and provide a stable context for proof generation, but are **not** the durable authority: the per-request detached-JWS proof (§7) and DID-anchored grant (§6) are (see §5 preamble). KYA-OS sessions are independent of MCP's session, which was removed in MCP 2026-07-28 (SEP-2567/SEP-2575). | | **Handshake Nonce** | A cryptographically random value provided by the client during session establishment. Used once; prevents replay attacks. | | **Audience** | The intended recipient of a credential or proof, typically the MCP server's DID or domain. Prevents credential/proof misuse across different servers. | --- ## 3. Protocol Overview The following diagram illustrates the KYA-OS protocol flow: ``` ┌─────────────────┐ ┌─────────────────┐ │ Client Agent │ │ MCP Server │ │ (did:key:z...) │ │ (did:web:srv) │ └────────┬────────┘ └────────┬────────┘ │ │ │ ┌──────────────────────────────────────────┐ │ │ │ 1. HANDSHAKE REQUEST │ │ │ │ - nonce: <22-char base64url> │ │ │ │ - audience: "did:web:srv" │ │ │ │ - timestamp: │ │ │ │ - agentDid: "did:key:z6Mk..." │ │ │ │ - clientProtocolVersion: "1.0" │ │ ├──┴──────────────────────────────────────────┴──► │ │ │ ┌─ Validate: │ │ │ • timestamp within ±120s │ │ │ • nonce not seen before │ │ │ • audience matches server DID │ │ │ • version of this major (§13) │ │ └──────────────────────────────────────┤ │ │ │ ┌──────────────────────────────────────────┐ │ │ │ 2. HANDSHAKE RESPONSE │ │ │ │ - sessionId: "kyaos_" │ │ │ │ - serverDid: "did:web:srv" │ │ │ │ - protocolVersion: "1.0" │ │ │ │ - sessionTtl: 1800 │ │ ◄──┴──────────────────────────────────────────┴──┤ │ │ │ ┌──────────────────────────────────────────┐ │ │ │ 3. TOOL CALL REQUEST │ │ │ │ method: "tools/call" │ │ │ │ params: │ │ │ │ name: "read_file" │ │ │ │ arguments: { path: "/etc/hosts" } │ │ │ │ _meta: │ │ │ │ org.kya-os/session: "kyaos_..." │ │ │ │ org.kya-os/delegation-credential: │◄── Optional │ │ │ │ ├──┴──────────────────────────────────────────┴──► │ │ │ ┌─ Process: │ │ │ • Resolve session (if named) │ │ │ • Verify delegation (if present) │ │ │ • Execute tool │ │ │ • Generate detached proof │ │ └──────────────────────────────────────┤ │ │ │ ┌──────────────────────────────────────────┐ │ │ │ 4. TOOL CALL RESPONSE │ │ │ │ content: [ { type: "text", ... } ] │ │ │ │ _meta: │ │ │ │ org.kya-os/response-proof: │ │ │ │ jws: "eyJhbGciOiJFZERTQSI..." │ │ │ │ meta: │ │ │ │ did: "did:web:srv" │ │ │ │ kid: "did:web:srv#key-1" │ │ │ │ ts: 1710288000 │ │ │ │ nonce: "..." │ │ │ │ requestHash: "sha256:..." │ │ │ │ responseHash: "sha256:..." │ │ ◄──┴──────────────────────────────────────────┴──┤ │ │ ▼ ▼ ``` --- ## 4. Agent Identity ### 4.1 Supported DID Methods KYA-OS implementations MUST support: | Method | Use Case | Resolution | |--------|----------|------------| | `did:key` | Ephemeral agents, development, testing | Local derivation from public key bytes | | `did:web` | Production servers, organizational identity | HTTPS fetch of `/.well-known/did.json` or path-based document | Implementations MAY support additional DID methods. `did:cheqd` support, when implemented, MUST be additive: it MUST NOT replace or weaken existing `did:key` or `did:web` behavior, and it MUST NOT make cheqd resolution mandatory for deployments that have not configured it. ### 4.2 Key Material KYA-OS uses Ed25519 (EdDSA over Curve25519) for all cryptographic operations: - **Key Size**: 32-byte private seed, 32-byte public key - **Signature Size**: 64 bytes - **Algorithm Identifier**: `EdDSA` (in JWS headers) - **JWK Key Type**: `OKP` (Octet Key Pair) - **JWK Curve**: `Ed25519` > **Terminology.** This specification uses _secret key_ for the private half of a > key pair, following current cryptographic convention. _Private key_ is synonymous > and is retained where referenced standards use it (e.g. PKCS#8, JWK). An agent's key pair MUST be generated by the agent or its designated custodian. The secret key MUST NOT be generated by, transmitted to, or escrowed with any registration, DID, directory, or reputation service; such services receive only the public key (as the DID document or an indexing record). For `did:key` this holds by construction — the DID is derived locally from the public key (§4.3) and no service participates in creation. For `did:web`, the controller publishes only the public key in the DID document (§4.4). A key-management proxy or HSM that holds the secret key on the agent's behalf (key custody, §11.0) is part of the agent's own trust boundary and is distinct from the shared services this requirement constrains. ### 4.3 did:key Derivation A `did:key` DID is derived from an Ed25519 public key as follows: 1. Prepend the Ed25519 multicodec prefix `0xed01` to the 32-byte public key 2. Encode the result using base58btc 3. Prepend the multibase prefix `z` 4. Construct the DID: `did:key:z` Example: ``` Public Key (hex): 8076ee2cfc1a...32 bytes... Multicodec: ed01 + 8076ee2cfc1a... Base58btc: 6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK DID: did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK ``` The verification method ID is `#`: the fragment repeats the `z`-prefixed multibase value, as the W3C did:key method defines it. For the example above: ``` did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK ``` This fragment identifies the Ed25519 verification method; `#keys-1` does not. A `did:key` document may also carry an X25519 `keyAgreement` method derived from the same key; its fragment is the X25519 key's own multibase value (`#z6LS…`). ### 4.4 did:web Resolution A `did:web` DID resolves to a DID Document via HTTPS: | DID | Resolution URL | |-----|---------------| | `did:web:example.com` | `https://example.com/.well-known/did.json` | | `did:web:example.com:agents:bot1` | `https://example.com/agents/bot1/did.json` | The DID Document MUST contain at least one verification method with `publicKeyJwk` in Ed25519 format: ```json { "id": "did:web:example.com", "verificationMethod": [{ "id": "did:web:example.com#key-1", "type": "Ed25519VerificationKey2020", "controller": "did:web:example.com", "publicKeyJwk": { "kty": "OKP", "crv": "Ed25519", "x": "" } }], "authentication": ["did:web:example.com#key-1"], "assertionMethod": ["did:web:example.com#key-1"] } ``` ### 4.4.1 Optional did:cheqd Resolution and Registrar Writes A KYA-OS implementation MAY support `did:cheqd` as an additional resolvable DID method. `did:cheqd` resolution MUST be explicit opt-in through a configured resolver endpoint, such as `https://resolver.cheqd.net/1.0/identifiers/{did}`. Resolution failures MUST fail closed and MUST NOT fall back to accepting an unresolved key. Resolvers SHOULD accept both raw DID Documents and Universal Resolver-style DID Resolution Results containing `didDocument`. They MUST reject malformed `did:cheqd` values, HTTP or transport failures, invalid JSON, malformed DID Documents, and DID Document `id` mismatches by returning no document. KYA-OS deployments that expose cheqd support SHOULD use the generic DID method resolver registry rather than a vendor-specific core config block: ```ts didResolvers?: Record< string, DIDResolver | ((fetchProvider: FetchProvider) => DIDResolver) >; didResolvers: { cheqd: cheqdResolver({ resolverUrl: 'https://resolver.cheqd.net' }), } ``` cheqd-specific resolver URL, cache, and header settings live in the cheqd resolver factory or integration module, not in core middleware/provider configuration. Registrar URLs are for explicit operator/admin write flows only. Runtime proof generation and normal MCP tool-call handling MUST NOT create, update, or publish cheqd ledger entries. Updates to cheqd DID Documents and DID-Linked Resources SHOULD use cheqd DID Registrar's client-managed-secret flow for `/create`, `/update`, and `/{did}/create-resource`: the registrar returns a `jobId` and serialized payload, the controller signs the serialized payload locally, then the client submits `secret.signingResponse` back to the registrar. Secret keys MUST NOT be transmitted to the registrar. Signing MAY be delegated to a KMS/HSM-backed signer hook. Local Ed25519 helpers MUST keep key material inside the caller's trust boundary and send only signatures to the registrar. Mainnet deployments SHOULD run or contract against their own fee-payer registrar deployment. Public or staging registrar endpoints SHOULD be treated as testnet-only unless the operator has an explicit mainnet service agreement. When linking an existing `did:web` identity to a `did:cheqd` identity, verifiers SHOULD require bidirectional `alsoKnownAs` linkage: 1. Resolve the `did:web` DID Document. 2. Resolve the `did:cheqd` DID Document. 3. Confirm the `did:web` document lists the `did:cheqd` DID in `alsoKnownAs`. 4. Confirm the `did:cheqd` document lists the `did:web` DID in `alsoKnownAs`. `did:web` remains canonical unless an operator explicitly publishes reciprocal linkage. `alsoKnownAs` values on DID Documents MUST be strings. Resource metadata aliases, where supported by a registrar, use a different resource-specific shape and MUST NOT be accepted as DID Document `alsoKnownAs` entries. Selected durable artifacts MAY be anchored as cheqd DID-Linked Resources under the `did:cheqd` subject. Supported KYA-OS DLR artifact categories are: | Artifact | Purpose | |----------|---------| | `CapabilityManifest` | Durable description of agent/tool capabilities and outputs | | `ConformanceManifest` | Durable statement of protocol profiles and checks satisfied | | `AccessHashManifest` | Durable hashes of off-chain policy/access artifacts | | `TrustConfigManifest` | Durable trust policy, accepted DID methods, and linkage requirements | DLR content SHOULD be canonicalized before hashing, and content hashes SHOULD use `sha256:<64 lowercase hex characters>`. Updating a DLR means publishing a new resource version in the same resource collection/name/type; prior content is not overwritten. High-volume runtime events, raw operational logs, normal tool-call proofs, and frequently changing metadata MUST remain off-chain. Out of scope for this specification section: external registry changes, reputation VC snapshot publication, status-list backend hosting, KYC/KYB issuance, and replacing `did:web` as the canonical identity. ### 4.4.2 Reference Implementation Resource Policy **Reference implementation (non-normative).** This section describes limits of the reference implementation, not requirements of this specification, and not limits of DID syntax. The reference implementation refuses DID resolution and status-list inputs over the limits below, and never cuts an identifier, a document or a list to fit: | Resource | Limit | | --- | --- | | DID: the one resolved, a document's `id` and a listed method's `controller` | 2,048 UTF-16 code units | | Key identifier: the one a proof names, a listed method's `id` and a relationship reference | 4,096 UTF-16 code units | | did:web response | 1,048,576 decompressed UTF-8 bytes | | cheqd resolver response, a bare document or a DID Resolution Result | 4,194,304 decompressed UTF-8 bytes, 65 containers deep, 131,072 object members in all | | DID document | 1,048,576 bytes of compact JSON in UTF-8 | | JSON nesting / object member name | 64 containers / 256 UTF-16 code units, decoded | | JSON object members | 8,192 in all, counting duplicate names before parsing | | Entries of `verificationMethod` and the five verification relationships | 8,192 in all | | Status-list response | 1,048,576 decompressed UTF-8 bytes, under the same JSON nesting, member name and member limits as a DID document | | Fetch and body consumption | One deadline for each DID resolution and each status-list read: 5 seconds, unless the host sets another as `dependencyTimeoutMs` | | One check of a delegation chain | 30 seconds for the chain's resolution, every credential's verification and every status or revocation answer together, unless the host sets another as `totalTimeoutMs`; the number of credentials is not limited unless the host sets `maxChainLength` | | Redirects a did:web, status-list or cheqd resolver read follows | 3 | | Each built-in network resolver's cache | 128 documents and 8 MiB of compact JSON, plus its TTL, evicting the least recently used | In a document, the identifier limits apply to its `id` and to each entry of `verificationMethod` and the five verification relationships: an embedded method's `id` and `controller`, and a reference to a method. Every other identifier a document may carry, such as its top-level `controller`, its `alsoKnownAs` entries and the members of a service, is bounded only by the document's byte, nesting and member limits. DID syntax sets no length limit, and some valid DIDs are longer than 2,048 UTF-16 code units: a did:key for a post-quantum key, such as an ML-DSA-65 or ML-DSA-87 public key (about 2,680 and 3,550 characters), and a did:peer:2 that lists many keys or services. The reference implementation refuses such a DID before it asks any resolver, so it verifies no credential or proof that such a DID issued. `RuntimeFetchProvider.resolveDID` asks a resolver configured for the DID's method first, and falls back to its built-in did:web or did:key resolver only when the configured one finds no document: not after it returns a document these limits refuse, nor after it misses the deadline. One deadline covers the configured resolver and the fallback; a fallback read the deadline abandons ends by its own deadline. The built-in readers count the bytes they receive after content decoding, never trusting `Content-Length`, and check JSON nesting and members before `JSON.parse`. The pinned connection the reference implementation makes on Node asks for gzip alone, with the `Accept` and `User-Agent` the runtime's `fetch` sends, decodes a gzip body under the same cap, and refuses a body in any other content coding. They refuse a non-2xx response whatever its body, and a body that is not valid UTF-8. A refusal names the URL by its origin and path alone, never the credentials before its host, its query or its fragment, where an operator may keep a key. They cancel a refused response, and refuse one that sends more than 64 empty body chunks. A response buffer grows with the bytes received, up to the cap, so a stalled read does not reserve the whole cap. A read that misses its deadline fails with that deadline's own reason, such as `DID resolution deadline exceeded`. A response whose `body` is a WHATWG `ReadableStream` is read as it streams, never through its `text()` or `json()`, which hold the whole body before the reader can count it. A custom `FetchProvider` may return a response whose body is not one, such as a response with no body, or one whose body is the Node stream that node-fetch v2 returns. The reader reads such a response through its `text()`, which must answer a string, or, when it has none, through its `json()`, whose value it reads as the JSON text `JSON.stringify` writes for it, and it refuses a response with neither, and a value that has no JSON text. It waits for that answer within the read's one deadline, counts the UTF-8 bytes of the text against the same byte cap, and holds the text to the same JSON limits before it parses it. The provider has by then held the whole body, so only the provider bounds what that costs. A status list a publisher writes holds at least 131,072 entries, 16 KiB, under both StatusList2021 and Bitstring Status List 1.0, GZIP-compressed and encoded in its credential as §6.6 states; during 1.x a reader also reads a shorter list (§6.6). An incompressible list of that minimum encodes to about 22 KB, and 1 MiB holds an incompressible list of about 6.3 million entries, 48 times the minimum; a list with few entries set compresses to a few hundred bytes. A credential's status list is read only after the credential's own signature has verified, and in a delegation chain only after the chain's links have been checked, so a credential that merely names an issuer causes no status read. `DelegationCredentialVerifier` reports a status it did not read as not checked: when the signature fails, its result's `checks` has no `statusValid`. The cheqd resolver asks for the DID document alone, with `Accept: application/did+ld+json` in place of any `Accept` header the application configures, which the cheqd DID resolver answers without resolution metadata. It still accepts a DID Resolution Result, whose `didDocumentMetadata` lists every resource the DID has published, within the larger response limits above, and the document inside it meets every document limit. It resolves the application's `headers` within the read's one deadline, so a headers function that never answers ends that resolution at the deadline. It follows a redirect from its endpoint as a did:web read does, below, so a redirect to another origin carries none of those `headers` but the CORS-safelisted ones; since the operator names the resolver, a private or local host is admitted for it and for each redirect. Every did:web read, by the delegation gate, `DidWebResolver`, `createDidWebResolver` or `RuntimeFetchProvider.resolveDID`, and every status-list read, by `CheqdStatusListResolver` or `RuntimeFetchProvider.fetchStatusList`, goes through one private-network rule, whatever `FetchProvider` it is given. Before any request, the rule refuses a URL that is not an absolute http or https URL. It refuses a URL that includes credentials, a user name or a password before its host, first or redirected, operator-named or not, as the runtime's `fetch` refuses one; `SafeFetch` refuses it too, and neither refusal echoes them. A status-list read also refuses an http URL, first or redirected, on a private host and under `allowPrivateNetworkHosts: true` too, since over http an on-path party can replay an older signed list from before a revocation (§6.6). It reads http only at an exact URL the operator's `statusListIssuers` binds, given to `RuntimeFetchProviderOptions`, on any host but never for a redirect, and from a private or local host under `development: true`, as a local deployment serves its lists. `createRevocationChecker`, which reads through `SafeFetch`, holds a list to the same rule: it reads http only at an exact URL its own `statusListIssuers` binds, on any host but never for a redirect. Unless the provider's `allowPrivateNetworkHosts` is `true`, or the reader was built with `development: true`, it also refuses a URL whose host is a non-public IP literal or a local name, in any case and with any trailing dots. A local name is a single label, such as `ip6-localhost` or `metadata`, which a resolver completes through its search domains to a host on the local network. It is also `localhost` (RFC 6761 §6.3), `localdomain`, `localdomain6`, `local` (RFC 6762), `internal`, which is reserved for private use, or `home.arpa` (RFC 8375), or a name under one of them, such as `localhost.localdomain`, `localhost6.localdomain6` or the cloud metadata names `metadata.google.internal` and `instance-data.ec2.internal`. It classifies an IP literal as `SafeFetch` classifies a resolved address, so an IPv4-mapped, IPv4-translated or NAT64 form of a private address is refused as that address is. Where the provider makes its connections for the rule and the runtime resolves names, as `RuntimeFetchProvider` does on Node, each request, every redirect included, also resolves its host once before it connects, is refused when any address the host resolves to is not public, classified as above, and is connected only to the addresses it checked, each tried in turn when the one before cannot be reached, pinned, so a second lookup cannot move it, over a connection no other request shares, so no socket another request left open, to whatever address, carries it. A provider whose `fetch` is its own, a subclass of `RuntimeFetchProvider` included, makes its own connections, and a runtime that resolves no name, such as a Cloudflare Worker or a browser, has no address to check, so their reads are held to the URL alone, and a verifier needs an egress control that refuses private addresses for a public name that points at one. A runtime resolves no name only where `node:dns` does not load or its `lookup` says it is not implemented; any other failure of the lookup that asks, such as a resolver busy for a moment, leaves the read to resolve its own host, and to fail if that fails too, and is asked again on the next read. Each fall back to the URL alone is logged once per process for each reason. So is a request the runtime's `fetch` sends through a proxy: where Node's global dispatcher is undici's `ProxyAgent`, or its `EnvHttpProxyAgent`, which Node installs itself under `NODE_USE_ENV_PROXY=1`, for a URL it sends through the proxy set for the URL's scheme, `RuntimeFetchProvider` reads through that `fetch`, held to the URL alone, and warns once that the proxy must refuse private and local addresses itself. A URL the `EnvHttpProxyAgent` sends straight to its host, because no proxy is set for its scheme or `NO_PROXY` names the host, is read pinned, and so is a request under any other dispatcher, such as undici's `Agent`, a subclass of it, a `RetryAgent` or a `MockAgent`: a dispatcher the provider cannot read never turns the check off. Either proxy agent counts only where it dispatches as its class does: one composed with interceptors, which may resolve the host and connect on their own, is read as any other dispatcher. Deciding makes no request and opens no connection. An application whose own dispatcher sends requests through a proxy passes `transport: fetchTransport`, which makes each checked request through `fetch` by the host's name. A lookup given to `RuntimeFetchProviderOptions` is still used, proxy or not. A name that resolves to a private address is learned from the network, so the refusal tells the presenter only that the DID or the list could not be read, with the code and the `transient` a name that does not resolve gets, `did_unavailable` for a DID and `status_unavailable` for a list, both transient: a code that told the two apart would tell whoever chose the name which names the verifier's DNS answers with a private address. The log says `host_refused` and names the host and the address. The hosts the operator names are its own, and are read wherever they are, through the provider's own `fetch`: the did:web documents of the DIDs given as `trustedRootIssuers` to `DidWebResolverOptions` or `RuntimeFetchProviderOptions`, which the middleware passes on from its own, and the status lists at the URLs and https origins `statusListIssuers` binds, given to `RuntimeFetchProviderOptions`. A URL is the operator's only as the operator wrote it, byte for byte, as `statusListIssuers` binds a list's URL to its issuer (§6.6), so a presenter who writes a bound URL in another spelling that parses to the same URL, such as its host in upper case or a `/./` in its path, has that read held to the rule. A redirect is matched as the URL parser writes the URL it resolves to, so a binding written in another form, such as `https://lists.example:443/list`, binds a status entry that names it so but no redirect. A reader takes such a binding, as §6.6 does, and says once, when it is configured, which form a redirect reaches; it says once as well of a binding no read reaches, one that includes credentials or does not parse. The provider reads those hosts through its own `fetch`, neither resolved nor pinned: the operator chose them, and that `fetch` carries what the application configures for its own hosts, such as client certificates or a proxy. The scheme rule, the checked redirects, the byte caps and the deadlines still hold for them. Each request of a read is decided on the URL it asks for, as `SafeFetch` decides its `allowOrigins`: a request for a URL the operator names is read wherever its host is, and a redirect from it to any URL the operator does not name, an open redirect on the operator's own host included, is held to the rule, resolved, checked and pinned. The reference implementation's status-list checker, `createRevocationChecker`, reads through `SafeFetch` instead, and reads as the operator's own, on any host and still pinned to the addresses it looked up, the lists at the URLs and origins its `statusListIssuers` binds and the list a pinned root's own credential names (§6.6, rule 3), the latter over https alone, since the root's credential names it and the operator does not, and only once that credential's proof has verified: once `evaluateDelegationChain` has verified every hop proof with `verifyHopProof`, `verifyRequestDelegation` or `requireDelegation` has verified them, or `verifyCard`'s accountability check has verified the Card's responsible party as that root. It reads the root's list so only at the root's own host: the https origin, host and port, its did:web DID names, written as an origin binding is (§6.6). A root's word reaches no further than its own host, so its list on any other private host, and every list of a root with no host of its own, such as a did:key root, is read as any URL a presenter names unless `statusListIssuers` binds it. A pinned root is one the operator names, as the `resourceOwner` or in `trustedRootIssuers`, on every path: `verifyCard` takes its own `trustedRootIssuers`, since an accountability verifier that accepts any root, as `verifyRequestDelegation` does under `allowAnyRootIssuer`, lets the presenter be the root and choose the URL, and a root no pin names has its list read as any URL a presenter names. Until then the presenter of the chain wrote that URL, so a credential that names the pinned root as its issuer, but whose proof did not verify or was not checked, has its list read as any URL a presenter names is. It decides each request on its own URL, as `SafeFetch` decides its `allowOrigins`, so a redirect from one of those URLs to any URL that is not one of them is held as a URL a presenter named. `development: true` is an option of `DidWebResolverOptions`, of `CheqdStatusListResolverOptions` and of the middleware's `KyaOsConfig`, which `withKyaOs` passes on, and on the middleware it holds for every resolver and reader the middleware builds, whatever its provider. It admits non-public IP literals, local names and names that resolve to private addresses as `allowPrivateNetworkHosts: true` does, for a local deployment whose parties run on names such as `*.localhost`, and reads a status list over http from a private or local host, which `allowPrivateNetworkHosts: true` does not, and changes nothing else: the checked redirects, the byte caps and the deadlines all hold. It is for development alone: set while `NODE_ENV` is `production`, it throws when what it is set on is built, naming the setting, so a deployment that must read a private host in production gives its provider `allowPrivateNetworkHosts: true` instead. Each read asks its provider not to follow redirects (`redirect: "manual"`) and follows at most 3 itself, within the one deadline, holding each target to the same rule and refusing a step from https down to http. A redirect to an origin other than the first carries only the CORS-safelisted request headers `Accept`, `Accept-Language` and `Content-Language`, when the Fetch standard safelists their values, and the request's cache directives `Cache-Control` and `Pragma`, which carry no credential, and drops every other header. A provider that passes `redirect` on to its request keeps every request to hosts the rule admits. A provider that drops it lets its runtime follow a redirect, making the request before the reader sees the response. The reader then refuses, unread, a response that says it was redirected or names a URL other than the one requested; it cannot undo the request, nor detect a provider that reports neither. In a browser, which hides where a redirect leads, every redirect is refused. Before a verifier calls a resolver it checks the DID and key identifier limits, it waits at most 5 seconds, or the time the host set, for the resolver's promise, and it checks the document returned before it selects a key. That check walks the document as plain JSON data: it refuses cycles, an accessor on an object member, enumerable or not, sparse arrays, enumerable symbol keys, objects other than arrays and plain objects of any realm, and values JSON cannot hold, and it never calls an object member's getter or `toJSON`. It reads array elements as values, since a descriptor read for each index costs several times as much. So a getter on an array index is not refused: it runs once, as the application code it is, like a Proxy trap, and the walk measures the value it returns, or refuses the document when it throws. It skips an object member that is a data member but not enumerable, or whose value is `undefined`, as `JSON.stringify` does, and measures the document's compact JSON size in UTF-8 without serializing it. A returned document, including one from a custom `FetchProvider.resolveDID`, must have an `id` that is a DID, a string that starts with `did:`, within the DID limit. A document a built-in resolver parses is walked once, frozen and branded, so neither its cache nor a verifier walks it again and no caller can change it; a verifier knows it by that brand, whichever provider, subclass or wrapper returns it. Any other document is walked on each resolution, and the walk copies what it measures, each own enumerable data member and each array element by index, read once, into plain objects and arrays that it freezes and brands as it does a parsed document. A verifier reads that copy, and so does a caller of a `RuntimeFetchProvider` that returns it from a configured resolver, so what is read is what was measured, whatever the resolver's object inherits, answers a second time or becomes afterwards; the resolver's own object is neither frozen nor changed. Concurrent resolutions of one DID by one built-in resolver share one fetch until the resolution deadline; a fetch still pending then is dropped, so the next resolution starts a fresh one. A custom resolver remains responsible for bounding its own network, parsing and CPU work. A promise deadline cannot interrupt synchronous JavaScript, or cancel a callback that ignores cancellation. A hosting application must also bound incoming MCP request bodies and how many resolutions run at once. These limits bound exposure; they do not make `JSON.parse` linear-time or bound the heap to 8 MiB in total. Selecting a key from a document takes work linear in the document's size, within these limits or not. ### 4.5 Agent-Controlled Key Generation An agent MUST generate its own keypair locally. No other party generates, holds, escrows, or otherwise gains access to an agent's secret key at any point: 1. The agent generates an Ed25519 keypair (§4.2) using a local CSPRNG. 2. The agent derives its DID from the public key (`did:key`, §4.3) or publishes a DID document referencing the public key (`did:web`, §4.4). 3. Where a DID document is registered or published through a service, the agent signs the registration request with its secret key. 4. The service verifies the signature and publishes the document. It receives the public key only. A registry (§6.8), verifier, or any registration or provisioning service MUST NOT generate, escrow, or otherwise gain access to an agent's secret key. This invariant keeps identity infrastructure from becoming a centralized key escrow: a compromise of a registry or verifier MUST NOT yield agent secret keys (see §11.11). Implementations that generate or hold agent secret keys on the agent's behalf are non-conformant. --- ## 5. Session Lifecycle > **Normative framing (MCP 2026-07-28).** The KYA-OS session described in this > section is an **OPTIONAL convenience layer**, not the protocol's durable source > of authority. The **normative, durable authority** for every KYA-OS interaction > is (a) the per-request **holder-of-key proof** the caller signs over the call, > which is self-contained and replay-bound on its own: the holder proof of §14, a > detached proof (§7.4) by the delegation's subject (§11.8), or the Entity Card > request proof (SPEC-ENTITY-CARD §8); and (b) the **DID-anchored > delegation grant** (§6). A conformant verifier MUST be able to authorize and > audit a request from the proof and grant alone, with no server-side session > state. > > This independence is deliberate. MCP 2026-07-28 removed `initialize`/ > `initialized` (SEP-2575) and the `Mcp-Session-Id` header (SEP-2567), making the > MCP core stateless: every request is self-contained, and client info, version, > and capabilities ride in `_meta` per request. KYA-OS sessions are **KYA-OS's > own layer**: they are established through the `_kyaos` tool's `handshake` action (§14), independent of > MCP's now-removed session, and exist only as a **transport/UX convenience** > (e.g. for wallet-less clients, nonce bookkeeping, and a stable context for proof > generation). They are an *application-state handle* in the SEP-2575 sense: > explicit and model-visible, never hidden server state on which authorization > silently depends. > > The `sessionId`/`nonce` carried in a proof (§7.2) therefore bind a proof to its > originating handshake for replay defense; they are **not** a substitute for > verifying the proof signature and the delegation chain. The mechanics below > remain valid where a session is used. ### 5.1 Handshake Request To establish a session, the client sends a handshake request: ```typescript interface HandshakeRequest { nonce: string; // At least 16 random bytes, base64url without padding (22 chars or more) audience: string; // The server's DID timestamp: number; // Unix epoch seconds agentDid?: string; // Client's DID: a claim, since the handshake is unsigned clientInfo?: { // Optional client metadata name: string; version?: string; platform?: string; }; clientProtocolVersion?: string; // The version the client speaks, "1.0" (§13) } ``` The client calls the `_kyaos` tool with `action: "handshake"` beside these members as its arguments (§14). The handshake request is those arguments without `action`, as `schemas/handshake-request.json` describes it. ### 5.2 Validation Rules The server MUST validate the handshake request. It checks the protocol version first, and refuses a request of another major version with `protocol_version_unsupported` before it reads the rest (§13). 1. **Timestamp Skew**: `|server_time - request.timestamp| <= 120 seconds` - Reject if outside this window - Remediation: "Check NTP sync on client and server" 2. **Nonce Uniqueness**: The (nonce, agentDid) pair MUST NOT have been seen before - Reject with "Nonce already used (replay attack prevention)" - Nonces MUST be retained for at least the acceptance window of rule 1, as §5.5 specifies; retention is not tied to the session TTL - When `agentDid` is omitted, the dedupe key is `nonce` alone. Servers MAY keep a shorter minimum retention for anonymous nonces than for authenticated ones (for example 60 and 120 seconds), never below what §5.5 requires 3. **Audience Match**: `request.audience` MUST equal the server's DID, character for character - Prevents credential forwarding attacks - A domain is not the server's DID: `mcp-server.example.com` does not match `did:web:mcp-server.example.com` 4. **Nonce Form**: `request.nonce` SHOULD be at least 22 base64url characters, as §5.1 says - A 1.x server MAY accept a shorter nonce; 2.0.0 refuses one ### 5.3 Session Creation On successful validation, the server creates a session: ```typescript interface SessionContext { sessionId: string; // Format: "kyaos_" audience: string; // Echoed from request nonce: string; // Echoed from request timestamp: number; // Request timestamp createdAt: number; // Server timestamp at creation lastActivity: number; // Updated on each request ttlMinutes: number; // Default: 30 agentDid?: string; // Client DID if provided serverDid?: string; // Server's DID identityState: 'anonymous' | 'authenticated'; // 'anonymous' for every session a handshake opens } ``` A session a handshake opens is `anonymous`, with or without an `agentDid`: the handshake is unsigned, so its `agentDid` is a claim the server records and not an identity it has verified. The server answers a handshake with a JSON object, sent as the text of the first content item of the tool's result: | Member | In | Value | |---|---|---| | `success` | every response | `true` when the session is opened, `false` for a refusal | | `protocolVersion` | every response | the protocol version the server speaks (§13) | | `sessionId` | an acceptance | the session's id, which the client names on its calls (§5.6) | | `serverDid` | an acceptance | the server's DID | | `serverKid` | an acceptance | the verification method of `serverDid` the server signs its proofs with | | `sessionTtl` | an acceptance | the session's idle timeout, in seconds (§5.4) | | `error` | a refusal | `{ code, message, remediation? }`, with a code of Appendix A | A refusal also sets the tool result's `isError`. `schemas/handshake-response.json` describes an acceptance. ### 5.4 Session TTL and Expiry - **Idle Timeout**: Sessions expire after `ttlMinutes` of inactivity - **Absolute Lifetime**: Implementations MAY enforce a maximum session lifetime - **Activity Update**: `lastActivity` is updated on each valid request ### 5.5 Replay Prevention The nonce cache implementation MUST: - Store (nonce, agentDid, expiry) tuples - Support TTL-based automatic expiry - Be atomic to prevent race conditions in concurrent environments - For distributed deployments: use a shared store with an atomic conditional insert and expiry, such as Redis `SET NX PX`, a DynamoDB conditional write or a Durable Object transaction (not in-memory). Eventually consistent stores such as Cloudflare Workers KV cannot provide the atomic check-and-set on their own. **Retention.** A verifier MUST retain each admitted nonce at least until the timestamp it was admitted with leaves the acceptance window on the verifier's clock: until `ts + skew`, plus a margin of at least one second for second-granularity timestamps. `ts` is the handshake `timestamp` or the proof's `ts`, and `skew` is the largest timestamp skew the verifier may apply while the nonce is retained; a verifier that can widen its skew at runtime (§10.1) retains for the widest. Servers MUST NOT evict a nonce before its retention ends, to prevent replay via early eviction. Verifiers MAY retain longer, and a verifier whose clock can be stepped backwards SHOULD add the largest expected step to the margin. Retention is bounded by the acceptance window, not by the session TTL. A nonce presented after its window is rejected on its timestamp (§5.2 rule 1, §11.3) before the cache is consulted, so keeping it longer adds memory and denial-of-service exposure and no replay protection. The bound holds because every nonce-checked path checks a timestamp window in the same verification: the handshake (§5.2), the detached proof and the holder-binding request proof (`ts` within skew, signed with the nonce, §7.4), and the Entity Card proof (`created`/`expires`, SPEC-ENTITY-CARD §8). The handshake request is unsigned, so a replayed handshake gives its sender nothing that a fresh handshake would not; its nonce check deduplicates and follows the same window. A path that checked a nonce without a timestamp window would have to retain the nonce for as long as the message it protects stays valid. ### 5.6 Naming the Session on a Call A client that has a session names it on each tool call, in `params._meta["org.kya-os/session"]`, as §14 says. A session is OPTIONAL: a server serves a call that names none as it serves any other, and a call with no session is authorized by its delegation and proofs alone, as this section's preamble requires. Naming a session authorizes nothing either: the session a call names is the caller's claim, and chooses no more than where the server would prove a call that names none (§14). --- ## 6. Delegation ### 6.1 DelegationRecord Structure Internal representation of a delegation: ```typescript interface DelegationRecord { id: string; // Unique delegation identifier issuerDid: string; // DID of the delegator subjectDid: string; // DID of the delegate controller?: string; // DID that can revoke this delegation vcId: string; // URN of the Verifiable Credential parentId?: string; // Parent delegation ID (for chains) parentCredentialDigest?: string; // §7.8 digest of the parent credential (optional, §6.2) constraints: DelegationConstraints; signature: string; // Extracted from VC proof status: 'active' | 'revoked' | 'expired'; createdAt?: number; revokedAt?: number; revokedReason?: string; metadata?: Record; } ``` ### 6.2 DelegationCredential as W3C VC > **Note:** A Delegation credential is itself a W3C Verifiable Credential. The Delegation Registry is a specialized index of delegations, which are VCs. Delegations are issued as W3C Verifiable Credentials: ```json { "@context": [ "https://www.w3.org/2018/credentials/v1", "https://schema.kya-os.org/v1/protocol/delegation/context/v1.0.0" ], "id": "urn:uuid:d7f8a9b0-1234-5678-9abc-def012345678", "type": ["VerifiableCredential", "DelegationCredential"], "issuer": "did:key:z6MkIssuer...", "issuanceDate": "2024-03-01T12:00:00Z", "expirationDate": "2024-03-02T12:00:00Z", "credentialSubject": { "id": "did:key:z6MkDelegate...", "delegation": { "id": "del-001", "issuerDid": "did:key:z6MkIssuer...", "subjectDid": "did:key:z6MkDelegate...", "constraints": { "scopes": ["tool:read_file", "tool:list_directory"], "notBefore": 1709294400, "notAfter": 1709380800, "audience": "did:web:mcp-server.example.com" }, "status": "active" } }, "credentialStatus": { "id": "https://example.com/status/1#42", "type": "StatusList2021Entry", "statusPurpose": "revocation", "statusListIndex": "42", "statusListCredential": "https://example.com/status/1" }, "proof": { "type": "Ed25519Signature2020", "created": "2024-03-01T12:00:00Z", "verificationMethod": "did:key:z6MkIssuer...#z6MkIssuer...", "proofPurpose": "assertionMethod", "proofValue": "" } } ``` **The proof.** The example's `proof.type` is `Ed25519Signature2020`, but this profile does not use the W3C suite of that name, and a W3C Data Integrity verifier will not verify it. A conformant issuer produces, and a conformant verifier checks, exactly this: - **Signing input.** The UTF-8 bytes of the RFC 8785 (JCS) canonicalization of the credential with its `proof` member removed. There is no RDF canonicalization and no hash of the proof options. - **Signature.** Ed25519 (RFC 8032), 64 bytes. - **`proofValue`.** The signature as base64url without padding (86 characters), with no multibase prefix. - **Key.** The verification method `proof.verificationMethod` names, as an absolute DID URL of the issuer or a `#fragment` read against the issuer's DID. The issuer's DID document, whose `id` MUST be the issuer's DID, MUST list that method under `assertionMethod`, by reference or embedded (W3C Controlled Identifiers v1.0 [CID] §3.3). The method MUST be a conforming verification method, whose `id`, `type` and `controller` are non-empty strings (CID §3.3 step 8), and its `controller` MUST be the issuer's DID (step 10), so a document cannot list as the issuer's a key that another DID controls. A key the document lists only under another verification relationship, such as `authentication`, or under none, does not verify a credential: a key kept for signing in, perhaps on a less protected device, is not thereby one that issues the issuer's credentials. The method is looked for only among those in `verificationMethod` and those `assertionMethod` embeds, never among those another relationship embeds. If more than one of them has the method's id, written as an absolute DID URL of the issuer or a `#fragment`, the id names no method, whether or not each of them conforms or names the issuer as its `controller`, and a verifier MUST NOT verify the credential with any of them. - **`proof.type`.** Issuers set `Ed25519Signature2020`. A verifier MAY also accept `DataIntegrityProof` for the same construction, and MUST reject any other `proof.type`. The other `proof` members (`type`, `created`, `verificationMethod`, `proofPurpose`) are not covered by the signature; a verifier uses `verificationMethod` only to select the key. A credential is an assertion by its issuer, so a verifier MUST reject a proof that states a `proofPurpose` other than `assertionMethod`. A proof that states none is checked as one made for `assertionMethod`: the member is not signed, so it is the key's listing under `assertionMethod` that holds the proof to that purpose. The `StatusList2021Credential` of §6.6 is signed the same way. The delegation credentials in the `delegation-chain` and `status-list` conformance vectors, and the status lists in the `status-list` vectors, carry this construction. Whether 2.0 moves this profile to a standard cryptosuite is tracked in [#184](https://github.com/decentralized-identity/kya-os-mcp/issues/184). The §6.10 profile uses `DataIntegrityProof` with `eddsa-jcs-2022` and is not affected. **The VC-JWT form.** A delegation credential can also travel as a VC-JWT, as in the `KYA-OS-Delegation-Credential` header of §8.1, with the issuer's DID as `iss`. Its signature is checked with the key the JOSE header's `kid` names, read as `proof.verificationMethod` is above: an absolute DID URL of the issuer, or a `#fragment` read against the issuer's DID. The issuer's DID document MUST list that method under `assertionMethod`, as for the proof above. An issuer SHOULD set `kid`; [VC-JOSE-COSE] §4.1.1 requires it of the credentials it secures whenever the issuer's key is expressed as a DID URL. A `kid`, or a proof's `verificationMethod`, names a key only when it is a non-empty string. A verifier MUST reject a VC-JWT whose `kid` is present and is empty or not a string, and a credential or §6.6 status list whose proof's `verificationMethod` is present and is empty or not a string, and MUST NOT read such a name as naming no key. A verifier MUST check a VC-JWT that carries no `kid` only with a method the issuer's DID document lists under `assertionMethod`, and never with one it lists only elsewhere. It MAY try only the method that the first entry of `assertionMethod` names, under the rules for the proof's key above, and reject the VC-JWT when that entry names no method that meets them, without trying later entries. The reference implementation does so, and checks a §6.6 status list whose proof names no key the same way, so an issuer that omits the name is verified there only when its signing key is that first entry. **The issuer.** A credential's `issuer`, or the `id` of an issuer object, MUST be a URL, as [VC-DATA-MODEL-2.0] §4.7 requires and as every DID is, and so MUST a VC-JWT's `iss`. A verifier MUST reject one that the [URL] parser does not parse as it is written: one with white space at either end, or one holding a control character (Unicode general category Cc), a format character (Cf), U+2028, U+2029, a code point that renders as nothing by default (Default_Ignorable_Code_Point) or a lone surrogate anywhere. The set is fixed as Unicode 16.0 and 17.0 assign it, and `conformance/unseen-code-points.json` lists it, so that verifiers built on different Unicode versions give one verdict. The parser removes some of these before it parses and accepts the others, most of which render as nothing or reorder the text around them, so an issuer holding one could be taken for another DID. **The subject.** The `id` of a credential's `credentialSubject` MUST be a URL by the same rule, and a verifier MUST reject a credential whose subject `id` is not one. A party that re-delegates writes the subject of the credential it signs, and a verifier hands that `id` on as the acting agent's DID: into its log, its audit trail and the context of the call it authorizes. A line break there would end a log line and start one the party wrote, and a format character could show the `id` as another agent's DID. **The start.** A credential's `issuanceDate` is "the date and time the credential becomes valid" ([VC-DATA-MODEL] 1.1 §4.6), in either form, VC-JWT or object, and MUST be a date as §6.6 defines one. A verifier MUST reject a credential whose `issuanceDate` is ahead of its clock, or cannot be read as such a date, since it names no start, as `delegation_not_yet_valid`. It MAY hold the start with the clock tolerance §6.6 permits for a status list, of no more than 600 seconds, since an issuer stamps it with the moment it signs; the reference implementation holds it with 120 seconds. **The parent commitment.** A re-delegation names its parent by `parentId` (§6.4), and an id is a name the parent's issuer chose. A parent issued again under the id of another would therefore carry every re-delegation signed under the first. A re-delegation MAY state, in its `delegation` object beside `parentId`, `parentCredentialDigest`: the digest §7.8 gives its parent credential, `SHA-256(UTF8("org.kya-os.delegation.credential.v1") || 0x00 || JCS(signed form))`, written as `sha256:` and 64 lowercase hex digits. It is the commitment §6.10 defines for a hop of that profile, stated in this profile's credential. The digest is of the parent in the form the chain carries it, a credential object with its `proof` or a VC-JWT; the two forms of one delegation have different signed forms (§7.8), so an issuer states the digest of the form its verifiers resolve. A verifier MUST check the digest of every credential that states one against its parent, as the chain resolves it, and MUST refuse the chain, as `chain_invalid`, when the two differ, when that parent has no signed form, or when a credential with no `parentId` states one, since it has no parent credential. A credential states the member when its `delegation` object holds it, whatever its value, so one that states it as `null` states a digest that is not its parent's. A re-delegation that states none, leaving the member out, is accepted as before, its parent named by its `parentId` alone; version 2.0.0 requires it of every re-delegation. An issuer that holds the parent credential when it signs a re-delegation SHOULD state it, and the reference implementation's `createAndIssueDelegation` writes it when given the parent as `options.parent`. The digest of a credential covers what the credential states, so a chain each of whose re-delegations states the member is fixed by the digest of its last credential alone, which is what a holder's request proof names (§7.8). The `delegation-chain/parent-digest-*` conformance vectors carry the member. A `DelegationCredential` carries a _permission_, not a _claim_. To keep claim semantics out of an authorization decision — a confused-deputy vector (§11.6) — the `credentialSubject` MUST contain only two properties: `id` (the delegate's DID) and `delegation` (the permission payload). A verifier MUST reject a `DelegationCredential` whose `credentialSubject` carries any other property, and MUST reject a credential whose `type` array does not include both `VerifiableCredential` and `DelegationCredential`. Implementations MAY offer an explicit, audited opt-out of the `credentialSubject` shape check to bridge non-conformant issuers. Such an opt-out MUST default to off and MUST emit a one-time warning when enabled, so the relaxation is visible in operational logs. > **Schema dialect (MCP 2026-07-28).** All KYA-OS JSON Schemas in this > specification — and the normative copies in `schemas/*.json` — are authored > against **JSON Schema 2020-12** and MUST declare > `"$schema": "https://json-schema.org/draft/2020-12/schema"`. KYA-OS MCP tool > definitions MUST likewise express their `inputSchema` and `outputSchema` in > JSON Schema 2020-12 (SEP-2106). Consistent with the RC, a tool's > `structuredContent` MAY be any JSON value permitted by its `outputSchema`, not > only a JSON object. ### 6.3 CRISP Constraint Envelope ```typescript interface DelegationConstraints { // Temporal bounds (Unix epoch seconds) notBefore?: number; notAfter?: number; // Simple scope list (tool names, resource patterns) scopes?: string[]; // Audience restriction (server DID or domain) audience?: string | string[]; // Extended CRISP constraints crisp?: { budget?: { unit: 'USD' | 'ops' | 'points'; cap: number; window?: { kind: 'rolling' | 'fixed'; durationSec: number; }; }; scopes: Array<{ resource: string; matcher: 'exact' | 'prefix' | 'path-prefix' | 'regex'; constraints?: Record; }>; }; } ``` #### Budget windows A CRISP `budget` with no `window` caps what the delegation spends for all time. A `rolling` window caps what it spends within any span of `durationSec` seconds. A `fixed` window counts from the Unix epoch, 1970-01-01T00:00:00Z: its windows are the consecutive spans from k × `durationSec` to (k + 1) × `durationSec` seconds after the epoch, for each whole number k, and the `cap` holds within each. A `fixed` window does not start when the credential does, so every delegation that states a `fixed` window of one `durationSec` has the same windows. An enforcer MUST count a `fixed` window so. #### CRISP scope matchers | `matcher` | Semantics | Intended value | |-----------|-----------|----------------| | `exact` | Strict string equality. | Any. Preferred for sensitive resources (§11.4). | | `prefix` | Character-level: the value starts with the pattern; one trailing `*` is optional sugar. An empty base grants nothing. | Scope **identifiers** (`repo:` matches `repo:write`). | | `path-prefix` | Path-level: the value equals the pattern or lies beneath it as a `/`-separated path. `notes` matches `notes` and `notes/2026/plan.md`, never `notesx/secret.md`. A trailing `/` or `/*` is optional sugar; an empty base grants nothing. | Resource **paths** (files, folders, URL paths). | | `regex` | Anchored full-string match; invalid patterns never match. Verifiers bound pattern and value length and reject nested-quantifier patterns. | Any; issuers accepting patterns from untrusted parties SHOULD prefer the other three. | Verifiers MUST treat `prefix` and `path-prefix` as distinct: applying `prefix` to a resource path lets a grant for `notes` authorize `notesx/secret.md`, which is a boundary escape, not a match. A verifier MUST NOT match a `path-prefix` value or pattern that has a `.` or `..` segment, each dot written as `.` or as `%2e` in either case, or that holds `%2f` or `%5c` in either case anywhere. A consumer that decodes or normalizes such a path would resolve it outside the granted path. A verifier MUST NOT take a `prefix` scope as contained in a `path-prefix` scope when it checks that a re-delegation narrows its parent. A verifier decodes nothing else, and the `exact`, `prefix` and `regex` matchers compare the text as written. ### 6.4 Delegation Graph Delegations form a directed acyclic graph (DAG): ``` [Root: Responsible Party → Principal] │ [Principal → Agent A] │ ┌──────┴──────┐ ▼ ▼ [A → B] [A → C] │ ▼ [B → D] ``` - Each node is a `DelegationCredential` - `parentId` links to the parent delegation - Child delegation's `issuerDid` MUST equal parent's `subjectDid` - Scope constraints MUST be equal to or narrower than parent's constraints - Under a parent that states a CRISP `budget` (§6.3), a verifier MUST reject a re-delegation that states none, or one that is not the parent's as written and is not narrower: a budget in the same `unit` whose `cap` is no higher, with no `window`, which caps all time, or, under a parent's window, a `rolling` window at least as long, or, under a parent's `fixed` window, a `fixed` window of the same `durationSec`. A `fixed` window of the parent's `durationSec` has the parent's windows (§6.3), so its `cap` holds within each of them. One that is shorter, or whose `durationSec` is not a whole multiple of the parent's, ends within one of the parent's windows and starts its next window there, and one under a `rolling` window starts wherever a charge falls, so either would let the re-delegation spend its cap twice within one of the parent's windows. A `fixed` window a whole multiple as long contains whole windows of the parent's, and a verifier MUST still reject it, so that it compares a `fixed` window only as its parent states it. A budget is compared only when it states a `unit` that is a string other than the empty one, a `cap` that is a finite number of 0 or more, and, if it states a `window`, a `kind` of `rolling` or `fixed` and a `durationSec` greater than 0, and no other member; a child's budget that is not compared passes only as its parent's, as written. - A member of `constraints`, or of `constraints.crisp`, that §6.3 does not define MUST be stated with an equal value (RFC 8785) by every re-delegation below the delegation that states it, as §6.10 requires of a caveat, and a verifier MUST reject a re-delegation that drops or changes one. Whatever enforces such a member, or a budget, reads it from the presented credential alone, so a re-delegation that dropped or raised it would widen its parent. - A delegation that states no scopes of either kind (§6.3) grants none, so a verifier MUST reject a re-delegation under it that states any - A re-delegation that states `parentCredentialDigest` (§6.2) MUST state the digest of its parent credential, and a delegation with no `parentId` MUST NOT state one; a verifier MUST reject a chain in which either rule is broken - The root delegation's `issuerDid` MUST equal the `issuer` of its `DelegationCredential`, the DID whose key signs it (§6.2), and a verifier MUST reject a chain whose root names any other DID, so the Responsible Party is always a DID that signed - Every chain MUST terminate at a Responsible Party. The Responsible Party's DID is the `issuerDid` of the root `DelegationCredential` and is the entity ultimately accountable for actions taken under any descendant delegation. In personal use the Responsible Party equals the Principal; in organizational use the Responsible Party is the parent organization while the Principal is the immediate human delegator (see §2). **Chain length (non-normative).** The §6.2 profile does not limit how many times authority may be re-delegated. Separately, a verifier may cap how many credentials it will verify for one request, as a local resource limit: each credential costs a signature check and possibly a DID resolution. The reference implementation exposes this as `maxChainLength`, unset by default. Such a cap is the verifier's policy, not a protocol rule, and a chain it refuses is not thereby invalid elsewhere. What the reference implementation bounds by default is the time of one check, since a chain of any length is then held by its time: 30 seconds for the chain's resolution, every credential's verification and every revocation answer together, unless the host sets another as `totalTimeoutMs` (§4.4.2). ### 6.4.1 Designation Invariant A `DelegationCredential` may authorize multiple resources, either via a list of explicit scope strings (`constraints.scopes[]`) or via pattern matchers (`constraints.crisp.scopes[].matcher`: `'exact' | 'prefix' | 'path-prefix' | 'regex'`). When the credential is used to invoke a specific tool or resource, the invocation MUST designate the specific scope being exercised, and verifiers MUST confirm that the designated scope is a member of (or matches a pattern in) the delegation's authorized scopes. In other words: multi-resource delegations are valid as authority grants but cannot be used in invocations without designation. An invocation that omits the specific resource designation MUST be rejected, even if the delegation would have authorized it under any matching scope. This is the designation/authorization separation: without it, an attacker who acquires a multi-resource delegation can use it against resources the original delegator did not anticipate. Together with the audience-on- re-delegation requirement (§11.6), this closes the confused-deputy class on the invocation path. Reference implementation: each tool wrapped via `wrapWithDelegation` is registered with a fixed `scopeId`; invocations carry the wrapped tool's name and the verifier requires the delegation's scopes to contain that exact scopeId before the handler runs. ### 6.5 Cascading Revocation When a delegation is revoked: 1. Mark the delegation as `revoked` in the delegation graph 2. Recursively mark all descendant delegations as `revoked` 3. Update StatusList2021 credential for each revoked delegation 4. Emit revocation events for audit logging A server that reads revocation from its delegation graph reads a delegation's chain from a root down to it. When the graph holds a delegation but not that whole chain, as a replica that has not received a node, or a store that lost one, does not, the server cannot say whether an ancestor above the gap is revoked: it refuses the delegation as `status_unavailable` and never reads it as standing. A delegation the graph does not hold at all is read as not revoked there, since the server asks the graph about every credential of a chain, its ancestors among them. So the graph removes a delegation only once none is registered under it, and a removed delegation that reads as revoked leaves a record that its id is revoked. It leaves that record whether or not the delegation has a status list entry: a revocation whose write to the list failed, or left the list unchanged, is recorded in the graph alone. A removed delegation that does not read as revoked leaves no record, and its id may be registered again. #### 6.5.1 Revocation Rights For v1.0, the parties authorized to revoke a delegation are: 1. **The direct issuer of the delegation.** The party that signed the `DelegationCredential` MAY revoke it at any time. 2. **Any ancestor issuer in the delegation chain.** A party that issued an upstream delegation MAY revoke any descendant delegation; cascading revocation propagates downward through the graph (§6.5). 3. **The Responsible Party at the root of the chain.** The root issuer MAY revoke the entire chain. 4. **The subject of a delegation MAY NOT revoke it.** Revocation requires authority from above; an agent cannot unilaterally invalidate a delegation it received. Revocation requests SHOULD be signed by the revoking party's key, and verifiers SHOULD validate the revoker's identity against the chain before honoring the revocation. Future versions may adopt an explicit "revocation as a delegatable permission" model (UCAN-style), allowing the responsible party to grant revocation authority to other parties (e.g. a security operations team) without those parties being in the original chain. Tracked for v1.1. #### 6.5.2 Concurrency and the Revocation Race Revocation and invocation are concurrent operations in the Lamport sense. An invocation that arrives at a verifier between the moment a revocation is issued and the moment that revocation propagates to the verifier will succeed despite the revocation being logically prior. This race is unavoidable in any distributed system; implementations can bound the window but cannot eliminate it. Implementations MUST: - Propagate revocations to all known verifiers as quickly as possible, including immediate StatusList2021 updates and cache invalidation. - Cache status-list lookups with a TTL no longer than the revocation propagation target. For high-privilege scopes, ≤ 60 seconds is recommended. - Honor explicit revocation signals (e.g., a side-channel notification from a trusted source) immediately, ahead of the next status-list refresh. Operators of high-stakes resources SHOULD reduce the race window by issuing short-lived delegations (so revocation by expiration is the primary mechanism) and polling status lists frequently. The unavoidable race is the same trade-off familiar from PKI: short certificate lifetimes reduce the window during which a compromised credential can be used. ### 6.6 Status List Revocation KYA-OS publishes revocation as a status list, in the terms of W3C Bitstring Status List v1.0 [BITSTRING-STATUS-LIST], a W3C Recommendation: ```json { "@context": ["https://www.w3.org/ns/credentials/v2"], "id": "https://example.com/status/1", "type": ["VerifiableCredential", "BitstringStatusListCredential"], "issuer": "did:web:example.com", "validFrom": "2024-03-01T00:00:00Z", "validUntil": "2024-03-08T00:00:00Z", "credentialSubject": { "id": "https://example.com/status/1#list", "type": "BitstringStatusList", "statusPurpose": "revocation", "encodedList": "uH4sIAAAAAAAAA-3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAIC3AYbSVKsAQAAA", "ttl": 300000 } } ``` A credential names its entry of that list as its `credentialStatus`: ```json { "id": "https://example.com/status/1#94567", "type": "BitstringStatusListEntry", "statusPurpose": "revocation", "statusListIndex": "94567", "statusListCredential": "https://example.com/status/1" } ``` The list's `encodedList` is a list of 131,072 entries with none set, the list of the [STATUS-LIST-2021] example written in the form below, and each example list leaves out its `proof` (§6.2). **Formats.** A status list is a `BitstringStatusListCredential`, the list of Bitstring Status List v1.0 and a [VC-DATA-MODEL-2.0] document, or a `StatusList2021Credential`, the list of [STATUS-LIST-2021] and a [VC-DATA-MODEL] 1.1 document, which the first succeeds. A list is of a format when it is typed as that format's list in both places its specification names: a `type` that includes `BitstringStatusListCredential` and a subject whose `type` is `BitstringStatusList` (Bitstring Status List v1.0 §2.2), or a `type` that includes `StatusList2021Credential` and a subject whose `type` is `StatusList2021`. A list typed as one in one place alone is of neither format, and a verifier MAY refuse it. A publisher SHOULD publish a `BitstringStatusListCredential`, and MUST write one as its §2.2 requires: a [VC-DATA-MODEL-2.0] document, whose first `@context` is `https://www.w3.org/ns/credentials/v2`, that states the start of its window as `validFrom`, its end as `validUntil`, and one string, or an array of them, as its `statusPurpose`. A publisher MAY publish a `StatusList2021Credential` instead, and a verifier MUST read a list of either format. An entry is of its list's format: a `BitstringStatusListEntry` names a `BitstringStatusListCredential`, whose `type` its §2.1 requires to include that value, and a `StatusList2021Entry` names a `StatusList2021Credential`. A publisher SHOULD NOT name a list of one format from an entry of the other: Bitstring Status List v1.0 §2.1 requires the list a `BitstringStatusListEntry` names to be a `BitstringStatusListCredential`. This specification does not require a verifier to refuse a credential for that alone, and the reference readers read the list an entry names as the format the list is typed as. An entry states one string as its `statusPurpose`, and an `id` it states MUST NOT be the URL of its list (§2.1). The reference implementation's `StatusList2021Manager` writes a `StatusList2021Credential` and `StatusList2021Entry` entries through the 1.x line, and a `BitstringStatusListCredential` and `BitstringStatusListEntry` entries when its `format` option is `BitstringStatusList`, which 2.0.0 makes its default. It keeps a stored list in the format the list was created in, and allocates no entry on a list of the other format. The same list as a `StatusList2021Credential` states its window as `issuanceDate` and `expirationDate`, and has no `ttl`: ```json { "@context": [ "https://www.w3.org/2018/credentials/v1", "https://w3id.org/vc/status-list/2021/v1" ], "id": "https://example.com/status/1", "type": ["VerifiableCredential", "StatusList2021Credential"], "issuer": "did:web:example.com", "issuanceDate": "2024-03-01T00:00:00Z", "expirationDate": "2024-03-08T00:00:00Z", "credentialSubject": { "id": "https://example.com/status/1#list", "type": "StatusList2021", "statusPurpose": "revocation", "encodedList": "uH4sIAAAAAAAAA-3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAIC3AYbSVKsAQAAA" } } ``` **Encoding.** Under both StatusList2021 and Bitstring Status List v1.0, a list's `encodedList` is the multibase prefix `u` followed by the base64url encoding (RFC 4648 §5), without padding, of the GZIP (RFC 1952) compression of the list's bitstring, in which the entry at index 0 is the most significant bit of the first byte, as Bitstring Status List v1.0 §2.2 and §3.3 write it. A publisher MUST write `encodedList` in that form. For the 1.x line, a reader MUST also accept an `encodedList` in the legacy forms the reference implementation reads, alone or together: with no `u`; with any of its characters in the base64 alphabet (RFC 4648 §4), `+` standing for `-` and `/` for `_`; and with `=` after its last character, no more of them than complete its last group of four characters. They are the forms a publisher that follows [STATUS-LIST-2021] may write: it names no multibase prefix, its example has none, and it calls the encoding base-64 (RFC 4648), which admits the base64 alphabet and padding. A reader MAY refuse an `encodedList` in any other form, such as one with white space, another multibase prefix, a last group of one character, or `=` before a character. 2.0.0 removes the legacy forms. **Length.** A publisher MUST write a list of at least 131,072 entries, 16 KiB uncompressed, as Bitstring Status List v1.0 §2.2 requires, so that each credential's entry is one among many. The reference implementation's `StatusList2021Manager` writes 131,072 entries unless its `defaultListSize` option sets another size; a size below 131,072 writes a `StatusList2021Credential` this rule forbids, and is refused, where the manager is built, for a `BitstringStatusListCredential`. For the 1.x line, for compatibility, a reader MUST NOT refuse a list for holding fewer entries. Bitstring Status List v1.0 §3.2 refuses such a list (step 9) unless a specification sets another lower bound (step 2), and this one sets none for 1.x; 2.0.0 refuses a list of fewer than 131,072 entries. Whatever its length, a list holds no entry at or past its end, so an index there is rejected (§6.7). A verifier that reads a status list, of either format, MUST verify its proof, as §6.2 states, before reading any bit. A list whose proof does not verify is unresolvable: the credential it covers is rejected, never read as active. A list's proof shows only who signed it, so a verifier MUST also hold the list to the one issuer that keeps the URL the credential's status entry names. These checks decide by the list's `issuer`, so they mean something only when the list's proof verifies under a key that `issuer` lists under `assertionMethod` (§6.2), and a proof check plugged into a verifier, such as the reference implementation's `verifyStatusList` seam, resolves `true` only then. W3C Bitstring Status List v1.0 lets a list's issuer differ from the credential's (§2.2), and an informative note in its §3.2 says a verifier will ensure that it trusts the issuer of a verifiable credential as well as the issuer of the associated `BitstringStatusListCredential`. Trusting an issuer is not enough. A list's `id` binds the list to a URL, but nothing in a list binds a URL to one signer, so a verifier that read a list from any issuer it trusts for a credential would let each of them speak at every URL an entry names. Every `statusListCredential` URL therefore has exactly one keeper. A verifier MUST decide the keeper before it fetches the list, from its own configuration and the signed credentials, and MUST NOT decide it from the list. The keeper of the URL a credential's status entry names is the first of these that applies: 1. the issuer the verifier's configuration binds that exact URL to; 2. the issuer the verifier's configuration binds the URL's `https:` origin to; 3. the `issuer` of the first credential of the credential's delegation chain (§6.10), the chain's root, when the verifier pins the root to its own configuration (the resource owner it asserts, or one of its trusted root issuers, SPEC-ENTITY-CARD.md §11.4) and the status entry of the root's own credential names the same URL, byte for byte; 4. the credential's own `issuer`. The credential MUST be rejected unless the list's `issuer` is the keeper. So the configuration decides before a root's credential does, and at a URL a configured issuer or the root keeps, a list the credential's own issuer signed is rejected as any other is. A configuration binds a URL to exactly one issuer, and a verifier MUST refuse a configuration that binds one URL or one origin to two. An exact URL bound to one issuer MAY lie at an origin bound to another, and the exact binding decides. An origin is `https://`, a lower-case host and an optional port, and a URL is at an origin when it continues the origin's string with `/`, `?` or `#`. The comparison is on the bytes as written, with no parsing and no normalisation, so that every implementation decides alike and no URL is placed at an origin a URL parser would not place it at. A verifier SHOULD refuse, as a configuration error, a binding that is an origin followed by `/`, a binding that is an origin but for an upper-case letter (`A` to `Z`) in its host, and any other binding that ends in `/`, since each is almost always an origin or a prefix written in a form this section does not read as one. Read as this section reads it, each is an exact URL, which binds only an entry that names it byte for byte; any other exact URL, whatever the case of its host, is read as written. A verifier takes the URL the root's credential names (rule 3) only from a root credential whose proof it has verified, since until then the presenter of the chain wrote it. Once it has, the URL is the word of a root the verifier's configuration pins, so the verifier MAY read it as a URL its operator named, a private host included (§4.4.2), as it reads a URL its configuration binds, where the URL is at the root's own origin: `https://` and the host, with its port if written, that the root's did:web DID names. It MUST NOT read so the URL of a root credential whose proof it has not verified, a URL at any other origin, or any URL of a root that is not a did:web DID, which names no host; its configuration binds such a URL in `statusListIssuers` to have it read so. The port is part of the origin, as in an origin binding, since one host may serve each party on a port of its own, and a root at one port does not speak for another. For an Entity Card's `revocation` entry the Card's `id` is the credential's own `issuer`, and the Card's `responsibleParty` takes the root's place once the Card's accountability check has verified it as the root issuer of the Card's delegation chain, with the list URL that check reports the root credential names (SPEC-ENTITY-CARD.md §10.3). A pinned root can revoke its own credential, which revokes every credential below it in its chains, so the list its own credential is on speaks for each credential of its chains that names that list. A root that keeps other lists for its delegates, the shards of one herd list for example, has the verifier bind them to it, by URL or by origin, once for all its delegates. A deployment whose root credential carries no status entry does the same, since rule 3 then gives the root no URL. A verifier that pins no root reads the root's list only for the root's own credential, whose `issuer` the root is, and at the URLs its configuration binds to the root. The issuers between the root and the credential keep no URL but those of their own credentials' entries. A credential that states no `parentCredentialDigest` (§6.2, §6.10) commits to its parent only by an `id` the parent's issuer chose, so whoever presents a chain decides who stands between the root and the credential, while the root is held to the verifier's own configuration. One that states it commits to the one parent credential it was signed under, and a chain each of whose hops but the root states it is fixed from the root to the credential. An issuer between them still revokes what it delegated, as §6.5.1 allows, by revoking its own credential on its own list, which the cascading chain walk (§6.10) carries to every credential below it. The credential's own `issuer` is the one the credential names, so that issuer is trusted only once the credential's proof verifies. The reference implementation's `DelegationCredentialVerifier` reads the credential's status only once that proof verifies (§4.4.2), and accepts the credential only when both checks pass. A deployment whose lists one status service signs binds that service's origin, or each list URL, to the service. Rule 4 gives a URL to the issuer whose credential names it, whoever serves a list there. So where a credential names, as its own, a URL at which another party in fact keeps a list, and neither the configuration nor a pinned root's credential says so, that party's list is rejected there, which fails closed, and a list the credential's issuer signs there is read as that issuer's own. A credential issuer always decides its own credential's status in this way, by choosing the list it names; a party that needs its list to count for another issuer's credentials has the verifier bind the list's URL to it. A status entry MAY state `statusSize`, the size of its status in bits (Bitstring Status List v1.0 §2.1). A verifier MUST reject a credential whose entry states a `statusSize` that is not an integer greater than zero. An entry that states none is one bit wide. An entry's status is the value at the position its `statusListIndex` multiplied by its `statusSize` gives (§3.2, step 10), so the bit at the index of a wider entry belongs to another entry. Bitstring Status List v1.0 §2.1 describes the `revocation` and `suspension` purposes as one status bit each, and gives entries of several values to the `message` purpose. A verifier that checks the `revocation` or `suspension` purpose MUST therefore reject a credential whose entry states a `statusSize` other than 1, before it fetches any list. The credential is also rejected when the list's `statusPurpose` does not include the purpose of the credential's status entry. Only a list typed as a Bitstring Status List v1.0 list in both places its §2.2 names, a `type` array that includes `BitstringStatusListCredential` and a subject whose `type` is `BitstringStatusList`, may state its `statusPurpose` as an array of strings. Any other list, a `StatusList2021Credential` among them, states one string, as Verifiable Credentials Status List v2021 §2.2 requires, and the credential is rejected when it states an array, whatever the array holds. The credential is likewise rejected when the list states an `id` that is not, byte for byte, the `statusListCredential` URL it was fetched from. Only the `id` binds a list to the URL it is served at, and Bitstring Status List v1.0 §2.2 makes it optional. A list the credential's own `issuer` signed MAY be read when it states no `id`, but only when that issuer keeps the URL as the credential's issuer, by rule 4 or as the pinned root whose own credential it is (rule 3), and nobody else keeps any URL: the verifier pins no other root, and its configuration names no other issuer. So a pinned root's list without an `id` MAY be read for the root's own credential, and MUST NOT be read for a credential below it. A reader may refuse it, as the reference implementation's `CheqdStatusListResolver` does: it reads only a list that states its URL as its `id`. Any other list MUST state that URL as its `id`, or the credential is rejected. A keeper signs lists for other URLs as well, and one of them, with the credential's bit clear, could otherwise be served at this one. Where the credential's own `issuer` may leave the `id` out, a list that states none can still be served in place of another list its own issuer signed, so an issuer SHOULD state the `id` of each list. Nor do these checks tell versions of one list apart. An earlier version of a list, signed before a credential was revoked, can be served in place of the current one. Over http, an on-path party can replay an older signed list from before a revocation, so a verifier reads a list over https, every redirect included, whatever host it is on. It MUST NOT read over http a URL a credential names, nor follow a redirect to http, unless its own configuration binds that exact URL, since then the operator chose that exposure for its own list; an origin binding is `https://` alone. The window a list states bounds how long it can be. W3C Bitstring Status List v1.0 §2.2 gives a list a `validFrom`, "The earliest point in time at which the status list is valid.", and a `validUntil`, "The latest point in time at which the status list is valid.", and a `StatusList2021Credential` states the same window as `issuanceDate` and `expirationDate`. A verifier MUST NOT read a list outside the window it states. A list past its `validUntil`, or before its `validFrom`, is unresolvable, as an unreachable list is: the credential it covers is rejected, never read as active. A list that states no `validUntil` is bounded by its `expirationDate`, and one that states no `validFrom` by its `issuanceDate`; the bounds are inclusive. A bound a list states that is not a date leaves its window unknown, so that list is unresolvable too. A date is an [RFC3339] §5.6 date-time, which always states its offset from UTC, as `Z` or as `+hh:mm` or `-hh:mm`, as the `xsd:dateTimeStamp` that [VC-DATA-MODEL-2.0] requires of `validFrom` and `validUntil` does. A bound in any other form is not a date. One that states no offset, such as `2026-11-17T00:00:00`, names no single instant: each verifier would read it in its own time zone, and two verifiers would give one list two answers. A date alone, such as `2026-11-17`, an HTTP date, and a date-time no calendar has, such as the 30th of February or a 60th second, are not dates either. This holds for `issuanceDate` and `expirationDate` too, though [VC-DATA-MODEL] lets an `xsd:dateTime` leave its offset out. A verifier MAY hold each bound with a tolerance for the difference between its clock and the issuer's, of no more than 600 seconds, the largest skew of §10.1: it then reads a list from its `validFrom` less the tolerance until its `validUntil` plus the tolerance. Without one, a list whose issuer stamps its `validFrom` with the moment it publishes the list is refused, for as long as the difference, by every verifier whose clock runs behind the issuer's. The reference implementation holds both bounds with a tolerance of 120 seconds, the default skew of §11.3, which each status-list reader's `maxClockSkewMs` option sets, from 0 to 600,000 milliseconds. A list that states no end is read until its issuer replaces it, so an earlier version of it can be served for as long as it verifies. An issuer SHOULD therefore state an end on every version of a list it signs, as the list's `validUntil` or, on a `StatusList2021Credential`, its `expirationDate`, and republish the list before that end passes. How long a version is valid, its validity period, is the issuer's to choose: it is the longest an earlier version can be served after a revocation, and Bitstring Status List v1.0 §7.2 suggests "no minimum or maximum validity period" for all status lists. A `BitstringStatusListCredential` MAY also state `credentialSubject.ttl`, which its §2.2 defines as "the "time to live" in milliseconds before a refresh SHOULD be attempted": a hint to a reader that keeps the list, which a publisher SHOULD serve the list's caching headers in agreement with, as that section says. A `ttl` is no part of the window, since "the value does not override or replace the validity period". A verifier MUST NOT read a list past its `validUntil` because its `ttl` has not run out. A `ttl` counts from when a reader fetched the list, never from the list's `validFrom`, so a verifier MUST NOT refuse, because of its `ttl`, a list it has just fetched inside its window. A `StatusList2021Credential` has no such member, since its context defines none, so a publisher SHOULD NOT state a `ttl` on one, and a verifier gives it no meaning there. The reference implementation's `StatusList2021Manager` states the end `validityPeriodMs` after it signs each version, when that option is set, and its `renewStatusList` signs a list again with a new end and the same bits. Without the option its lists state no end, through the 1.x line. Its `ttl` option is the `ttl` each `BitstringStatusListCredential` it signs states. It refuses, where it is built, a `ttl` for a `StatusList2021Credential`, and a `ttl` longer than its validity period, which no reader could keep to. The reference readers do not read `ttl`: each keeps a list or a verdict no longer than its own configuration says. In the reference implementation every status-list reader refuses a list outside its window with the transient code `status_unavailable`, since the issuer republishing the list ends it, and with a reason that names the bound and quotes the time the list states. That reason reaches the presenter only once the list's proof verifies (§6.10), so a reader that checks no proof, as the reference checker without its `verifyStatusList` seam, gives it to the operator's log, and the reason says only that the list could not be read or checked. An Entity Card's Entity keeps the URL its own Card names unless the verifier's configuration binds that URL to another issuer, so whoever holds the Entity's key and controls what the Card's `statusListCredential` URL returns can serve a list the Entity signed, with the Card's bit clear. Against a compromised Entity key, the responsible party revokes the root delegation credential, which the Card's accountability check reads (SPEC-ENTITY-CARD.md §12.5). In the reference implementation, the delegation middleware tells a `StatusListResolver` only the credential's own issuer, even when the verifier pins the chain's root. On that path a list the root signed for a re-delegated credential is refused, which fails closed, unless the resolver's own configuration, a `statusListIssuers` map it passes to `statusListExpectationFor`, binds the list's URL or its origin to the root. Even then the root's list is read only when it states its URL as its `id`. `CheqdStatusListResolver` is an explicit global-pin exception to per-credential authority: its configured DID is the keeper of every URL it reads, for any hop, regardless of the chain root. That comes from resolver configuration, not from the middleware discovering or authenticating a root. `withStatusCache` separates entries by URL, index, purpose, size, credential issuer, root and the root's list URL; an omitted purpose and an explicit `null` have distinct keys. Cached verdicts still obey the configured staleness window, and a cache keeps them when the trust configuration changes, so that change requires a new cache. A cache keeps only a verdict read inside its list's window, and may serve it past the window's end for no longer than its staleness window. L1 implementations do not require revocation support; revocation checking is available at L3 only. Revocation does not require a globally accessible list. A verifier only needs to know whether a delegation has been revoked **for the resources it gates**, so the revocation state MAY be held as verifier-local state rather than fetched from an external URL. A status list is the interoperable wire format for _publishing_ revocation when the delegator and verifier are operationally decoupled; it is not a requirement to operate a public, globally-readable certificate-revocation list. A verifier that issues and gates its own delegations MAY check revocation entirely from local state. ### 6.7 Orchestration & Extensibility Orchestration scope is service-local; directory federation is out of scope for this version. Delegation graphs and revocation state are managed within a single service boundary and are not synchronized across independent KYA-OS deployments or external agent directories (e.g. NANDA). - Each delegation is assigned a `statusListIndex`, which MUST be less than the number of entries its list holds: 0 to 131071 in a list of 131,072 entries, and more in a longer one - A credential whose index is at or past its list's end is rejected, as Bitstring Status List v1.0 §3.2 (step 10) raises a range error for it - Bit at index is 0 = valid, 1 = revoked - The bitstring is encoded as §6.6 states ### 6.8 Protocol Registry The registry indexes anything addressable by DID — agents, MCP servers, services, and delegation policies. Three registry types are defined within the protocol: - **Delegation Registry** — stores `DelegationCredential` objects and supports querying by issuer, subject, scope, and revocation status. - **Credential Registry** — stores all W3C Verifiable Credentials issued within the ecosystem, providing a general-purpose VC index. - **Trust Registry** — indexes entities by DID for discovery, enabling participants to resolve trust relationships and verify standing. `DelegationCredential` IS a Verifiable Credential; Delegation Registry is a specialized Credential Registry view. Trust-registry rejection is advisory, not blocking. The cryptographic delegation check is the load-bearing gate (§11.0); registry standing is a secondary signal. Services SHOULD honor well-formed delegations from low-standing delegates but MAY apply rate limits, additional verification, or scope reduction. Outright rejection of well-formed delegations pushes the same authority through worse channels — credential sharing, request proxying — which reduces auditability rather than improving security. ### 6.9 Ephemeral Delegate Keys (Non-Normative) A delegator MAY subject a `DelegationCredential` to a one-off ephemeral public key (typically a `did:key`) instead of a long-lived agent DID. This privacy-preserving pattern lets a chain authorize an action without correlating the delegate across unrelated delegations (§12.1). ```json { "credentialSubject": { "id": "did:key:z6Mk-ephemeral-...", "delegation": { "id": "del-ephemeral-001", "subjectDid": "did:key:z6Mk-ephemeral-...", "parentId": "urn:uuid:...", "constraints": { "scopes": ["files:read"] }, "status": "active" } } } ``` The ephemeral key signs presentations of this credential and is discarded once the delegation expires. The `credentialSubject` carries only `id` and `delegation`, so the example remains conformant with the subject-shape rule in §6.2. Implementations MAY support this pattern; it is not required for any conformance level. ### 6.10 Card-era profile: VC 2.0 + ZCAP-LD delegation The Entity Card profile ([SPEC-ENTITY-CARD.md](./SPEC-ENTITY-CARD.md) §10) uses a newer credential shape than §6.2: a W3C Verifiable Credentials 2.0 credential whose `credentialSubject` IS an attenuated ZCAP-LD capability, revoked via W3C Bitstring Status List v1.0 (the successor to the StatusList2021 mechanism of §6.6). The delegation model of this chapter - one credential per hop, subset discipline at every link, cascading revocation (§6.5), the designation invariant (§6.4.1), and the per-hop `audience` rule (§11.6) - is unchanged; only the wire shape and the revocation list format differ. Both shapes remain valid for the 1.x line: §6.2 is what the legacy session profile issues and verifies, this profile is what the Entity Card path issues and verifies, and an implementation encountering one never needs to accept the other in its place. The JSON Schema is published at `schemas/card-delegation-credential.json`. **Telling the profiles apart (non-normative).** Neither profile carries a separate profile identifier; the first `@context` entry selects the rule set. `https://www.w3.org/2018/credentials/v1` marks a §6.2 credential, and `https://www.w3.org/ns/credentials/v2`, with the ZCAP-LD context, marks a credential of this profile. **Credential shape.** One `DelegationCredential` per delegation **hop**; a chain runs `root → … → leaf`. A `DelegationCredential` is a VC 2.0 whose `credentialSubject` IS an attenuated ZCAP-LD capability: ```jsonc { "@context": [ "https://www.w3.org/ns/credentials/v2", "https://w3id.org/security/zcap/v1", "https://kya-os.org/ns/delegation/v1" ], "type": [ "VerifiableCredential", "DelegationCredential" ], "issuer": "", "validUntil": "2027-01-01T00:00:00Z", "credentialSubject": { "id": "urn:zcap:del_123", "invoker": "", // or "controller" (§2.3) "parentCapability": "", "parentCredentialDigest": "sha256:<64 hex>", // OPTIONAL; never on the root (below) "invocationTarget": "", "allowedAction": [ "payments.transfer" ], "caveats": [ { "type": "ValidUntil", "date": "…" }, { "type": "MaxAmount", "limit": "500.00", "currency": "USD" } ] }, "credentialStatus": { "type": "BitstringStatusListEntry", "statusPurpose": "revocation", "statusListIndex": "42", "statusListCredential": "https://…/status/delegations" }, "proof": { "type": "DataIntegrityProof", "cryptosuite": "eddsa-jcs-2022" } } ``` Per-hop signature verification (the `DataIntegrityProof`, `eddsa-jcs-2022`) is a separate injected concern; this profile specifies the attenuation + continuity recompute. The reference implementation accepts that verifier as `verifyHopProof` in the context of `evaluateDelegationChain`: it runs the local chain checks first, then verifies every hop root to leaf, stopping at the first failure, before it reads any status list (SPEC-ENTITY-CARD.md §11). The option remains optional for compatibility until the next major version; omitting it keeps the legacy status walk and logs one warning per process. Whichever verifier is injected, it MUST accept an `eddsa-jcs-2022` proof, on a hop or on a status list credential, only from a key that the signer's DID document lists under the verification relationship the proof's `proofPurpose` names: `assertionMethod` in this profile, by reference or embedded (W3C Controlled Identifiers v1.0 [CID] §3.3). The cryptosuite retrieves that key as CID §3.3 does, so its verification method MUST also be a conforming one (step 8) whose `controller` is the signer's DID (step 10). The method is looked for only among those in `verificationMethod` and those `assertionMethod` embeds, never among those another relationship embeds. If more than one of them has the method's id, written as an absolute DID URL of the signer or a `#fragment`, the id names no method, whether or not each of them conforms or names the signer as its `controller`, and a verifier MUST NOT verify the proof with any of them. An issuer MUST create the proof as [VC-DI-EDDSA] §3.3.1 does, setting `proof.@context` to the credential's `@context`, since a verifier MUST verify it as §3.3.2 does, rebuilding the signed configuration from the proof alone. During 1.x a verifier MUST also accept a proof without `proof.@context` whose configuration, as signed, includes the credential's `@context`, a shape issuers wrote before this rule, the reference implementation from 1.22.0 to 1.25.0 among them. **The delegate.** The delegate is `credentialSubject.invoker`, falling back to `credentialSubject.controller`; a capability MUST name one of them. **Attenuation invariants (fail-closed, on resolve).** Note: earlier drafts labelled these "CRISP attenuation"; they are the chain-attenuation rules and are distinct from the §6.3 CRISP constraint envelope, whose subset discipline they generalize to ZCAP chains. A chain is valid only if EVERY hop attenuates its parent. Any broadening hop invalidates the whole chain: - **action subset** - child `allowedAction ⊆ parent`; - **monotone caveats** - no parent caveat may be silently dropped; for a shared caveat type, child `MaxAmount ≤ parent` (same currency; compared as exact decimals, never rounded or truncated) and child `ValidUntil ≤ parent`; a caveat of an unknown type, or of a known type with a member this section does not define, MUST be replicated **verbatim**; - **top-level `validUntil` narrowing** - child `validUntil ≤ parent`, each read as a date (below); - **continuity** - the parent's delegate (`invoker`) MUST equal the child's `issuer` (you may only re-delegate what was delegated to YOUR key), and child `parentCapability` MUST reference the parent capability `id`; - **parent commitment** - a hop other than the root MAY state `parentCredentialDigest`, and when it does it MUST be the digest of its parent credential (below); the root MUST NOT state one; - **constant `invocationTarget`** along the chain; - **root** - root `parentCapability` MUST equal its `invocationTarget` (the resource); when a resource owner / resource is asserted, root `issuer` MUST equal the resource owner and root `invocationTarget` MUST equal the resource. **The parent commitment.** Continuity ties a hop to its parent by two names, the parent's delegate and the parent's capability `id`, and both are the parent issuer's to choose. A parent issued again under the `id` of one that was revoked would therefore carry every hop signed under the first. A hop commits to the one parent credential it was signed under by stating, in its `credentialSubject`, `parentCredentialDigest`: the digest §7.8 gives that credential, `SHA-256(UTF8("org.kya-os.delegation.credential.v1") || 0x00 || JCS(signed form))`, written as `sha256:` and 64 lowercase hex digits. The signed form is every member of the parent but `proof`, and the signature its `proof.proofValue` carries, which §7.8 reads as it reads any signature string: six bits for each base64 or base64url character, the bits short of a byte dropped. A `proofValue` of this profile is multibase base58btc, each character of which is a base64 character, so §7.8 reads every one, and it MUST be read so and not decoded from base58, or two implementations would digest one parent differently. An `eddsa-jcs-2022` signature also covers the proof's configuration, so the digest fixes the parent and its whole proof, while a copy of the parent stored or serialized another way keeps its digest. It is the digest §7.8 gives each credential of a chain, so a party that holds those digests matches a hop's commitment against them. A verifier MUST check the digest of every hop that states one against the hop before it in the chain, as received, and MUST refuse the chain, as `chain_invalid`, when the two differ, when that hop has no signed form, or when the root states one, since the root has no parent credential. The reference implementation checks it after the local chain rules and before any hop proof, since it reads nothing from the network. A hop states the member when its `credentialSubject` holds it, whatever its value, so a hop that states it as `null` states a digest that is not its parent's, and a root that does states one. A hop that states none, leaving the member out, is accepted as before, its parent named by its `id` alone; version 2.0.0 requires it of every hop but the root. An issuer that holds the parent when it signs a hop SHOULD state it, and the reference implementation's `signDelegationCredential` writes it when given the parent as `options.parent`. **Caveats (fail-closed).** Every caveat of every hop applies to every call the chain authorizes. A `MaxAmount` states `limit`, one or more decimal digits optionally followed by `.` and one or more digits, and MAY state `currency`, a string. One that names a currency limits the amount of a call in that currency and permits no call in another; one that names none limits the amount of every call, whatever its currency. So a hop that adds a caveat, or names a currency its parent left open, only narrows its parent. A `ValidUntil` states `date`, a date as below. A `MaxAmount` whose `limit` is missing or not of that form, or whose `currency` is not a string, and a `ValidUntil` whose `date` is missing or not a date, are malformed and invalidate the chain; a member either type does not define makes neither malformed. A verifier that accepts a chain MUST hold each call to every caveat of every hop, or refuse the call; a caveat it does not interpret it MUST enforce by a rule of its own or refuse the call. The reference implementation returns the chain's caveats on its verdict, at their tightest, and its `caveatRefusal` helper holds a call to them. **Validity window (fail-closed).** A chain is valid only while every hop is inside the window it states: no hop past its `validUntil` or a `ValidUntil` caveat's `date`, and none before its `validFrom`. A hop may also state its end as its `expirationDate`, the member [VC-DATA-MODEL] names for it, or as its proof's `expires`, after which [VC-DATA-INTEGRITY] has the proof expire, and its proof covers both, so a hop is past its end once any end it states has passed, whatever its `validUntil` says. Likewise a hop may state its start as its `issuanceDate`, the member [VC-DATA-MODEL] 1.1 names for it, which its proof covers, so a hop is before its start until every start it states, its `validFrom` and its `issuanceDate`, has come, whether or not it states a `validFrom`. Each of these, and each date the narrowing invariants compare, MUST be a date as §6.6 defines one, an [RFC3339] date-time with its offset from UTC. A hop that states one in any other form, a date-time with no offset included, is malformed and invalidates the chain. A verifier MAY hold each bound with the clock tolerance §6.6 permits for a status list, of no more than 600 seconds. The reference implementation reads a hop's window and a status list's by one rule, with 120 seconds unless the `maxClockSkewMs` option of `validateDelegationChain`, `evaluateDelegationChain`, `verifyRequestDelegation` or `requireDelegation` sets it. It refuses a hop past its end as `delegation_expired`, one before its start as `delegation_not_yet_valid`, and one whose date is malformed as `delegation_malformed`. **Chain length (non-normative).** As in §6.4, this profile does not limit how many times a capability may be re-delegated. Earlier drafts listed a 10-hop cap among the invariants above, but a longer chain broadens nothing, so it was never an attenuation rule. A verifier may cap how many credentials it evaluates for one chain as a local resource limit: each hop may cost a signature check and a status-list fetch. The reference implementation takes the same `maxChainLength` option here, unset by default for a chain a request carries as for one it resolves, and exports `MAX_DELEGATION_DEPTH` (10) as a suggested value. Such a cap is the verifier's policy, not a protocol rule, and a chain it refuses is not thereby invalid elsewhere. What holds a chain of any length is the order a verifier checks it in and the time it gives the check (SPEC-ENTITY-CARD.md §10.5 rule 2), 30 seconds in the reference implementation unless the host sets another as `totalTimeoutMs`. A verifying resource SHOULD assert its own identity as the expected resource when it evaluates a chain (the `resource` context of `evaluateDelegationChain`), so that a chain minted for a different resource fails at the root check instead of being accepted by an unrelated Verifier. **Revocation.** Revocation uses **W3C Bitstring Status List v1.0** [BITSTRING-STATUS-LIST] (`BitstringStatusListEntry`) - the **successor to** the deprecated StatusList2021 - behind a pluggable `RevocationChecker` seam so status-list churn never reaches callers. The default checker resolves `statusListCredential` via SafeFetch (SPEC-ENTITY-CARD.md §6.6), inflates the multibase (`u` = base64url) + GZIP `encodedList`, or a 1.x legacy form of it (§6.6), and reads the bit at `statusListIndex` MSB-first within each byte. A verifier MUST verify the status list credential's proof before it reads a bit, as Bitstring Status List v1.0 requires. The reference checker does so when given its `verifyStatusList` seam (optional until 2.0) and ships a verifier for `eddsa-jcs-2022` lists. With that seam it also holds each hop's list to the keeper §6.6 names for the URL of the hop's entry: the issuer its `statusListIssuers` option binds the URL or its origin to, else the chain's root issuer when the verifier pins it with its trusted root issuers or the resource owner it asserts and the root hop's own entry names the same URL, else the hop's own issuer. A list is read without an `id` only when the hop's own issuer signed it and keeps the URL as that issuer, not by a binding, no other root is pinned and `statusListIssuers` names no other issuer; any other list is read only when it states its URL as its `id`. The hop's own issuer is the one the hop names, so a verifier checks every hop's proof before it reads their status (SPEC-ENTITY-CARD.md §11.4). It is **fail-closed**: an unreachable list, malformed credential, rejected list proof, a list outside the validity window it states (§6.6), list `issuer` that is not the keeper of the entry's URL, list `id` other than the `statusListCredential` URL, no list `id` where §6.6 requires one, a list `statusPurpose` that does not include the checker's, a `statusPurpose` array on a list §6.6 holds to one string, an entry whose `statusPurpose`, when present, is not the checker's (`null` included), an entry whose `statusSize`, when present, is not 1, or out-of-range index all resolve to `{ revoked: true }`, with a `reason` that says which once the list's proof verifies, as below. Whoever presents an entry chooses the URL it names, so the document read there may be any JSON the verifier can reach. A verdict about a list reaches the presenter only once the list's proof verifies, since only then is what the list says its issuer's word; before that, the reason and the remedy go to the operator's log, and the `reason` says only that the list at the URL could not be read or checked, as for a list that could not be read. So a list refused for its `issuer`, its `id` or its `statusPurpose`, which the reference checker asks before the proof, or for its window where no proof is checked, has that `reason`, and the operator's log says which, with the `statusListIssuers` configuration that would accept a list another DID signed. This refines the rule that a refusal tells the presenter only what the DID or the URL alone decides, or a deadline: a verdict about a list that was read keeps its reason once the list's proof verifies, and not before. Each verdict also reports `fresh` - `true` only when read live from a status list inside its validity window (`validFrom`/`validUntil`, or `issuanceDate`/`expirationDate`), as every list the reference checker reads is, since it refuses one outside its window; a checker that answers from a cache reports `false` for a verdict it did not read live. The chain walk is **cascading**: root→leaf, short-circuiting on the first revoked/unresolvable hop (a revoked ancestor invalidates the subtree), with `fresh` the AND of every checked hop. L2 accepts a non-revoked chain (cached / offline acceptable); L3 additionally requires `fresh` (a live check). **KYC/KYB.** KYC/KYB rides the same rail as an `IdentityVerificationCredential` whose `credentialSubject` is the `responsibleParty` and which asserts the verification **fact + level** (`verificationLevel ∈ { basic, enhanced, loa3 }`), never raw PII. It is verified via the same trusted-issuer + signature + expiry path as an L2 capability attestation and surfaced through the Card's `attestations[]`. --- The equalities a Verifier recomputes from a resolved chain, and their place in the fail-closed verification order, are specified in SPEC-ENTITY-CARD.md §10.2 and §11. A request may also carry the chain itself, so that the Verifier needs no lookup to obtain it (SPEC-ENTITY-CARD.md §10.5). --- ## 7. Proof Generation ### 7.1 Purpose Detached proofs provide: - **Non-repudiation**: Cryptographic evidence that the server processed the request - **Integrity**: Hashes bind the exact request and response together - **Audit Trail**: Proofs can be stored and verified offline ### 7.2 ProofMeta Fields ```typescript interface ProofMeta { did: string; // Server's DID (signer) kid: string; // Key ID used for signing ts: number; // Unix epoch seconds when proof was generated nonce: string; // Fresh random nonce per proof (replay protection, §5.5) audience: string; // Session audience sessionId: string; // Session identifier requestHash: string; // SHA-256 of the canonicalized request (§7.3) responseHash?: string; // SHA-256 of canonicalized response. Present on success // AND on needs_authorization challenges (binds the // challenge content, incl. authorizationUrl); ABSENT on // denial / step-up proofs (no response body). scopeId?: string; // Scope under which the call was made delegationRef?: string; // Reference of the delegation credential the call presented (§7.8) delegationChainDigest?: string; // Digest of the delegation chain the server // evaluated, root to leaf (§7.8). ABSENT when the producer // does not sign the claim, and on a refusal where the // presented value, or a credential the server // examined, has no signed form, or where a value // handed to it for the chain could not be read. clientDid?: string; // Client's DID if authenticated outcome?: 'allowed' | 'denied' | 'step_up_required' | 'needs_authorization'; // Authorization outcome; ABSENT ⇒ implicitly 'allowed' (success) reason?: string; // Human-readable reason on a non-'allowed' outcome prf?: 'org.kya-os/response-proof.envelope'; // Response-proof profile discriminator, COVERED by the // JWS signature. ABSENT ⇒ the body profile (body-only // responseHash, the original wire shape). Verifiers // MUST reject any other value (fail-closed; §7.3). } ``` A detached proof is an assertion by its signer. A verifier MUST retrieve its key by `meta.kid` from the signer's own DID document, whose `id` MUST equal `meta.did`, and MUST use only a method listed under `assertionMethod`, by reference or embedded (W3C Controlled Identifiers v1.0 [CID] §3.3). The method MUST be defined exactly once among `verificationMethod` and embedded `assertionMethod` entries, have a non-empty `id`, `type` and `controller`, have an id under the signer's DID, and name that DID as its `controller`. A key listed only under another relationship, such as `authentication`, MUST NOT verify a detached proof. Although a proof MUST carry `meta.kid`, a key-retrieval API called without a `kid` MUST select only the first `assertionMethod` entry under these rules and MUST refuse an unusable first entry without trying later entries. A verifier given a key by its caller relies on that caller to enforce this retrieval rule. ### 7.3 Hash Generation 1. **Canonicalize**: Convert request/response to RFC 8785 (JCS) canonical JSON 2. **Hash**: Compute SHA-256 of the canonical JSON bytes (UTF-8 encoded) 3. **Format**: `sha256:<64-char-lowercase-hex>` Request canonicalization covers the JSON-RPC request as sent: its `method` and `params`. The envelope members `jsonrpc` and `id` are not covered. Two kinds of member are removed before canonicalizing: 1. `params._meta`, if present. `_meta` is intermediary-mutable transport metadata that also carries proofs (§7.6), so it is never signed. Only that top-level member is removed; values nested under other `params` members are not touched. 2. For `method: "tools/call"`, every member of `params.arguments` whose name begins with `_kyaos`: the KYA-OS control arguments (`_kyaos_delegation`, `_kyaos_proof`, `_kyaos_approvals`). They carry the credentials that authorize the call, each authenticated on its own, and the holder-of-key request proof and approval grants are themselves bound to this hash, so covering them would make the hash depend on its own output. Tool handlers SHOULD NOT receive control arguments, so that the covered request is the call the tool executes. A client SHOULD carry this data in `params._meta` instead (§14), where rule 1 removes it; the 1.x line still reads the arguments. An absent `params.arguments` is covered as `{}`, since a server cannot tell it from an empty one. Every other `params` member (`name`, `task`, and any future member) is covered. When `params` is absent the covered request is `{ "method": ... }`. For a tool call: ```json { "method": "tools/call", "params": { "name": "echo", "arguments": { /* minus _kyaos* members */ } } } ``` A client, a PEP or a third-party auditor recomputes `requestHash` this way from the request it sent or received, and for the 1.x line also accepts the legacy shapes below. Rule 1 is the rule Entity Card request proofs use (SPEC-ENTITY-CARD §8.3). Appendix C.1 gives vectors. **Legacy shapes in 1.x.** For the 1.x line, a verifier MUST accept a `requestHash` computed over any of three shapes of the tool call it holds: the covered request above; the legacy shape; and the legacy shape with every `_kyaos*` argument removed. The legacy shape is `{"method": , "params": }`, canonicalized with JCS as above. An absent `params.arguments` is `{}`, and `params._meta` is never in it. Producers SHOULD sign the covered request. The 1.x releases of the reference implementation (`@kya-os/mcp`) sign one of the legacy shapes for every proof over a tool call: response and outcome proofs (§7.4), the approval `requestHash` of a step-up challenge, and holder-of-key request proofs. 2.0.0 removes the legacy shapes. The legacy shape is deprecated: it hashes a tool named after a JSON-RPC method like that method's request, and it has no room for `params` members other than the arguments. Response canonicalization is selected by the proof's response-proof profile, named by the signature-covered `prf` claim (§7.2): - **body** (`prf` ABSENT — the original profile): the `data` field only (excludes `_meta`). Under MCP carriage, `data` is the result's `content` array; result members outside it are NOT covered. - **envelope** (`prf: "org.kya-os/response-proof.envelope"`): the ENTIRE result object with the top-level `_meta` member removed, mirroring the request side's `{method, params minus _meta}` rule. This authenticates result members such as `structuredContent`, `isError`, and `resultType` that the body profile leaves uncovered, while `_meta` stays intermediary-mutable — which is what lets the proof itself be attached there after signing. A verifier derives the profile from the received proof's own `prf` claim, never from configuration, and MUST reject an unrecognized `prf` outright. Because `prf` is covered by the signature, stripping it from an envelope-profile proof breaks verification — a downgrade to body-only semantics is a hard failure, not a silent fallback. Producers default to the body profile (wire compatibility with existing verifiers); the envelope profile is an explicit opt-in (`responseProofProfile` in the middleware configuration). ### 7.4 JWS Compact Serialization The proof JWS is generated as: ``` BASE64URL(header) . BASE64URL(payload) . BASE64URL(signature) ``` **Header**: ```json { "alg": "EdDSA", "kid": "did:web:server.example.com#key-1" } ``` The header is part of the JWS signing input, so the signature covers every parameter of it. A holder's request proof carries one more parameter, `org.kya-os/delegation`, which states the delegation its call presents (§7.8). A verifier ignores a header parameter it does not know (RFC 7515 §4), so a proof that carries one verifies wherever a proof without it does, and the proof's `meta` holds no copy of it. **Payload** (canonicalized): ```json { "aud": "did:web:server.example.com", "iss": "did:web:server.example.com", "nonce": "...", "requestHash": "sha256:...", "responseHash": "sha256:...", "sessionId": "kyaos_...", "sub": "did:web:server.example.com", "ts": 1710288000 } ``` An envelope-profile proof (§7.3) additionally carries its `prf` claim in this payload — profile selection is signed, never advisory. Every optional `ProofMeta` member present on the proof with a value (`scopeId`, `delegationRef`, `delegationChainDigest`, `clientDid`, `outcome`, `reason`, `prf`) appears in the payload, and one given as an empty string does not (see "Members no signature covers" below). Every member of the mirrored `meta` block that the payload signs MUST reconcile exactly with the decoded payload. **Denial** and **step-up** proofs have no response body, so `responseHash` is omitted and `outcome` (plus an optional `reason`) is included instead. Keys remain RFC 8785-sorted: ```json { "aud": "did:web:server.example.com", "iss": "did:web:server.example.com", "nonce": "...", "outcome": "denied", "reason": "insufficient_scope", "requestHash": "sha256:...", "sessionId": "kyaos_...", "sub": "did:web:server.example.com", "ts": 1710288000 } ``` A **needs_authorization** challenge *does* carry a response body (the consent challenge, including the `authorizationUrl`), so its proof includes **both** a `responseHash` over that body — binding the URL against tampering / MITM substitution — and `outcome: "needs_authorization"`: ```json { "aud": "did:web:server.example.com", "iss": "did:web:server.example.com", "nonce": "...", "outcome": "needs_authorization", "reason": "requires delegation with scope: greeting:restricted", "requestHash": "sha256:...", "responseHash": "sha256:...", "sessionId": "kyaos_...", "sub": "did:web:server.example.com", "ts": 1710288000 } ``` **Reading a proof.** A verifier MUST read a proof's JWS as follows, and MUST refuse a proof whose JWS does not read so. 1. The JWS is exactly three segments, separated by `.`. Each segment is read as RFC 7515 §2 writes base64url: of the base64url alphabet alone, with no white space and no `=`. A last group of one character is refused, and bits short of a byte are dropped. A segment written in the base64 alphabet, or holding any other character, white space or padding, is no segment of a proof. This reading is for a proof and its key alone: §7.8 reads the third segment of a VC-JWT more loosely, as the JWS libraries that verify a credential read it. 2. The header is a JSON text in UTF-8, an object whose `alg` is `EdDSA` and whose `kid` is the `kid` of the proof's `meta`. A payload segment, where the JWS carries one, is a JSON text in UTF-8 too. Any other parameter of the header is acted on only once step 4 has verified the signature over that header, and of parameters that share a name the last is read, or the JWS is refused (RFC 7515 §4). 3. The key is the Ed25519 key that `kid` names. Given as a JWK, it has `kty` `OKP`, `crv` `Ed25519` and the same `kid`, and its `x` is read as step 1 reads a segment, and is 32 bytes. 4. The signature is verified over the header segment and the payload rebuilt from `meta` as above, written as base64url without padding. A payload segment the JWS carries that is not that one MUST verify under the same signature too. So every claim of `meta` that the payload signs is held to what was signed, and a proof whose signed claims differ from its payload fails. Reading a segment more loosely would let two strings stand for one signature, and a verifier that accepts one of them where another refuses it would give two verdicts on one proof. **Members no signature covers.** A generator writes in `meta` only the members the payload above signs, with `kid`, and writes no optional claim as an empty string. `schemas/detached-proof.json` describes that `meta`, the one a generator writes. A `meta` member no signature covers is a member the proof schema does not name, or an optional claim given as an empty string, which the payload leaves out. A verifier MUST NOT return or act on a `meta` member no signature covers. In 1.x a verifier ignores such members, and reads an empty optional claim as absent, so the proof verifies on what its signature covers and the `meta` it hands back holds nothing else. From 2.0.0 a verifier refuses a proof whose `meta` carries a member no signature covers. ### 7.5 _meta Attachment The proof is attached to tool responses under the reverse-DNS key `org.kya-os/response-proof` inside the standard MCP `_meta` field. Other `_meta` keys (e.g. `io.modelcontextprotocol/*`, `traceparent`) MAY coexist and are ignored by the verifier (§7.6): ```json { "content": [{ "type": "text", "text": "File contents..." }], "_meta": { "org.kya-os/response-proof": { "jws": "eyJhbGciOiJFZERTQSIsImtpZCI6Ii4uLiJ9.eyJhdWQiOi4uLn0.c2ln...", "meta": { "did": "did:web:server.example.com", "kid": "did:web:server.example.com#key-1", "ts": 1710288000, "nonce": "abc123...", "audience": "did:web:server.example.com", "sessionId": "kyaos_d7f8a9b0-...", "requestHash": "sha256:a1b2c3...", "responseHash": "sha256:d4e5f6..." } }, "traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01" } } ``` The `traceparent` key above illustrates a coexisting reserved key; it is not part of the proof and is never hashed or trusted (§7.6). ### 7.6 _meta Namespacing and Hash Exclusion The response hash is computed over the response object with `_meta` removed (see §7.3). Implementations MUST NOT rely on signature coverage of any `_meta` field. `_meta` is the Model Context Protocol per-request metadata channel and is shared real estate: under MCP 2026-07-28 it legitimately carries reverse-DNS–namespaced keys reserved by the MCP maintainers (`io.modelcontextprotocol/*`) and W3C Trace Context propagation keys (`traceparent`, `tracestate`, `baggage`). KYA-OS therefore namespaces its own payload and MUST NOT assume exclusive ownership of `_meta`. **Canonical key.** KYA-OS attaches its detached response proof under the reverse-DNS key `org.kya-os/response-proof` (the `proofMetaKey`). The key is named for its role, pairing with the request proof's `org.kya-os/request-proof` (SPEC-ENTITY-CARD §8); the two keys carry different objects, and neither carries a version - the request proof's profile version lives inside the object (`prf`). This key SHOULD be configurable (e.g., a single build-time constant rather than a value scattered through the code), so that if and when KYA-OS is registered as an MCP Extension (SEP-2133), its reverse-DNS extension id — and hence this key — can be re-pointed without a wire change. **Backward compatibility.** Two prior keys carried this proof: bare `proof` (pre-1.1) and `org.kya-os/proof` (1.1 until the role-named rename). For one major version, verifiers MUST also accept a proof published under either prior key. Producers emit `org.kya-os/response-proof` and MAY additionally mirror the proof under a prior key when targeting older verifiers. When several keys are present, the newest canonical form wins (`org.kya-os/response-proof`, then `org.kya-os/proof`, then `proof`). **`metaPolicy` semantics.** The `session.metaPolicy` setting governs how a verifier treats `_meta` keys that are *not* KYA-OS's proof key: - `strict` (the default) — the verifier processes **only** the KYA-OS proof key (`org.kya-os/response-proof`, or a prior key `org.kya-os/proof` / `proof`). All other keys are **ignored**: never hashed, never trusted, and — critically — **never a cause for rejection**. In particular a `strict` verifier MUST NOT reject a response merely because `_meta` also carries `io.modelcontextprotocol/*`, `traceparent`, `tracestate`, or `baggage`; these reserved/standard keys are explicitly allowlisted and pass through untouched. - `allow-extensions` — identical trust boundary (still only the KYA-OS proof key is hashed or trusted), but the verifier additionally surfaces non-KYA-OS `_meta` keys to the application layer rather than discarding them. Under no policy does a verifier include any non-proof `_meta` key in a hash or signature computation. The signature covers the profile-selected response material only — the `data` body under the body profile, the result envelope minus its top-level `_meta` under the envelope profile — and never covers `_meta` itself (§7.3). > **Note.** The proof object's shape is normatively defined by > `schemas/detached-proof.json` (`$schema: draft/2020-12`). The *placement* key > inside `_meta` is `org.kya-os/response-proof`; the schema describes the value > (`{ jws, meta }`), not the key. ### 7.7 Delegation Chain Audit Example The following shows how audit records link across a 3-level delegation chain: User → Agent A → Agent B → tool call. **Step 1 — User delegates to Agent A** ```json { "id": "urn:uuid:1111-aaaa", "type": "DelegationCredential", "issuer": "did:web:user.example.com", "credentialSubject": { "id": "did:web:agent-a.example.com", "parentDelegation": null, "scope": "files:read files:write" } } ``` **Step 2 — Agent A delegates to Agent B** ```json { "id": "urn:uuid:2222-bbbb", "type": "DelegationCredential", "issuer": "did:web:agent-a.example.com", "credentialSubject": { "id": "did:web:agent-b.example.com", "parentDelegation": "urn:uuid:1111-aaaa", "scope": "files:read" } } ``` The `parentDelegation` field links this record back to the User → Agent A credential, forming a verifiable chain. **Step 3 — Agent B calls a tool; the server generates an audit record** ```json { "content": [{ "type": "text", "text": "file contents..." }], "_meta": { "org.kya-os/response-proof": { "jws": "eyJhbGciOiJFZERTQSJ9...", "meta": { "did": "did:web:tool-server.example.com", "kid": "did:web:tool-server.example.com#key-1", "ts": 1710288120, "nonce": "xyz789", "audience": "did:web:tool-server.example.com", "sessionId": "kyaos_f1e2d3c4-...", "requestHash": "sha256:aabbcc...", "responseHash": "sha256:ddeeff...", "delegationRef": "urn:uuid:2222-bbbb", "delegationChainDigest": "sha256:112233...", "clientDid": "did:web:agent-b.example.com" } } } } ``` The `delegationRef` in the proof points to Agent B's delegation credential (`urn:uuid:2222-bbbb`), which in turn carries `parentDelegation: urn:uuid:1111-aaaa` back to the original user grant. An auditor can reconstruct the full chain — User → Agent A → Agent B → tool call — by following `delegationRef` → `parentDelegation` links. All three records are independently verifiable offline using the signers' DID documents. Those links are ids, and an id names a credential without fixing its bytes. `delegationChainDigest` is what ties this proof to the two credentials above and to no others: the auditor recomputes it over the chain it reconstructed and compares it with the signed value (§7.8). ### 7.8 Delegation Binding A proof about a delegated call says which delegation the server decided it under, in two members. **`delegationRef`** names the credential the caller presented, the last of its chain. It is derived from the credential in two steps, and this is its only definition: a producer signs it, an audit trail records it and a verifier that holds the credential recomputes it, all by these steps. 1. **The id a credential shows**, in the form it was presented in, is the first of the following that is a non-empty string. For a credential object (§6.2): its `id`, then `credentialSubject.delegation.id`. For a compact VC-JWT of three segments whose payload is a JSON object with an object member `vc`: `vc.id`, then `jti`, then `vc.credentialSubject.delegation.id`. The payload is read strictly: as a JWS segment (step 1 of the digest, below), as UTF-8, and as JSON (RFC 8259), which a byte order mark is no part of. A number in the payload is read whatever its length, since RFC 8259 sets no limit on one, and its value plays no part in the id. A payload whose arrays and objects nest more than 64 levels deep is not read as JSON at all (the nesting bound, below), so a VC-JWT that carries one shows no id. A credential object shows its id however deep the rest of it nests. A credential with none of these shows no id, and neither does any other value. 2. **The reference** for an id is the id itself, unless the id is longer than 256 UTF-16 code units, holds a character that does not print or a surrogate without its pair, already reads as `sha256:` followed by 64 lowercase hexadecimal digits, or is the word `unknown`. The reference for such an id is the SHA-256 of its UTF-8 encoding, written in the hash format of §7.3. An id that is not well-formed Unicode has no UTF-8 encoding, and its bytes are its WTF-8 encoding instead: UTF-8, with each surrogate without its pair written as UTF-8 writes a code point of the same value, in three bytes from `ED A0 80` to `ED BF BF`. The characters that do not print are those Unicode 16.0 and 17.0 give the general category Cc, Cf, Zl or Zp or the property Default_Ignorable_Code_Point, the set §6.2 refuses in an issuer, listed here and in `conformance/unseen-code-points.json` so that every implementation hashes the same ids whatever Unicode version its platform follows: U+0000 to U+001F, U+007F to U+009F, U+00AD, U+034F, U+0600 to U+0605, U+061C, U+06DD, U+070F, U+0890 to U+0891, U+08E2, U+115F to U+1160, U+17B4 to U+17B5, U+180B to U+180F, U+200B to U+200F, U+2028 to U+202E, U+2060 to U+206F, U+3164, U+FE00 to U+FE0F, U+FEFF, U+FFA0, U+FFF0 to U+FFFB, U+110BD, U+110CD, U+13430 to U+1343F, U+1BCA0 to U+1BCA3, U+1D173 to U+1D17A, and U+E0000 to U+E0FFF. A proof about a credential that shows no id carries no `delegationRef`. The id of a refused credential is untrusted and of any length, which is what step 2 is for: a reference is bounded and prints as what it holds whatever a caller wrote, and unlike cutting, the digest keeps two long ids with the same beginning apart. A control character could break a log line, and a format character, a bidirectional override say, or a zero-width space, could show a reader another id than the one recorded. The word `unknown` is what an audit record names a credential that shows no id by (AUDITABILITY.md), so an id written so is replaced by its digest, and the word never stands for a credential. An id that already reads as a digest is replaced by its own, so that a reference of that form always stands for the digest of an id, and never for an id a caller wrote to look like one. A reference is a name. An auditor uses it to find the credential, and follows the parent links from there (§7.7). Nothing stops two credentials from showing one id: an issuer can sign a second credential under an id it has already used, and on a refused call the id is whatever the caller wrote. **`delegationChainDigest`** fixes the chain. It is built from one digest per credential, each over the credential's signed form: what its issuer's signature covers, and that signature. 1. **Signed form.** For a VC-JWT, the JSON object `{"jwt": "
.", "signature": S}`, with the two segments exactly as received, neither of them empty. For a credential object (§6.2), the JSON object `{"credential": C, "signature": S}`, where `C` is the credential without its `proof` member. `S` is the base64url encoding (RFC 4648 §5), without padding, of the signature's bytes. The two forms carry those bytes in two kinds of string, and each is read the way its verifiers read it. A VC-JWT's third segment is read as a JWS segment: base64url as RFC 7515 §2 has it, and no more loosely than JWS libraries in use read it. This reading applies to a VC-JWT a chain holds, and to its payload segment read for its id, alone; a response proof's segments, and the `x` of its key, are read strictly, as §7.4 says. Its characters are of the base64url alphabet alone. ASCII whitespace (space, tab, line feed, carriage return, form feed) is passed over wherever it stands. `=` may only complete the last group of four characters: two after a group of two, one after a group of three. A last group of one character is refused, and bits short of a byte are dropped. `+` and `/` are not base64url, and a segment written with them was never a JWS segment. A credential object's `proof.proofValue` is read more loosely, because the decoders that read one differ: its characters in order, each one of the base64 or base64url alphabet, with `-` and `+` both standing for 62 and `_` and `/` for 63; ASCII whitespace passed over wherever it stands; `=`, in any number, passed over after the last of those characters; and bits short of a byte dropped. A `=` with a character of the alphabet after it is not padding, and decoders do not agree on it: some pass over it, and some stop reading there. Padding, a line break, the spare bits of a last character and, in a `proofValue`, the other alphabet each give another string that is read to the same bytes, so one signature has several strings, and these readings give them one `S`. A string outside its reading, or one that yields no byte, is not a signature, and the value that carries it has no signed form. 2. **Credential digest.** `SHA-256(UTF8("org.kya-os.delegation.credential.v1") || 0x00 || JCS(signed form))`, written in the hash format of §7.3. 3. **Chain digest.** `SHA-256(UTF8("org.kya-os.delegation.chain.v1") || 0x00 || JCS(D))`, where `D` is the JSON array of the credential digests, ordered root to leaf. The chain of an allowed call is the one the server evaluated: the presented credential last, preceded by the ancestors the server resolved for it (§6.4). A single credential is a chain of one. What the digest of a refusal covers is listed below. Appendix C.4 gives a vector. The signed form leaves out everything the issuer did not sign. The other members of a §6.2 `proof` (`type`, `created`, `verificationMethod`, `proofPurpose`, and anything a holder adds) are outside the signature, so they are outside the digest, and so is the choice among the strings that carry one signature. A credential therefore has one digest however it was stored, re-serialized or presented. A value has no signed form when it is neither a compact JWS of three segments, the header and the payload not empty, nor an object carrying a `proof.proofValue`, or when its signature string is not a signature as step 1 reads one. A credential object has none either when it nests deeper than the nesting bound below allows, or when `C` has no RFC 8785 form. `C` has none when it holds a string that is not well-formed Unicode, or a number that is not finite or is an integer of magnitude above 2^53 - 1, which a receiver need not read as an exact value (RFC 7493 §2.2). A number is first read as an IEEE 754 binary64 value, the form RFC 8785 serializes a number from (§3.2.2.3), and it is that value that is held to these rules, whatever the text the number was written as. So a `C` that holds `9007199254740993.5` has none: the number is no integer as written, and it reads as 9007199254740994. No signature covers such a value in a way two parties compute alike, so it is no credential: it does not verify, and it has no digest. **The nesting bound.** The arrays and objects of a credential nest at most 64 levels deep. A credential object is level 1, and an array or an object that is a member or an element of another is one level deeper than it. The whole object is counted, its `proof` included, although no signature covers `proof`. A credential object that nests deeper has no signed form. The header and the payload of a VC-JWT are each counted the same way, from the outermost array or object of the JSON text, and one that nests deeper MUST NOT be read as JSON. A VC-JWT whose header or payload is not read does not verify, and one whose payload is not read shows no id. It still has a signed form, since that is made of its segments as received and reads neither of them, and so it still has a digest. An implementation MUST accept nesting of exactly 64 levels, and MUST reach the answers above for a value nested to any depth. It therefore counts the levels before it parses, copies or canonicalizes what it counts, by a means that does not itself fail on a deep value. The number is the protocol's, and is not a limit an implementation may choose. Parsers and serializers recurse, and run out of stack at a depth that differs from one runtime to the next, so without one number two implementations would disagree on whether a deeply nested credential verifies and whether it has a digest. That a value has no signed form is a statement about the value, the same in every implementation. An implementation's own failure to read a value (a call stack that ran out, memory, a hash provider that failed) MUST NOT be reported as the value having no signed form. **Members that share a name.** RFC 8259 leaves open how an object that holds two members of one name is read, and parsers differ: most keep the last, some keep the first, and some refuse the text. Every JSON text this section reads is read keeping, of the members of one object that share a name, the lexically last, as ECMAScript's `JSON.parse` does and as RFC 7515 §4 and RFC 7519 §4 permit a JWS or JWT parser to. That is the header and the payload of a VC-JWT, and any JSON text a credential object is received in, such as the arguments of a call. An implementation whose parser keeps another of the members, or refuses the text, MUST still read it so. For a VC-JWT the rule decides the id the credential shows and the claims it is verified by, and not its digest, which is over its segments as received. For a credential object it decides `C`, and so the digest: two parties that read one text two ways would digest two credentials. A producer that signs `delegationChainDigest` MUST verify each credential's signature over this same signed form: over `C`, every member of the credential but `proof`, or over the two JWT segments, with the signature bytes read as above. Verification and digest are then one reading of the credential. Were they two, a member that one kept and the other dropped, or a signature string that one decoded and the other did not, would let a credential verify as its issuer signed it and be digested as something else, and the party holding it could make the producer sign a digest that the issuer's own copy fails to reproduce. Hashing the digests rather than the credentials is deliberate. A party that holds the per-credential digests, which the audit event of the server's decision records as `authorization.delegationChainDigests` (§15.3), recomputes the chain digest without the credentials themselves, and can tell which hop of a chain it was handed differs from the one the server saw. **When the members are present.** A producer that signs `delegationRef` sets it on every proof about a call that presented a credential, whatever the outcome. A producer that signs `delegationChainDigest` sets it on the same proofs. The members are those of the call the proof is about. A proof about a call that presented no credential carries neither member, unless the server authorized the call from a delegation it holds from an earlier presentation and verified again for this call. **What the members say.** On a proof with no `outcome`, or with `outcome: "allowed"`, the members describe the chain that authorized the call. On any other outcome they describe what the server was shown and did not act on: a chain it refused, or a chain it verified for a call it then refused on other grounds. `reason` says which. On such a proof the members are evidence of what was presented and examined, never a statement that it is valid. A caller chooses what it presents, so anyone can have a server sign a reference and a digest of their own choosing by presenting a chain the server refuses. The digest of a refusal covers the credentials the server had examined when it refused, root first: - A call refused after its chain verified (on scope, on holder binding, by policy, or by the handler): the whole chain. - A chain refused part way through, once the presented credential passed its own checks: the ancestors examined, up to and including the one the server stopped at, then the presented credential. The ancestors after that one are not covered, although the server may have read them to assemble the chain. - A presentation refused before any ancestor was examined: the presented credential alone. That is a VC-JWT whose header or payload is not read as JSON, or whose claims are not a delegation credential's, a credential object that is not a delegation credential, ancestors that could not be resolved into a chain of delegation credentials, a chain longer than the server evaluates (§6.4), and a chain whose links, or whose root's issuer, the server refuses, which it checks before it verifies any credential. So is a presented credential the server refuses on its own, as one that does not verify, a VC-JWT whose envelope signature does not among them, or whose audience does not admit the server: the server examines the presented credential before any ancestor, so that a party who cannot sign as its parent's subject costs no ancestor's verification and learns nothing of an ancestor's standing. - No digest, whichever case above the refusal is, when the presented value has no signed form, when a credential the server examined has none, or when a value handed to the server for the chain could not be read at all. A credential object nested past the bound has no signed form, and the server does not read one handed to it for the chain, nor a value that is not JSON data, such as an in-process object that is not plain data. The proof carries `delegationRef` where the presented value shows an id. The audit event of a refusal lists the digest of each credential covered (§15.3), so a party that holds the event knows which credentials the proof's digest is over. **Verification.** Both members are covered by the JWS signature (§7.4). A verifier that holds a chain, and is to take a proof as evidence that the server decided the call under it, MUST: 1. Reject a proof whose outcome is not the one it expects. Unless it is deliberately checking what a refusal recorded, it expects an allowed call: a proof with no `outcome`, or with `outcome: "allowed"`. A refusal binds what was presented, so a matching digest on its own shows only that the chain was put before the server. 2. Recompute the chain digest and reject a proof whose `delegationChainDigest` differs, or that carries none: an equal `delegationRef` is not evidence of which chain was evaluated. 3. Derive the reference of the chain's last credential and reject a proof whose `delegationRef` is not that reference, or that carries one where the credential has none. A verifier that holds only part of the chain, such as a caller that knows its own credential and not the ancestors the server resolved, cannot recompute the digest and leaves the comparison to a party that can. **A holder's request proof.** A holder-of-key request proof (§11.8) covers the call: the tool and its business arguments (§7.3). The delegation rides beside it, outside the request hash, so the proof alone is good beside any delegation of its subject. A party on the path that holds another delegation of the same subject, and no key, could put it in place of the one the holder chose, or take the delegation away so that authority the server retains for another one answers, and the call would be decided under a grant the holder did not choose. Nothing is replayed, so a nonce does not prevent it. The holder therefore states which delegation its call presents, where its signature covers the statement and every verifier of an earlier version still verifies the proof: in the protected header of the proof's JWS (§7.4), as the parameter `org.kya-os/delegation`. - **The statement** is the credential digest (step 2 above) of the credential the call presents, in the form it is sent, a credential object or a VC-JWT, written as `sha256:` and 64 lowercase hex digits; or the string `none`, for a call that presents no delegation. It names the presented credential alone, the last of its chain, so a holder needs no ancestor to make it. - **A holder** MUST state it in every request proof it makes: the digest of the credential the call presents, or `none`. A holder that makes its proof before it attaches the delegation states the delegation it will attach, never `none`. A value with no signed form has no digest and is no credential, so a proof for a call that sends one states nothing, and the call's verifier refuses the value whatever the proof says. - **A verifier** that checks a request proof for a delegated call MUST read the statement only from the protected header of the JWS whose signature it has verified (§7.4), and never from an unprotected header, the proof's `meta`, or the arguments of the call. It MUST refuse a proof whose statement is neither a credential digest nor `none`. When the call presents a credential, it MUST digest that credential in the form received, and MUST refuse a proof that states the digest of another. When the call presents none, and the verifier would authorize it under authority it retains from an earlier presentation, it MUST authorize a proof that states a credential digest only under authority retained for that credential. It MUST refuse a request proof whose signed `delegationRef` is not the reference of the presented credential, or is stated where that credential shows no id, or whose signed `delegationChainDigest` is not the digest of the chain the verifier evaluated for the call; a holder has no need to sign either member. - **A proof that names no credential** is one that states nothing, as a proof made before this parameter existed does, or one that states `none` beside a presented credential. It is bound to its subject alone, so the substitution above still succeeds against it. A verifier SHOULD refuse it, and SHOULD refuse a proof that states nothing for a call that presents no delegation. During the transition a verifier MAY accept such a proof, so that holders of an earlier version keep working; one that does MUST NOT report the call as bound to its delegation by the holder, and SHOULD record that the proof named none. Version 2.0.0 of this specification makes each of these refusals a MUST. The statement fixes the ancestors too, wherever each re-delegation states `parentCredentialDigest` (§6.2, §6.10): the digest of the presented credential covers the digest it states of its parent, and so on to the root. Where a credential states none, its parent is named by an id alone, and neither the statement nor anything else the holder signs fixes it. A verifier that reports whether a call's delegation is fixed by the holder reports both: whether the proof named the presented credential, and whether every re-delegation of the chain it evaluated states its parent's digest. The proof of the Entity Card profile (`org.kya-os/proof.v1`, SPEC-ENTITY-CARD.md §8) carries the same parameter in the protected header of its detached JWS, where the credential presented is the last of the chain the request carries, and is held by the same rules. The reference implementation's `generateRequestProof` makes the statement from the `delegation` it is given, which a call that carries its credential in `params._meta` (§14) passes, or else from the `_kyaos_delegation` argument a 1.x call sends, and its `verifyDelegatedCallProof` holds a proof to the credential a call presented, which it takes as a required input. Its server accepts a proof that names no credential by default, with a warning, through 1.x (`delegation.requestBinding: 'prefer'`), refuses one under `'require'`, and refuses one by default from 2.0.0. Appendix C.5 gives a vector, and the `signed-proof/request-binding-*` conformance vectors hold a verifier to each rule. **Compatibility.** `delegationChainDigest` is a new signed claim. A verifier that predates it rebuilds the payload of §7.4 without it and rejects the proof, so a producer SHOULD make the claim an explicit opt-in until the verifiers of its proofs know it. Signing either member from the server is not part of this release of the reference implementation: its server sets neither `delegationRef` nor `delegationChainDigest`, and its verifier checks both against a chain it is given. `delegationRef` has been a payload member since the first version of this chapter and needs no opt-in. The statement of a holder's request proof is a protected header parameter, and not a payload claim, for this reason: a verifier that predates it ignores the parameter (RFC 7515 §4) and verifies the proof as it did before, and one that knows it holds the proof to it. Releases 1.11.0 to 1.25.0 of the reference implementation accept a request proof that carries the parameter, and refuse one whose header was changed after signing (UPGRADING.md). --- ## 8. Outbound Delegation Propagation When an MCP server calls downstream services (APIs, other MCP servers), it MUST forward delegation context. ### 8.1 HTTP Headers | Header | Disposition | Value | |--------|-------------|-------| | `KYA-OS-Delegation-Credential` | **AUTHORITATIVE** | The delegation Verifiable Credential (VC-JWT). The verifier derives granted scopes and the delegation chain from it (its embedded scopes, its chain to a trusted root, its StatusList revocation state). | | `KYA-OS-Delegation-Proof` | **AUTHORITATIVE** | The holder-of-key delegation proof JWT (EdDSA-signed, `aud`-bound to the request authority, `sub` == the Layer-1 signature DID); see §8.2. | | `KYA-OS-Agent-DID` | **AUTHORITATIVE** | The agent's DID. A conformant verifier MUST check it equals the Layer-1 signature's resolved DID. | | `KYA-OS-Session-Id` | Anchor | An anchor of the forwarding server's session for the target's host; never the session ID itself. An anchor, not an authorization input. | | `KYA-OS-Delegation-Chain` | OPTIONAL (advisory) | A transport hint for routing/observability/debugging. **MUST NOT** be used for any authorization decision; ignored when it disagrees with the credential. | | `KYA-OS-Granted-Scopes` | OPTIONAL (advisory) | A transport hint for routing/observability/debugging. **MUST NOT** be used for any authorization decision; ignored when it disagrees with the credential. | **The Verifiable Credential is authoritative.** Granted scopes and the delegation chain are derived from cryptographically-signed artifacts — the `KYA-OS-Delegation-Credential` (VC-JWT) and the `KYA-OS-Delegation-Proof` JWT — never from advisory transport headers. A conformant verifier MUST derive authorization from the credential (its embedded scopes, its chain to a trusted root, its revocation state) and MUST check that `KYA-OS-Agent-DID` equals the Layer-1 signature's resolved DID. `KYA-OS-Delegation-Chain` and `KYA-OS-Granted-Scopes` are advisory only: a conformant verifier MUST NOT trust them for any authorization decision and MUST ignore them when they disagree with the credential. **The session anchor.** A server that resolves anything by its session ID alone, as a durable grant bound to a session is resolved, makes that ID a bearer of the session. A forwarding server MUST NOT send its session ID downstream, since every service it calls, and whatever logs or proxies their headers, would then hold it. It sends instead an anchor of the session for the target: the reference implementation sends `SHA-256(UTF8("org.kya-os.outbound.session-anchor.v1") || 0x00 || JCS([sessionId, host]))`, in the hash format of §7.3, where `host` is the target's host, the `aud` of §8.2. The anchor is one value for every call of one session to one host, so the target can tell which of its calls one session made, and it names nothing the target could present to the forwarding server. **A delegation in force.** A forwarding server MUST NOT forward a delegation that is not in force for it: one that is not active, is before its `notBefore` or past its `notAfter`, or names an `audience` that does not admit the forwarding server's DID. A delegation the forwarding server may not act under is not its to hand on, and forwarding it would send the credential and a fresh proof for it to every service it calls. The reference implementation's `buildOutboundDelegationHeaders` throws for such a record and builds no header. **Corollary (covered components).** Because authority is derived only from signed artifacts — the VC and the proof JWT, each with independent integrity — the Layer-2 headers are **NOT required** to be RFC 9421 covered components. Signing them is permitted as defense-in-depth but is not a conformance requirement. A tampered `KYA-OS-Granted-Scopes` or `KYA-OS-Delegation-Chain` is therefore not a vulnerability: it is ignored by a conformant verifier. ### 8.2 Delegation Proof JWT ```typescript interface DelegationProofJWT { // Standard JWT claims iss: string; // Server DID (JWT issuer) sub: string; // Responsible Party DID (the root issuer of the delegation chain) aud: string; // Target service hostname iat: number; // Issued at (Unix epoch) exp: number; // Expires at (iat + 60 seconds) jti: string; // Unique JWT ID (UUID) // KYA-OS claims delegation_id: string; // Current delegation ID delegation_chain: string; // Chain path (vcId>delegationId) scope: string; // Comma-separated scopes } ``` The JWT is signed with EdDSA using the server's secret key. ### 8.3 Chain String Format ``` > ``` Example: `urn:uuid:d7f8a9b0-1234-5678-9abc-def012345678>del-001` ### 8.4 Gateway Routing Without Body Inspection (MCP 2026-07-28) A policy enforcement point (PEP) or gateway in front of a KYA-OS server can make routing and coarse policy decisions from headers alone, without parsing the JSON body. Under MCP 2026-07-28 (SEP-2243), the request carries the routing headers `Mcp-Method` (the JSON-RPC method, e.g. `tools/call`) and `Mcp-Name` (the target, e.g. the tool name). A KYA-OS-aware gateway MAY: - route on `Mcp-Method` / `Mcp-Name`; and - authenticate the caller and check coarse authority from the KYA-OS delegation headers (§8.1) and the detached `KYA-OS-Delegation-Proof` (§8.2), all before the body is read. This is an optimization only: the origin server MUST still perform full delegation-chain and detached-proof verification (§6, §7) on the request body. Routing headers are advisory and MUST NOT be trusted as authority. --- ## 9. Authorization Flow ### 9.1 verifyOrHints Pattern When a tool call requires authorization: 1. Server checks for valid delegation in the request 2. If delegation is valid and covers required scopes: proceed 3. If delegation is missing or insufficient: return `needs_authorization` error ### 9.2 needs_authorization Error Structure ```typescript interface NeedsAuthorizationError { error: 'needs_authorization'; message: string; authorizationUrl: string; // URL where user can grant authorization resumeToken: string; // Token to resume flow after authorization expiresAt: number; // Unix timestamp in seconds when resumeToken expires scopes: string[]; // Scopes being requested display?: { title?: string; hint?: Array<'link' | 'qr' | 'code'>; authorizationCode?: string; qrUrl?: string; }; } ``` The `needs_authorization` response is itself **signed**: it carries a detached-JWS proof in `_meta` (`outcome: 'needs_authorization'`) whose `responseHash` binds the challenge content, including `authorizationUrl` (see §7.4). A client detects a substituted consent URL by verifying that proof against the resource's DID and recomputing `responseHash` over the challenge it actually received (`ProofVerifier.verifyProof(proof, jwk, { request, response })`) — see §11.1. ### 9.3 Resume Flow 1. Client receives `needs_authorization` error 2. Client verifies the challenge proof against the resource's DID — recomputing `responseHash` over the received content — before trusting `authorizationUrl` (detects a substituted consent URL; §11.1) 3. Client directs user to `authorizationUrl` 4. User authenticates and grants authorization 5. Authorization service issues DelegationCredential 6. Client retries request with `resumeToken` and new delegation 7. Server validates delegation and processes request ### 9.4 OAuth/OIDC Hardening Alignment (MCP 2026-07-28) Where the authorization service in §9.3 is an OAuth 2.0 / OIDC authorization server, the KYA-OS profile aligns with the MCP 2026-07-28 OAuth hardening SEPs. These are *additive* hardening requirements; they do not change the KYA-OS trust model (§15.1), in which authority rides on a verified delegation chain, not on a bearer token. 1. **Issuer validation (RFC 9207 / SEP-2468).** On the authorization callback / resume step, the client MUST validate the `iss` authorization-response parameter against the expected issuer and MUST reject a response whose `iss` does not exactly match. This is verified *in addition to* recomputing `responseHash` over the challenge (§9.3 step 2). 2. **Credential↔issuer binding (SEP-2352).** Any token or credential obtained in step 5 MUST be bound to, and accepted only for, the issuer that minted it; a credential MUST NOT be replayed against a different issuer or resource. 3. **Dynamic Client Registration `application_type` (SEP-837).** Clients performing DCR MUST declare `application_type` and MUST NOT use a redirect URI inconsistent with it. 4. **Refresh & step-up (SEP-2207 / SEP-2350).** Refresh tokens follow SEP-2207; a `step_up_required` outcome (§7.2) accumulates scope per SEP-2350 rather than discarding previously granted scope. 5. **Metadata discovery (SEP-2351).** `.well-known` authorization-server and protected-resource metadata use the SEP-2351 path-suffix form. A KYA-OS server MUST NOT treat successful completion of this OAuth flow as sufficient on its own: the resulting DelegationCredential is still verified per §6 and §7 on the retried request (§9.3 step 7). --- ## 10. Well-Known Endpoint KYA-OS servers SHOULD expose `/.well-known/mcp`. The normative shape is `schemas/well-known-mcpi.json`; the example below validates against it: ```json { "version": "1.0", "serverDid": "did:web:mcp-server.example.com", "capabilities": { "proofs": true, "delegation": true, "statusList": true, "crisp": true }, "clockSkewSeconds": 120, "endpoints": { "tools": "/mcp" }, "statusListCredential": "https://mcp-server.example.com/.well-known/status/1", "supportedDidMethods": ["did:key", "did:web", "did:cheqd"], "proofAlgorithms": ["EdDSA"] } ``` `version` is the protocol version the server speaks, written as §13 says; a 1.x reader also reads the `MAJOR.MINOR.PATCH` form. `serverDid` is the server's own DID, the audience a client binds proofs to. `supportedDidMethods` and `proofAlgorithms` are advisory additional properties (the schema permits them; it does not require them). Servers running the legacy 1.x session profile additionally list `endpoints.handshake` (SPEC-MCP-EXTENSION.md §4); servers on the stateless card-proof profile omit it. Servers SHOULD list `did:cheqd` only when cheqd resolution has been explicitly configured for that deployment. ### 10.1 Clock Skew Negotiation Servers MAY advertise a `clockSkewSeconds` field (type: number, default: 120, minimum: 30, maximum: 600) indicating the tolerance window for timestamp validation. Clients SHOULD read this value on first contact and use it for their own clock-skew tolerance when validating server timestamps, falling back to the hardcoded default (120 seconds) if the field is absent or out of range. --- ## 11. Security Considerations ### 11.0 Trust Model KYA-OS distributes verification work across three trust boundaries. Operators deploying the protocol need to know which component is trusted with what. **1. The agent process itself.** Every agent holds its own Ed25519 secret key and is trusted to use it only on operations the agent has been authorized to perform. Compromise here yields full compromise of every chain the agent can sign under. Mitigations are platform-level: software-only identity (default), proxy-managed identity (key held by a trusted local process), or hardware-attested identity (TEE-bound — SEV-SNP, TDX, Nitro Enclaves). The spec is signature-algorithm-agnostic; operators choose key custody to fit their threat model. **2. The verifier.** At Conformance Level 1 (edge-proxy verification), the verifier sits in front of legacy MCP servers that don't natively understand KYA-OS. In this deployment the verifier is part of the trusted computing base for any resource it gates — a compromised L1 verifier can forge accepts on requests the resource owner would have rejected. **Operators relying on L1 SHOULD treat the verifier as a TCB component**, deploy it with the same isolation as other TCB infrastructure, and minimize its blast radius via per-service or per-tenant verifier instances rather than a single global edge gate. At Conformance Level 2+, verification moves into the resource boundary (native server-side verification). This shrinks the TCB: the edge verifier becomes defense-in-depth rather than the sole gate. **Services protecting sensitive resources SHOULD adopt L2+ to remove the edge verifier from their TCB.** **3. The service / resource owner.** The service decides what scopes it accepts, who its trust registry trusts, and which `did:web` documents it will fetch. Trust-registry decisions are advisory: an adversarial agent can route around registry rejection via credential sharing or request proxying. The cryptographic delegation check is the load-bearing gate; the registry is a signal that raises the friction of adversarial behavior. **Mutual authentication.** Services SHOULD be addressable by a DID (typically `did:web`), and agents performing verification SHOULD authenticate the service identity before sending sensitive payloads. This prevents an agent's delegation from being harvested by a service masquerading as the intended audience. **L2+ is not OAuth-style client registration.** Direct server-side verification (Conformance Level 2+) authenticates the agent's identity, but the access decision still rests on the **delegation chain the agent presents** — the delegated authority rooted at a Responsible Party — not on the agent's identity alone. An authenticated agent holding no valid delegation for the requested resource is denied. This inverts the OAuth Dynamic Client Registration pattern, where a registered client gains access by virtue of being a recognized client: here, being a recognized agent grants nothing without a credential that designates the specific resource (§6.4.1). ### 11.1 Threat Model Summary The table below names each protocol-level threat, the protocol's mitigation, and the residual risk an operator carries. | Threat | Mitigation | Residual risk | |---|---|---| | **Impersonation** — a process claims to be an agent it is not. | Cryptographic identity (Ed25519 + DID). Every tool response carries a detached JWS proof; verifiers check the agent's DID document. | Compromise of an agent's secret key, or compromise of an L1 verifier (see §11.0). | | **Replay** — capturing a valid signed request and re-sending it. | Per-handshake nonces with bounded lifetime, dedupe cache on `(nonce, agentDid)`, ±120s clock skew. | Race within the dedupe cache window. Distributed deployments need atomic check-and-set on the cache. | | **Scope escalation** — a delegated agent invokes outside the delegator's intent. | Scope subset enforcement at every chain link; CRISP `matcher: 'exact'` for sensitive resources. See §11.4. | Implementation bugs in scope-subset checks. | | **Confused deputy** — a multi-resource delegation is repurposed for resources the delegator did not anticipate. | Designation invariant (§6.4.1) + audience-on-redelegation default `true` (§11.6). | Implementation bugs in the designation check. | | **Credential theft** — a `DelegationCredential` is intercepted and used by an attacker. | `audience` constraint; short `notAfter`; session binding at high-security tiers (§11.8); StatusList2021 revocation. | Window between theft and revocation. | | **Agent abuse** — a legitimate agent exceeds expected behavior. | Audit log of every signed tool call (§7); reputation tracking on both agent and Responsible Party (§11.12); revocation. | Detection latency; damage done before revocation propagates. | | **Key compromise** — an agent's secret key is exfiltrated. | Short-lived delegations; explicit revocation; key rotation via DID document update. | Window between compromise and detection. See §11.5. | | **Revocation race** — an invocation arrives while a revocation is propagating. | Status-list TTL bounded ≤ 60s for high-privilege scopes; side-channel revocation signals honored immediately; expiry as primary revocation mechanism. See §6.5.2. | Unavoidable Lamport-concurrent race. Operators bound the window; they cannot eliminate it. | | **Downgrade** — a client strips KYA-OS headers entirely. | Fail-closed: servers requiring identity MUST reject sessionless calls; `/.well-known/mcp` advertises requirements. See §11.7. | A non-compliant client that the operator has not configured to require identity. | | **Consent-URL substitution** — a malicious in-path intermediary swaps the `authorizationUrl` in a `needs_authorization` challenge to phish the user toward an attacker-controlled consent page. | The challenge is signed (`outcome: 'needs_authorization'`); its `responseHash` binds the challenge content incl. the URL (§7.4, §9.2). A client recomputes `responseHash` over the received challenge and verifies the proof against the resource DID, detecting the swap. | A client that does not verify the challenge proof / recompute the hash — the check is the verifier's responsibility (a §11.7-style downgrade). TLS protects the URL in transit; this adds defense against a malicious in-path component. | | **Delegation substitution** - after the fact, a party presents a different chain as the one a signed call was decided under: a credential re-issued under the same id, or another set of ancestors. | `delegationChainDigest` in the response proof, covered by the signature, over every credential the server evaluated; on a refusal as well as on an allowed call (§7.8). | A proof without the digest names the delegation by `delegationRef` alone, a name, so a verifier that needs the binding must require the digest. | | **Delegation swapped in flight** - a party on the path that holds no key forwards a holder's genuine request proof beside another delegation of the same agent, or with the delegation removed or added, so the call is decided under a grant the holder did not choose. | The request proof states the §7.8 digest of the credential its call presents, or `none`, in the JWS protected header its signature covers, and a verifier holds the proof to the credential presented (§7.8); `parentCredentialDigest` fixes each ancestor (§6.2, §6.10). | A proof that names no credential, which a verifier MAY still accept during the transition (§7.8); a re-delegation that states no parent digest; a subject whose key the verifier cannot bind (§11.8). | | **Refusal shown as acceptance** - a party presents a chain of its own making, is refused, and shows the signed refusal, whose digest is that chain's, as evidence that the server accepted it. | The proof's `outcome` is covered by the signature, and a verifier that checks a chain rejects any outcome but the one it expects, an allowed call unless it says otherwise (§7.8). | A verifier that compares the digest and not the outcome. | | **Denial of service** | Per-session and per-handshake rate limiting; session caps; external session storage with TTL eviction. See §11.9. | Standard transport-layer DoS exposure (DDoS) is out of scope — operators rely on conventional network defenses. | ### 11.2 Nonce Replay Attacks - Nonces MUST be cryptographically random (16 bytes minimum entropy) - Nonce cache MUST persist across server restarts (use external storage) - Nonce cache retention MUST cover the timestamp acceptance window (§5.5); it need not reach the session TTL - Distributed deployments MUST use atomic check-and-set operations ### 11.3 Timestamp Skew Attacks - Default skew tolerance is 120 seconds - Servers MAY reduce this for high-security deployments - Servers SHOULD use NTP for time synchronization - Timestamps in proofs allow detection of delayed replay attempts ### 11.4 Delegation Scope Escalation - Child delegations MUST NOT exceed parent scope - Servers MUST validate entire delegation chain, not just leaf - Scope comparison MUST be performed at each chain link - Use CRISP `matcher: 'exact'` for sensitive resources ### 11.5 Key Rotation - did:key: Generate new DID (no rotation mechanism) - did:web: Update `did.json` with new verification method - Old keys SHOULD remain in `did.json` for proof verification - An old key SHOULD stay listed under `assertionMethod` while any delegation credential or status list it signed is still outstanding, or any detached proof it signed is retained for verification (§12.4), since verifiers retrieve those keys only from that relationship (§6.2, §6.6, §7.2) - A new key verifies the issuer's delegation credentials, status lists and detached proofs only once the issuer's DID document lists it under `assertionMethod`, defined once, with an id under the issuer's DID and the issuer's DID as its `controller` (§6.2, §7.2); list it there before signing with it - An issuer SHOULD name its key in every VC-JWT `kid` and proof `verificationMethod` it writes, and MUST name it in a detached proof's `meta.kid` (§7.2); a verifier may check a VC-JWT with no `kid`, or a status list whose proof names no key, with the first `assertionMethod` entry alone (§6.2), so while one is outstanding the key that signed it SHOULD stay that first entry - Delegation credentials reference specific key IDs; reissue after rotation - Key custody options include software-only (default), proxy-managed, and hardware-attested (TEE). See §11.0. ### 11.6 Confused Deputy Attacks A confused deputy attack occurs when Agent B receives a valid delegation from Agent A, then uses it to invoke tools that Agent A did not intend. Because delegation scopes may be coarse-grained (e.g., `tool:*`), the delegated agent may access resources beyond the delegator's intent. - Servers SHOULD enforce the principle of least privilege when issuing delegations - Delegation scopes SHOULD be as narrow as possible (prefer `tool:read_file` over `tool:*`) - CRISP `matcher: 'exact'` SHOULD be used for sensitive resources - Servers MAY implement per-delegation call logging to detect misuse Two normative invariants close the confused-deputy class on the invocation path: 1. **Designation invariant (§6.4.1).** Invocations MUST designate the specific resource being exercised; verifiers MUST reject invocations that rely on a multi-resource delegation without designation. The reference implementation enforces this by requiring each tool's registered `scopeId` to be present in the delegation's authorized scopes before the handler runs. 2. **Audience-on-redelegation default (§this section).** Non-root credentials in a delegation chain MUST carry an `audience` constraint binding them to a specific verifying server. This default is `true` as of v1.3.x; opt-out is available with a one-time per-process warning for legacy integrations. ### 11.7 Downgrade Attacks An adversary or non-compliant client may omit KYA-OS headers entirely, bypassing identity and delegation checks. Because KYA-OS is an extension to MCP, a server cannot distinguish between a client that does not support KYA-OS and one that is deliberately stripping identity headers. - Servers that require identity MUST refuse a tool call that does not prove it (fail-closed): one that presents no delegation that verifies (§6), for a tool that requires delegation, and one without a request proof that verifies (§11.8, or SPEC-ENTITY-CARD §8), where the server requires one - A session is not an identity: sessions are OPTIONAL (§5), so this rule never refuses a call because it names no session - Servers SHOULD NOT fall back to unauthenticated mode for tools that require delegation - The `/.well-known/mcp` endpoint allows clients to discover server requirements before connecting ### 11.8 Delegation Credential Theft If a DelegationCredential is intercepted (e.g., via a compromised transport or log exposure), an attacker may present it to other servers. The `audience` constraint in the credential limits where it can be used, but does not bind it to a specific session or transport channel. - Delegations SHOULD include an `audience` constraint limiting them to the intended server DID - Delegations SHOULD use short `notAfter` expiration windows - Servers SHOULD bind delegation context to the session that presented it - High-security deployments SHOULD use session-scoped delegations (include `sessionId` in constraints) - Revocation via StatusList2021 provides a mitigation path for stolen credentials ### 11.9 Session Exhaustion (Denial of Service) An attacker may send a large volume of valid handshake requests to exhaust server memory. - Implementations MUST enforce a maximum number of concurrent sessions - Implementations SHOULD evict the oldest sessions when the limit is reached - Rate limiting on the handshake endpoint is RECOMMENDED - Distributed deployments SHOULD use external session storage with built-in TTL eviction ### 11.10 Revocation Freshness The Lamport-concurrent revocation race is documented in §6.5.2. The deployment-level controls are: - StatusList2021 credentials have cache-control considerations - Servers SHOULD set appropriate `Cache-Control` headers - High-security deployments MAY require real-time revocation checks - Cascading revocation MUST be atomic - Status-list cache TTL SHOULD be ≤ 60 seconds for high-privilege scopes ### 11.11 Key Custody and Escrow Exclusion KYA-OS excludes centralized agent-key generation as a failure mode. If a single service generated agent keypairs — even transiently — that service would hold the secret material for every identity it provisioned, recreating the escrow weakness of identity-based-encryption-style key-generation centers: one compromise yields every dependent secret key. Agent-controlled key generation (§4.5) removes that single point of total compromise. A registry or verifier that is breached leaks public material and metadata, never agent secret keys, because no protocol component ever holds them. Operators MUST NOT introduce a server-side key-generation or escrow step as a convenience; doing so is non-conformant (§4.5). ### 11.12 Reputation Scope Reputation is tracked primarily on the Responsible Party — the root issuer accountable for a delegation chain (§2). Agent-level reputation, where surfaced, is a secondary signal scoped to a specific binding rather than a free-floating per-agent score. A newly minted agent inheriting authority from a high-reputation Responsible Party MUST be treated as carrying that party's standing for capability decisions, modulo binding-specific risk signals. This closes reputation laundering in both directions: a bad actor cannot shed a poor Responsible-Party history by spawning fresh agents, and a new agent under a trusted party is not penalized for lacking its own history. --- ## 12. Privacy Considerations ### 12.1 DID Correlation A persistent `did:key` or `did:web` identifier acts as a pseudonym. Using the same DID across multiple MCP servers enables cross-server activity correlation. Implementations SHOULD consider per-server DID rotation for privacy-sensitive deployments. ### 12.2 Session Linkability Session IDs (`kyaos_*`) appear in detached proofs. Within a session, all tool calls are linkable. Implementations SHOULD use short session TTLs and avoid logging session IDs alongside PII. ### 12.3 Delegation Chain Disclosure Outbound `KYA-OS-Agent-DID` and `KYA-OS-Delegation-Chain` headers reveal the agent's identity and delegation provenance to downstream services. Implementations SHOULD only propagate delegation headers to trusted downstream services. ### 12.4 Proof Retention and Right to Erasure Detached proofs are audit records containing DIDs and session identifiers. Operators retaining proof logs SHOULD consider applicable data protection regulations (GDPR Art. 17, CCPA) and implement appropriate retention policies. ### 12.5 Per-Delegation Keys (Delegate Unlinkability) A delegate that does not wish to link its activity across delegations MAY present a fresh, single-purpose public key for each delegation it receives, rather than its long-term DID. The delegator issues the `DelegationCredential` to that one-off key, and the delegate proves control of it for that delegation only. This keeps the delegate's primary identity unlinkable across delegations and prevents a delegator — or an observer who sees multiple delegations — from correlating them through a shared subject DID. _Non-normative example:_ an organization delegating read access to an external auditing agent issues each engagement's delegation to a per-engagement key the auditor generates, so separate engagements cannot be cross-correlated via a common subject identifier. --- ## 13. Protocol Versioning The current protocol version is `1.0`. A protocol version is written `MAJOR.MINOR`: two decimal integers joined by a dot, as the handshake schemas take it. A handshake request SHOULD state the version the client speaks, as `clientProtocolVersion: "1.0"`. A request that states none is of version `1.0`. For the 1.x line a server MUST also read a `clientProtocolVersion` of the form `MAJOR.MINOR.PATCH`, which earlier text of this section told clients to send, by its major and minor version. A server MUST refuse a handshake whose `clientProtocolVersion` is of a major version other than its own (a `2.x` server refuses a `1.x` client), with the error code `protocol_version_unsupported` (Appendix A), and before it checks anything else of the request, so the refusal spends no nonce. A server MUST serve a client of its own major version, whatever its minor version. For the 1.x line a server reads a `clientProtocolVersion` that is not a version as none, as 1.x servers have; 2.0.0 refuses it. Every handshake response states the version the server speaks, as `protocolVersion`, a refusal as well as an acceptance (§5.3), so a client refused for its version learns the version to speak. The `identity` action of the `_kyaos` tool (§14) states it too. --- ## 14. Transport Binding KYA-OS is transport-agnostic. The handshake and proofs use standard MCP mechanisms: **Handshake**: Implemented as an MCP tool named `_kyaos`, called with `action: "handshake"` and the members of §5.1 as its arguments. The tool's other actions are `identity`, which answers the server's DID, key and protocol version, and `reputation`. A 1.x server MAY also register the tool `_kyaos_handshake`, which takes the members of §5.1 with no `action`; that name is deprecated, and 2.0.0 removes it. Both work over every MCP transport (stdio, SSE, HTTP Streamable) without modification. **Proof attachment**: Detached proofs are attached to tool responses in the standard MCP `_meta` field, which is transported transparently by all MCP transport implementations. **What a tool call carries**: Every KYA-OS datum of a `tools/call` rides its `params._meta`, under a key of its own, so none is a tool argument and none is covered by `requestHash` (§7.3 rule 1): | Datum | Carrier | Value | When | 1.x argument also read | |---|---|---|---|---| | Session | `params._meta["org.kya-os/session"]` | the `sessionId` of the handshake response (§5.3) | OPTIONAL, when the client has a session (§5.6) | none | | Delegation | `params._meta["org.kya-os/delegation-credential"]` | the §6.2 `DelegationCredential` the call presents, as its issuer signed it: a JSON object with its embedded proof, or a VC-JWT string | for a tool that requires delegation | `_kyaos_delegation` | | Holder-of-key request proof | `params._meta["org.kya-os/holder-proof"]` | a detached proof (§7.4) whose `did` is the delegation's subject and whose `audience` is the server's DID, with no `responseHash`, over the call (§7.3), stating its delegation (§7.8): a JSON object, or its JSON text | where the server requires holder binding (§11.8) | `_kyaos_proof` | | Approval grants | `params._meta["org.kya-os/approvals"]` | the approval grants of a step-up resume (§9.3) | on a resume | `_kyaos_approvals` | The response proof rides the result's `_meta["org.kya-os/response-proof"]` (§7.5). The Entity Card profile carries its request proof and delegation chain in `params._meta` too, under `org.kya-os/request-proof` and `org.kya-os/delegation-chain` (SPEC-ENTITY-CARD §8.2, §10.5). A client SHOULD carry each datum in `params._meta`. For the 1.x line a server MUST also read the argument the table names, and when a call carries a datum both ways the server MUST read `params._meta` and MUST NOT read the argument. A server MUST NOT hand a `_kyaos*` argument to the tool (§7.3). 2.0.0 reads `params._meta` alone. The session a call names is the caller's claim: the handshake that opened it is unsigned, and its id appears in every proof made under it, so anyone who has seen such a proof can name it. A server MUST NOT authorize a call on it, for instance on a grant it bound to that session. A server MUST NOT prove the call's result under it unless it would treat the call as made in that session had it named none, and MUST NOT renew the session's idle time for the call otherwise. A server MAY treat a call that names no session as made in its only live session. A server that cannot take the session a call names serves the call and makes no session-bound proof for it, and MUST NOT make one under another session. **Outbound delegation headers**: When an MCP server makes outbound HTTP calls (not MCP calls), delegation context is propagated via HTTP headers as defined in §8. For MCP-to-MCP calls, the delegation travels in the call itself, as the table above says. **Body-free routing**: On HTTP transports, intermediaries MAY route on the MCP 2026-07-28 routing headers `Mcp-Method` and `Mcp-Name` (SEP-2243) and verify the KYA-OS delegation headers (§8.1) and detached proof (§8.2) without inspecting the request body. See §8.4. The origin server remains responsible for full verification. --- ## 15. Conformance Implementation conformance requirements are defined in `CONFORMANCE.md`. Three compliance levels are specified: - **Level 1 — Core Crypto**: Basic key generation, signing, verification, and well-known endpoint - **Level 2 — Full Session**: Session handshake, nonce replay prevention, proof generation - **Level 3 — Full Delegation**: VC issuance/verification, delegation graphs, revocation, outbound propagation See `CONFORMANCE.md` for detailed requirements and test references. ### 15.1 Relationship to OAuth Dynamic Client Registration KYA-OS L2+ is not OAuth Dynamic Client Registration restated. OAuth-DCR binds a client by a `client_id`/`client_secret` registered with an authorization server, after which authority rides on a bearer token. KYA-OS binds an agent by its DID and requires the delegation chain to be presented and cryptographically verified at every invocation (§6, §7). The delegation chain remains required and verifiable at Level 2 and Level 3 regardless of whether or how the agent's identity is recorded in a trust registry (§6.8). Registry presence is discovery and a trust signal (§11.0), never a substitute for chain verification. This is complementary to, not in tension with, MCP 2026-07-28's OAuth hardening. Where KYA-OS interoperates with an OAuth/OIDC authorization server (§9.4), it adopts that server-side hardening — `iss` validation per RFC 9207 (SEP-2468), credential↔issuer binding (SEP-2352), DCR `application_type` (SEP-837) — as the *token-acquisition* layer, while the delegation chain (§6, §7) remains the *authority* layer verified at every invocation. OAuth hardening strengthens how a credential is obtained; it never becomes the basis on which a KYA-OS request is authorized. ### 15.2 MCP 2026-07-28 Compatibility KYA-OS is designed to layer cleanly on the MCP 2026-07-28 Release Candidate. - **Stateless core.** MCP removed `initialize`/`initialized` (SEP-2575) and the `Mcp-Session-Id` header (SEP-2567). KYA-OS does not depend on either: every KYA-OS request is authorized from its self-contained detached-JWS proof (§7) and DID-anchored grant (§6). The KYA-OS session (§5) is an optional KYA-OS-owned convenience layer delivered through the `_kyaos` tool's `handshake` action (§14) and is independent of MCP's removed session. A server proves a call under the session the call names only where it would prove a call that names none (§14), with or without `Mcp-Session-Id`. - **`_meta` reserved-namespace coexistence.** KYA-OS publishes its response proof under the reverse-DNS key `org.kya-os/response-proof` and ignores all other `_meta` keys, including the MCP-reserved `io.modelcontextprotocol/*` and W3C Trace Context keys `traceparent`/`tracestate`/`baggage` (SEP-414). See §7.6. - **Routing headers.** KYA-OS gateways MAY use `Mcp-Method`/`Mcp-Name` (SEP-2243) for body-free routing (§8.4). - **JSON Schema 2020-12.** Tool `inputSchema`/`outputSchema` and KYA-OS schemas use JSON Schema 2020-12 (SEP-2106); see §6.2. - **Extensions Track intent (SEP-2133).** KYA-OS intends to register as an MCP Extension under the proposed reverse-DNS extension id `org.kya-os/decentralized-authority`, with an `ext-*` repository, independent versioning, and negotiation via the `extensions` capability map. Once registered, the canonical proof key (§7.6 `proofMetaKey`) and capability advertisement (§10) will use that extension id; the key is configurable for this reason. KYA-OS targets the SEP-2133 Standards-Track path. - **Deprecations are zero-impact.** SEP-2577 deprecates MCP **Roots**, **Sampling**, and **Logging** on 12-month windows. KYA-OS uses **none** of these features, so the deprecations have **no impact** on KYA-OS implementations. ### 15.3 Auditability Protocol An implementation that advertises a KYA-OS Audit Assurance Profile (AAP) MUST use the versioned audit schemas under `schemas/audit-*.schema.json` and MUST NOT infer a stronger claim from detached proofs alone. The audit protocol separates three authorities: 1. The producer emits a strict, privacy-minimal event with a stable event ID, source ID, source sequence, and optional source-predecessor digest. 2. Exactly one authoritative recorder for a `(ledgerId, ledgerEpochId)` assigns recorder time, a monotonically increasing decimal sequence, the previous entry digest, and a signed append receipt through an atomic compare-and-append operation. 3. An independent observer MAY retain and compare signed RFC 9162 checkpoints. WORM, RFC 3161, and SCITT receipts are supporting anchors and MUST NOT be represented as independent split-view detection. The producer event, entry, receipt, checkpoint, observation, and bundle manifest MUST be strictly schema-valid before RFC 8785 canonicalization. Integrity hashes MUST use the domain-separated construction `SHA-256(UTF8(domain) || 0x00 || JCS(value))`. Entries are immutable: correction, redaction, disposal, retention, legal-hold, key transition, and epoch transition are represented by new events. Redelivery of the same authenticated producer/source/event identity and the same frozen producer bytes MUST return the original stored receipt. Reuse with different bytes MUST fail. This idempotency namespace spans retained epochs of the logical ledger. A new epoch starts at sequence zero only through a signed genesis that commits the prior epoch and its terminal checkpoint. Replay-bundle verification MUST receive recorder/observer/exporter trust and purpose/scope authorization out of band. Bundle contents cannot authorize their own signer or bootstrap their own trust root. A verifier MUST distinguish `valid`, `invalid`, and `indeterminate`, MUST keep authorization-as-observed separate from current authorization/revocation, and MUST NOT consume a live nonce cache when verifying historical proof artifacts. A verifier MUST NOT ignore a verification-policy constraint (checkpoint-bounded key validity, required assurance profile, key revocation mode), and a constraint it cannot evaluate for the artifacts at hand MUST NOT leave the affected dimension `valid`. Sensitive payloads SHOULD be encrypted in a separate evidence provider and referenced by opaque randomized identifiers and ciphertext commitments. The integrity ledger MUST NOT contain raw tool arguments, responses, access tokens, or free-form exception text by default. Evidence disposal MUST NOT mutate the retained integrity history. The AAP levels are cumulative: - **AAP-0:** no audit assurance. - **AAP-1 Recorded:** structured capture of delivered instrumented events. - **AAP-2 Chained:** durable atomic accepted history with non-best-effort delivery. - **AAP-3 Transparent:** AAP-2 plus durable source high-water reconciliation and signed RFC 9162 checkpoints/proofs. - **AAP-4 Observed:** AAP-3 plus independently administered checkpoint observation and authenticated view comparison, with supporting external receipt evidence. Implementations MUST advertise capabilities truthfully and MUST reject startup when configured mechanics cannot satisfy the selected profile. Full event semantics, provider contracts, failure behavior, privacy guidance, replay-bundle rules, and operational requirements are specified in [`AUDITABILITY.md`](./AUDITABILITY.md). --- ## 16. References ### Normative References - **[RFC 2119]** IETF. *Key words for use in RFCs to Indicate Requirement Levels*. https://datatracker.ietf.org/doc/html/rfc2119 - **[DID-CORE]** W3C. *Decentralized Identifiers (DIDs) v1.0*. https://www.w3.org/TR/did-core/ - **[CID]** W3C. *Controlled Identifiers v1.0*. https://www.w3.org/TR/cid-1.0/ - **[VC-DATA-MODEL]** W3C. *Verifiable Credentials Data Model v1.1*. https://www.w3.org/TR/vc-data-model/ - **[VC-DATA-MODEL-2.0]** W3C. *Verifiable Credentials Data Model v2.0*. https://www.w3.org/TR/vc-data-model-2.0/ - **[VC-DI-EDDSA]** W3C. *Data Integrity EdDSA Cryptosuites v1.0*. https://www.w3.org/TR/vc-di-eddsa/ - **[VC-DATA-INTEGRITY]** W3C. *Verifiable Credential Data Integrity 1.0*. https://www.w3.org/TR/vc-data-integrity/ - **[URL]** WHATWG. *URL Standard*. https://url.spec.whatwg.org/ - **[DID-KEY]** W3C CCG. *did:key Method Specification*. https://w3c-ccg.github.io/did-method-key/ - **[DID-WEB]** W3C CCG. *did:web Method Specification*. https://w3c-ccg.github.io/did-method-web/ - **[STATUS-LIST-2021]** W3C CCG. *Status List 2021*. https://w3c-ccg.github.io/vc-status-list-2021/ - **[BITSTRING-STATUS-LIST]** W3C. *Bitstring Status List v1.0*. https://www.w3.org/TR/vc-bitstring-status-list/ - **[RFC8037]** IETF. *CFRG Elliptic Curve Diffie-Hellman (ECDH) and Signatures in JOSE*. https://datatracker.ietf.org/doc/html/rfc8037 - **[RFC7517]** IETF. *JSON Web Key (JWK)*. https://datatracker.ietf.org/doc/html/rfc7517 - **[RFC7515]** IETF. *JSON Web Signature (JWS)*. https://datatracker.ietf.org/doc/html/rfc7515 - **[RFC8785]** IETF. *JSON Canonicalization Scheme (JCS)*. https://datatracker.ietf.org/doc/html/rfc8785 - **[RFC7493]** IETF. *The I-JSON Message Format*. https://datatracker.ietf.org/doc/html/rfc7493 - **[RFC3339]** IETF. *Date and Time on the Internet: Timestamps*. https://datatracker.ietf.org/doc/html/rfc3339 ### Informative References - **[MCP]** Anthropic. *Model Context Protocol Specification*. https://spec.modelcontextprotocol.io/ - **[VC-JOSE-COSE]** W3C. *Securing Verifiable Credentials using JOSE and COSE*. https://www.w3.org/TR/vc-jose-cose/ - **[MULTICODEC]** Multiformats. *Multicodec Table*. https://github.com/multiformats/multicodec - **[MULTIBASE]** Multiformats. *Multibase Specification*. https://github.com/multiformats/multibase --- ## Appendix A: Error Codes | Code | Description | |------|-------------| | `handshake_failed` | Handshake validation failed (timestamp, nonce, or audience) | | `protocol_version_unsupported` | The handshake states a protocol version of another major version (§13) | | `session_expired` | Session not found or expired | | `delegation_invalid` | Delegation verification failed | | `insufficient_scope` | Requested operation outside delegated scope | | `delegation_revoked` | Delegation has been revoked | | `invalid_proof` | Proof verification failed | | `did_not_found` | DID resolution failed | --- ## Appendix B: Base58btc Alphabet ``` 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz ``` Note: Excludes `0`, `O`, `I`, `l` to avoid visual ambiguity. --- ## Appendix C: Test Vectors These test vectors enable interoperability testing across implementations. ### C.1 SHA-256 Canonical Hash **Input JSON:** ```json {"method":"tools/call","params":{"name":"echo","arguments":{}}} ``` **JCS Canonicalized (RFC 8785):** ```json {"method":"tools/call","params":{"arguments":{},"name":"echo"}} ``` **SHA-256 (hex):** ``` 5057521f310b536837b619f0ac040ef8064f8c597da8ec22a56801b435744033 ``` **KYA-OS Format:** ``` sha256:5057521f310b536837b619f0ac040ef8064f8c597da8ec22a56801b435744033 ``` **Covered request (§7.3).** `requestHash` covers a request's `method` and `params` minus `params._meta` and, on a `tools/call`, minus the `_kyaos*` control arguments; an absent `arguments` is covered as `{}`. Each of these requests covers to the input above and hashes to the same value: ```json {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"echo","arguments":{"_kyaos_proof":{"jws":"...","meta":{}}},"_meta":{"traceparent":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}}} ``` ```json {"method":"tools/call","params":{"name":"echo"}} ``` Business arguments stay covered: **Input JSON:** ```json {"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"echo","arguments":{"msg":"hi","_kyaos_delegation":{"id":"urn:uuid:1111-aaaa"}},"_meta":{"progressToken":7}}} ``` **Covered request, JCS canonicalized:** ```json {"method":"tools/call","params":{"arguments":{"msg":"hi"},"name":"echo"}} ``` **KYA-OS Format:** ``` sha256:c8f3d59959c9247211de8c76b94ef17f0c279f09362350ced67f69ecdb89d6c7 ``` ### C.2 did:key Derivation **Ed25519 Public Key (32 bytes, hex):** ``` 8076ee2cfc1acdd3f8f4e38c665a0a3e6ad6e06dc05b4f6ec9c5b1ae7c81c9a2 ``` **Steps:** 1. Prepend multicodec prefix `0xed01` (Ed25519 public key) 2. Encode with base58btc 3. Prepend multibase prefix `z` **Multicodec + Key (hex):** ``` ed018076ee2cfc1acdd3f8f4e38c665a0a3e6ad6e06dc05b4f6ec9c5b1ae7c81c9a2 ``` **Base58btc Encoded:** ``` 6Mko6jQvza2BSKRcrbJwgwbL9KYDn1isCUV5Lnq7gSTTKJq ``` **did:key:** ``` did:key:z6Mko6jQvza2BSKRcrbJwgwbL9KYDn1isCUV5Lnq7gSTTKJq ``` **Verification Method ID:** ``` did:key:z6Mko6jQvza2BSKRcrbJwgwbL9KYDn1isCUV5Lnq7gSTTKJq#z6Mko6jQvza2BSKRcrbJwgwbL9KYDn1isCUV5Lnq7gSTTKJq ``` ### C.3 JWS Structure A valid detached proof JWS has the following structure: **Protected Header (decoded):** ```json { "alg": "EdDSA", "kid": "did:key:z6Mk...#z6Mk..." } ``` **Payload (decoded, canonicalized):** ```json { "aud": "did:web:server.example.com", "iss": "did:web:server.example.com", "nonce": "abc123...", "requestHash": "sha256:5057521f...", "responseHash": "sha256:d4e5f6...", "sessionId": "kyaos_d7f8a9b0-...", "sub": "did:web:server.example.com", "ts": 1710288000 } ``` **Signature:** ``` Ed25519Sign(privateKey, BASE64URL(header) || "." || BASE64URL(canonicalize(payload))) ``` **Compact JWS:** ``` .. ``` Note: Actual signature values are key-dependent. Implementers should verify the structure and use the test key material from the reference implementation's test suite for bit-exact validation. ### C.4 Delegation Chain Digest A two-credential chain (§7.8): the root as a credential object, the leaf as a compact VC-JWT. The credentials and their signatures are shortened to keep the vector readable; neither signature is meant to verify. **Root credential (object):** ```json { "id": "urn:uuid:1111-aaaa", "type": ["VerifiableCredential", "DelegationCredential"], "issuer": "did:web:user.example.com", "credentialSubject": { "id": "did:web:agent-a.example.com" }, "proof": { "type": "Ed25519Signature2020", "created": "2024-03-01T12:00:00Z", "verificationMethod": "did:web:user.example.com#key-1", "proofPurpose": "assertionMethod", "proofValue": "c2lnbmF0dXJlLW9mLXJvb3Q" } } ``` **Root signed form, canonical (RFC 8785):** ``` {"credential":{"credentialSubject":{"id":"did:web:agent-a.example.com"},"id":"urn:uuid:1111-aaaa","issuer":"did:web:user.example.com","type":["VerifiableCredential","DelegationCredential"]},"signature":"c2lnbmF0dXJlLW9mLXJvb3Q"} ``` **Root credential digest** (SHA-256 over `org.kya-os.delegation.credential.v1`, a zero byte, and the line above): ``` sha256:6fbe4c0f04413cb40ec3b3069bf7c73dc1b6a681765e95ac451672136328712e ``` The same digest results when `proofValue` is `c2lnbmF0dXJlLW9mLXJvb3R` (a spare bit set), `c2lnbmF0dXJlLW9mLXJvb3Q=` (padded) or `c2lnbmF0dXJl LW9mLXJvb3Q` (a space inside), each of which carries the same signature, and when any other member of `proof` changes. **Leaf credential (compact VC-JWT):** ``` eyJhbGciOiJFZERTQSJ9.eyJ2YyI6e319.c2lnbmF0dXJlLW9mLWxlYWY ``` **Leaf signed form, canonical:** ``` {"jwt":"eyJhbGciOiJFZERTQSJ9.eyJ2YyI6e319","signature":"c2lnbmF0dXJlLW9mLWxlYWY"} ``` **Leaf credential digest:** ``` sha256:d29d65862fce70137390bea2859696c7ad80ce88cede778fea1cab24d513eed1 ``` **Chain, canonical, root first:** ``` ["sha256:6fbe4c0f04413cb40ec3b3069bf7c73dc1b6a681765e95ac451672136328712e","sha256:d29d65862fce70137390bea2859696c7ad80ce88cede778fea1cab24d513eed1"] ``` **`delegationChainDigest`** (SHA-256 over `org.kya-os.delegation.chain.v1`, a zero byte, and the line above): ``` sha256:2df99ab7f9b80436dba945e0dfb7a37bd7b35400c82bbc72a5c2744f516eb788 ``` ### C.5 Request Proof Naming Its Delegation A holder's request proof that states the delegation its call presents (§7.8), signed, so that an implementation can reproduce it to the last byte: Ed25519 signs deterministically. The holder's key is the first test key of RFC 8032 §7.1, and its DID is the did:key §4.3 derives for it. The credential is shortened as in C.4, and its own signature is not meant to verify. **Holder private key (32 bytes, hex):** ``` 9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60 ``` **Holder public key (32 bytes, hex):** ``` d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a ``` **Verification method (`kid`):** ``` did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw#z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw ``` **Credential presented (object):** ```json { "id": "urn:uuid:2222-bbbb", "type": ["VerifiableCredential", "DelegationCredential"], "issuer": "did:web:user.example.com", "credentialSubject": { "id": "did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw" }, "proof": { "type": "Ed25519Signature2020", "created": "2024-03-01T12:00:00Z", "verificationMethod": "did:web:user.example.com#key-1", "proofPurpose": "assertionMethod", "proofValue": "c2lnbmF0dXJlLW9mLWNyZWRlbnRpYWw" } } ``` **Signed form, canonical (RFC 8785):** ``` {"credential":{"credentialSubject":{"id":"did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw"},"id":"urn:uuid:2222-bbbb","issuer":"did:web:user.example.com","type":["VerifiableCredential","DelegationCredential"]},"signature":"c2lnbmF0dXJlLW9mLWNyZWRlbnRpYWw"} ``` **Credential digest**, which the proof states: ``` sha256:52bf13b89717bcec22e230f770471f09746b081b7f73da43094cd9aad511dc1a ``` **Protected header**, as signed: ``` {"alg":"EdDSA","kid":"did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw#z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw","org.kya-os/delegation":"sha256:52bf13b89717bcec22e230f770471f09746b081b7f73da43094cd9aad511dc1a"} ``` **Payload, canonical**, for the call of C.1 whose business arguments are `{"msg":"hi"}`: ``` {"aud":"did:web:server.example.com","iss":"did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw","nonce":"bm9uY2UtYzUtMDAwMDAwMQ","requestHash":"sha256:c8f3d59959c9247211de8c76b94ef17f0c279f09362350ced67f69ecdb89d6c7","sessionId":"kyaos_c5-session","sub":"did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw","ts":1710288000} ``` **Compact JWS** (`BASE64URL(header) . BASE64URL(payload) . BASE64URL(signature)`): ``` eyJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa3R3dXBkbUxYVlZxVHpDdzRpNDZyNHVHeW9zR1hSblIzWGpONFpxN29NTXN3I3o2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsIm9yZy5reWEtb3MvZGVsZWdhdGlvbiI6InNoYTI1Njo1MmJmMTNiODk3MTdiY2VjMjJlMjMwZjc3MDQ3MWYwOTc0NmIwODFiN2Y3M2RhNDMwOTRjZDlhYWQ1MTFkYzFhIn0.eyJhdWQiOiJkaWQ6d2ViOnNlcnZlci5leGFtcGxlLmNvbSIsImlzcyI6ImRpZDprZXk6ejZNa3R3dXBkbUxYVlZxVHpDdzRpNDZyNHVHeW9zR1hSblIzWGpONFpxN29NTXN3Iiwibm9uY2UiOiJibTl1WTJVdFl6VXRNREF3TURBd01RIiwicmVxdWVzdEhhc2giOiJzaGEyNTY6YzhmM2Q1OTk1OWM5MjQ3MjExZGU4Yzc2Yjk0ZWYxN2YwYzI3OWYwOTM2MjM1MGNlZDY3ZjY5ZWNkYjg5ZDZjNyIsInNlc3Npb25JZCI6Imt5YW9zX2M1LXNlc3Npb24iLCJzdWIiOiJkaWQ6a2V5Ono2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsInRzIjoxNzEwMjg4MDAwfQ.wn1TFvrzCXbbYlB4f8q3g3JTJvVZOO7CzyutpqvVILWfAo1Xg-VXJZ1H0lbVgfi_ImIPdytpT561MBCOUqwtBw ``` A verifier that is presented the credential above beside this proof binds it. One that is presented any other credential, the same one with another `proofValue` included, refuses it, since that credential has another digest. **The same delegation sent as a compact VC-JWT** has another signed form, so another digest, and a proof names the form its call sends. The VC-JWT is shortened as the object is: its header is `{"alg":"EdDSA","typ":"JWT"}`, and its payload states the `iss`, `sub` and `jti` of the credential above. **Credential presented (compact VC-JWT):** ``` eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkaWQ6d2ViOnVzZXIuZXhhbXBsZS5jb20iLCJzdWIiOiJkaWQ6a2V5Ono2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsImp0aSI6InVybjp1dWlkOjIyMjItYmJiYiIsInZjIjp7InR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJEZWxlZ2F0aW9uQ3JlZGVudGlhbCJdfX0.c2lnbmF0dXJlLW9mLWNyZWRlbnRpYWw ``` **Signed form, canonical (RFC 8785):** ``` {"jwt":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkaWQ6d2ViOnVzZXIuZXhhbXBsZS5jb20iLCJzdWIiOiJkaWQ6a2V5Ono2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsImp0aSI6InVybjp1dWlkOjIyMjItYmJiYiIsInZjIjp7InR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJEZWxlZ2F0aW9uQ3JlZGVudGlhbCJdfX0","signature":"c2lnbmF0dXJlLW9mLWNyZWRlbnRpYWw"} ``` **Credential digest**, which the proof states: ``` sha256:118311d6a525a36fe5e3d7fc5dc67b7e4fdd032d8b9b71799b476a82cbacb1ca ``` **Protected header**, as signed: ``` {"alg":"EdDSA","kid":"did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw#z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw","org.kya-os/delegation":"sha256:118311d6a525a36fe5e3d7fc5dc67b7e4fdd032d8b9b71799b476a82cbacb1ca"} ``` **Compact JWS**, over the same payload: ``` eyJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa3R3dXBkbUxYVlZxVHpDdzRpNDZyNHVHeW9zR1hSblIzWGpONFpxN29NTXN3I3o2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsIm9yZy5reWEtb3MvZGVsZWdhdGlvbiI6InNoYTI1NjoxMTgzMTFkNmE1MjVhMzZmZTVlM2Q3ZmM1ZGM2N2I3ZTRmZGQwMzJkOGI5YjcxNzk5YjQ3NmE4MmNiYWNiMWNhIn0.eyJhdWQiOiJkaWQ6d2ViOnNlcnZlci5leGFtcGxlLmNvbSIsImlzcyI6ImRpZDprZXk6ejZNa3R3dXBkbUxYVlZxVHpDdzRpNDZyNHVHeW9zR1hSblIzWGpONFpxN29NTXN3Iiwibm9uY2UiOiJibTl1WTJVdFl6VXRNREF3TURBd01RIiwicmVxdWVzdEhhc2giOiJzaGEyNTY6YzhmM2Q1OTk1OWM5MjQ3MjExZGU4Yzc2Yjk0ZWYxN2YwYzI3OWYwOTM2MjM1MGNlZDY3ZjY5ZWNkYjg5ZDZjNyIsInNlc3Npb25JZCI6Imt5YW9zX2M1LXNlc3Npb24iLCJzdWIiOiJkaWQ6a2V5Ono2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsInRzIjoxNzEwMjg4MDAwfQ.tki3aTL2MZwFUmKHZHQ28GRmI1kEahphrsJr-1v245z4M_n-qVp_Wabn-gdaIFjy1YYHCFalRarTOMzs9DT1Dg ``` A verifier that is presented the VC-JWT beside this proof binds it, and refuses it beside the credential object, as it refuses the proof above beside the VC-JWT. **For a call that presents no delegation**, the same holder states `none`. **Protected header**, as signed: ``` {"alg":"EdDSA","kid":"did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw#z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw","org.kya-os/delegation":"none"} ``` **Compact JWS**, over the same payload: ``` eyJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa3R3dXBkbUxYVlZxVHpDdzRpNDZyNHVHeW9zR1hSblIzWGpONFpxN29NTXN3I3o2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsIm9yZy5reWEtb3MvZGVsZWdhdGlvbiI6Im5vbmUifQ.eyJhdWQiOiJkaWQ6d2ViOnNlcnZlci5leGFtcGxlLmNvbSIsImlzcyI6ImRpZDprZXk6ejZNa3R3dXBkbUxYVlZxVHpDdzRpNDZyNHVHeW9zR1hSblIzWGpONFpxN29NTXN3Iiwibm9uY2UiOiJibTl1WTJVdFl6VXRNREF3TURBd01RIiwicmVxdWVzdEhhc2giOiJzaGEyNTY6YzhmM2Q1OTk1OWM5MjQ3MjExZGU4Yzc2Yjk0ZWYxN2YwYzI3OWYwOTM2MjM1MGNlZDY3ZjY5ZWNkYjg5ZDZjNyIsInNlc3Npb25JZCI6Imt5YW9zX2M1LXNlc3Npb24iLCJzdWIiOiJkaWQ6a2V5Ono2TWt0d3VwZG1MWFZWcVR6Q3c0aTQ2cjR1R3lvc0dYUm5SM1hqTjRacTdvTU1zdyIsInRzIjoxNzEwMjg4MDAwfQ.o0ar1iBiL7mHkjvhOEvKqgtBqxG5t6O_byDoAqUv3ZXB9pwvlCHqG9fhFS1ugg2vznN1D-FFgpI_LCly9FAJBA ``` --- *End of Specification*