Skip to content
Mandate

Protocol

How mandates, delegation and revocation work, precisely. The code is in crates/mandate-core and crates/mandate-crypto.

The core rule

A delegated mandate may only reduce authority. It may never expand it.

Everything else in Mandate exists to enforce and explain this rule. It's implemented in a single function, can_delegate(parent, child).

Delegation

A child mandate is valid only if all of these hold:

RuleRejected with
Parent is delegablePARENT_NOT_DELEGABLE
Child's parent is the parent's IDINVALID_PARENT
Child's issuer is the parent's subjectINVALID_ISSUER
Same actionACTION_ESCALATION
Same resourceRESOURCE_ESCALATION
max_amount ≤ parent's, and kept if the parent had oneAMOUNT_ESCALATION
allowed_recipients ⊆ parent's, and kept if the parent had oneRECIPIENT_ESCALATION
expires_at ≤ parent'sEXPIRATION_ESCALATION

A child can lower a limit, drop recipients or expire sooner. It can never remove a restriction its parent had: a parent capped at $1000 can't produce an uncapped child.

Where authority starts. A signature proves who granted authority, not that they had it to grant. So every chain must end at a root mandate issued by a trust anchor, a principal configured as an owner of that resource (in the demo, Alice owns wallet:treasury-demo). An agent that signs itself a root mandate gets UNTRUSTED_ROOT.

Revocation

Revocation is a separate signed document, never an edit to the mandate. Only a mandate's own issuer can revoke it. In the running example, M1 is Alice's mandate to FinanceAgent and M2 is FinanceAgent's mandate to InvoiceAgent: Alice can revoke M1, and FinanceAgent can revoke M2.

While checking a request, the engine walks the whole chain from the agent's mandate up to the root. A valid revocation anywhere on that path denies the request:

RevokedInvoiceAgent's request is denied with
M2 (its own mandate)REVOKED
M1 (an ancestor)ANCESTOR_REVOKED, naming M1 and the revocation record

A revocation counts only if it targets that exact mandate ID, comes from the mandate's issuer, and its signature verifies. Forged or misdirected revocations are ignored, and a forgery can't hide a real revocation: the engine checks every revocation the store returns, not just the first. A revocation applies as soon as it's visible. Its revoked_at timestamp is kept for audit only, so clock skew can't keep a revoked mandate alive.

Mandate

FieldMeaning
idDeterministic ID, see below
issuerPrincipal granting authority (lowercase EVM address)
subjectPrincipal receiving authority
actionFree-form verb: transfer, read, merge_pr, send_email, …
resourcekind:id, e.g. wallet:treasury-demo, mcp:github:create_issue
constraints.max_amountOptional upper bound on amount
constraints.allowed_recipientsOptional set of allowed recipients
parentID of the mandate this was delegated from, or none for a root grant
delegableWhether the subject may delegate further
issued_at, expires_atUnix seconds
nonceLets an issuer create otherwise-identical mandates
signatureIssuer's 65-byte Ethereum signature

Mandate is not specific to wallets. action and resource are plain strings, so the same model covers payments, GitHub, databases or MCP tools.

Mandate IDs

id = keccak256( canonical_encoding(mandate without id and signature) )

The canonical encoding is a hand-written, length-prefixed binary format with the domain separator mandate/0.1 (encoding.rs). It never depends on JSON field order. Changing any field that carries authority changes the ID, and the signature is never part of it. The recipient list is treated as a set, so order doesn't matter.

Signatures

The issuer signs the 32-byte mandate digest with EIP-191 personal_sign (secp256k1), so any Ethereum wallet or tool can sign a mandate. A test pins a signature produced by Foundry's cast to make sure we interoperate.

Verification recomputes the digest from the mandate's content and never trusts the stored ID. It recovers the signer and requires it to equal issuer. Verification rejects:

  • non-canonical addresses
  • an ID that doesn't match the content
  • malformed signatures
  • malleable high-s signatures

Decisions and deny codes

Every check returns ALLOW with evidence (mandateId, rootPrincipal, delegationPath, chain, effectiveConstraints) or DENY with one stable code and the evidence behind it:

CodeMeaning
NO_MANDATEThe agent holds no mandate for this action and resource
INVALID_SIGNATUREA mandate in the chain has a bad signature or a forged ID
INVALID_DELEGATIONA link escalates authority, a parent is missing, or the chain is longer than 16 hops
UNTRUSTED_ROOTThe chain doesn't start with a trusted owner of the resource
EXPIREDA mandate in the chain has expired (the Warden's clock decides)
REVOKEDThe agent's own mandate was revoked
ANCESTOR_REVOKEDA mandate above the agent's was revoked; names the highest one
AMOUNT_EXCEEDEDOver the effective limit, or no amount given where a limit applies
RECIPIENT_NOT_ALLOWEDRecipient not in the effective set, or none given where recipients are restricted

If an agent holds several mandates and none authorizes the request, the denial comes from the one that got closest, so a planted forgery can't hide the real reason.