The mandate is the authorization a person gives their agent: a six-field SD-JWT, compatible with AP2,
signed with the human's credential, with the agent key bound in `cnf` and a one-time presentation.
CRDCA does not sign mandates, does not custody them and does not revoke them: it publishes the format
and the verifier checks it.

## Who signs
The person signs, with a credential from one of the two families in the closed list:
| Family | Credential |
| --- | --- |
| wallet | a WebAuthn passkey with a P-256 key, verified as an ES256 signature |
| legal signature | the Ed25519 signature of the human's credential |
The issuer is compared by origin —scheme and host— and its key is pinned by fingerprint. No CRDCA root
appears as an issuer. The agent does not sign the mandate: it presents it with its `kb-jwt`.

## The six fields
| Field | What it carries |
| --- | --- |
| `iss` | absolute `https` URL of an admitted issuer |
| `sub` | AgentID of the presented card |
| `cnf` | a single subfield, `jwk`, with the agent public key |
| `scope` | list of strings with the authorized actions, no catalog |
| `limits` | `max_amount`, `currency` and `per`, and nothing else |
| `exp` | integer expiry, after the verification instant |
`limits.max_amount` is a positive decimal, `currency` matches `^[A-Z]{3}$` and `per` is `day`, `month`
or `total`. A fourth subfield is not admitted. Limits are verified per request: amounts are not
accumulated across mandates.

`cnf` is bound to the SPKI of the class certificate. Its `kid` is the SHA-256 fingerprint of the SPKI of
`x5c[0]`, with a single hash; the verifier recomputes it and does not trust the value carried in the
mandate.

## The presentation and the nonce
The presentation chains the JWT, the disclosures and the `kb-jwt`, separated by `~`. Selective
disclosures go in `_sd` with `_sd_alg` equal to `sha-256`, and the `kb-jwt` closes the presentation with
three claims:
| Claim | What it fixes |
| --- | --- |
| `aud` | AgentID of the presentation receiver |
| `nonce` | one-time value chosen by the receiver |
| `iat` | issue instant, never after the verification instant |
The receiver stores the `aud+nonce` pair as soon as it accepts and rejects a second presentation with
the same pair. The entry is retained until the accepted mandate's `exp`. A mandate may be presented
several times within its validity, but every presentation uses a fresh nonce.

::: peligro
The mandate carries no personal data. The eight claims in the closed list —`name`, `email`, `phone`,
`address`, `national_id`, `birthdate`, `biometric` and `geo`— are prohibited and their presence rejects
the presentation with `R13`.
:::

## How it travels
There are two surfaces and no more:
- the HTTP header `CRDCA-Mandate`, with the complete mandate;
- the A2A message metadata, under the `crdca.mandate` key.
The message body is not a surface. If both arrive and do not match, the transport is invalid; if neither
arrives, there is no mandate. In TypeScript, `transporte` and `leerMandato` are the functions that
enforce that rule:
```typescript
import { leerMandato, transporte } from '@nexgensys/crdca-plugin-a2a';

const entrega = transporte(presentacion, { superficie: 'cabecera' });
console.log(entrega.cabeceras);
const leido = leerMandato({
  cabeceras: entrega.cabeceras,
  metadatos: entrega.metadatos,
});
console.log(leido.mandato, leido.superficie);
```

## How it is verified
Step 8 of the middleware validates the mandate when the action asks for it. Earlier, step 2 already
checked that the `cnf` `kid` is the SPKI fingerprint of `x5c[0]`, and step 6 checked the card's validity.
The mandate verifier adds:
- the human signature with the issuer's key;
- the `cnf` binding to the class key, recomputed;
- the `kb-jwt` signed with that same key, its `aud`, its `nonce` and its `iat`;
- the issuer inside the closed list, with no remote `jku` or `x5u`;
- the action inside `scope` and `limits`;
- an `exp` strictly after the verification instant.
```python
from crdca.mandato import Contexto, IndiceNonces, ListaEmisores, verificar

contexto = Contexto(
    agent_id="https://example.com/agents/invoices/agent-card.json",
    lista=ListaEmisores(),
    nonces=IndiceNonces(),
    accion={"tipo": "pagar", "importe": "10.00", "moneda": "MXN"},
)
resultado = verificar(presentacion, contexto, spki=spki_de_la_clase)
print(resultado.aceptado, resultado.codigos, resultado.detalle)
```
`ListaEmisores()` declares the two families and the pinned fingerprints, but the SPKI material comes
from your local store. Without material that matches the fingerprint, verification fails closed with
`R14`: it downloads no keys and does not accept the key the mandate itself presents.

## The mandate codes
| Code | When |
| --- | --- |
| `R03` | the `cnf.jwk` `kid` is not the SPKI fingerprint, or the `kb-jwt` is signed by another key |
| `R09` | verification happens at or after `exp` |
| `R13` | invalid mandate: fields, limits, `scope`, reused nonce or action outside limits |
| `R14` | issuer not admitted, expired document, remote `jku` or key different from the pinned one |
There are no new codes: they are the same fourteen from `algoritmo-v1`. `R13` and `R14` can also appear
in the middleware result when step 8 rejects.

## What CRDCA does not do
- It does not issue mandates and does not appear as an issuer.
- It does not custody the human's key or the agent's key.
- It does not revoke mandates: expiry and the nonce are the two levers.
- It does not query the issuer during verification. The list and the material live in the verifier.

::: limite
The complete WebAuthn ceremony, authenticator attestation and the trust chain of a legal-signature
provider are not implemented in this piece. Verification covers the credential signature and the closed
list; whatever needs hardware or an external provider is declared simulated in the tests.
:::

## Next step
- [Verify a card](/en/use/verify): how step 8 fits into the call.
- [TypeScript](/en/use/typescript): the plugin that carries the mandate.
- [The CLI](/en/use/cli): the card and chain that the mandate binds.
