# ABY-1 — Grant: Format, Human Signature, Delegation, Lifecycle

Version 0.2.8-draft · Part of the AllowedBy specification set

## 1. Purpose

A grant answers "who allowed it". It is a statement by a human, verified at a stated level, that a given runtime may exercise given capabilities, within constraints, until a deadline that only a human can extend. It is signed by the human's passkey over the exact text they were shown, and countersigned by a node so that any service can verify it offline.

Every grant traces back to a human signature. There are no L0 grants: L0 means a passport-only request (identification without consent, OAID-7 §2).

## 2. Format

JWS `typ: aby-grant+jwt`, signed by a node key with role `countersign`. The payload embeds the human's signature.

```json
{
  "v": 1,
  "iss": "node.example.org",
  "iat": 1761480100,
  "nbf": 1761480100,
  "exp": 1761483700,
  "jti": "01JB3KC2…",
  "gid": "01JB3KC2…",
  "rev": 0,
  "initiator": { "by": "service", "kid": "s1" },
  "actor": {
    "sub": "did:oaid:node.example.org:01JB3KA0…",
    "operator": { "id": "acme.example", "verified": "dns-txt" },
    "runtime": { "id": "acme.example/assistant" },
    "custody": { "tier": 1, "attestation": "tpm2" },
    "key": { "kty": "OKP", "crv": "Ed25519", "kid": "T7uQ…", "x": "…" },
    "exp": 1761483600
  },
  "human": {
    "id": { "https://api.example.com": "pQ3x0lW9…" },
    "level": 2,
    "reg": "eyJ0eXAiOiJvYWlkLWh1bWFuK2p3dCIs…"
  },
  "audience": ["https://api.example.com"],
  "capabilities": [
    { "cap": "invoices:approve",
      "constraints": { "amount": { "max": "5000.00", "currency": "EUR", "per": "call", "field": "/total" },
                       "scope": "invoice:4711" } }
  ],
  "display": {
    "summary": "Approve invoice 4711, up to 5000.00 EUR per call",
    "lines": ["Approve invoice 4711, up to 5000.00 EUR per call"],
    "lang": "en"
  },
  "single_use": { "request_digest": "X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE" },
  "class": "write-hard",
  "parent": null,
  "depth": 0,
  "approval": "01JB3KB7…",
  "disclosure_hash": null,
  "human_sig": {
    "alg": "webauthn",
    "credential_id": "base64url…",
    "authenticator_data": "base64url…",
    "client_data_json": "base64url…",
    "signature": "base64url…"
  },
  "authority": null,
  "status": { "status_list": { "idx": 184301, "uri": "https://node.example.org/oaid/v1/status" } },
  "log": { "idx": 99120 }
}
```

| Member | Required | Meaning |
|---|---|---|
| `iss`, `iat`, `nbf`, `exp` | yes | Countersigning node, issuance time, validity period |
| `jti` | yes | Id of this revision; each revision has its own. Outside the core. |
| `gid` | yes | Grant id. Equals `jti` of revision 0; stable across revisions (§6) |
| `rev` | yes | Revision number, 0 at issuance, incremented by each rebind (§6) |
| `initiator` | yes | `{ "by": "service", "kid": "<kid from the audience's keys>" }` or `{ "by": "runtime" }` (AMH-1 §3). When `by` is `service`, `audience` is exactly the one origin whose key signed the approval request. |
| `actor` | yes | §2.1 |
| `human.id` | yes | Object mapping each `audience` origin to the human's pairwise id for that origin (§2.2). A verifier uses only its own origin's entry. |
| `human.level` | yes | Level reached for this approval: 1, 2 or 3 (OAID-7) |
| `human.reg` | yes | The human registration, a compact `oaid-human+jwt` signed by the human's home node (OAID-7 §4). Carries the passkey public key, `authn` class, level and log index. |
| `audience` | yes | Non-empty array of explicit origins (`https://host[:port]`). `"*"` is forbidden. |
| `capabilities` | yes | Non-empty array (ABY-3) |
| `display` | yes | `{ summary, lines, lang }`: exactly what the approval page rendered (§3). `lines` has one entry per capability, in order. |
| `single_use` | no | `{ request_digest }`; the grant is consumed by one request (§7) |
| `class` | yes | Class of the most sensitive capability under the audience's route map (ABY-3 §4). Informational for verifiers, which derive the class themselves. |
| `parent` | no | `gid` of the grant this one attenuates (§4) |
| `depth` | yes | 0 for a human-signed grant, parent depth + 1 otherwise; ≤ 1 |
| `approval` | no | Approval request id (AMH-1) |
| `renews` | no | `gid` of the grant this one renews, copied from the approval request (§8) |
| `acting_for` | no | `{ org, mandate }`: the organisation the human acts for and the employer's `aby-mandate+jwt` (ORG-1 §6). In the core, so the human signs it. `exp` MUST NOT exceed the mandate's `exp`. |
| `disclosure_hash` | no | base64url SHA-256 of the disclosure SD-JWT VC delivered alongside the grant (OAID-7 §7). The disclosure itself is never in the grant. |
| `human_sig` | yes when `depth = 0` | The WebAuthn assertion (§3) |
| `authority` | no | Organisational countersign (§5) |
| `qes` | no | Signature over the core assembled by the home node: compact detached JAdES, OCSP response, trusted-list snapshot, `class` and `ra`; root only, outside the core (OAID-7 §10.2) |
| `status` | yes | IETF Token Status List reference, one index per revision |
| `log` | yes | `{ idx }`: the log leaf index assigned to this document in the issuing transaction (OAID-4). A node that signs an index it does not log has signed proof of its own misbehaviour. |

`exp − nbf` MUST NOT exceed the maximum lifetime for the grant's class (ABY-3 §4) nor 30 days. Single-use grants: at most 1 hour.

### 2.1 The `actor` member

The node copies from the bound passport: `sub`, `operator.id` and `operator.verified`, `runtime.id`, `custody.tier` and `custody.attestation`, and the public `key`. It copies nothing else. It sets `actor.exp` to the earlier of the passport's `exp` and the attestation's validity.

Proofs (ABY-2 §3) MUST be signed by `actor.key` of the leaf grant. Verifiers MUST reject a proof whose `iat` is after `actor.exp` with `actor_expired`, even when the grant's `exp` is later. Passport renewal keeps the key; a runtime rebinds the grant (§6) after a tier 0 restart or when `actor.exp` approaches.

### 2.2 Pairwise human ids

`human.id[origin] = base64url(HMAC-SHA-256(home_secret, utf8(human_internal_id) ‖ utf8(origin)))` (OAID-1 §2.5), computed by the home node. Two services cannot correlate a person by id; the home node's wallet sees all of that person's grants. A service that needs to know *which* account approved links it once through `aby:link` (ABY-3 §6) and stores the pair `(human.reg.iss, human.id)`.

## 3. Human signature

### 3.1 The human-signed core

The **grant core** is the payload with these members removed:

- `actor`, except `actor.operator` and `actor.runtime`, which stay in the core;
- `jti` and `rev`;
- `human_sig`;
- `authority`;
- `status`;
- `log`.

Everything else, including `initiator`, `display`, `single_use`, `disclosure_hash`, `iss`, `iat`, `nbf`, `exp` and `gid`, is in the core. The core never contains a signature over itself. Because the key, custody and `actor.exp` are outside the core, a rebind (§6) never breaks `human_sig`; because operator and runtime are inside it, a rebind can never move the grant to another operator or runtime.

### 3.2 Ceremony

The human's **home node** is the only party that builds what the human sees and signs. It never signs or displays a core built elsewhere.

1. The creating node sends the home node the **request** (OAID-2 §4.5): `iss`, `gid`, `approval`, `actor.operator`, `actor.runtime`, `audience`, `capabilities` with constraints, `class`, `initiator`, `single_use` with `request_digest`, `renews`, `nbf`, `exp`. The home node accepts forwarded requests only from nodes in its own trust list and rate-limits per human (default 30 pending approvals).
2. The home node fetches the audience's templates from `/.well-known/allowedby` over TLS (ABY-3 §5) and renders `display`; it computes `human.id` for every audience with its own `home_secret` (§2.2); it embeds its own `human.reg`. This gives the core (§3.1).
3. It serialises the core with RFC 8785 (JCS), computes `challenge = SHA-256(core_bytes)`, renders the page **only** from `display` (AMH-1 §6), and runs WebAuthn `get()` with that challenge, `userVerification: required`, `rpId` = `human.reg.rp_id`.
4. It verifies the assertion as in §3.3 step 2 and returns the core and `human_sig` to the creating node.
5. The creating node adds `jti` (= `gid` for revision 0), `rev`, `actor`, `status` and `log`, countersigns, and MUST send the countersigned grant back to the home node with `POST {approvals}/{aid}/grant` on the home node, so the wallet holds every grant and can revoke it.

**Batch.** Only for `read` and `write`, all items with the same audience and the same runtime, n ≤ 20, one new binding code for the batch. The challenge is `SHA-256(JCS({ "batch": [h1, …, hn] }))` with `hi` the core hash of each item still selected when the human taps Allow, exactly those and no others. `human_sig` carries the `batch` list.

### 3.3 Verification

Every verifier MUST, for each grant at `depth = 0` in a chain:

1. verify `human.reg` against a home node in its trust list (OAID-5);
2. recompute the core and check `human_sig`:
   - `clientDataJSON.type == "webauthn.get"`;
   - `clientDataJSON.challenge` is base64url of `SHA-256(JCS(core))`, or, for a batch, of the batch challenge with its own core hash in `batch`;
   - `clientDataJSON.origin == "https://" + human.reg.rp_id`;
   - `authenticatorData.rpIdHash == SHA-256(human.reg.rp_id)`;
   - flags UP and UV are set;
   - the signature over `authenticator_data ‖ SHA-256(client_data_json)` verifies with `human.reg.key`. It is the WebAuthn encoding (ASN.1 DER for ES256), not the JWS raw `r‖s`; `client_data_json` is verified as the bytes received, never re-serialised;
3. check that the **effective level** `min(human.level, human.reg level, max_level of the countersigning node, max_level of the home node)` meets the route's level;
4. check `authn` in `human.reg` against the route's `authn`, and for a level-3 route with `level_profile`, check `human.reg.level_source.profile` against it (ABY-3 §4.1; else `level_insufficient`);
5. for routes of class `write-hard` or `irreversible`, require `initiator.by == "service"` with `initiator.kid` one of its own `keys` (ABY-3 §5);
6. for routes with `qes: true`, verify `qes` (OAID-7 §10);
7. when `acting_for` is present, or the route sets `mandate: true`, verify the mandate (ORG-1 §6).

A countersigning node therefore cannot invent a human its trusted home node does not vouch for.

## 4. Delegation and attenuation

A runtime holding a grant MAY derive a child grant for a sub-agent by `POST {approvals}/grants/{gid}/attenuate`, authenticated by a proof signed with the parent's `actor.key`, body:

```json
{ "actor_passport": "<child passport JWS, any trusted node>",
  "capabilities": [ … ], "audience": [ … ], "exp": 1761483000 }
```

The node verifies the child passport, copies `actor` from it, copies `human` from the parent, sets `parent = gid`, `depth = parent.depth + 1`, and refuses unless all hold:

- `depth ≤ 1` (a root and one child: what the 8 KiB envelope of ABY-2 §2 can carry);
- each child capability attenuates a parent capability (ABY-3 §3);
- child `audience ⊆` parent `audience`; child `nbf ≥` parent `nbf`; child `exp ≤` parent `exp`;
- the parent is not single-use.

A child carries no `human_sig`, no `display` and no `initiator`; it is covered by its root's, and `initiator` is checked on the root. A child's `human` MUST be byte-identical to its parent's. Proofs are signed by the leaf's `actor.key`.

**Chain verification is mandatory for every verifier.** The envelope carries the chain (ABY-2 §3). The verifier checks, for every link: the countersignature, `child.parent == parent.gid`, `child.depth == parent.depth + 1`, `depth ≤ 1`, the narrowing rules above, the status bit of every grant in the chain, and §3.3 on the root. A revoked ancestor invalidates every descendant.

## 5. Organisational authority

This section is the only definition of organisational authority; OAID-7 refers to it.

An organisation that owns the resource (the audience's organisation, not the agent's operator) MAY publish an **authority policy**: JWS `typ: aby-authority-policy+jwt`, signed by a key in `keys` of the organisation's `/.well-known/allowedby` (ABY-3 §5), the same key set as its approval keys.

```json
{
  "jti": "01JB2…",
  "org": "https://api.globex.example",
  "iat": 1761400000,
  "exp": 1792936000,
  "rules": [
    { "cap": "invoices:approve", "amount": { "max": "5000.00", "currency": "EUR" },
      "group": "finance-approvers", "quorum": 1 },
    { "cap": "invoices:approve", "amount": { "min": "5000.01", "currency": "EUR" },
      "group": "cfo-office", "quorum": 2 }
  ],
  "groups": { "finance-approvers": ["<pairwise id>", "…"], "cfo-office": ["…"] }
}
```

A rule MAY carry `budget: { "max", "currency", "per": "day" | "week" | "month", "tz"? }` (`tz` as ABY-3 §2): the service counts the amounts it accepts under the rule and refuses requests beyond it with `403 budget_exceeded` (ORG-1 §5.3). `groups` lists pairwise ids for `org`. `cap` and `amount` follow ABY-3 §2; `min` and `max` are inclusive and either may be absent. The first rule whose `cap` matches and whose range contains the request amount (the value at the route's `amount_field`, in `currency`) applies. Deputies, cover and "any 1 of N" are expressed in groups and quorum, not in the protocol. A verifier that is the organisation holds its own policy; others fetch it from `authority_policy` in the organisation's `/.well-known/allowedby`.

A grant that satisfies a policy carries the plain object:

```json
"authority": {
  "policy": "01JB2…",
  "policy_hash": "<base64url SHA-256 of the policy JWS>",
  "approvers": [ { "reg": "<human.reg>", "id": "<pairwise id>", "sig": { "…": "WebAuthn assertion, as human_sig" } } ]
}
```

Every co-approver signs the same challenge `SHA-256(JCS(core))` on their own home node, which re-renders `display` from the audience's templates and refuses unless it is identical. The creating node collects the assertions and adds `authority` before countersigning; `authority` is outside the core.

Verifiers of a route with `authority: true` (ABY-3 §4.1) MUST check: the policy signature and `exp`; `policy_hash`, naming the policy in force or, through a renewal, the immediately previous one of the same rules and groups (ORG-1 §5.3, Policy lifetime); each approver's `reg` and `sig` exactly as §3.3 steps 1–2; that each `id` is in the rule's group; and that the distinct approvers, counting the primary human when `human.id[org]` is in the group, reach `quorum`. The approvers counted are distinct verified credentials, each once: a credential is its `reg`'s `iss` and `cred`, and its public key (`key`). An approval in which two approvers, or an approver and the primary human, share a credential (the same `reg` under two ids, or the primary's own passkey under another id) is refused, even when the quorum is otherwise met. Membership of the group comes from each approver's `id`, which the `reg` does not carry: only the creating home node vouches for it, by countersigning the grant. A verifier therefore trusts that node to bind each approver's `id` to the credential that signed (§10). Otherwise `authority_required`.

## 6. Rebind

Rebind replaces the actor of a live grant without a human, after a tier 0 restart or when `actor.exp` approaches. `POST {approvals}/grants/{gid}/rebind` with `Allowed-By` = the new passport and a proof signed by the **new** passport's key. The node issues a new **revision**: same `gid`, `rev` incremented, its own `jti`, `actor` copied from the new passport, a new `status` index and a new `log` index; every core member is unchanged, so `human_sig` stays valid.

The node MUST refuse unless:

- the new passport chains to the grant's current `actor.sub` through `prev` (OAID-3 §6), **or** the body carries `operator_sig`: a JWS `typ: aby-operator+jwt` over `{ "gid", "sub", "aud": "<node>", "iat", "exp" }` with `exp ≤ iat + 300` and `sub` the new passport, signed by a key in the operator's `https://<domain>/.well-known/oaid-operator` JWKS (a DNS TXT record may pin its thumbprint);
- the new passport has the same `operator.id` and `runtime.id`, and a custody tier not lower;
- the grant is not single-use and has no children.

Operators without a verified domain cannot rebind after a tier 0 restart; they request new approvals.

Earlier revisions are not revoked; each dies at its own `actor.exp`. Several replicas MAY each hold their own revision. Counters and cumulative amounts are shared by all revisions (ABY-3 §3).

## 7. Single-use grants

A grant with `single_use` is valid for exactly one request:

```
request_digest = base64url(SHA-256(JCS({ "htm": …, "htu": …, "query": …, "bdh": … })))
```

`htm`, `htu` and `bdh` are as in the proof (ABY-2 §3); `query` is the raw query string. Members that are empty (no query, no body) are omitted. The verifier recomputes the digest from the actual request and rejects a mismatch.

Services MUST consume the `gid` atomically across all their instances (a shared store with compare-and-set or equivalent) and keep it until `exp`; a second presentation fails with `single_use_consumed`. The human cannot narrow a single-use approval on the page, since any change breaks the digest. Single-use grants cannot be attenuated or rebound.

## 8. Renewal

Renewal is a new grant. The home node prompts the human before `exp` (AMH-1 §9). The approval request carries `renews: <old gid>`; the human signs a new core with new `nbf`/`exp`; the new grant has a new `gid` and `renews: <old gid>`. The old grant expires naturally. A runtime SHOULD request renewal when a quarter of the period remains and MUST stop using a grant at `exp`.

## 9. Revocation

`POST {approvals}/revoke`, body a compact JWS `typ: aby-revoke+jwt` signed by the caller. The node verifies it, logs it, and flips the status bits it covers.

```json
{ "iss": "<caller>", "iat": 1761481000, "jti": "01JB3M…",
  "target": { "gid": "01JB3KC2…" },
  "reason": "human_request" }
```

| `target` | Effect | Who may sign |
|---|---|---|
| `{ "gid" }` | Every revision of the grant and every descendant | The human, the operator, the issuing node |
| `{ "kid" }` | Every grant revision whose `actor.key.kid` is that key; `reason` MUST be `key_compromise` | The operator, the issuing node, or the key itself |
| `{ "operator" }` | Every grant of this human for this operator ("revoke everything from this operator"), at the node that receives it; the wallet sends it to every node that issued such a grant | The human |
| `{ "vouch" }` | The vouching statement with that `jti` (OAID-5 §4) | The vouching node |
| `{ "reg" }` | Every grant revision whose root was signed under that `human.reg` (by its `jti`), and the registration itself (ORG-1 §7.2) | The human, the home node that issued the registration |
| `{ "audience" }` | Every grant of this human for that origin, at the node that receives it | The human, the home node |
| `{ "log_idx" }` | Erasure of the document at that log index; `reason` MUST be `redacted` (OAID-4 §8) | The node holding it |

Authentication:

- **Human**: a WebAuthn assertion on the home node's wallet page over `SHA-256(JCS(revoke payload))`. The home node then signs the `aby-revoke+jwt` with its `countersign` key and forwards it to the issuing node, which accepts it when the home node is the `iss` of the grant's `human.reg`.
- **Operator**: signed with an operator key (OAID-2 §5–6), for grants whose `actor.operator.id` is that operator.
- **Key**: signed with the key being revoked (proof of possession suffices to kill it).
- **Node**: signed with its own `countersign` key, for policy reasons.

Reasons: `human_request`, `operator_request`, `key_compromise`, `node_policy`, `redacted`. Revoked documents keep their log entries. Rebind supersession is not a revocation.

## 10. Security considerations

- A dishonest node could countersign a grant no human signed. Mandatory `human_sig` and `human.reg` verification (§3.3) makes that detectable by every verifier, not only auditors.
- The human signs `display`, so the sentence they saw is bound to the capabilities. Only the audience writes the template; only the node fills it.
- `audience` prevents a grant for one service from being replayed at another; wildcards are forbidden.
- `actor.exp` limits a leaked tier 0 key to its passport's life (≤ 1 h) whatever the grant's `exp`.
- Grants carry no names. Disclosure is a separate document bound by hash, encrypted to the audience, never logged.
- Co-approvers (§5): a verifier checks each approver's registration and passkey signature, and counts each credential once, but it cannot tell from them whose pairwise `id` an approver holds. It trusts the creating home node, which countersigns the grant and is already the trust anchor for the primary human, to have bound each approver's `id` to the credential that signed. A dishonest node could put a group member's `id` on another person's credential; as with an unsigned grant, the countersignature makes it accountable, not impossible.

## Change log

Every change to this document adds a row here and increments its version (README, Versioning).

| Version | Date | Change |
|---|---|---|
| 0.2.8-draft | 2026-11-28 | §5: the approvers counted are distinct verified credentials (`reg`'s `iss` and `cred`, and its key), each once; a credential shared by two approvers, or by an approver and the primary human, refuses the approval. Group membership comes from the approver's `id`, which only the creating home node vouches for: §10 states that trust. `policy_hash` may name the policy a renewal replaced (ORG-1 §5.3). |
| 0.2.7-draft | 2026-11-28 | §5: a rule budget's optional `tz`; an approver with the primary human's credential is not another approver. |
| 0.2.6-draft | 2026-11-28 | §2, §4: `depth ≤ 1`, not 3: a chain of more than two grants does not fit the 8 KiB envelope (ABY-2 §2, 0.2.14). |
| 0.2.5-draft | 2026-11-18 | Check of `level_profile`; `qes` member contents (OAID-7 §10.2, CHANGES §24). |
| 0.2.4-draft | 2026-10-29 | `acting_for` (mandate) in the core; authority rule `budget`; revocation targets `reg` and `audience` (CHANGES §18). |
| 0.2.3-draft | 2026-10-28 | `human.level` 1–3; optional `qes` member and its check (CHANGES §17). |
| 0.2.2-draft | 2026-10-27 | Child grants carry no `initiator` and an identical `human`; WebAuthn signature encoding stated (CHANGES §16). |
| 0.2.1-draft | 2026-10-27 | Home node builds the core; full WebAuthn checks; `initiator` in the core; `jti` outside the core; one authority mechanism (CHANGES §15). |
| 0.2.0-draft | 2026-10-27 | Display inside the signed core; `actor.exp`; leaf key signs; mandatory chains; rebind revisions; authority countersign (CHANGES §3, §6, §7). |
