@rohan-zk/sdk
v0.1.1
Published
The Trust Layer for AI Agents – Zero-Knowledge Handshakes between autonomous machines.
Downloads
30
Maintainers
Readme
@rohan-zk/sdk
The Trust Layer for AI Agents.
Zero-Knowledge Handshakes between autonomous machines. Private deals, public proof.
What is this?
Rohan enables AI agents to negotiate confidential deals (NDAs, payments, contracts) with each other using Zero-Knowledge Proofs. The deal content stays private. Only a cryptographic commitment lands on-chain.
Think of it as Stripe for machine-to-machine trust – but instead of credit cards, your agents use ZK-SNARKs.
Install
npm install @rohan-zk/sdkQuickstart
import { RohanNode } from '@rohan-zk/sdk';
// 1. Create an agent
const agent = new RohanNode({
port: 4000,
walletKey: process.env.ROHAN_KEY!,
});
// 2. Listen for incoming deals
agent.onHandshake((deal) => {
console.log(`Deal from ${deal.from}: ${deal.commitment}`);
});
// 3. Go live
await agent.start();That's it. Your agent is now a ZK-enabled node in the Rohan network.
Send a Confidential Handshake
const result = await agent.handshake(
'http://partner-agent:4000/api/zk-handshake',
'NDA for Project Alpha – Confidential',
150 // utility fee
);
console.log(result.txId); // "tx_e9fb3b78..."
console.log(result.onChainCommitment); // "e2d68af9..."The deal content ("NDA for Project Alpha") never leaves your machine. Only the cryptographic proof is sent to the partner agent, who verifies it without seeing the data.
API Reference
new RohanNode(config)
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| port | number | ✅ | – | Port to listen on for incoming handshakes |
| walletKey | string | ✅ | – | Private key (load from env, never hardcode) |
| did | string | ❌ | Auto-generated | Decentralized Identifier for this node |
| minFee | number | ❌ | 100 | Minimum utility fee for incoming handshakes |
| verbose | boolean | ❌ | true | Enable console logging |
agent.start(): Promise<void>
Start the node. Begins listening for incoming ZK-Handshakes on the configured port.
agent.stop(): Promise<void>
Gracefully shut down the node.
agent.onHandshake(callback): void
Register a callback that fires when a verified handshake arrives.
agent.onHandshake(async (handshake) => {
console.log(handshake.from); // DID of the sender
console.log(handshake.commitment); // On-chain commitment hash
console.log(handshake.txId); // Transaction ID
console.log(handshake.verified); // Always true (rejected proofs don't fire)
});agent.handshake(url, payload, fee): Promise<HandshakeResult>
Initiate a confidential deal with a remote agent.
| Parameter | Type | Description |
|-----------|------|-------------|
| url | string | Full URL of the remote agent's handshake endpoint |
| payload | string | Secret deal content (never transmitted) |
| fee | number | Utility fee (default: 150) |
Returns:
{
status: 'success' | 'error',
message: string,
onChainCommitment?: string, // The public proof hash
txId?: string // Ledger transaction ID
}agent.getDid(): string
Returns the Decentralized Identifier of this node.
Architecture
┌──────────────────────────────────────────────────────┐
│ Your Application │
│ │
│ const agent = new RohanNode({ port, walletKey }) │
│ agent.handshake(url, secret, fee) │
└──────────────────┬───────────────────────────────────┘
│
┌──────────▼──────────┐
│ @rohan-zk/sdk │
│ │
│ ┌───────────────┐ │
│ │ Prover │ │ ← Generates ZK-Proof locally
│ │ (prover.ts) │ │ (secret data stays here)
│ └───────┬───────┘ │
│ │ proof │
│ ┌───────▼───────┐ │
│ │ Express API │ │ ← Sends/receives proofs
│ │ /api/zk-* │ │
│ └───────┬───────┘ │
│ │ │
│ ┌───────▼───────┐ │
│ │ Verifier │ │ ← Validates incoming proofs
│ │ (verifier.ts) │ │
│ └───────────────┘ │
└─────────────────────┘
│
┌──────────▼──────────┐
│ Midnight Network │ ← The ZK-Settlement Layer
│ (coming soon) │
└─────────────────────┘Endpoints
Every RohanNode automatically exposes:
| Method | Path | Description |
|--------|------|-------------|
| GET | /health | Node status, DID, version, uptime |
| POST | /api/zk-handshake | Incoming ZK-Proof verification |
Security
- Private keys are held in RAM only. Never written to disk.
- Deal content never leaves the prover machine. Only the ZK-Proof travels.
- Idempotency keys prevent replay attacks on handshake endpoints.
- Minimum fee enforcement rejects underpaid handshakes automatically.
Roadmap
- [x] Mock ZK-Proof simulation (SHA-256 commitments)
- [x] Express-based handshake protocol
- [x] TypeScript with full type definitions
- [ ] Real zk-SNARK integration via Midnight Network
- [ ] On-chain commitment verification
- [ ] DID exchange protocol
- [ ] Multi-agent routing
License
MIT © Rohan Protocol
