HomeDocumentation

Delegation Extension

A delegation is a signed statement that an issuer authorizes a delegate to act on its behalf within a defined scope. Delegations can be chained: if A delegates to B and B delegates to C, a verifier walks the chain from C back to A, checking each link independently.

Delegations support two binding modes. In key-bound mode, the delegate is identified by the hash of their public key, and verification is purely cryptographic — no network lookups needed. In domain-bound mode, the delegate is identified by one or more domains, and the verifier resolves the delegate's current public key from their .well-known/ocp-keys endpoint at verification time.


Binding Modes

A delegation binds to its delegate by key, by domain, or both:

Key-bound (secretHash)

The delegate is identified by the hash of their public key. Verifiers checkhash(childPublicKey) == secretHash. Used for cryptographic key chains where the delegate will sign further claims. Verification requires only public keys — no shared secrets.

Domain-bound (domains)

The delegate is identified by one or more domains. Verifiers resolve the delegate's current public key from https://<domain>/.well-known/ocp-keys at verification time. Used for publisher and distribution grants where the delegate may rotate keys independently.

Both may be present to pin a domain to a specific key. If both are present and disagree (the key fetched from the domain doesn't match secretHash), verification fails.


Statement Fields

Required

FieldTypeDescription
parentstringIdentity of the delegator. For ES256: SHA-256(parentPublicKey) as hex. For EIP712/k256: Ethereum address.
labelstringScoping string. Delegations with different labels are independent — a key delegated under one label cannot be used under another.
issuedTimeintegerUnix timestamp of when the delegation was created.

Standard Optional

FieldTypeDescription
secretHashstringHash of the delegate's public key. For ES256: SHA-256(childPublicKey) as hex. For EIP712/k256: keccak256(childPublicKey) as hex. Required for key-bound delegations.
domainsarray of stringsDomains that identify the delegate. All listed domains are treated as one delegate (e.g. ["publisher.com", "app.publisher.com"]). Required for domain-bound delegations.
contextstringFreeform string constraining the delegation's scope. Application-defined. Default: "".
limitsarray of objectsRate limits the delegate must enforce when granting access downstream. Each object has one quantity key (freeform, application-defined) and a per field naming the period. See Rate Limits below.
geoobjectGeographic restrictions. Contains either includeCountries or excludeCountries (not both). See Geographic Restrictions below.
allowIPsarray of stringsIP allowlist. If present, requests must originate from a matching IP. Supports CIDR notation and wildcards. See IP Restrictions below.
maxDepthintegerMaximum re-delegation depth. 0 means the delegate cannot re-delegate at all (can only act, not authorize others). 1 means one level of re-delegation is allowed (e.g. publisher can issue viewer tickets but viewers can't re-delegate). Absent means unlimited depth. See Re-delegation Depth below.

At least one of secretHash or domains must be present.

Application-Defined Fields

Additional fields may appear in stm beyond the ones listed above. The standard fields have defined semantics that verifiers must respect. Application-defined fields are opaque to generic verifiers but meaningful to specific implementations.


Rate Limits

The limits array contains one or more rate limit objects. Each object has exactly one quantity key and a per field:

json
"limits": [
  { "minutes": 30, "per": "day" },
  { "videos": 5, "per": "day" },
  { "minutes": 200, "per": "month" }
]

The quantity key (e.g. minutes, videos) is freeform and application-defined. The protocol does not prescribe which quantities exist — applications define and enforce their own. Common examples include minutes, videos,bytes, requests.

The per field is one of: hour, day, week,month, year. Periods reset on natural boundaries (midnight UTC forday, first of month for month, etc.).

When multiple limits are present, all of them apply simultaneously. A request that would exceed any single limit is denied.

Rate limits are declarative constraints. The issuer states the limits; the verifying server (e.g. a Safecloud jet) enforces them by tracking consumption per viewer per delegation.


Geographic Restrictions

The geo object restricts where the delegation is valid, based on the viewer's IP geolocation:

Exclude Mode

Valid everywhere except the listed countries:

json
"geo": {
  "excludeCountries": ["KP", "IR", "SY"]
}

Include Mode

Valid only in the listed countries:

json
"geo": {
  "includeCountries": ["US", "CA", "GB", "AU"]
}

Country codes are ISO 3166-1 alpha-2. Only one of includeCountries orexcludeCountries should be present. If both are present, includeCountriestakes precedence.

The verifying server determines the viewer's country by IP geolocation and checks it against the restriction. If geo is absent, the delegation is valid globally.


IP Restrictions

The allowIPs array restricts which source IPs may use this delegation. This is useful when the delegate is a server with known IPs (e.g. a publisher's backend), not an end user on a dynamic IP.

Entries support three formats:

  • Exact: "203.0.113.5"
  • CIDR: "203.0.113.0/24"
  • Wildcard: "203.0.113.*", "10.0.*.*"
json
"allowIPs": [
  "203.0.113.0/24",
  "198.51.100.5",
  "2001:db8::/32"
]

IPv4 and IPv6 are both supported. If allowIPs is absent, no IP restriction applies. If present, a request from an IP that doesn't match any entry is denied.

allowIPs restricts the delegate's server IP (where signed viewer certs originate from). geo restricts the viewer's IP (where playback requests come from). Both can be present — they apply independently.


Re-delegation Depth

The maxDepth field limits how many times a delegation can be re-delegated:

  • 0 — the delegate can act under this delegation but cannot authorize anyone else. A publisher with maxDepth: 0 could use the content themselves but couldn't issue viewer tickets.
  • 1 — one level of re-delegation. A publisher can issue viewer tickets, but viewers can't re-delegate further. This is the typical setting for publisher/distribution grants.
  • 2 — two levels. A distributor can delegate to regional publishers, who can issue viewer tickets.
  • Absent — no depth limit.

When a delegate re-delegates, the child delegation's effective maxDepth isparent.maxDepth - 1. A delegate cannot set a maxDepth higher than its own remaining depth. A chain that exceeds the depth limit at any link fails verification.


Scope Narrowing

Each link in a delegation chain can only narrow the parent's constraints, never widen them. Verifiers must enforce this:

  • Rate limits: A child's limits must be less than or equal to the parent's for the same quantity and period. A child may add limits the parent didn't have (further restriction) but cannot raise a limit the parent set.
  • Geographic restrictions: A child cannot add countries to an includeCountries list or remove countries from an excludeCountries list. It can further restrict by removing from includes or adding to excludes.
  • IP restrictions: A child's allowIPs must be a subset of the parent's. If the parent has allowIPs, the child cannot remove that restriction or add IPs outside the parent's set.
  • Time bounds: A child's nbf must be >= the parent's, and its exp must be <= the parent's.
  • Domains: A child's domains must be a subset of the parent's.

If a child delegation violates any of these, the chain fails verification at that link.


Referrer Enforcement

For domain-bound delegations, the verifying server should check the Origin orReferer HTTP header of incoming requests against the delegation's domainslist. This prevents a publisher's embed code from being copied to an unauthorized domain. This is an enforcement recommendation, not an additional field — the domains field already carries the information needed.


Time Bounds

Use OCP's existing top-level nbf (not before) and exp (expiration) fields on the delegation claim, not custom fields inside stm. These are standard OCP fields with defined semantics.


ES256 Examples

Key-bound delegation (cryptographic chain)

json
{
  "ocp": 1,
  "delegations": [{
    "ocp": 1,
    "iss": "alice",
    "sub": "chat.room.42",
    "stm": {
      "parent": "HEX_SHA256_OF_ALICE_PUBKEY",
      "label": "chat.room.42",
      "secretHash": "HEX_SHA256_OF_BOB_PUBKEY",
      "issuedTime": 1731000000,
      "context": ""
    },
    "key": ["data:key/es256;base64,..."],
    "sig": ["BASE64_SIGNATURE"]
  }]
}

Domain-bound delegation with rate limits and geo restrictions (publisher/distribution)

json
{
  "ocp": 1,
  "delegations": [{
    "ocp": 1,
    "iss": "author-identity",
    "sub": "my-video-catalog",
    "stm": {
      "parent": "HEX_SHA256_OF_AUTHOR_PUBKEY",
      "label": "my-video-catalog",
      "domains": ["publisher.com", "app.publisher.com"],
      "limits": [
        { "minutes": 30, "per": "day" },
        { "videos": 5, "per": "day" },
        { "minutes": 200, "per": "month" }
      ],
      "geo": {
        "excludeCountries": ["KP", "IR"]
      },
      "allowIPs": ["203.0.113.0/24", "198.51.100.5"],
      "issuedTime": 1731000000
    },
    "nbf": 1731000000,
    "exp": 1762536000,
    "key": ["data:key/es256;base64,..."],
    "sig": ["BASE64_SIGNATURE"]
  }]
}

EIP712 Example

json
{
  "ocp": 1,
  "delegations": [{
    "ocp": 1,
    "fmt": "EIP712",
    "iss": "evm:1:address:0xAlice",
    "sub": "chat.room.42",
    "stm": {
      "parent": "0xALICE_ADDRESS",
      "label": "chat.room.42",
      "secretHash": "0xKECCAK256_OF_BOB_PUBKEY",
      "issuedTime": "1731000000",
      "context": ""
    },
    "key": ["data:key/eip712,evm:1:address:0xAlice"],
    "sig": ["0x..."]
  }]
}

EIP712 Type Schema

solidity
Delegation {
  bytes32 parent,
  string label,
  uint64 issuedTime,
  string context,
  bytes32 secretHash
}

Note: limits, geo, and domains are not part of the EIP712 typed struct because EIP712 requires fixed schemas. These fields are available only in ES256 format, where stm is freeform JSON. If an EIP712 delegation needs rate limits or geo restrictions, enforce them at the application layer using the delegation's labelor context as a lookup key.


Chain Verification

To verify a delegation chain [link_0, link_1, ..., link_n]:

  1. For each link, verify the signature against the key(s) in key.
  2. For key-bound links: confirm link_i.stm.secretHash == hash(childPublicKey_{i+1}).
  3. For domain-bound links: fetch the delegate's public key from https://<domain>/.well-known/ocp-keys and verify that the next link's signature matches that key.
  4. Check nbf/exp bounds on each link.
  5. Check geo restrictions on each link that has them.
  6. The root link_0.stm.parent must match a trusted root identity.
  7. Rate limits are enforced by the verifying server, which tracks consumption per viewer per delegation.

For backward compatibility: if a verifier has a derivedSecret instead of achildPublicKey, it derives the child keypair from the secret and hashes the resulting public key. If that doesn't match, it falls back to hashing the derivedSecretdirectly (legacy mode). This ensures old delegation statements still verify.


Revocation

Domain-bound delegations may be revocable at the verifying server (e.g. a Safecloud jet). The author can revoke a delegation through the server's control panel, and the server immediately stops honoring it. If the publisher has registered a webhook, the server sends a revocation notice to the publisher's domain.

Key-bound delegations without a verifying server are not revocable — they are valid untilexp. Applications that need revocation for key-bound delegations should use shortexp windows and re-issue, or use a revocation list published at a well-known URL.


Notes

  • Key-bound verification requires only public keys — no shared secrets need to be transmitted to verifiers.
  • Domain-bound verification allows key rotation without re-signing the delegation — the delegate updates their .well-known/ocp-keys endpoint.
  • Rate limit quantity keys are freeform and application-defined. The protocol standardizes the structure ({ "<quantity>": <number>, "per": "<period>" }) but not the vocabulary of quantities.
  • Geographic restrictions are checked by IP geolocation at the verifying server. They are best-effort — VPNs can circumvent them.
  • Teasers (e.g. low-resolution video previews) are typically served without any delegation check. They are published alongside the full content with decryption keys in the public metadata.
  • Delegations support OCP's standard multisignature mechanism. A delegation's key and sig arrays can hold multiple entries, requiring multiple parties to co-sign (e.g. both an author and their label or manager). The signing threshold is application-defined.
  • For domain-bound delegations, the verifying server should check Origin/Referer headers against domains to prevent unauthorized embedding.