Rohan Shield
Official# Rohan Protocol (v0.8.3)
[](https://www.npmjs.com/package/@rohan-protocol/sdk)
[](LICENSE)
[](https://midnight.network)
[](https://glama.ai/mcp/servers/rohan-protocol/sdk)
[](https://mcprush.com/to/rohan-protocol-mcp?ref=badge)
> **The Sovereign Privacy & Settlement Layer for Autonomous AI Agents on the Midnight Blockchain.**
Rohan Protocol equips autonomous AI agents with zero-knowledge intent commitments, confidential state transitions, and a complete, verifiable audit lifecycle. Sensitive parameters (budgets, vendor contracts, PII) are strictly canonicalized (RFC 8785) and hashed in client RAMβnever exposed on-chain or leaked in LLM context windows.
---
## π The Closed-Loop Multi-Agent Architecture
Rohan Protocol eliminates the classic "dead-end" MCP agent problem by establishing a complete, multi-turn lifecycle between coordinating agents:
```text
βββββββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ
β Agent Alpha β β Agent Beta β β Agent Beta β β Agent Beta β
β (State Mutation) β β (State Inspection)β β (History Review) β β (Agreement Audit) β
βββββββββββ¬ββββββββββ βββββββββββ¬ββββββββββ βββββββββββ¬ββββββββββ βββββββββββ¬ββββββββββ
β β β β
β 1. rohan_execute_handshakeβ 2. rohan_get_ledger_stateβ 3. rohan_get_transaction_historyβ 4. rohan_verify_commitment
β (Confidential Payload)β (Read Anchored Root) β (Settlement Receipts) β (RFC 8785 In-Memory JCS)
βΌ βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Rohan Protocol Relayer β
β Midnight Preprod L1 Settlement & Paymaster β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
* **Step 1 β Write (`rohan_execute_handshake`):** Agent Alpha commits an intent. The Relayer verifies proof commitments and anchors the state root on Midnight Preprod L1. The legacy `rohan_zk_handshake` name remains accepted.
* **Step 2 β Read (`rohan_get_ledger_state`):** Agent Beta inspects the contract's anchored state root, block height, and transaction receipt from cache (0 Gas, <1 ms).
* **Step 3 β History (`rohan_get_transaction_history`):** Agent Beta lists recorded settlement transactions and receipts (0 Gas).
* **Step 4 β Verify (`rohan_verify_commitment`):** Agent Beta checks plaintext against its canonical SHA-256 payload digest in local RAM (0 Gas). This is the inner payload digest, not the outer on-chain `intentHash`.
---
## π οΈ The 5 MCP Tools
| Tool | Category | Gas Cost | Latency | Description |
| :--- | :--- | :--- | :--- | :--- |
| `rohan_execute_handshake` | Mutation / Write | Relayer-submitted | ~25s L1 (or <1ms `dryRun`) | Submits a confidential state transition (supports `dryRun: true` and legacy `rohan_zk_handshake` alias). |
| `rohan_get_ledger_state` | Inspection / Read | Read-only (0 Gas) | <5 ms (15s Cache) | Reads the contract state root, block height, and last transaction hash. |
| `rohan_get_transaction_history` | Inspection / Read | Read-only (0 Gas) | <5 ms | Lists recent settlement transactions and receipts. |
| `rohan_verify_commitment` | Audit / Verify | Local RAM (0 Gas) | <1 ms | Checks plaintext against the inner `payloadDigest` via RFC 8785 JCS + SHA-256, or verifies a `RohanAuditBundle`. |
| `rohan_get_agent_status` | Identity / Status | Read-only (0 Gas) | Local / Relayer ping | Reports the configured `did:key` identity, network, and relayer reachability. |
---
## π¦ Monorepo Packages
* [`@rohan-protocol/sdk`](packages/sdk): Zero-dependency Node.js SDK (`>=20.0.0`) with cryptographic zeroization, Ed25519 `did:key` signing, and `RohanAuditBundle` verification. Browser-safe offline verification primitives are exported via `@rohan-protocol/sdk/identity`. *(Client-side Compact ZK-SNARK proving in WASI Preview 2 is active R&D under RFC-006 / Midnight Grants Milestone 1.)*
* [`@rohan-protocol/mcp`](packages/mcp): Official Model Context Protocol (MCP) server & CLI (`init`, `status`, `verify`) for Claude Desktop, Cursor, Cline, and Gemini, with local Ed25519 agent identity (`rohan-shield`).
* [`@rohan-protocol/webmcp`](packages/webmcp): Browser-native WebMCP shield with zero-width character sanitization (V-07).
---
## π Documentation
* [Quickstart: Claude, Cursor & Remote MCP](docs/quickstart.md)
* [SDK & A2A Non-Repudiation Guide](docs/sdk-a2a-guide.md)
* [Architecture & Security Model](docs/architecture-security.md)
* [API & MCP Tool Reference](docs/api-reference.md)
* [Examples](examples/)
---
## π Quickstart
### 1. Install SDK
```bash
npm install @rohan-protocol/sdk
```
### 2. Basic SDK Usage (Signed V-08 Handshake & Offline Audit)
```ts
import {
RohanClient,
InMemoryEd25519Signer,
verifyAuditBundle,
} from '@rohan-protocol/sdk';
// 1. Create a Sovereign Agent Identity (Ed25519 W3C did:key)
const signer = await InMemoryEd25519Signer.generate();
const client = new RohanClient({
network: 'preprod',
signer,
});
// 2. Inspect on-chain state (Read)
const state = await client.getLedgerState();
console.log('Current Root:', state.currentStateRoot, 'Block:', state.blockHeight);
// 3. Submit a signed confidential handshake (Write β agentId defaults to signer.did)
const deal = { budgetUsd: 75000, approvalCode: 'AUTH-99' };
const receipt = await client.submitHandshake({
intent: 'Vendor Purchase Order #1042',
confidentialPayload: deal,
});
console.log('Confirmed TxHash:', receipt.txHash);
console.log('Inner PayloadDigest:', receipt.payloadDigest);
// 4. Verify AuditBundle & plaintext commitment offline (0 Gas, 0 Network)
const audit = await verifyAuditBundle(receipt.auditBundle!, deal);
console.log('Cryptographic match?', audit.valid); // true (payloadMatch, intentBindingValid, signatureValid)
signer.destroy();
```
---
## π‘οΈ Security & Zero-Trust Principles
* **RFC 8785 JSON Canonicalization Scheme (JCS):** Deterministic, cross-platform key sorting and whitespace elimination.
* **DoS & ReDoS Guarding:** Recursive depth ceiling (max. 32 levels) and RAM payload bounds (max. 256 KB).
* **Zeroize RAM Sanitation:** Sensitive witnesses and private keys are scrubbed from RAM immediately after commitment derivation.
* **Optimistic Credit Escrow:** Atomic balance reservations prevent concurrent quota-drain exploits.
---
## π License
Apache-2.0. Copyright (c) 2026 Rohan Protocol Authors.
TDQS
Scored across 5 tools
Each tool has a clearly distinct role: execute settlement, read ledger state, list transaction history, inspect agent identity/health, and verify commitments offline. The descriptions explicitly cross-reference the other tools to redirect common misuses, leaving little overlap.
All tools use a consistent rohan_ prefix followed by a snake_case verb_noun pattern (execute_handshake, get_ledger_state, get_transaction_history, get_agent_status, verify_commitment). The convention is predictable throughout.
Five tools is well-scoped for this domain: one write operation, three reads/diagnostics, and one offline verification tool. Each tool earns its place without obvious redundancy.
The surface covers the core settlement lifecycle: execution, state read, history, identity/health, and cryptographic verification. Minor gaps exist, such as querying a specific commitment by ID or cancelling a pending settlement, but agents can work around them via history and state reads.