Authorization for autonomous commerce

Signed mandates for agents that spend.

A procurement agent can buy only what an Ed25519 mandate allows. Watch one purchase get authorized, then watch a $50,000 prompt get stopped before the handler runs.

DSN v0.1 · live decision Signing mandate…

Signed mandate

Northwind Treasury

Agent
agent:ap-clerk-07
Tool
payments.transfer
Per call
500.00 USD
Total
1000.00 USD
Recipient
vendor:alpine-parts

Signature held. The prompt cannot rewrite it.

This call

Awaiting a call

The mandate is signed.

Run a purchase inside the cap, or inject a prompt that asks for $50,000.

    Receipt chain

    Spent 0.00 of 1000.00 USD

      Ed25519 and SHA-256 run in this browser via WebCrypto. An ALLOW receipt authorizes the handler. It does not settle funds. Any millisecond figure is this click, not a benchmark.

      Signature
      Ed25519 over dsn.v0.1.mandate
      Guard
      withMoneyGuard
      Receipt
      Hash-chained dsn.v0.1.receipt
      License
      Apache-2.0

      Vision

      The financial & trust infrastructure for autonomous AI and robot commerce.

      That is the horizon. DSN v0.1 is the part that exists today.

      Today is a signed spending mandate, a fail-closed guard at the tool call, and an authorization receipt a third party can recompute with the public key. The profile and the reference implementation are Apache-2.0.

      The category those pieces point toward is larger: agents, and later machines, that can spend under a check a treasury can verify. v0.1 does not include a robot runtime, a payment network, or a hosted authority. None of those are implied by an ALLOW receipt.

      Quickstart

      The same boundary, in code.

      The snippet is the public API in this repository. @dasenix/mcp is a workspace package, not an npm install. Denied calls throw MandateDeniedError and never reach the handler.

      import { MandateSession, withMoneyGuard } from "@dasenix/mcp";
      
      const session = await MandateSession.issue({
        issuer: "Northwind Treasury",
        subject: "agent:ap-clerk-07",
        audience: "api://treasury",
        allowedTools: ["payments.transfer", "payments.refund"],
        spendCap: { maxPerCall: "500.00", maxTotal: "1000.00", currency: "USD" },
        allowedCounterparties: ["vendor:alpine-parts"],
        expiresAt: new Date(Date.now() + 86_400_000).toISOString(),
        policyMeta: ["EU_AI_ACT_ART14", "INTERNAL_TREASURY"],
      });
      
      // The host authenticator supplies `caller`. The mandate's subject is not that proof.
      const transfer = withMoneyGuard(
        "payments.transfer",
        async (command) => payments.transfer({
          amount: command.amount,
          currency: command.currency,
          to: command.recipient,
        }),
        {
          session,
          caller: { subject: "agent:ap-clerk-07", audience: "api://treasury" },
          amount: (args) => args.amount,
          currency: (args) => args.currency,
          counterparty: (args) => args.to,
        },
      );

      Why now

      Autonomous commerce needs a mandate.

      Agents are leaving the chat window. The next action is a tool call that can spend. A payment rail can authorize a cardholder, a merchant, or a session. It does not carry a signed limit on which agent may call which tool, for how much, with whom, and until when.

      That limit has to exist before autonomous spend can scale. It has to be open, so a treasury and a payment system can verify the same bytes. It has to be deterministic, so the same mandate and the same call produce the same decision. And it has to be enforced at the handler, fail closed, rather than requested of the model.

      Dasenix is the cryptographic authorization and execution-boundary layer for that call. DSN v0.1 is the open profile. withMoneyGuard is the boundary. An ALLOW receipt proves the authorization decision. It does not move, clear, or settle funds. A verifier needs the public key, not an account on a Dasenix service.

      The problem

      A prompt is not a control.

      A system prompt is text in the model context. It can be overridden, truncated, or ignored, and the process can still call the tool. Dasenix does not ask the model to comply.

      The issuer signs which agent may call which tools, for how much, with whom, and until when. withMoneyGuard checks that signature against a pinned public key, compares the host-authenticated caller with the mandate, and only then invokes the handler. On DENY it throws MandateDeniedError. The handler is not called.

      Every completed authorization is appended before the handler runs. Allowed and denied calls both produce a receipt. If the handler throws, the ALLOW receipt stays, and the amount still counts toward the cap.

      Checks in examples/mcp-payment-guard.ts. Verify time is printed by the script and is not a benchmark.
      ALLOW  payments.transfer  120.00 USD  vendor:alpine-parts  VALID
      DENY   payments.transfer  900.00 USD  vendor:alpine-parts  EXCEEDS_PER_CALL_CAP
      DENY   db.drop_table      demo non-money guard         TOOL_OUT_OF_SCOPE
      ALLOW  payments.transfer    1.00 USD  handler throws       VALID
             receipt kept, spend is 121.00
      DENY   payments.transfer   50.00 USD  after revoke()       REVOKED
      CHAIN  valid
      TAMPER seq 0  HASH_MISMATCH

      Architecture

      Checked at the call, not in the prompt.

      1. 01

        Issue

        MandateSession.issue signs the mandate with Ed25519 over RFC 8785 canonical JSON, domain dsn.v0.1.mandate. The private key stays on the session. Verifiers need publicKey.

      2. 02

        Name the caller

        The host passes a caller it has already authenticated. The guard compares it to subject, and to audience and tenant when the mandate sets them. A mismatch is CALLER_MISMATCH. The mandate subject is not that proof.

      3. 03

        Bind the money

        withMoneyGuard requires amount, currency, and the recipient. A missing field is MALFORMED. It is not replaced with 0.00 or the mandate currency. Amounts are decimal strings at the currency’s minor-unit scale. Floats are rejected, not rounded.

      4. 04

        Decide, then run or stop

        verifyCall is fail-closed: pinned key and signature first, then caller, revocation, expiry, tool, amount, counterparty, currency, and the caps. DENY throws. ALLOW calls the handler with a frozen command whose amount, currency, and recipient are the values the ledger signed.

      5. 05

        Append the receipt

        The decision is signed as dsn.v0.1.receipt and linked by SHA-256 to the previous receipt. The first prevHash is 64 zeroes. verifyLedgerChain recomputes the chain from the public key alone.

      DSN v0.1

      What the guard enforces.

      The properties below are the ones implemented and covered by the suite in this repository. The byte-level profile is SPEC.md.

      Signed amount, currency, and recipient

      The Ed25519 signature covers the canonical mandate: per-call cap, total cap, currency, tools, counterparties, subject, expiry, and any audience, tenant, or policy tags. Key order does not change the signature. Changing a signed field does.

      A verifier pins the issuer public key. A mandate re-signed by any other key is INVALID_SIGNATURE, even when the embedded key matches the attacker. Equal-to-cap amounts are allowed. One cent over the per-call cap is EXCEEDS_PER_CALL_CAP and does not count. Past the total is EXCEEDS_TOTAL_CAP.

      Fail-closed verification

      Signature failure wins, so untrusted fields are ignored. On the money path, omitted amount, currency, or recipient is MALFORMED, stored as an empty field, and the handler does not run. Denied amounts do not advance spend.

      USD has 2 minor units, JPY has 0, BHD has 3. A sign, an exponent, a non-string number, or more fractional digits than that scale is MALFORMED and is not rounded. 10.5 USD is authorized as 10.50.

      Frozen command

      On ALLOW, the handler receives a frozen command. Its amount, currency, and recipient are the signed values. Its arguments are a frozen clone, not the caller’s object. Observers receive frozen copies of the decision and the receipt.

      Mutating the original input, or attempting to write the published receipt, does not change the command the handler runs or the receipt stored on the ledger. withMandateGuard is the demo path for a non-money tool. A missing amount there becomes 0.00. Do not use it to move money.

      No cross-domain replay

      The signing input is UTF-8 of the domain label, a newline, and canonical JSON. The labels are dsn.v0.1.mandate, dsn.v0.1.receipt, and dsn.v0.1.args. A mandate signature does not verify as a receipt, and a receipt signature does not verify as a mandate. Any other version label is rejected.

      That binds a signature to one document type. It is not a nonce. A second in-policy call is allowed until a cap, expiry, or revocation says otherwise. Argument digests use dsn.v0.1.args. Values that cannot be canonicalized are denied with MALFORMED and still appended.

      UTC authorization clock

      expiresAt is YYYY-MM-DDTHH:MM:SSZ or the same form with exactly three fractional digits. The year is 0100–9999. Offsets, including +00:00, a lowercase z, and impossible dates are MALFORMED.

      Expiry is exclusive, in epoch milliseconds: the call is allowed one millisecond before that instant and denied at it. The clock is copied once, before any verifier callback await. Mutating that Date afterward does not move the decision or the receipt timestamp. The instant is authorization time, not the time the handler returns.

      Hash-chained receipts

      verifyLedgerChain recomputes each SHA-256, checks prevHash and seq, and verifies the Ed25519 signature. Mutation, reordering, deletion, or a forged signature fails with HASH_MISMATCH, LINK_MISMATCH, SEQ_MISMATCH, or INVALID_SIGNATURE.

      Pass expectedHead from outside the array to test whether this export ends at a head you trust. A match does not prove there is no later receipt elsewhere. v0.1 does not issue that checkpoint. Receipts store a digest of the arguments, not the arguments. Appends in one process are serialized, so concurrent calls there cannot both pass the same remaining budget.

      Implementation

      Open profile. Reference core.

      The profile and the code in this repository are Apache-2.0. v0.1 has no proprietary core and no hosted control plane.

      DSN v0.1 is public

      SPEC.md is the normative signing profile. Fixed vectors ship in the repository, and the suite recomputes the bytes, hashes, and Ed25519 signatures. An implementation that produces different bytes is not DSN v0.1.

      Zero-dependency core

      @dasenix/core declares no runtime dependencies. Ed25519 and SHA-256 use WebCrypto on Node.js 20+ or a modern browser. @dasenix/mcp depends only on that core. Neither package is published to the npm registry in v0.1.

      Deterministic boundary

      Canonical JSON is RFC 8785. After the signature, the check order is fixed. The same mandate, call, clock, revocation set, and spent total produce the same decision. DENY does not reach the handler. The command the handler does receive is frozen.

      Verified in CI

      The suite in this repository is 69 tests: canonical JSON, the fixed vectors, domain separation, spend caps, the money guard, UTC expiry, the kill switch, and hash-chain failures. GitHub Actions runs npm ci, typecheck, lint, npm test, and build on Node.js 20 and Node.js 22.

      Boundary

      What an ALLOW receipt is.

      ALLOW means the signing key recorded an authorization. The reference guard writes that receipt before the handler. Handler failure leaves it in place. Settlement is outside the receipt.

      Cumulative spend is the sum of ALLOW receipts in that MandateSession. Revocation is an in-memory set in the same process. session.revoke() denies later calls with REVOKED, and revocation is reported before expiry when both apply. restore exists so the console can rehearse the switch. Two processes do not share a budget or a revocation.

      v0.1 does not provide a KMS, an HSM, a hosted authority, multi-hop delegation, a persistent shared budget, or a distributed kill switch. Policy tags such as EU_AI_ACT_ART14 are signed metadata. This verifier does not interpret them and does not claim legal compliance.

      Verifier

      Reason codes.

      Code Meaning
      VALID Call is authorized.
      INVALID_SIGNATURE Signature failed, or the token was not signed by the pinned key.
      CALLER_MISMATCH The host caller does not match subject, or audience / tenant when the mandate sets them.
      REVOKED Kill switch is armed for this mandate in this verifier.
      EXPIRED Authorization time is at or past expiresAt.
      TOOL_OUT_OF_SCOPE Tool matches no allowed name or glob.
      COUNTERPARTY_NOT_ALLOWED Payment counterparty is outside the allow-list.
      CURRENCY_MISMATCH Call currency differs from the mandate.
      EXCEEDS_PER_CALL_CAP Amount is above maxPerCall.
      EXCEEDS_TOTAL_CAP Amount would push cumulative allowed spend above maxTotal.
      MALFORMED Signed document, timestamp, or amount cannot be interpreted.

      After a valid signature, checks run in this order: caller binding, revocation, expiry, tool, amount, counterparty, currency, then the caps. Revocation wins over expiry. An unparseable document, timestamp, or amount is MALFORMED at the point it cannot be interpreted.

      Design partners and investors

      If this is the boundary you need.

      Write if your team is putting agents on a path that can move money, or if you invest in the infrastructure underneath autonomous commerce.

      The subject is DSN v0.1 as it stands in this repository: the open profile, the fail-closed guard, and the receipt a third party can recompute.

      Write

      daisen0211y@icloud.com
      GitHub Issues

      Vulnerability reports go to hello@dasenix.dev.