# Rohan Protocol > Zero-gas cryptographic non-repudiation, confidential RFC 8785 commitments, and W3C Ed25519 `did:key` agent authentication anchored on Midnight Network (Preprod, Ledger v9). Rohan Protocol lets autonomous AI agents and B2B Node.js backends sign and anchor confidential action commitments without holding crypto wallets, `$NIGHT`, or `$tDUST` gas. Plaintext confidential parameters are canonicalized (RFC 8785 JCS) and SHA-256 hashed in local client RAM; only 32-byte commitments and state roots settle on-chain via the Rohan Paymaster Relayer. ## Canonical Network & Endpoints - **Network:** Midnight Preprod (Ledger v9, Protocol `2001100`, `network: 'preprod'`) - **Active Contract Address:** `585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e` - **Relayer Base URL:** `https://api.rohanprotocol.network` (configurable via `ROHAN_RELAYER_URL` for self-hosted relayers) - **Remote HTTP MCP:** `https://api.rohanprotocol.network/mcp` - **MCP Server Card:** `https://rohanprotocol.network/.well-known/mcp/server-card.json` - **Public Read Endpoints:** `GET /health`, `GET /api/v1/ledger-state`, `GET /api/v1/transactions?limit=10` - **Write Endpoints:** `POST /api/v1/handshake`, `POST /api/v1/handshake/stream` ## Runtime Prerequisites (Node.js ESM) `@rohan-protocol/sdk` (`v0.8.3`) is pure ESM (`"type": "module"`) with **zero external runtime dependencies** and targets Node.js `>= 20.0.0` (with browser-safe verification exported at `@rohan-protocol/sdk/identity`). Minimal `package.json`: ```json { "name": "rohan-a2a-example", "type": "module", "dependencies": { "@rohan-protocol/sdk": "^0.8.3" } } ``` ## Core Concepts: `payloadDigest` vs. `intentHash` & `intent` vs. `actionSummary` - **`payloadDigest` (`sha256:<64-hex>`):** Deterministic RFC 8785 JCS SHA-256 hash of your plaintext `confidentialPayload` object alone. Used for offline plaintext verification. - **`intentHash` (`<64-hex>`):** Outer timestamp-salted commitment anchored on Midnight L1 (`SHA-256(agentDid : sealedIntent : {} : timestamp)`), bound into the Ed25519 `SignedHandshakeV1` envelope. Prevents correlation of identical deals across time while cryptographically binding `payloadDigest` via `intentBindingValid`. - **Field naming (`intent` vs. `actionSummary`):** In the TypeScript SDK (`RohanClient.submitHandshake`), the public label field is named `intent`. In the MCP tool `rohan_execute_handshake`, the public label field is named `actionSummary` (and `RohanAuditBundle.actionSummary` stores the unsealed public label). - **`agentId` rule:** When a `signer` is passed to `RohanClient`, omit `agentId` (the SDK injects `signer.did` automatically). Passing an `agentId` that differs from `signer.did` fails locally (`SIGNER_MISMATCH`) or at the relayer (`403 IDENTITY_MISMATCH`). ## Complete Two-Agent (Buyer <-> Seller) TypeScript Example ```typescript import { RohanClient, InMemoryEd25519Signer, verifyAuditBundle, canonicalizeJson, sealActionIntent, } from '@rohan-protocol/sdk'; // ── AGENT A (Buyer): Signs & anchors confidential deal on Midnight L1 ──────── const buyerSigner = await InMemoryEd25519Signer.generate(); // Or in Node.js with a persisted 64-hex key: // const buyerSigner = await InMemoryEd25519Signer.fromPrivateKeyHex(process.env.BUYER_PRIV_HEX!); const buyerClient = new RohanClient({ network: 'preprod', signer: buyerSigner, }); const dealPayload = { counterparty: 'Helios Compute GmbH', amountEUR: 48500, currency: 'EUR', reference: 'HC-2026-Q4', }; let receipt; try { receipt = await buyerClient.submitHandshake({ intent: 'Vendor Compute Procurement', // Public non-sensitive label ONLY (MCP tool uses actionSummary) confidentialPayload: dealPayload, // Stays in local RAM; hashed via RFC 8785 + SHA-256 }); } catch (err: any) { // Error handling & retry policy: // - 409 REPLAY_DETECTED: Nonce already consumed -> DO NOT retry with same nonce; check getTransactionHistory() // - 401 STALE_TIMESTAMP: Clock skew > ±5 min -> retry with a fresh submitHandshake() call // - 403 IDENTITY_MISMATCH: Ensure agentId is omitted or equals signer.did // - 503 Queue / Syncing: Wait 5s and retry throw new Error(`Handshake failed: ${err.message}`); } // Agent A shares `receipt.auditBundle` and `dealPayload` (via private channel) with Agent B. console.log('L1 TxHash:', receipt.txHash); console.log('Signed DID:', receipt.auditBundle!.agentDid); console.log('Inner PayloadDigest:', receipt.payloadDigest); // ── AGENT B (Seller / Auditor): Independent Offline & L1 Verification ──────── // 1. Offline cryptographic verification (0 network calls, 0 gas): // Checks schema, RFC 8785 payloadDigest match, intentHash binding (intentBindingValid), and Ed25519 signature. const audit = await verifyAuditBundle(receipt.auditBundle!, dealPayload); if (!audit.valid) { throw new Error(`Audit failed [${audit.errors.join(', ')}]`); } // Output: { valid: true, schemaValid: true, payloadMatch: true, intentBindingValid: true, signatureValid: true } // 2. Alternative direct digest verification (against inner payloadDigest, NOT outer intentHash): const sellerReader = new RohanClient({ network: 'preprod' }); const digestCheck = await sellerReader.verifyCommitment(dealPayload, receipt.auditBundle!.payloadDigest!); console.log('Direct digest match:', digestCheck.valid); // true // 3. Optional read-only confirmation against relayer history or Midnight Preprod indexer (0 gas): const history = await sellerReader.getTransactionHistory(10); const settled = history.transactions.find((tx) => tx.txHash === receipt.txHash); console.log('Confirmed on Midnight Preprod:', Boolean(settled)); ``` ## Exported Helper Signatures - `InMemoryEd25519Signer.generate(): Promise` — Generates an in-memory Ed25519 `did:key` signer (browser + Node). - `InMemoryEd25519Signer.fromPrivateKeyHex(hex: string): Promise` — Node-only loader from 32-byte hex seed. - `verifyAuditBundle(bundle: RohanAuditBundle, plaintextPayload?: Record): Promise` — Offline verification (browser-safe via `@rohan-protocol/sdk/identity`). - `computePayloadDigest(payload: Record): Promise` — Returns `'sha256:<64-hex>'` using RFC 8785 JCS (browser-safe via `@rohan-protocol/sdk/identity`). - `canonicalizeJson(obj: unknown): string` — Deterministic RFC 8785 JSON Canonicalization Scheme serializer (max depth 32). - `sealActionIntent(actionSummary: string, confidentialPayload?: Record): string` — Returns `" (digest: sha256:<64-hex>)"` for legacy/custom proof calls. ## MCP Server (`@rohan-protocol/mcp@0.8.3`) - **Registries:** Official MCP Registry (`io.github.rohan-protocol/mcp`), Glama (`https://glama.ai/mcp/servers/rohan-protocol/sdk`), MCP Rush. - **CLI Subcommands:** `npx -y @rohan-protocol/mcp@0.8.3 init | status | verify | --help`. - **Tools:** `rohan_execute_handshake` (supports `dryRun: true` for local-only preview without L1 tx), `rohan_get_ledger_state`, `rohan_get_transaction_history`, `rohan_verify_commitment` (accepts `auditBundle` or `expectedDigest`), `rohan_get_agent_status` (local stdio). - **Resource:** `rohan://identity`. ## Documentation Links - [Documentation Overview](https://rohanprotocol.network/docs/): Hosted documentation hub on rohanprotocol.network. - [Quickstart (Claude Desktop, Cursor & Remote MCP)](https://rohanprotocol.network/docs/quickstart) ([Raw Markdown](https://rohanprotocol.network/docs/quickstart.md) · [GitHub](https://github.com/rohan-protocol/sdk/blob/main/docs/quickstart.md)) - [SDK & A2A Guide](https://rohanprotocol.network/docs/sdk-a2a-guide) ([Raw Markdown](https://rohanprotocol.network/docs/sdk-a2a-guide.md) · [GitHub](https://github.com/rohan-protocol/sdk/blob/main/docs/sdk-a2a-guide.md)) - [Architecture & Security Model](https://rohanprotocol.network/docs/architecture-security) ([Raw Markdown](https://rohanprotocol.network/docs/architecture-security.md) · [GitHub](https://github.com/rohan-protocol/sdk/blob/main/docs/architecture-security.md)) - [API & MCP Reference](https://rohanprotocol.network/docs/api-reference) ([Raw Markdown](https://rohanprotocol.network/docs/api-reference.md) · [GitHub](https://github.com/rohan-protocol/sdk/blob/main/docs/api-reference.md)) - [Source & Docs Repository](https://github.com/rohan-protocol/sdk) ## Guardrails for Coding Agents - **Zero Docker / No Midnight Node in Client:** Never add `@midnight-ntwrk/*` or `compactc` to client apps. - **Honest Scope:** `did:key` proves Ed25519 key control (Proof-of-Control), not human KYC. Client-side WASI Preview 2 ZK-SNARK proving is RFC-006 Grant R&D. - **Independent L1 Verification:** Do NOT query deprecated `indexer.preprod.midnight.network` (HTTP 410). Query Blockfrost Midnight Indexer v4 (`https://midnight-preprod.blockfrost.io/api/v0`) using `transactions(offset: { hash: "" })` or `contractAction(address: "585ac0c4...")`.