Skip to content

Latest commit

 

History

History
1246 lines (1124 loc) · 85 KB

api.md

File metadata and controls

1246 lines (1124 loc) · 85 KB

API (HTTP and gRPC)

Authentication

  • Per-account Miden requests MUST include credentials authorized by the account's policy.
  • Miden credentials are provided via HTTP headers x-pubkey, x-signature, x-timestamp and the same keys in gRPC metadata.
  • Miden x-pubkey is interpreted by the account auth policy:
    • Miden Falcon/ECDSA accounts use the serialized public key or its commitment.
    • Per-signer-scheme (Miden) accounts use either scheme's serialized public key or its commitment.
  • On a per-signer-scheme (Miden) account each request is verified under the scheme its signer is registered with, against only the cosigners registered under that scheme: a raw signature of exactly 1524 bytes is Falcon and one of exactly 65 bytes (r || s || v) is ECDSA, any other length is rejected, and x-auth-format: eip712 is ECDSA.
  • EVM HTTP requests under /evm/* use a guardian_evm_session cookie. The session EOA is recovered from a wallet signature and is checked against the configured account signer set or proposal signer snapshot.
  • Miden per-account requests MAY instead be signed by a delegated signer registered through POST /session (x-auth-format: session-v2, see Session Authentication).
  • Replay protection applies to every Miden signed request. EVM challenge nonces are single-use and time-limited, and EVM sessions expire.

Replay Protection

  • The signed payload includes a Unix timestamp in milliseconds.
  • The server enforces a maximum clock skew window of 300,000 milliseconds (5 minutes), and 60,000 milliseconds for session-signed reads, except the session-signed canonical nonce poll, which may be at most 60,000 ms behind and 30,000 ms ahead of server time. A timestamp outside its window is refused with the stable code timestamp_out_of_window (HTTP 401 / gRPC Unauthenticated, meta.retryable: false): the client's clock is off, and the credentials are not in question, so clients keep their session.
  • Wallet requests and session writes use a timestamp floor: the server tracks last_auth_timestamp per (account, signer commitment) for wallet requests and per (account, session-<hex SHA-256 of the session key>) for session writes, and a request whose timestamp is not strictly greater than the last accepted one under the same key is rejected with the dedicated stable code authentication_replay (HTTP 401 / gRPC Unauthenticated, meta.retryable: true). Independent authorized signers never contend on one timestamp, while a replayed request from the same key always loses: every accepted request advances that key's own record.
  • Session reads are not ordered: each signed session read is admitted once, fleet-wide, keyed on SHA-256 of the session public key and the signed envelope, so reads with equal or reordered timestamps are all accepted and only an exact copy is refused with authentication_replay. The session-signed canonical nonce poll (GET /state/nonce, GetCanonicalNonce) is the exception: it is accepted every time it is presented inside its window and is never refused as a replay. Details are under Session Authentication.
  • All other authentication failures (invalid or unauthorized signature, malformed credentials) share the terminal code authentication_failed (meta.retryable: false). Clients MUST branch on the stable code, never on message text.
  • last_auth_timestamp is updated atomically (compare-and-swap) when authentication succeeds; a session read's record is inserted atomically the same way.
  • POST /configure enforces the same timestamp skew and replay CAS, and every configuration consumes its timestamp before it writes any state. A registered account consumes it first, before any chain read or policy module call, so a reconfiguration that a module refuses, or that fails on a chain read, uses its signed request up and is retried with a fresh signature. A first-time configuration first claims the account: it creates the metadata row only if none exists, atomically, and only the request that created it proceeds as a first configuration. Replay state has a foreign key to account metadata, so the claim is what lets the timestamp be consumed before the state write. A request that loses the claim (a concurrent duplicate or a replay of the signed request) re-reads the account and is judged as a reconfiguration, so a replay from the same signer is refused with authentication_replay before it writes any state. A configuration from a different signer that loses the claim passes its own replay check and reconfigures the account it lost to, under the rule below; callers must not use /configure as a general concurrent state-update mechanism.
  • POST /configure registers only guarded multisig accounts: an initial_state without the multisig threshold slot is refused with invalid_input.
  • initial_state must be the account's current on-chain state, with two exceptions: a first configuration at nonce 0, which the account seed binds to its account id (decoding checks it) and whose vault must be empty (invalid_input otherwise), whoever claimed the account id before; and a stored cosigner of an active account re-registering the state already stored. Every other configuration needs the chain: a first configuration past nonce 0 (an account that already transacted, for example one switching to this GUARDIAN), a released account, a key the stored auth does not list, and any state other than the stored one. Until the chain holds the submitted state the request fails with state_not_on_chain (HTTP 409 / gRPC FailedPrecondition, meta.retryable: true), for example right after the transaction is submitted; retry once it lands. After a guardian switch both SDKs wait for the chain to hold the switched state (a chain read, about 45 seconds at most) before they register on the new GUARDIAN; a registration itself is not retried. One head read decides, so a state the chain has already moved past fails the same way, and its retries keep failing until the client submits the account's current state. A state older than the stored one is refused from the same read with commitment_mismatch (not retryable) when a stored cosigner submits it and the chain sits at the stored state; otherwise it gets state_not_on_chain. rpc_unavailable when the chain cannot be read. A configuration that skipped the chain read fails with state_not_on_chain when the account was released while it ran and its state is not the chain head; the retry of it is held to the chain.
  • A first configuration that fails after its claim (a storage error before the state write) leaves metadata with no stored state. Such an account is not listed by GET /state/lookup and is skipped by the release sweep. A retry of the same account id finishes it: the retry is held to the new-account scheme policy and counted as the account's creation.
  • Migrated stores retain the former account-scoped value as a lower bound for signers first seen later, preventing a removed signer from regaining a replay window when it is authorized again.
  • Clients generate strictly increasing timestamps per instance (max(now_ms, previous + 1)) and retry only authentication_replay, bounded, with a fresh timestamp, recomputed digest, and fresh signature over the identical payload on each attempt. Terminal authentication failures are never retried.
  • During a mixed server/client rollout, a replay CAS reported under the older authentication code—or received by a client without replay-specific retry handling—can surface as a terminal 401. Current clients retry only authentication_replay and never retry authentication_failed.
  • HTTP /configure failures use the standard API error envelope ({ code, message, meta }), not ConfigureResponse with success: false. Direct HTTP consumers that inspect the old error body must migrate with the server rollout. The shared protobuf response fields remain for gRPC.

Miden Request Signing

  • HTTP request payload digest: RPO256 over canonical JSON bytes of the request payload (body for POST/PUT, query object for GET).
  • gRPC request payload digest: RPO256 over protobuf-encoded request bytes.
  • ExecuteDeltaProposal is domain-separated, because its body (account_id, proposal_id) encodes to the same bytes as a GetDeltaProposalExecution read on both transports. Its payload digest is RPO256 over the ASCII tag guardian.ExecuteDeltaProposal and one zero byte, followed by the request bytes: the protobuf-encoded request over gRPC, the canonical JSON body over HTTP. No protobuf message begins with that tag, and canonical JSON begins with {. A signed status read therefore never authenticates an execute.
  • CheckDeltaProposal (POST /delta/proposal/check) is domain-separated the same way, with the tag guardian.CheckDeltaProposal, because it takes proposal creation's body: without the tag a wallet-signed check would also be a valid POST /delta/proposal.
  • Signed message format: RPO256_hash([account_id_prefix, account_id_suffix, timestamp_ms, payload_hash_0, payload_hash_1, payload_hash_2, payload_hash_3]).
  • ECDSA accounts may send x-auth-format: eip712 with the same three required headers. The signature is over GuardianRequest(bytes32 requestHash) in the EIP712Domain { name: "Guardian Request", version: "1" }; requestHash is the 32-byte little-endian encoding of the signed message above. An absent format header keeps the raw signature behavior. Falcon does not accept EIP-712 request auth. The existing timestamp skew and replay checks apply to both formats.
  • The typed request message displays a hash, not the decoded HTTP operation or proposal. The client must show the transaction details separately before prompting a hardware wallet.
  • EIP-712 ECDSA signatures use the Miden r || s || v encoding with v normalized to 0 or 1 before submission.

Lookup Request Signing

The GET /state/lookup endpoint and the matching GetAccountByKeyCommitment gRPC method use a dedicated, account-less signed-message format because the account ID is the very value the caller is trying to discover. The format is domain-separated by construction from Miden Request Signing above so a signature crafted for one shape cannot validate against the other in either direction. Raw Falcon and ECDSA signatures remain supported. ECDSA signers may instead send x-auth-format: eip712 and sign GuardianLookup(bytes32 lookupHash) in the EIP712Domain { name: "Guardian Lookup", version: "1" }, where lookupHash is the 32-byte little-endian encoding of the lookup message below.

  • Domain tag: DOMAIN_TAG = RPO256(felts(b"guardian.lookup.v1")) — a fixed 4-felt word, computed once and embedded in the binary. Future incompatible changes MUST bump the version segment.
  • Signed message format: RPO256_hash([DOMAIN_TAG_w0..w3, timestamp_ms, key_commitment_w0..w3]).
  • Authentication: proof-of-possession of the queried commitment. Raw signatures derive the identity from the signature itself — Falcon embeds the public key and ECDSA recovers it. A raw signature must be exactly 1524 bytes (Falcon) or 65 bytes (ECDSA r || s || v), and an EIP-712 signature exactly 65 bytes; any other length is rejected. For EIP-712, the server verifies the typed digest against x-pubkey. Both paths require the verified public key's commitment to equal the queried commitment. Raw lookup continues to ignore x-pubkey.
  • Replay protection: MAX_TIMESTAMP_SKEW_MS skew window only. No per-commitment last-seen tracking; a replayed valid request returns the same account_id to a key holder who already obtained it.

Session Authentication

Issue #219. A wallet authorizes a client-held P-256 key, the delegated signer, once with a signed session grant; the delegated signer then signs per-account Miden requests, so wallets (including hardware wallets) are not prompted for every request. Per-account authentication stays explicit and replay-protected: requests are still signed over the same AuthRequestMessage, only the signing key is delegated. Sessions remove request prompts, not approval prompts: the wallet still signs every transaction summary.

  • Every Guardian that accepts grants advertises sessions: { max_ttl_seconds, request_auth_version } on GET /status; an older Guardian omits it, and SDKs fail early instead of falling back silently. request_auth_version is the session request envelope version requests must be signed with (2). Version 2 also fixes how session requests are judged: each signed session read is admitted once, in any order, within 60 s of server time, except the canonical nonce poll, accepted every time within 60 s behind and 30 s ahead of server time; session writes advance a per-key timestamp floor, and wallet requests and session writes keep a 5-minute window. A change to these rules is a new version.

  • Grant. The wallet signs, in the clear:

    • signer_commitment: the commitment of the wallet key that signs;
    • session_public_key: the delegated signer's SEC1-compressed P-256 key (33 bytes; the 65-byte uncompressed form is rejected);
    • origin: the website that asked for the grant, e.g. https://app.example, at most 256 bytes; empty for clients outside a browser. The page writes it, so it is unverified; wallets display it, and Guardian does not check it against requests;
    • issued_at and expires_at (Unix seconds), plus expires, the canonical readable form of expires_at (YYYY-MM-DD HH:MM:SS UTC);
    • the scope, a fixed text every v1 grant states: Every account this signer cosigns on this Guardian, now or later, until this grant expires;
    • guardian_commitment: this Guardian's ACK key commitment for the wallet's scheme (GET /pubkey?scheme=<scheme>);
    • network: the status environment, exactly local, devnet, testnet, cedar or mainnet. It is not a bech32 HRP and cannot be derived from one: local and devnet share mdev, and Cedar and mainnet share mm, so a wallet must display this field rather than infer the network from an address.

    expires and the scope are derived by Guardian, never sent: a wallet that displayed anything else signed a different digest and is rejected.

  • Falcon and raw ECDSA wallets sign the RPO digest of these fields under the domain tag guardian.session.v1. EIP-712 wallets sign them as readable typed data, every field a top-level member, so the device shows what it authorizes: GuardianSession(bytes32 signer,bytes sessionKey,string origin,uint64 issuedAt,uint64 expiresAt,string expires,string scope,bytes32 guardianKey,string network) in domain { name: "Guardian Session", version: "1" }. Raw wallets show only a hash, so SDKs show the grant fields to the user before asking them to sign. That is UX, not phishing protection: a phishing page shows what it wants, so raw wallets blind-sign the grant there (accepted for v1; the follow-up is the wallet rendering the guardian.session.v1 grant itself).

  • POST /session (gRPC CreateSession) carries the scheme, the optional auth_format (eip712), the wallet public key, the signature and the grant fields. Falcon embeds its key; raw ECDSA recovers it and falls back to the supplied key; EIP-712 always uses the supplied key. Guardian rejects grants that:

    • name another network or ACK key;
    • have an issued_at outside the 5-minute (300-second) skew window;
    • expire within 300 seconds, or later than GUARDIAN_SESSION_MAX_TTL_SECONDS from now;
    • carry a session key that is not a valid compressed P-256 point;
    • carry a wallet signature that does not verify, or a signer commitment that does not match the signing key;
    • come from a key that is not a cosigner of any account on this Guardian (authorization_failed, HTTP 403).

    It returns the signer commitment, expires_at (RFC 3339), and request_auth_version for the session. SDKs refuse a Guardian that does not report version 2, both when starting a session and when resuming a stored one.

    Checks that need no cryptography run before signature verification; the cosigner check runs after it, so only the key's holder learns whether it cosigns anything. Guardian records the session as issued at the earlier of the grant's issued_at and the registration time. Re-submitting the grant of a live session (also re-signed with another issued_at) succeeds and returns the same expiry while its issued_at is inside the skew window, the retry after a lost response it exists for (later the grant fails the issued_at check); the record, including its recorded issue time, is left unchanged, so a re-submission cannot escape a revoke-all. A key already bound to a different grant (another signer, origin or expiry) is refused, so another cosigner who learns a session key from x-pubkey cannot re-bind it; clients generate a fresh key for every grant, renewals included. The grant of a revoked session is refused until its record is swept after expiry, so a revoked session cannot be revived.

  • Requests. x-pubkey is the compressed session public key, x-signature the delegated signer's ECDSA P-256/SHA-256 signature (raw r || s, 64 bytes) over the 62-byte version 2 session request envelope, plus x-auth-format: session-v2:

    "GUARDIAN_SESSION_REQUEST" 0x00 || u16be(2) || u8(transport)
        || u16be(operation) || AuthRequestMessage word (32 bytes)
    

    transport is 1 for HTTP and 2 for gRPC, so equivalent HTTP and gRPC requests carry different signatures. operation is the route's permanent id: 1 GET /state, 2 GET /state/nonce, 3 GET /delta, 4 GET /delta/since, 5 GET /delta/history, 6 GET /delta/proposal, 7 GET /delta/proposal/single, 8 POST /delta, 9 POST /delta/proposal, 10 PUT /delta/proposal, 11 POST /delta/proposal/execution, 12 GET /delta/proposal/execution, 13 GET /delta/execution/current, 14 GET /state/tail, 15 GET /policies, 16 POST /delta/proposal/check (the gRPC twins share the ids). 15 and 16 are reads: the check takes proposal creation's body but stores nothing, and its own id keeps a creation signature from passing on it or the reverse. Guardian derives both from the request it received, never from a header, so a signature made for one route or transport never verifies on another, even when the payloads serialize to the same bytes. Test vectors: crates/shared/tests/fixtures/session_request_vectors.json. The version 1 format (x-auth-format: session, signed over the bare word) is refused on every per-account route with unsupported_auth_version (HTTP 400, gRPC INVALID_ARGUMENT, not retryable); SDKs keep the session and do not fall back to the wallet. On wallet-only routes Guardian still checks a session credential over the bare request word, so it only ever answers wallet_signature_required or an authentication error there. On every request Guardian, in this order, verifies the signature, resolves the session to its grant (ended or unknown sessions fail here, see below), applies the route allow-list (see Routes), re-checks that the grant names this Guardian's current ACK key for the account's scheme and its network (key rotation ends sessions), requires the grant's signer to be a current cosigner of the account, and finally applies the replay check. Session reads are the exception: their replay check runs right after the signature, so a read refused by a later check has already used its signature. A signer that does not cosign the account, or a grant for this Guardian's key of the other signature scheme, gets authorization_failed (HTTP 403, gRPC PERMISSION_DENIED) and keeps its session for its other accounts; removing a signer ends its delegated access to that account, adding it back restores an unexpired grant.

  • Origin is informational. Guardian never compares the grant's origin with a request's Origin. A page that obtains a grant holds the key and can send requests from anywhere, so such a check would only stop a careless phishing page. The field is written by the page and unverified: the real signal is the wallet's own indicator of the requesting site (e.g. MetaMask's); hardware-wallet users have no verified origin in v1. The read exposure to a page the user wrongly approves is an accepted risk.

  • Replay protection. Session writes advance their own timestamp floor per (account, delegated key); wallet requests keep the floor per (account, signer). Every session read, including reads of sessions stored by an earlier release, records its signed request (SHA-256 of the session key and the envelope) and is admitted once, fleet-wide: reads with equal or reordered timestamps are all accepted, a copy of any one is refused with authentication_replay. At admission the timestamp is checked again against the store's clock, and a purge first raises a fence that admission refuses timestamps at or below, so a delayed or purged request is never admitted again. A session read's timestamp must be within 60 s of server time; wallet requests and session writes keep 5 minutes. The canonical nonce poll records nothing: it is accepted every time it is presented while its session is live and its timestamp is at most 60 s behind and 30 s ahead of server time, checked again against the store's clock when it is served. A copy of one reveals only the account's current nonce and commitment, for at most about 90 s after it was signed; its signature binds the operation, so it is never accepted for any other read. Wallet-signed nonce polls keep the floor: a wallet signature does not bind the operation, so it would also be a GET /state signature. A record that cannot be written fails the read closed. The record is written at admission, before the request is served, so a read that fails afterwards (for example with a storage error) has still consumed its signature; clients sign a new request rather than resending the old one. SDKs give each session request a strictly increasing timestamp per account, never more than a second ahead of the local clock, so two identical reads from one client never collide. A stolen session that stamps requests at the edge of the skew window therefore cannot lock the wallet out. Parallel requests on the same floor can still lose the race with authentication_replay; SDKs re-sign with a new timestamp and retry. Session floors are stored next to wallet floors, keyed session-<hex SHA-256 of the session key>, which never collides with a signer commitment or the legacy floor row. A session floor is deleted once no session can use it any more: GUARDIAN_SESSION_MAX_TTL_SECONDS plus twice the skew window after its last request.

  • Routes. Session credentials are accepted only on the session-eligible routes: GET /state, GET /state/nonce, GET /state/tail, GET /delta, GET /delta/since, GET /delta/history, GET /delta/proposal, GET /delta/proposal/single, GET /delta/proposal/execution, GET /delta/execution/current, GET /policies, POST /delta/proposal/check, POST /delta/proposal, PUT /delta/proposal, POST /delta and POST /delta/proposal/execution (and their gRPC twins). Every other route is wallet-only by default, including routes added later: after the delegated signature verifies and the session resolves (an ended session gets its own code first), it is rejected with wallet_signature_required (HTTP 403, gRPC PERMISSION_DENIED) before any state change. An unverifiable delegated signature is authentication_failed. A session-signed POST /delta meets the same cosigner signature gate as a wallet-signed one (insufficient_signatures below the floor), so a delegated signer cannot push a transaction the cosigners did not approve. A tail without the multisig auth, which that gate does not cover (an account registered before /configure required the multisig), keeps POST /delta wallet-only: it answers wallet_signature_required before the delta is applied or acknowledged. The candidate-queue checks run first, so such a push can be refused with conflict_pending_delta or commitment_mismatch before it is refused as session-signed. A session-signed POST /delta/proposal/execution meets the same readiness checks as a wallet-signed one, so Guardian executes only what the cosigners approved.

  • Ended sessions. A request from an expired session fails with session_expired, from a revoked one with session_revoked (both HTTP 401, gRPC UNAUTHENTICATED). An unknown key (an expired one whose record was swept, or any key after a restart of a Guardian without persistent sessions), or a grant naming a rotated key or another network is authentication_failed. On any of these three answers to a session-signed request, SDKs stop using the session, sign with the wallet again and tell the app (onEnded), which starts a new session.

  • Logout. POST /session/logout (gRPC RevokeSession) is signed by the delegated signer over SessionLogoutMessage (domain tag guardian.session.logout.v1, timestamp, session public key). The timestamp is Unix milliseconds, the request's x-timestamp. Idempotent once the delegated signature verifies; never answered with wallet_signature_required. Logging out an expired session leaves it reported as session_expired.

  • Revoke all. POST /session/revoke-all (gRPC RevokeAllSessions) is signed by the wallet over SessionRevokeAllMessage (domain tag guardian.session.revoke_all.v1, timestamp, signer commitment), raw or as GuardianSessionRevokeAll(bytes32 signer,uint64 timestamp) typed data (x-auth-format: eip712), with the signer commitment in the body. The timestamp is Unix milliseconds, the request's x-timestamp. It revokes every session of that signer whose recorded issue time is at or before the signed timestamp and returns the count: a replay inside the skew window cannot end a session granted after it. It is account-less, so it never touches a replay floor and no session request can block it. Page logout is not revocation, since a script that holds the key keeps it; this is the recovery path for a compromised page. The message names no Guardian: a revoke-all signature also ends that signer's older sessions on any other Guardian it reaches within the skew window. It can only revoke, so this is accepted. The signed timestamp comes from the revoking device's clock and a session's issue time from the granting device's (capped at server time), so a replay inside the skew window can also end a session started just after it on a device whose clock runs behind; the user starts a new session. Accepted limits: revoke-all ends only sessions already registered, so a grant a page got signed but has not registered yet can still be registered afterwards, up to about 10 minutes after signing (its issued_at may lie up to 5 minutes ahead and must be within 5 minutes of registration); and a revoking device whose clock runs behind Guardian's misses sessions started in that gap. SDKs therefore advise running revoke-all again 10 minutes later when a key may be compromised.

  • POST /session, /session/logout and /session/revoke-all are covered by the per-IP rate limiter like every other client route.

EVM Session Authentication

  • EVM support is behavior-gated by the server evm feature. Default builds do not register /evm/* routes or initialize EVM session state, Alloy readers, or proposal handlers.
  • EVM clients authenticate through /evm/auth/challenge and /evm/auth/verify, and clear the session through /evm/auth/logout.
  • Challenge signatures use eth_signTypedData_v4 over EIP-712 typed data:
    • Domain: { name: "Guardian EVM Session", version: "1" }.
    • Message: { wallet, nonce, issued_at, expires_at }.
  • Guardian derives the authenticated EOA with ecrecover, consumes the challenge nonce once, and stores the recovered address in a secure cookie-backed session.
  • Cross-origin browser clients use credentialed CORS when configured with an explicit origin allowlist. The EVM session cookie remains host-only and HttpOnly.
  • EVM sessions expire; challenge nonces are time-limited and single-use.

Data Shapes

Account Identifiers

  • Miden account IDs use the existing Miden account identifier format.
  • EVM account IDs are canonical strings: evm:<chain_id>:<normalized_smart_account_address>.
  • EVM accounts are registered through /evm/accounts and use /evm/proposals* for proposal coordination.

AuthConfig

HTTP JSON uses externally tagged variants:

{ "MidenFalconRpo": { "cosigner_commitments": ["0x..."] } }
{ "MidenEcdsa": { "cosigner_commitments": ["0x..."] } }
{
  "Miden": {
    "cosigners": [
      { "commitment": "0x...", "scheme": "ecdsa" },
      { "commitment": "0x...", "scheme": "falcon" }
    ],
    "guardian_scheme": "ecdsa"
  }
}
{ "EvmEcdsa": { "signers": ["0x..."] } }

MidenFalconRpo and MidenEcdsa bind every cosigner and the GUARDIAN to one scheme. Miden declares each cosigner's scheme ("falcon" or "ecdsa") and the GUARDIAN's scheme separately, for an account whose approvers mix Falcon and ECDSA keys (issue #563). Clients send Miden only when the cosigners and the GUARDIAN do not all share one scheme; servers before #563 reject it, and the single-scheme variants keep their wire shape. The server accepts Miden for a uniform set too and stores the declared variant as is.

For every variant /configure checks the declaration against initial_state: the cosigner commitments must equal the approver map in index order, every approver must have a supported scheme in the approver scheme map (invalid_input otherwise; the chain verifies each approver under that scheme), each cosigner's scheme must equal it, the GUARDIAN slot must hold this server's ACK commitment for the GUARDIAN scheme, and the GUARDIAN scheme slot must store that scheme. Over HTTP the scheme names are lowercase ("falcon", "ecdsa"): the request signature covers the canonical JSON of the parsed body, so a name in another case could not authenticate and is rejected when the body is parsed. gRPC signs the message as sent and accepts any case. The GUARDIAN scheme selects the ACK key the account's deltas are acknowledged with. When canonicalization syncs the cosigners from a new canonical state it keeps the GUARDIAN scheme and the schemes the state stores: a single-scheme auth whose cosigners all keep its scheme stays single-scheme, and one that gains a cosigner of another scheme becomes Miden.

The contract may expose EVM-shaped auth metadata, but /configure and the Miden delta routes only accept Miden auth variants. EVM account registration derives signer metadata from the validator module through /evm/accounts.

gRPC uses AuthConfig::{miden_falcon_rpo, miden_ecdsa, evm_ecdsa, miden} for schema compatibility (MidenAuth { repeated MidenCosigner cosigners; string guardian_scheme }, MidenCosigner { string commitment; string scheme }; scheme names are case-insensitive), while EVM behavior remains HTTP-only under /evm/*.

NetworkConfig

HTTP JSON uses a kind discriminator:

{ "kind": "miden", "network_type": "local" }
{
  "kind": "evm",
  "chain_id": 31337,
  "account_address": "0x...",
  "multisig_validator_address": "0x..."
}
  • network_config is optional for legacy Miden /configure requests and defaults to { "kind": "miden", "network_type": "local" }.
  • Miden state/delta routes only accept kind: "miden" accounts. EVM account metadata is created through /evm/accounts.
  • EVM account_address is the smart account address and must match account_id.
  • EVM multisig_validator_address is the ERC-7579 multisig validator module address.
  • Guardian does not trust client-provided RPC endpoints. RPC URLs are resolved server-side from GUARDIAN_EVM_RPC_URLS; the EntryPoint address is resolved server-side from GUARDIAN_EVM_ENTRYPOINT_ADDRESS and defaults to the EntryPoint v0.9 address.

gRPC uses NetworkConfig::{miden, evm}.

StateObject

{
  "account_id": "string",
  "state_json": {},
  "commitment": "string",
  "created_at": "string",
  "updated_at": "string",
  "auth_scheme": "falcon"
}

auth_scheme may be "falcon" or "ecdsa" when the account's cosigners and GUARDIAN share that scheme, and "mixed" when they do not.

DeltaObject

{
  "account_id": "string",
  "nonce": 0,
  "prev_commitment": "string",
  "new_commitment": "string",
  "delta_payload": {},
  "ack_sig": "string",
  "ack_pubkey": "string",
  "ack_scheme": "falcon",
  "status": { "status": "candidate", "timestamp": "string", "retry_count": 0 }
}

status is one of:

  • { "status": "pending", "timestamp": string, "proposer_id": string, "cosigner_sigs": CosignerSignature[] }
  • { "status": "candidate", "timestamp": string, "retry_count": number }
  • { "status": "canonical", "timestamp": string }
  • { "status": "retained", "timestamp": string, "reason": "retry_exhausted" | "diverged" | "orphaned" } — a candidate the worker gave up verifying, kept for background reconciliation (issue #345): promoted to canonical if the chain ever shows it landed, dropped after a server-side TTL otherwise. orphaned (issue #17) marks a candidate whose predecessor in the account's candidate queue was parked, discarded, or abandoned. reason is omitted when not recorded.
  • { "status": "discarded", "timestamp": string, "reason": "client_abandoned" } — reason is omitted for discards without a recorded reason.

Proposal Payloads

Miden delta proposals use:

{
  "tx_summary": { "data": "base64-transaction-summary" },
  "metadata": { "proposal_type": "p2id" },
  "signatures": []
}

metadata.proposal_type is required and must be a non-empty string, but its value is not restricted to a fixed set: the server accepts any label (issue #266). The first-party multisig operations use add_signer, remove_signer, change_threshold, update_procedure_threshold, switch_guardian, consume_notes, and p2id; any other label is accepted and surfaced verbatim. Clients that do not model a given label bucket it as custom while preserving the original string for display. The server makes no security decision based on proposal_type — integrity comes from the tx_summary/state-commitment check, the cosigner threshold, and the GUARDIAN ack. Restricting which types an account may submit is a policy-layer concern, not a core-server one.

p2id metadata carries recipient_id, faucet_id, amount, and an optional note_type ("public" or "private", issue #322). Clients emit note_type only when the note is private; an absent field means public, which keeps proposals created before the field existed valid. The value is part of the signed metadata: verifiers rebuild the transaction from it, so a tampered note_type fails the tx_summary commitment check.

p2id metadata may additionally carry reclaim_height and/or timelock_height (issue #366): absolute u32 block heights that make the proposal create a P2IDE note instead of a plain P2ID note (reclaim_height lets the sender reclaim an unconsumed note from that block on; timelock_height blocks consumption before that block). Presence of either field selects P2IDE; both absent means plain P2ID, which keeps pre-existing proposals valid. 0 is rejected because it is the on-chain encoding for "no constraint". Like note_type, the heights are part of the signed metadata and a tampered value fails the tx_summary commitment check.

A proposal created by a Guardian-executable client additionally carries transaction_request, the serialized TransactionRequest Guardian executes, in an envelope:

{
  "transaction_request": {
    "format_version": 1,
    "protocol_line": "0.17",
    "checksum": "0x<lowercase sha-256 of the raw bytes>",
    "bytes": "<base64 of the raw bytes>"
  }
}

protocol_line is the Miden line of the SDK that sealed the request: 0.18 from the Rust SDK and 0.17 from the TypeScript SDK. Request serialization carries no miden-client version tag. Creation checks the body (base64, checksum, format_version) and the size caps. Execution accepts protocol lines 0.17 and 0.18 and refuses any other (GUARDIAN_EXECUTION_PROTOCOL_MISMATCH), decodes the bytes, and refuses a request that does not decode (GUARDIAN_EXECUTION_REQUEST_CODEC) or does not reproduce the signed summary (GUARDIAN_EXECUTION_BINDING_MISMATCH). A self-executed proposal omits the field, so its wire shape is unchanged, and the proposal id is the summary commitment either way.

A proposal may name the state its summary was built on (issue #517):

{
  "base_commitment": "0x<64 hex>"
}

POST /delta/proposal classifies it against the candidate queue as POST /delta classifies a delta's prev_commitment: the queue tail (the canonical state when nothing is queued) is recorded; the canonical state or a non-tail candidate's post-state while a later candidate already claimed it is 409 conflict_pending_delta (build on GET /state/tail, or wait for the queue to drain); any other state is 400 commitment_mismatch against the canonical commitment. A value that is not a 0x-prefixed 32-byte hex string is 400 invalid_delta. Without it the proposal is judged by its nonce alone, which cannot tell the tail from a sibling state at the tail's nonce. Both multisig SDKs send it from 0.19.0 for every proposal they build (not for a summary the caller supplies). It travels in the payload rather than as a request field because a server before 0.19.0 rebuilds the signed request from the fields it knows: a new request field would fail authentication there, while a payload key is signed and stored unchanged (and ignored). It is stored with the payload, and the recorded prev_commitment is the same state.

Every proposal, with or without a base, is recorded pinned to the tail the request read, and the storage admission checks that pin again under the account lock candidates are admitted under: a candidate admitted after the read, or one that left the queue, moved the tail, and the proposal is refused with 409 conflict_pending_delta rather than stored on a state its delta could never build on. Read the tail again and rebuild.

Only the single-proposal reads (GET /delta/proposal/single, GetDeltaProposal) and the create and sign responses return transaction_request. Listings (GET /delta/proposal, GetDeltaProposals) omit it on both transports: each request may be as large as GUARDIAN_MAX_PROPOSAL_REQUEST_BYTES, so a listing that carried every stored request could outgrow a client's message limit (tonic decodes at most 4 MiB). Nothing a cosigner verifies, signs or exports reads the field, and the proposal id never covers it.

Every proposal the multisig SDKs create also carries bound_block_num, the u32 block its transaction summary binds. It is not signed and the server does not read it: the clients read the block from the signed summary and refuse a proposal whose bound_block_num disagrees, so a wrong value can deny a proposal, never get a wrong one accepted. Proposals created by 0.18.0 clients carry chain_anchor (a base64 Miden ChainAnchor) instead; current clients take their block from the summary, never read the anchor and never write it.

EVM proposals use EVM-specific request and response shapes under /evm/proposals. They do not use DeltaObject or the /delta/proposal envelope.

EVM proposal creation request:

{
  "account_id": "evm:31337:0x...",
  "user_op_hash": "0x...",
  "payload": "{\"packedUserOperation\":{}}",
  "nonce": "0",
  "ttl_seconds": 900,
  "signature": "0x..."
}

EVM proposal response:

{
  "proposal_id": "0x...",
  "account_id": "evm:31337:0x...",
  "chain_id": 31337,
  "smart_account_address": "0x...",
  "validator_address": "0x...",
  "user_op_hash": "0x...",
  "payload": "{\"packedUserOperation\":{}}",
  "nonce": "0",
  "nonce_key": "0",
  "proposer": "0x...",
  "signer_snapshot": ["0x..."],
  "threshold": 2,
  "signatures": [
    { "signer": "0x...", "signature": "0x...", "signed_at": 1700000000000 }
  ],
  "created_at": 1700000000000,
  "expires_at": 1700000900000
}
  • The payload is opaque application data supplied by the client.
  • user_op_hash is the 32-byte hash that EVM signers sign.
  • nonce is the full uint256 EntryPoint nonce as a decimal string or 0x-prefixed hex string.
  • Guardian snapshots signer EOAs and threshold through Alloy, verifies signatures against user_op_hash, and stores an EVM proposal record in a domain-specific proposal store.
  • EVM signatures are verified against the client-supplied 32-byte hash.
  • Guardian does not build UserOperations, decode payloads, or submit transactions on-chain.

Proposal Signatures

{
  "signer_id": "0x...",
  "signature": { "scheme": "falcon", "signature": "0x..." }
}
{
  "signer_id": "0x...",
  "signature": { "scheme": "ecdsa", "signature": "0x...", "public_key": "0x..." }
}

For an EIP-712 Miden approval, the same endpoint and envelope use "message_format": "eip712" inside the ECDSA signature. The signed type is MidenTransaction(bytes32 txSummaryHash) under { name: "Miden Transaction", version: "1" }. txSummaryHash is the transaction-summary commitment encoded as four little-endian u64 field elements. The ECDSA signature is r || s || v; Guardian requires v as 0/1 and verifies the approval against the stored summary and the request signer. Wallets returning 27/28 must normalize it before submission. The request-auth signature remains a separate signature over GuardianRequest.

  • Miden Falcon signer IDs are signer commitments.
  • Miden ECDSA signer IDs are signer commitments.
  • EVM proposal signatures use EvmProposalSignature records: { signer, signature, signed_at }.
  • EVM create/approve request bodies carry raw ECDSA signatures. Signer identity is derived from guardian_evm_session.
  • Stored EVM signers are normalized EOA addresses.
  • EVM proposal signatures are verified with ecrecover(hash, signature).

Guardian verifies every Miden approval against the proposal's transaction summary before storing it:

  • Falcon and raw ECDSA approvals sign the transaction-summary commitment; EIP-712 approvals sign the typed-data hash above. The Falcon public key comes from the signature. ECDSA approvals must carry public_key; a raw approval's v must be 0/1 and recover to that key, as execution recovers it.
  • The verified key's commitment is the approval's signer. It must be signed under the scheme the account registers that signer with: a key the account stores under the other scheme is refused, since the chain verifies each approver under its stored scheme. On PUT /delta/proposal it must be one of the account's configured cosigners, but it need not be the request signer: an authenticated signer may relay an approval another cosigner produced off channel (the SDK execute flows relay a proposal document's collected approvals this way before requesting the acknowledgement). The approval is credited to the cosigner the signature verifies for, never to the relaying caller, and one the proposal already holds for that cosigner is rejected with proposal_already_signed.
  • On POST /delta/proposal, signatures may carry at most the proposer's own approval. Other cosigners approve through PUT /delta/proposal.
  • A signature that does not parse or verify, whose signer is not a cosigner of the account (PUT) or the proposer (POST), or that is made under another scheme than the account registers its signer with, is rejected with invalid_proposal_signature.

ProposalExecution

The envelope every execution operation returns, identical on HTTP and gRPC (where error.meta travels as meta_json):

{
  "account_id": "0x...",
  "proposal_id": "0x...",
  "state": "failed",
  "error": { "code": "GUARDIAN_EXECUTION_EXPIRATION_REACHED", "message": "...", "meta": { "bound": "approval" } },
  "delta_nonce": 7,
  "newly_accepted": false,
  "proposal_exists": true,
  "ignored_signatures": 0,
  "updated_at": "2026-09-30T12:00:00Z"
}
  • state is one of exactly five values: pending, proving, submitted, committed, failed. They move forward only. submitted means the transaction may have been sent and is never retried; it resolves only from what the chain shows.
  • error is present exactly when state is failed. These codes carry meta: GUARDIAN_EXECUTION_REQUEST_INVALID (reason: bound_block_not_declared, auth_args_missing, approval_expiration_missing, input_notes_not_pinned, too_many_declared_blocks), GUARDIAN_EXECUTION_EXPIRATION_REACHED (bound: approval, transaction) and GUARDIAN_EXECUTION_FOREIGN_ACCOUNT_UNAVAILABLE (reason: private, unavailable); on servers with policy modules, GUARDIAN_EXECUTION_MODULE_DENIED (reason_code, and module, layer, client_message unless the denial is generic) and GUARDIAN_EXECUTION_MODULE_UNAVAILABLE (module, absent when the instance's denials are generic). The full list is in docs/TROUBLESHOOTING.md.
  • delta_nonce is set once the execution committed to its candidate delta.
  • newly_accepted separates the request that started the execution from a repeat that found it running (HTTP also answers 202 versus 200).
  • proposal_exists is a fact about storage, not retry advice: a post-submission failure deletes the proposal.
  • ignored_signatures counts stored signatures that were invalid, duplicated or not from a cosigner, which never block an otherwise ready proposal.

DeltaProposalEnvelope

{ "delta": {}, "commitment": "0x..." }
  • Miden proposal IDs are derived by the configured Miden network client from (account_id, nonce, tx_summary).

HTTP Endpoints

Rate Limiting

  • Both transports are rate limited by client IP, metered from one store.
  • Burst limits are applied per IP and endpoint, where the endpoint is the HTTP path or the gRPC method. HTTP paths and gRPC method names differ, so a burst bucket is never shared across transports.
  • Sustained limits are applied per IP alone, so HTTP and gRPC calls from one client draw on the same allowance, and per IP+account/signer when available.
  • Client IP detection prefers the rightmost X-Forwarded-For entry (the one the nearest proxy appended; any prefix is client-supplied and ignored), then X-Real-IP, then the socket peer IP.
  • Exceeded limits return 429 Too Many Requests with Retry-After on HTTP, and RESOURCE_EXHAUSTED with a retry-after metadata key (ASCII decimal seconds) on gRPC. Both carry the same rate_limit_exceeded error envelope, including meta.retry_after_secs.

Request Size Limits

  • HTTP request bodies are limited to a configurable maximum size (default: 1 MB).
  • Requests exceeding this limit return 413 Payload Too Large.

Endpoint catalog

The authoritative, machine-readable description of every HTTP endpoint — request/response shapes, status codes, query/path parameters, and auth schemes — is the generated OpenAPI spec, not this document. See docs/OPENAPI.md; the spec files live at docs/openapi.json (combined) and the per-surface docs/openapi-client.json, docs/openapi-dashboard.json, and docs/openapi-evm.json. The gRPC contract is crates/server/proto/guardian.proto.

To avoid drift, this section does not restate per-endpoint request/response shapes — it is an index plus the cross-cutting behavior the OpenAPI spec cannot express. Wire shapes are defined once under Data Shapes (also covering gRPC) and in the OpenAPI component schemas.

Surface Method & path Auth Summary
client POST /configure signed headers Register an account with its auth set and initial state
client POST /delta signed headers Push a delta; a multisig account must meet its cosigner threshold
client GET /delta signed headers Fetch the delta at a nonce
client GET /delta/since signed headers Merged delta since a nonce
client GET /delta/history signed headers Paginated canonical delta history with decoded note summaries
client GET /state signed headers Latest canonical state
client GET /state/nonce signed headers Nonce and commitment of the latest canonical state (sync pre-check)
client GET /state/tail signed headers The candidate queue tail a new delta or proposal must build on, and the queued candidates that lead to it
client GET /state/lookup lookup signing (PoP) Resolve a key commitment to account IDs
client GET /pubkey public ACK public key / commitment for ?scheme=falcon|ecdsa (default falcon)
client GET /status public Server liveness, version, environment, uptime, execution capability, session parameters
client GET / public Alias of GET /status
client POST /delta/proposal signed headers Create a multisig proposal
client GET /delta/proposal signed headers List pending proposals (without transaction_request; see Proposal Payloads)
client GET /delta/proposal/single signed headers Fetch one proposal by commitment
client PUT /delta/proposal signed headers Add a cosigner signature
client POST /delta/candidate/abandon signed headers Record an abandon intent for a stuck candidate (202; worker resolves after quarantine). The request names the transaction with proposal_id (its summary's commitment) as well as the nonce; the abandon answers for the delta carrying it, at the nonce or archived after a Guardian execution took the nonce, and another transaction at the nonce is answered delta_not_found. The response carries the abandoned delta's commitment. Without proposal_id (SDKs up to 0.18.3) the delta at the nonce is named. Either way, an active Guardian execution's own candidate is never abandoned (HTTP 409 GUARDIAN_EXECUTION_CONFLICT; over gRPC the in-band error_code), and a malformed proposal_id is refused with 400 invalid_commitment
client POST /delta/proposal/execution signed headers Ask Guardian to prove and submit a threshold-met proposal (202 new, 200 already running). Body {account_id, proposal_id}, both required and signed as guardian.ExecuteDeltaProposal (see Miden Request Signing)
client GET /delta/proposal/execution signed headers The latest execution of a proposal (404 GUARDIAN_EXECUTION_NOT_FOUND when the proposal exists but was never executed; 404 proposal_not_found when the proposal is gone and no attempt is left, which is how a proposal whose records retention deleted reads: see GUARDIAN_EXECUTION_RECORD_RETENTION_DAYS)
client GET /delta/execution/current signed headers The account's in-flight execution; {"execution": null} when none
client GET /policies signed headers The policy modules that apply to ?account_id, as far as each instance's catalog entry discloses them, in evaluation order; empty without modules
client POST /delta/proposal/check signed headers Dry run of POST /delta/proposal (same body): its checks, the account's gate modules with dry_run = true and the account-wide request byte limit; stores nothing. 200 {allowed: true, complete}, or the error creation would return. Rate limited per account and signer (GUARDIAN_MODULE_CHECK_RATE_PER_MIN)
client POST /session wallet-signed grant in the body Register a delegated signer (see Session Authentication)
client POST /session/logout session-key-signed headers Revoke this session
client POST /session/revoke-all wallet-signed headers Revoke every session of a signer
dashboard GET /auth/challenge public Operator login challenge
dashboard POST /auth/verify public Verify challenge, establish session
dashboard POST /auth/logout session Invalidate the operator session
dashboard GET /dashboard/accounts session + dashboard:read Paginated account list
dashboard GET /dashboard/accounts/{account_id} session + dashboard:read Account detail
dashboard GET /dashboard/accounts/{account_id}/snapshot session + dashboard:read Decoded vault snapshot
dashboard GET /dashboard/accounts/{account_id}/deltas session + dashboard:read Per-account delta feed
dashboard GET /dashboard/accounts/{account_id}/deltas/{nonce} session + dashboard:read Decoded delta detail
dashboard GET /dashboard/accounts/{account_id}/proposals session + dashboard:read Per-account proposal queue
dashboard POST /dashboard/accounts/{account_id}/pause session + accounts:pause Pause an account
dashboard POST /dashboard/accounts/{account_id}/unpause session + accounts:pause Unpause an account
dashboard GET /dashboard/info session + dashboard:read Inventory & lifecycle summary
dashboard GET /dashboard/stats session + dashboard:read Account counts, Miden asset totals, and coverage in one request
dashboard POST /dashboard/stats/refresh session + stats:refresh Request an out-of-cycle refresh of the stats aggregate (202)
dashboard GET /dashboard/session session Session introspection
dashboard GET /dashboard/modules session + dashboard:read Policy module catalog with runtime state (enabled, params, drift, circuit, undeclared stored instances)
dashboard GET /dashboard/modules/{module_id}/params/history session + dashboard:read Params history of an instance, newest first (before, limit)
dashboard PUT /dashboard/modules/{module_id}/params session + policies:write_global Replace an instance's global params (validated by the module; reason required)
dashboard POST /dashboard/modules/{module_id}/enable session + policies:write_global Enable an instance after its startup checks
dashboard POST /dashboard/modules/{module_id}/disable session + policies:write_global or modules:disable Disable an instance the catalog marks operator_can_disable
dashboard GET /dashboard/accounts/{account_id}/modules session + dashboard:read The modules that apply to an account, its layers and assignments
dashboard PUT /dashboard/accounts/{account_id}/modules/{module_id}/params session + policies:write Set an account's layer on an all instance
dashboard DELETE /dashboard/accounts/{account_id}/modules/{module_id}/params session + policies:write Remove that layer
dashboard PUT /dashboard/accounts/{account_id}/modules session + policies:write Replace an account's default and assigned module entries
dashboard GET /dashboard/deltas session + dashboard:read Cross-account delta feed
dashboard GET /dashboard/proposals session + dashboard:read Cross-account proposal feed
evm GET /evm/auth/challenge public EIP-712 session challenge
evm POST /evm/auth/verify public Verify challenge, establish session
evm POST /evm/auth/logout evm session Invalidate the EVM session
evm POST /evm/accounts evm session Register an EVM smart-account
evm POST /evm/proposals evm session Create an EVM proposal
evm GET /evm/proposals evm session List EVM proposals
evm GET /evm/proposals/{proposal_id} evm session Fetch an EVM proposal
evm POST /evm/proposals/{proposal_id}/approve evm session Approve an EVM proposal
evm GET /evm/proposals/{proposal_id}/executable evm session Executable (threshold-met) proposal
evm POST /evm/proposals/{proposal_id}/cancel evm session Cancel an EVM proposal

"signed headers" = x-pubkey + x-signature + x-timestamp (see Miden Request Signing); "session" = the guardian_operator_session cookie; "evm session" = the guardian_evm_session cookie. EVM endpoints exist only when the server is built with the evm feature.

HTTP behavioral notes

Semantics not captured by the OpenAPI shapes:

  • Pagination. Paginated endpoints (the dashboard feeds and the client GET /delta/history) return { items, next_cursor }; limit defaults to 50 and is capped at 500 (invalid_limit outside [1, 500]). Cursors are opaque and signed, scoped to the issuing endpoint; tampered/stale/cross-endpoint cursors return invalid_cursor. Per-account feeds key the cursor on immutable fields (nonce, (nonce, commitment)) and are fully stable; cross-account feeds order by status_timestamp / originating_timestamp and MAY skip or repeat an entry whose timestamp is bumped mid-traversal (FR-005).
  • GET /delta/history. Canonical deltas only, newest-first by nonce. Each entry carries an explicit status (always canonical today; the closed set widens if the feed gains a status= filter) and decoded notes carry note_type (public / private) from the on-chain note metadata, with input/output note summaries decoded server-side from the stored TransactionSummary. An entry whose payload cannot be decoded is still returned, with empty note sections and a decode_warnings item. Read-only: served while the account is paused. Only transactions pushed through Guardian appear — history of transactions the account executed elsewhere is not visible to it. EVM-configured accounts are rejected with unsupported_for_network, like the other Miden delta APIs.
  • GET /state/nonce. The head of the canonical state without the state blob: the account nonce carried by the state GUARDIAN currently holds as canonical, plus that state's commitment (issue #191). Both are stored with the state when it is written, so the server answers without loading, decrypting, or decoding the blob. SDK sync calls it before GET /state and skips the full fetch only when the reported nonce is below the local account nonce, or equal to it with the same commitment. An equal nonce at a different commitment is divergence and a higher nonce means GUARDIAN is ahead; both fall through to the unchanged full sync. Read-only: served while the account is paused. A state stored before the server kept nonces is decoded on its first read and its nonce stored; if that state no longer decodes to an account, the call is account_data_unavailable (503) rather than a nonce of 0. EVM-configured accounts are rejected with unsupported_for_network.
  • GET /state/tail. The state a new delta or proposal must build on (issue #517): { "state": <StateObject>, "queue": [{ "nonce", "prev_commitment", "new_commitment" }], "accepts_submissions": <bool> }. With GUARDIAN_MAX_PENDING_CANDIDATES_PER_ACCOUNT above 1 a submission must build on the queue tail, the post-state of the newest queued candidate, which GET /state does not serve; this read replays the queued candidates onto the canonical state and serves the result in state, shaped as GET /state serves a state (updated_at is when the newest candidate was queued). queue lists the candidates oldest first: the first builds on the canonical state, each later one on the one before it, and the last one's new_commitment is state.commitment. With nothing queued, state is the canonical state and queue is empty. accepts_submissions is false while a delta or proposal built on the tail would be refused with 409 conflict_pending_delta: the queue is full (at the default depth of 1, whenever anything is queued), the tail changes the signer set or the guardian key, or its newest candidate was queued by a server before 0.19.0 under a label other than its nonce. A client then waits for the queue to drain and reads again rather than build. True holds only for this read: the tail can move before the push, and the account's status and the proposal limits still apply. The tail is not on chain until the queued candidates land; a client can check that the chain sits at the canonical state or one of the queued post-states before building on it, and if a queued candidate never lands, everything built on the tail is abandoned with it. Authorized like GET /state, by the canonical state's signers (requests are authorized against the canonical metadata until a candidate promotes; nothing queues behind a candidate that changes the signer set or the guardian key, so only the newest candidate can change them). Each read replays the queue, one delta application per queued candidate on the server's reconstruction pool, so it is a read to make before building on the account, not a poll; GET /state/nonce is the poll. A queue that does not chain from the canonical state (a candidate left it and the worker has not swept its successors yet) or whose replay does not reproduce the stored tail has no tail to serve and is refused with 409 conflict_pending_delta until it drains. A separate route rather than a /state parameter so that a server before 0.19.0 answers 404 (gRPC UNIMPLEMENTED), not authentication_failed for a signature over a query it does not know. Read-only: served while the account is paused. EVM-configured accounts are rejected with unsupported_for_network.
  • /state/lookup. An empty accounts list is a successful response, not a 404 — distinguishing "no account" from "wrong key" would leak account presence to non-key-holders. Authentication is proof-of-possession of the queried commitment (see Lookup Request Signing).
  • EVM exclusions (v1). EVM accounts return an empty page on the per-account proposal queue and never appear on the global proposal feed (FR-017); the account snapshot returns unsupported_for_network for EVM accounts (no Miden vault to decode).
  • Aggregate degradation. On the filesystem backend, cross-account fan-out aggregates (/dashboard/info delta / proposal / activity fields, /dashboard/deltas, /dashboard/proposals) short-circuit to data_unavailable (503) or a degraded_aggregates marker above the configured filesystem_aggregate_threshold (default 1,000 accounts) rather than full-scan the inventory (FR-029). On /dashboard/info the threshold is applied by the /dashboard/stats walk that computes those fields, and the affected names surface in degraded_aggregates; total_account_count and accounts_by_auth_method are always returned once a snapshot exists.
  • Aggregate stats (GET /dashboard/stats, issue #371). Served from one snapshot per fleet: the holder of the dashboard_stats lease walks the inventory every GUARDIAN_DASHBOARD_STATS_REFRESH_INTERVAL_SECS (default 300 s) and publishes to the shared store with lease-fenced, atomic publication (sealed with the storage cipher when at-rest encryption is configured); every replica polls and serves the same version. A request never reads storage or decodes a vault, and reports the snapshot time as as_of (the interval is not a bound on its age). POST /dashboard/stats/refresh (stats:refresh) queues an out-of-cycle walk (202, queued / in_progress); requests inside the 60-second cooldown are 429 rate_limit_exceeded with Retry-After. ?updated_since=<RFC3339> restricts the asset aggregate to accounts whose metadata updated_at >= updated_since (account counts are always unfiltered; blank is treated as absent; any other non-RFC3339 value is 400 invalid_timestamp; percent-encode a + offset or use Z). Eligibility is Miden-only. Fungible totals are base-10 decimal strings summed in 128-bit; coverage satisfies covered + Σskipped == eligible, and any skipped account (reasons state_unavailable, state_undecodable) makes complete: false — a missing or undecodable state is never reported as a zero balance. Until the first refresh after startup the endpoint returns 503 data_unavailable (retryable). A walk that fails at any systemic storage read keeps the previous snapshot published; a single corrupt row is explicit state_undecodable coverage. Every cross-account aggregate on /dashboard/info reads the same snapshot (reported as aggregates_as_of), so the two endpoints never disagree.
  • Account detail / snapshot. Both are decode-only views of Guardian's stored state at the last-canonicalized commitment — no live Miden RPC and no cross-account joins. has_pending_candidate: true means the decoded vault may already be stale relative to the chain.
  • Cross-cutting errors. Every endpoint may also return 429 (rate limit, with Retry-After) and 413 (body size limit); see Rate Limiting and Request Size Limits. All errors use the structured GuardianError envelope (see Errors).

Errors

Codes come in two spellings. The lowercase snake_case codes below keep that spelling. The uppercase codes carry a GUARDIAN_ prefix (GUARDIAN_<AREA>_<CONDITION>, for example GUARDIAN_EXECUTION_EXPIRATION_REACHED), and every new code uses that form. Existing codes are not renamed, because a code is a wire contract that clients match on.

Stable error codes include:

  • account_not_found
  • account_already_exists
  • account_data_unavailable
  • invalid_account_id
  • state_not_found
  • delta_not_found
  • invalid_delta
  • conflict_pending_delta
  • conflict_pending_proposal
  • pending_proposals_limit
  • commitment_mismatch
  • state_not_on_chain (a reconfiguration that must submit the account's on-chain state submitted one the chain does not hold yet; HTTP 409 / gRPC FailedPrecondition, retryable, as is a state the chain has moved past, unless a stored cosigner submits a state older than the stored one while the chain sits at the stored state, which is commitment_mismatch)
  • invalid_commitment
  • authentication_failed
  • authentication_replay (retryable replay-CAS rejection, see Replay Protection)
  • authorization_failed
  • signature_scheme_not_allowed (a new-account registration, or a reconfiguration adding a scheme the account did not use, used a scheme excluded by GUARDIAN_ALLOWED_ACCOUNT_SCHEMES; HTTP 403 / gRPC PermissionDenied, meta.scheme + meta.allowed_schemes)
  • invalid_input
  • storage_error
  • network_error
  • signing_error
  • configuration_error
  • proposal_not_found
  • proposal_already_signed
  • invalid_proposal_signature
  • unsupported_for_network
  • unsupported_evm_chain
  • invalid_network_config
  • rpc_unavailable
  • rpc_validation_failed
  • Guardian execution: GUARDIAN_PROVING_UNAVAILABLE, GUARDIAN_PROPOSAL_NOT_READY, GUARDIAN_PROPOSAL_MISSING_TRANSACTION_REQUEST, GUARDIAN_PROPOSAL_EXECUTES_LOCALLY (meta.proposal_type and meta.reason: switch_guardian for a guardian switch, labelled switch_guardian or with a signed summary that changes the guardian public key slot, which only the client that finishes the GUARDIAN handoff executes. Nothing is reserved and the proposal stays pending), GUARDIAN_EXECUTION_CONFLICT (meta.blocking_proposal_id), GUARDIAN_EXECUTION_BUSY (retryable: another request is starting an execution for the account, the process already holds GUARDIAN_EXECUTION_MAX_CONCURRENT executions, or the server is shutting down and its drain refuses new executions; nothing is reserved, and a retry reaches another replica or the restarted server), GUARDIAN_EXECUTION_NOT_FOUND, GUARDIAN_PROPOSAL_REQUEST_TOO_LARGE, GUARDIAN_ACCOUNT_REQUEST_CAPACITY_EXCEEDED. An execution request gets commitment_mismatch when the proposal builds on a state other than the account's current one, and conflict_pending_delta while a client candidate is pending. Their HTTP and gRPC status pairs are verified by crates/server/src/api/execution_tests.rs.
  • signer_not_authorized
  • wallet_signature_required (session credentials on a wallet-only route; HTTP 403 / gRPC PermissionDenied)
  • session_expired, session_revoked (the delegated signer's session ended; HTTP 401 / gRPC Unauthenticated)
  • unsupported_auth_version (a session request in a format Guardian no longer accepts, the version 1 x-auth-format: session; HTTP 400 / gRPC InvalidArgument, not retryable)
  • invalid_evm_proposal
  • insufficient_signatures
  • rate_limit_exceeded
  • invalid_cursor (dashboard pagination, see feature 005-operator-dashboard-metrics)
  • invalid_limit
  • invalid_status_filter
  • invalid_timestamp (/dashboard/stats?updated_since= is not RFC3339, issue #371)
  • GUARDIAN_INSUFFICIENT_OPERATOR_PERMISSION
  • GUARDIAN_ACCOUNT_PAUSED
  • Policy modules (servers started with a module catalog): GUARDIAN_MODULE_DENIED (HTTP 403 / gRPC PermissionDenied; meta.module, meta.reason_code, meta.layer = global or account, and meta.client_message when the module set one; an instance with client_reason = "generic" sends only meta.reason_code = "policy_denied") and GUARDIAN_MODULE_UNAVAILABLE (HTTP 503 / gRPC Unavailable, meta.module unless the instance's denials are generic, retryable: a fail-closed module could not decide). Both are returned by POST /configure (hook before_account_registered), POST /delta/proposal and POST /delta/proposal/check (before_proposal_created, and in the check also before_transaction_approved) and POST /delta (before_transaction_approved), and by their gRPC methods; a Guardian execution reports them as GUARDIAN_EXECUTION_MODULE_DENIED and GUARDIAN_EXECUTION_MODULE_UNAVAILABLE (see ProposalExecution). The operator module routes add GUARDIAN_MODULE_NOT_FOUND (404, meta.module) and GUARDIAN_MODULE_NOT_DISABLEABLE (409 / gRPC FailedPrecondition, meta.module), GUARDIAN_MODULE_PARAMS_STALE (409, a params write whose optional expected_version no longer matches the params version, or an account write without one that another write to the same account overtook), and return GUARDIAN_MODULE_UNAVAILABLE when an instance being enabled fails its startup checks.
  • data_unavailable

HTTP endpoints that return structured error envelopes include code when available. GUARDIAN_INSUFFICIENT_OPERATOR_PERMISSION additionally carries missing_permissions: string[] and retryable: false. GUARDIAN_ACCOUNT_PAUSED additionally carries paused_at, paused_reason, and retryable: false. gRPC responses include error_code in response messages and use matching gRPC status codes for transport errors.

gRPC

The gRPC surface mirrors the Miden state/delta methods. EVM account registration, session auth, and proposal coordination are HTTP-only under /evm/*; gRPC proposal methods remain Miden-oriented and reject EVM inputs with unsupported_for_network.

  • Configure(ConfigureRequest) -> ConfigureResponse
  • PushDelta(PushDeltaRequest) -> PushDeltaResponse
  • GetDelta(GetDeltaRequest) -> GetDeltaResponse
  • GetDeltaSince(GetDeltaSinceRequest) -> GetDeltaSinceResponse
  • GetState(GetStateRequest) -> GetStateResponse
  • GetStateTail(GetStateTailRequest) -> GetStateTailResponse
  • GetPubkey(GetPubkeyRequest) -> GetPubkeyResponse
  • PushDeltaProposal(PushDeltaProposalRequest) -> PushDeltaProposalResponse
  • GetDeltaProposals(GetDeltaProposalsRequest) -> GetDeltaProposalsResponse
  • GetDeltaProposal(GetDeltaProposalRequest) -> GetDeltaProposalResponse
  • SignDeltaProposal(SignDeltaProposalRequest) -> SignDeltaProposalResponse
  • GetAccountByKeyCommitment(GetAccountByKeyCommitmentRequest) -> GetAccountByKeyCommitmentResponse
  • GetDeltaHistory(GetDeltaHistoryRequest) -> GetDeltaHistoryResponse
  • ExecuteDeltaProposal(ExecuteDeltaProposalRequest) -> ExecuteDeltaProposalResponse
  • GetDeltaProposalExecution(GetDeltaProposalExecutionRequest) -> GetDeltaProposalExecutionResponse
  • GetCurrentExecution(GetCurrentExecutionRequest) -> GetCurrentExecutionResponse
  • GetCanonicalNonce(GetCanonicalNonceRequest) -> GetCanonicalNonceResponse
  • CreateSession(CreateSessionRequest) -> CreateSessionResponse
  • RevokeSession(RevokeSessionRequest) -> RevokeSessionResponse
  • RevokeAllSessions(RevokeAllSessionsRequest) -> RevokeAllSessionsResponse
  • GetPolicies(GetPoliciesRequest) -> GetPoliciesResponse (mirrors GET /policies)
  • CheckDeltaProposal(CheckDeltaProposalRequest) -> CheckDeltaProposalResponse (mirrors POST /delta/proposal/check)

Every gRPC method is rate limited from the same store as the HTTP surface; see Rate Limiting for the keying rules and the rejection shape.

GetAccountByKeyCommitment mirrors the HTTP GET /state/lookup route. Authentication is carried in gRPC metadata (x-pubkey, x-signature, x-timestamp, and optional x-auth-format) and signed under the Lookup Request Signing format. Errors propagate as tonic::Status via the structured GuardianError mapping (InvalidInput → INVALID_ARGUMENT, AuthenticationFailed → UNAUTHENTICATED, StorageError → INTERNAL); the response contains a repeated AccountRef accounts field, with empty list as the success-with-no-matches signal.

Metrics Endpoint (Prometheus)

The server can expose operational telemetry in the Prometheus text exposition format (text/plain; version=0.0.4). This surface is operator-only and additive: it is not part of the client contract, is not consumed by any SDK, and does not change any /dashboard/* behavior.

  • Listener. GET <GUARDIAN_METRICS_PATH> (default /metrics) is served on a dedicated listener bound to GUARDIAN_METRICS_ADDR (default 127.0.0.1:9464), never on the main API port. The main API router returns 404 for /metrics. The metrics listener bypasses rate limiting, CORS, and body limits.
  • Enablement. Everything is off unless GUARDIAN_METRICS_ENABLED=true: no listener, no recorder, no storage instrumentation, no background refresh task.
  • Authentication. When GUARDIAN_METRICS_BEARER_TOKEN is set, requests MUST carry Authorization: Bearer <token>; missing, malformed, or mismatching credentials receive an empty 401 (constant-time comparison). When unset the endpoint is open and MUST be protected by network isolation (the v1 deployment assumption: private network or reverse proxy, which also terminates TLS).
  • Scrape cost. Scrapes serialize in-memory state only. Slow cross-account aggregates (delta status counts, in-flight proposals, account count) are computed by a background refresher every GUARDIAN_METRICS_REFRESH_INTERVAL_SECS (default 30) and published as gauges; a scrape never triggers storage reads. Staleness is observable as time() - guardian_metrics_refresh_timestamp_seconds; refresh failures increment guardian_metrics_refresh_failures_total and leave the previous gauge values in place.
  • Cardinality. Label values are strictly bounded: HTTP routes use the route template (/dashboard/accounts/{account_id}), unmatched paths collapse into route="unmatched", gRPC service/method are matched against an allowlist generated from the proto definition (anything unserved collapses into service="unknown", so path-spraying clients cannot mint time series), and the remaining labels are small closed enums declared in crates/server/src/metrics/labels.rs. Account IDs, nonces, commitments, pubkeys, client IPs, and error strings never appear in labels.

Metric taxonomy

Metric Type Labels
guardian_build_info gauge (=1) version, git_commit, profile
guardian_http_requests_total counter method, route, status
guardian_http_request_duration_seconds histogram method, route
guardian_http_requests_in_flight gauge —
guardian_grpc_requests_total counter service, method, code
guardian_grpc_request_duration_seconds histogram service, method
guardian_grpc_requests_in_flight gauge —
guardian_miden_rpc_requests_total counter operation, outcome
guardian_miden_rpc_duration_seconds histogram operation
guardian_storage_operations_total counter operation, outcome
guardian_storage_operation_duration_seconds histogram operation
guardian_execution_outcomes_total counter outcome (committed/failed), code
guardian_execution_reconcile_outcomes_total counter outcome
guardian_execution_chain_view_duration_seconds histogram —
guardian_execution_proving_duration_seconds histogram (1 s to 20 min) —
guardian_execution_phase_duration_seconds histogram phase (prepare, acknowledge, execute, prove, seal, checks, boundary, send)
guardian_execution_prover_retries_total counter —
guardian_execution_capacity_refusals_total counter none
guardian_execution_oldest_reservation_age_seconds gauge —
guardian_execution_observation_outage_seconds gauge —
guardian_execution_records_pruned_total counter none
guardian_execution_batches_total counter outcome (accepted/unknown/refused/not_built/prover_busy)
guardian_execution_batched_transactions_total counter outcome (same values)
guardian_execution_batch_proving_duration_seconds histogram (5 ms to 20 min) —
guardian_db_pool_connections_max / _connections / _connections_available / _pending_acquires gauges pool (storage/metadata; postgres builds)
guardian_canonicalization_runs_total counter outcome (completed/partial/cancelled/error)
guardian_canonicalization_run_duration_seconds histogram —
guardian_canonicalization_fast_runs_total counter outcome (completed/partial/cancelled/error)
guardian_canonicalization_fast_run_duration_seconds histogram —
guardian_canonicalization_reconcile_runs_total counter outcome (completed/partial/cancelled/error)
guardian_canonicalization_reconcile_run_duration_seconds histogram —
guardian_release_sweep_rotations_total counter outcome (completed/partial)
guardian_release_sweep_rotation_duration_seconds histogram —
guardian_release_sweep_accounts_total counter outcome (released/confirming/still_bound/own_key_mismatch/storage_opaque/no_binding/chain_behind_stored/probe_failed)
guardian_block_watch_blocks_total counter transport (stream/poll)
guardian_block_watch_last_block gauge —
guardian_block_watch_lag_blocks gauge —
guardian_block_watch_account_updates_total counter outcome (not_guarded/skipped_pending_candidate/at_stored/own_history/unfinished_configuration/observed/undecodable)
guardian_block_watch_observations_pending gauge —
guardian_block_watch_observations_long_waiting gauge —
guardian_block_watch_observation_visits_total counter outcome (checked/deferred/waiting/failed/dropped)
guardian_block_watch_reconnects_total counter reason (status_<grpc code>/transport/ended/out_of_sequence/malformed/unavailable_block/stall/timeout/skipped_malformed_block/skipped_unavailable_block)
guardian_block_watch_walk_requests_total counter reason (cursor_init/cursor_jump/genesis_changed/genesis_unknown/node_behind_too_long/cursor_ahead_of_tip/observations_lost/undecodable_updates/skipped_malformed_block/skipped_unavailable_block/observation_dropped)
guardian_block_watch_transport gauge transport (stream/poll; 1 for the active one)
guardian_block_watch_block_processing_seconds histogram —
guardian_module_evaluate_duration_seconds histogram module (catalog instance id), outcome (allow/deny/error/skipped)
guardian_module_fail_open_total counter module
guardian_module_request_refused_total counter module, reason (unavailable: the request could not be built; too_large: over GUARDIAN_MODULE_REQUEST_MAX_BYTES; rejected: the module rejected it as one it cannot judge); refused whatever on_error says
guardian_module_up gauge module (1 when the last health probe succeeded)
guardian_module_circuit_open gauge module (1 while the replica's breaker is open)
guardian_module_enabled gauge module
guardian_module_config_drift gauge module (1 when the catalog's enabled or params differ from the stored values)
guardian_module_catalog_info gauge catalog_hash (constant 1)
guardian_module_over_budget_accounts gauge none
guardian_module_orphaned_assignments gauge none
guardian_canonicalization_candidates_total counter outcome (canonicalized/retried/discarded/grace_deferred/divergence_deferred/diverged/orphaned/abandoned/stale_base/retained/reconciled/reconcile_deferred/reconcile_expired)
guardian_canonicalization_retries_total counter —
guardian_canonicalization_commitment_mismatches_total counter —
guardian_canonicalization_pass_accounts gauge —
guardian_canonicalization_deltas_fetched_total counter —
guardian_canonicalization_candidate_age_seconds histogram —
guardian_deltas_submitted_total counter kind (direct/proposal_commit)
guardian_proposals_total counter event (created/signed/finalized)
guardian_operator_auth_challenges_total counter outcome
guardian_operator_auth_verifications_total counter outcome
guardian_operator_sessions_started_total counter —
guardian_rate_limit_rejections_total counter limit_type (burst/sustained), transport (http/grpc)
guardian_deltas gauge status (candidate/canonical/retained/discarded)
guardian_proposals_in_flight gauge —
guardian_accounts gauge —
guardian_accounts_created_total counter kind (miden/evm)
guardian_metrics_refresh_timestamp_seconds gauge —
guardian_metrics_refresh_failures_total counter —
guardian_dashboard_stats_refresh_timestamp_seconds gauge —
guardian_dashboard_stats_refresh_failures_total counter —
guardian_dashboard_stats_refresh_duration_seconds histogram —
process_* (CPU, RSS, fds, start time) standard —

Durations use seconds with explicit buckets from 1ms to 10s, except guardian_canonicalization_run_duration_seconds, guardian_canonicalization_fast_run_duration_seconds, guardian_canonicalization_reconcile_run_duration_seconds and guardian_dashboard_stats_refresh_duration_seconds, which use extended buckets up to 5 minutes, guardian_release_sweep_rotation_duration_seconds, which spans 1 minute to 24 hours, and guardian_canonicalization_candidate_age_seconds which spans 1 second to 24 hours so stuck candidates stay visible. The authoritative taxonomy (including help text and the enforced label allowlist) lives in crates/server/src/metrics/names.rs; the closed label value sets live in crates/server/src/metrics/labels.rs.

Example scrape config:

scrape_configs:
  - job_name: guardian
    authorization:
      credentials: <GUARDIAN_METRICS_BEARER_TOKEN>
    static_configs:
      - targets: ["guardian-host:9464"]

Idempotency and Ordering

  • push_delta MAY be retried by clients; identical Miden deltas SHOULD be treated as idempotent when possible.
  • Miden push_delta enforces prev_commitment match. A multisig push is also rejected with insufficient_signatures until the matching proposal's verified cosigner signatures meet the effective threshold of the procedures the pushed transaction invokes.
  • EVM proposal create is idempotent for duplicate active proposals with the same deterministic proposal ID.
  • EVM proposals remain active/pending-only in the EVM proposal store; expired or finalized proposals are lazily deleted.

Examples

Miden Configure

curl -X POST http://localhost:3000/configure \
  -H 'content-type: application/json' \
  -H 'x-pubkey: 0x...' \
  -H 'x-signature: 0x...' \
  -H 'x-timestamp: 1700000000000' \
  -d '{
    "account_id": "0x...",
    "auth": { "MidenFalconRpo": { "cosigner_commitments": ["0x..."] } },
    "network_config": { "kind": "miden", "network_type": "testnet" },
    "initial_state": { "...": "..." }
  }'

Miden Proposal Create

curl -X POST http://localhost:3000/delta/proposal \
  -H 'content-type: application/json' \
  -H 'x-pubkey: 0x...' \
  -H 'x-signature: 0x...' \
  -H 'x-timestamp: 1700000000000' \
  -d '{
    "account_id": "0x...",
    "nonce": 42,
    "delta_payload": {
      "tx_summary": { "data": "..." },
      "metadata": { "proposal_type": "p2id" },
      "signatures": []
    }
  }'

EVM Account Registration And Proposal Create

curl 'http://localhost:3000/evm/auth/challenge?address=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
curl -X POST http://localhost:3000/evm/accounts \
  -H 'content-type: application/json' \
  -H 'cookie: guardian_evm_session=...' \
  -d '{
    "chain_id": 31337,
    "account_address": "0x1111111111111111111111111111111111111111",
    "multisig_validator_address": "0x2222222222222222222222222222222222222222"
  }'
curl -X POST http://localhost:3000/evm/proposals \
  -H 'content-type: application/json' \
  -H 'cookie: guardian_evm_session=...' \
  -d '{
    "account_id": "evm:31337:0x1111111111111111111111111111111111111111",
    "user_op_hash": "0x...",
    "payload": "{\"packedUserOperation\":{}}",
    "nonce": "0",
    "ttl_seconds": 900,
    "signature": "0x..."
  }'