zkzkMCP
Midnight

Overview

The proving, private-state, transaction, and public-ledger layer behind zkMCP authorization.

Midnight is not used to prove the AI model. It proves the deterministic authorization statement surrounding the model's requested side effect.

@zkmcp/midnight is the adapter that turns a normalized request into a proof-backed authorization transaction and then returns a compact public receipt to the MCP gateway.

Architecture diagram. Click to zoom.
Click to zoom

Package responsibilities

The current package owns:

  • wallet setup and synchronization;
  • local private policy loading and validation;
  • identifier digesting;
  • private-state provider configuration;
  • proof-server configuration;
  • contract binding/connection;
  • fresh nonce generation;
  • authorization call serialization;
  • proof-backed transaction submission;
  • public ledger readback;
  • receipt construction;
  • typed Midnight/proof/replay error translation;
  • privacy-safe evlog events.

What the Compact layer proves

Every request shares common constraints:

private policy hashes to the deployment commitment
request agent matches the allowed agent
request tool matches a committed capability
nullifier is fresh

Then the tool branch adds its own rule:

documents.read     → resource matches private scope
email.send         → trusted approval is true
payments.transfer  → amount <= private hard maximum
                     and threshold approval rule passes

The exact fields and current coverage gaps are documented in Circuit constraints.

Private vs public

The policy, request amount, resource, approval state, and nonce can remain private circuit inputs.

The ledger deliberately exposes commitments and replay state:

policyCommitment
executionCommitment
nullifier
usedNullifiers
authorizationCount

The TypeScript receipt then adds transaction metadata such as block height and transaction ID.

Runtime stack

The validated local environment combines:

Midnight node
Indexer
Proof server
Wallet SDK
Level private-state provider
Compiled Compact assets

See Runtime stack for the provider topology and local services.

Read in order

On this page