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.
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 freshThen 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 passesThe 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
authorizationCountThe 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 assetsSee Runtime stack for the provider topology and local services.
Read in order
Runtime stack
Understand the providers, wallet, proof server, node, indexer, and private-state storage.
Compact contract
Inspect the private policy struct, public ledger, commitment functions, and authorize circuit.
Circuit constraints
See the exact predicate each demo tool proves and which application fields are not yet covered.
Proof lifecycle
Follow one request through witness resolution, proving, finalization, ledger query, and receipt construction.
Combining constraints
A successful zkMCP authorization proves the conjunction of the common policy rules and the selected capability's tool-specific constraints.
Runtime stack
The Midnight.js providers, wallet, local private state, proof server, node, and indexer used by the current authorization client.