@rohan-protocol/mcp 0.8.0 β†’ 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1,280 +1,60 @@
1
1
  #!/usr/bin/env node
2
- import crypto from 'node:crypto';
3
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
- import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
6
- import { SemanticFirewall } from './firewall.js';
7
- import { RohanClient, sealActionIntent, canonicalizeJson } from '@rohan-protocol/sdk';
8
- import { resolveSignerFromEnv } from './identity.js';
9
- const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
10
- const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
11
- const API_KEY = process.env.ROHAN_API_KEY || '';
12
- const configuredSigner = await resolveSignerFromEnv();
13
- if (configuredSigner) {
14
- console.error(`πŸ›‘οΈ [MCP V-08] Sovereign Agent Signer armed: ${configuredSigner.did}`);
15
- }
16
- const rohanClient = new RohanClient({
17
- contractAddress: CONTRACT_ADDRESS,
18
- relayerUrl: RELAYER_URL,
19
- apiKey: API_KEY,
20
- signer: configuredSigner,
21
- });
22
- const server = new Server({
23
- name: 'rohan-protocol-mcp',
24
- version: '0.8.0',
25
- }, {
26
- capabilities: {
27
- tools: {},
28
- },
29
- });
30
- // ── Tool 1 Schema: Write / Settlement ───────────────────────────────────────
31
- export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
32
- name: 'rohan_execute_handshake',
33
- description: 'Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAMβ€”never exposed on-chain or in model logs.',
34
- inputSchema: {
35
- type: 'object',
36
- properties: {
37
- agentId: {
38
- type: 'string',
39
- description: 'Decentralized Identifier (DID) of the initiating agent',
40
- },
41
- actionSummary: {
42
- type: 'string',
43
- description: "Public high-level action label (e.g. 'Vendor Agreement Execution', 'Database Audit Anchor')",
44
- },
45
- confidentialPayload: {
46
- type: 'object',
47
- description: 'OPTIONAL confidential parameters (budgets, deals, PII). Automatically canonicalized via RFC 8785 and hashed in local memory.',
48
- },
49
- counterpartyId: {
50
- type: 'string',
51
- description: 'Optional counterparty agent identifier',
52
- },
53
- intent: {
54
- type: 'string',
55
- description: 'Legacy fallback for actionSummary',
56
- },
57
- },
58
- required: ['agentId'],
59
- },
60
- };
61
- // ── Tool 2 Schema: Audit / In-Memory Verification ───────────────────────────
62
- export const ROHAN_VERIFY_TOOL_SCHEMA = {
63
- name: 'rohan_verify_commitment',
64
- description: 'Verifies a plaintext confidential payload against its SHA-256 digest using RFC 8785 JSON Canonicalization. Supply the inner payload digest, not the outer on-chain intentHash. Zero gas cost; runs in local memory.',
65
- inputSchema: {
66
- type: 'object',
67
- properties: {
68
- payload: {
69
- type: 'object',
70
- description: 'The plaintext contract, agreement, or intent data to be verified.',
71
- },
72
- expectedDigest: {
73
- type: 'string',
74
- pattern: '^(?:sha256:|0x)?[0-9a-fA-F]{64}$',
75
- description: 'The expected SHA-256 digest of the canonicalized confidential payload (the inner payload digest referenced as digest: sha256:<hash> in actionSummary), not the outer timestamp-salted on-chain intentHash. Accepts raw hex, 0x, or sha256: prefixes.',
76
- },
77
- },
78
- required: ['payload', 'expectedDigest'],
79
- },
80
- };
81
- // ── Tool 3 Schema: Read / Ledger State Inspection ───────────────────────────
82
- export const ROHAN_LEDGER_STATE_TOOL_SCHEMA = {
83
- name: 'rohan_get_ledger_state',
84
- description: 'Reads the current anchored state of the Rohan Protocol smart contract on Midnight Preprod L1. Returns the state root, block height, and last mined transaction hash from memory cache.',
85
- inputSchema: {
86
- type: 'object',
87
- properties: {},
88
- },
89
- };
90
- export const ROHAN_HISTORY_TOOL_SCHEMA = {
91
- name: 'rohan_get_transaction_history',
92
- description: 'Lists historical settlement transactions and receipts anchored on Midnight Preprod L1.',
93
- inputSchema: {
94
- type: 'object',
95
- properties: {
96
- limit: {
97
- type: 'integer',
98
- description: 'Maximum number of historical transactions to return (default: 10, max: 50).',
99
- },
100
- },
101
- },
102
- };
103
- server.setRequestHandler(ListToolsRequestSchema, async () => {
104
- return {
105
- tools: [
106
- ROHAN_HANDSHAKE_TOOL_SCHEMA,
107
- ROHAN_LEDGER_STATE_TOOL_SCHEMA,
108
- ROHAN_HISTORY_TOOL_SCHEMA,
109
- ROHAN_VERIFY_TOOL_SCHEMA,
110
- ],
111
- };
112
- });
113
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
114
- const toolName = request.params.name;
115
- const rawArgs = request.params?.arguments;
116
- if (!rawArgs || typeof rawArgs !== 'object' || Array.isArray(rawArgs)) {
117
- return {
118
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'INVALID_ARGUMENTS: Expected a valid arguments object.' }) }],
119
- isError: true,
120
- };
121
- }
122
- const args = rawArgs;
123
- // ── Tool 1: rohan_zk_handshake ────────────────────────────────────────────
124
- if (toolName === 'rohan_execute_handshake' || toolName === 'rohan_zk_handshake') {
125
- const actionLabel = args.actionSummary || args.intent;
126
- if (!actionLabel) {
127
- throw new Error('Invalid arguments: Either actionSummary or intent is required.');
128
- }
129
- const isValid = SemanticFirewall.validate({
130
- agentId: args.agentId,
131
- action: 'rohan_execute_handshake',
132
- payload: args,
133
- });
134
- if (!isValid) {
135
- return {
136
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)' }) }],
137
- isError: true,
138
- };
139
- }
140
- try {
141
- const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
142
- const receipt = await rohanClient.submitHandshake({
143
- agentId: args.agentId,
144
- intent: finalIntent,
145
- counterpartyId: args.counterpartyId,
146
- });
147
- return {
148
- content: [{
149
- type: 'text',
150
- text: JSON.stringify({
151
- status: 'success',
152
- message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain.',
153
- receipt,
154
- }, null, 2),
155
- }],
156
- };
157
- }
158
- catch (err) {
159
- return {
160
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Handshake execution failed' }) }],
161
- isError: true,
162
- };
163
- }
164
- }
165
- // ── Tool 2: rohan_verify_commitment ───────────────────────────────────────
166
- if (toolName === 'rohan_verify_commitment') {
167
- // Payload-Size-Guard (Max 256 KB im RAM)
168
- const payloadString = JSON.stringify(args.payload);
169
- if (payloadString.length > 256 * 1024) {
170
- return {
171
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'PAYLOAD_TOO_LARGE: Plaintext exceeds maximum allowed size of 256 KB.' }) }],
172
- isError: true,
173
- };
174
- }
175
- if (!args.payload || typeof args.payload !== 'object' || Array.isArray(args.payload)) {
176
- return {
177
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid argument: payload must be a non-null object.' }) }],
178
- isError: true,
179
- };
180
- }
181
- if (!args.expectedDigest || typeof args.expectedDigest !== 'string') {
182
- return {
183
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid argument: expectedDigest must be a string.' }) }],
184
- isError: true,
185
- };
186
- }
187
- try {
188
- // LLM Prefix Tolerance: Strips 'sha256:' or '0x'
189
- const normalizedExpected = args.expectedDigest.replace(/^(?:sha256:|0x)/i, '').toLowerCase();
190
- if (!/^[0-9a-f]{64}$/.test(normalizedExpected)) {
191
- return {
192
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid expectedDigest: must resolve to a 64-character hexadecimal SHA-256 hash.' }) }],
193
- isError: true,
194
- };
195
- }
196
- // Single Source of Truth: Canonicalization via @rohan-protocol/sdk
197
- const canonicalPayload = canonicalizeJson(args.payload);
198
- const computedDigest = crypto.createHash('sha256').update(canonicalPayload, 'utf8').digest('hex').toLowerCase();
199
- const match = crypto.timingSafeEqual(Buffer.from(computedDigest, 'hex'), Buffer.from(normalizedExpected, 'hex'));
200
- return {
201
- content: [{
202
- type: 'text',
203
- text: JSON.stringify({
204
- status: 'success',
205
- valid: match,
206
- match,
207
- expectedDigest: normalizedExpected,
208
- computedDigest,
209
- algorithm: 'SHA-256 (RFC 8785 JCS)',
210
- verifiedAt: Date.now(),
211
- }, null, 2),
212
- }],
213
- };
214
- }
215
- catch (err) {
216
- return {
217
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Verification execution failed' }) }],
218
- isError: true,
219
- };
220
- }
3
+ import { RohanClient } from '@rohan-protocol/sdk';
4
+ import { resolveAgentIdentity } from './identity/keystore.js';
5
+ import { ROHAN_HANDSHAKE_TOOL_SCHEMA } from './identity/handshake.js';
6
+ import { runCli } from './cli.js';
7
+ import { createRohanMcpServer, ROHAN_MCP_VERSION, ROHAN_MCP_INSTRUCTIONS, ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS, ROHAN_VERIFY_TOOL_SCHEMA, ROHAN_LEDGER_STATE_TOOL_SCHEMA, ROHAN_HISTORY_TOOL_SCHEMA, ROHAN_AGENT_STATUS_TOOL_SCHEMA, } from './mcp-app.js';
8
+ export const ROHAN_EXECUTE_TOOL_SCHEMA = ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS;
9
+ export { ROHAN_HANDSHAKE_TOOL_SCHEMA, ROHAN_MCP_INSTRUCTIONS, ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS, ROHAN_VERIFY_TOOL_SCHEMA, ROHAN_LEDGER_STATE_TOOL_SCHEMA, ROHAN_HISTORY_TOOL_SCHEMA, ROHAN_AGENT_STATUS_TOOL_SCHEMA, createRohanMcpServer, };
10
+ function resolveConfiguredNetwork() {
11
+ const raw = (process.env.ROHAN_NETWORK || 'preprod').trim().toLowerCase();
12
+ if (raw !== 'preprod' && raw !== 'testnet' && raw !== 'mainnet') {
13
+ throw new Error(`INVALID_CONFIGURATION: Unsupported ROHAN_NETWORK "${raw}". Expected preprod, testnet, or mainnet.`);
221
14
  }
222
- // ── Tool 3: rohan_get_ledger_state ────────────────────────────────────────
223
- if (toolName === 'rohan_get_ledger_state') {
224
- try {
225
- const ledgerState = await rohanClient.getLedgerState();
226
- const cacheAgeMs = Date.now() - (ledgerState.fetchedAt || Date.now());
227
- return {
228
- content: [{
229
- type: 'text',
230
- text: JSON.stringify({
231
- status: 'success',
232
- contractAddress: ledgerState.contractAddress,
233
- currentStateRoot: ledgerState.currentStateRoot,
234
- blockHeight: ledgerState.blockHeight ?? null,
235
- lastTxHash: ledgerState.lastTxHash ?? null,
236
- network: ledgerState.network || 'midnight-preprod',
237
- isMinedOnChain: ledgerState.isMinedOnChain ?? true,
238
- cacheAgeMs: ledgerState.cacheAgeMs ?? cacheAgeMs,
239
- cacheTtlMs: ledgerState.cacheTtlMs ?? 15000,
240
- fetchedAt: ledgerState.fetchedAt,
241
- }, null, 2),
242
- }],
243
- };
244
- }
245
- catch (err) {
246
- return {
247
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Failed to fetch ledger state' }) }],
248
- isError: true,
249
- };
250
- }
251
- }
252
- if (toolName === 'rohan_get_transaction_history') {
253
- try {
254
- const rawLimit = Number(args.limit) || 10;
255
- const history = await rohanClient.getTransactionHistory(rawLimit);
256
- return {
257
- content: [{
258
- type: 'text',
259
- text: JSON.stringify({ status: 'success', ...history }, null, 2),
260
- }],
261
- };
262
- }
263
- catch (err) {
264
- return {
265
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Failed to fetch transaction history' }) }],
266
- isError: true,
267
- };
268
- }
15
+ return raw;
16
+ }
17
+ async function runStdioServer() {
18
+ const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS ||
19
+ '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
20
+ const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
21
+ const API_KEY = process.env.ROHAN_API_KEY || '';
22
+ const NETWORK = resolveConfiguredNetwork();
23
+ const loadedIdentity = await resolveAgentIdentity();
24
+ const configuredSigner = loadedIdentity.signer;
25
+ console.error(`πŸ›‘οΈ [MCP V-08] Agent identity active (${loadedIdentity.source}): ${loadedIdentity.did}`);
26
+ if (loadedIdentity.filePath) {
27
+ console.error(`πŸ›‘οΈ [MCP V-08] Keystore path: ${loadedIdentity.filePath}`);
269
28
  }
270
- throw new Error(`Unknown tool: ${toolName}`);
271
- });
272
- async function run() {
29
+ const rohanClient = new RohanClient({
30
+ network: NETWORK,
31
+ contractAddress: CONTRACT_ADDRESS,
32
+ relayerUrl: RELAYER_URL,
33
+ apiKey: API_KEY,
34
+ signer: configuredSigner,
35
+ });
36
+ const server = createRohanMcpServer({
37
+ contractAddress: CONTRACT_ADDRESS,
38
+ relayerUrl: RELAYER_URL,
39
+ network: NETWORK,
40
+ rohanClient,
41
+ configuredSigner,
42
+ loadedIdentity,
43
+ });
273
44
  const transport = new StdioServerTransport();
274
45
  await server.connect(transport);
275
- console.error('πŸ›‘οΈ Rohan Protocol MCP Server running via stdio (v0.8.0)...');
46
+ console.error(`πŸ›‘οΈ Rohan Protocol MCP Server running via stdio (v${ROHAN_MCP_VERSION}, network=${NETWORK})...`);
47
+ }
48
+ async function main() {
49
+ const cliArgs = process.argv.slice(2);
50
+ if (cliArgs.length > 0 && cliArgs[0] !== '--stdio') {
51
+ const exitCode = await runCli(cliArgs);
52
+ process.exit(exitCode);
53
+ return;
54
+ }
55
+ await runStdioServer();
276
56
  }
277
- run().catch((error) => {
57
+ main().catch((error) => {
278
58
  console.error('Fatal MCP server error:', error);
279
59
  process.exit(1);
280
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAGA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAA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,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rohan-protocol/mcp",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "mcpName": "io.github.rohan-protocol/mcp",
5
5
  "description": "Model Context Protocol (MCP) Gateway for Rohan Protocol ZK-Handshakes",
6
6
  "main": "dist/index.js",
@@ -23,8 +23,12 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@modelcontextprotocol/sdk": "^1.32.2",
26
- "@rohan-protocol/sdk": "^0.8.0"
26
+ "@rohan-protocol/sdk": "^0.8.2"
27
27
  },
28
+ "files": [
29
+ "dist",
30
+ "README.md"
31
+ ],
28
32
  "devDependencies": {
29
33
  "@types/node": "^22.0.0",
30
34
  "typescript": "^5.5.0"
package/server.json DELETED
@@ -1,46 +0,0 @@
1
- {
2
- "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
- "name": "io.github.rohan-protocol/mcp",
4
- "title": "Rohan Protocol MCP",
5
- "description": "Stateless zero-knowledge trust gateway and WebMCP shield for AI agents on Midnight.",
6
- "version": "0.8.0",
7
- "websiteUrl": "https://rohanprotocol.network",
8
- "repository": {
9
- "url": "https://github.com/rohan-protocol/sdk",
10
- "source": "github",
11
- "subfolder": "packages/mcp"
12
- },
13
- "packages": [
14
- {
15
- "registryType": "npm",
16
- "identifier": "@rohan-protocol/mcp",
17
- "version": "0.8.0",
18
- "transport": {
19
- "type": "stdio"
20
- },
21
- "environmentVariables": [
22
- {
23
- "name": "ROHAN_AGENT_PRIVATE_KEY",
24
- "description": "Optional 32-byte Ed25519 seed as 64 hex characters for local stdio request signing. Keep it in a secret store; never provide it as a tool argument.",
25
- "default": "",
26
- "isRequired": false,
27
- "format": "string"
28
- },
29
- {
30
- "name": "ROHAN_CONTRACT_ADDRESS",
31
- "description": "Midnight Preprod Contract Address for Rohan Trust Gateway",
32
- "default": "585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e",
33
- "isRequired": false,
34
- "format": "string"
35
- },
36
- {
37
- "name": "ROHAN_RELAYER_URL",
38
- "description": "Rohan Relayer API URL",
39
- "default": "https://api.rohanprotocol.network/api/v1/handshake",
40
- "isRequired": false,
41
- "format": "string"
42
- }
43
- ]
44
- }
45
- ]
46
- }
package/smithery.yaml DELETED
@@ -1,23 +0,0 @@
1
- # Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
2
- startCommand:
3
- type: stdio
4
- configSchema:
5
- type: object
6
- properties:
7
- rohanApiKey:
8
- type: string
9
- description: "Optional Rohan Relayer API key for production throughput (defaults to free 10 tx/day sandbox)"
10
- commandFunction:
11
- |-
12
- (config) => ({
13
- command: 'npx',
14
- args: ['-y', '@rohan-protocol/mcp@latest'],
15
- env: {
16
- ROHAN_FIREWALL_LEVEL: 'V-01_STRICT',
17
- ROHAN_CONTRACT_ADDRESS: '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e',
18
- ROHAN_RELAYER_URL: 'https://api.rohanprotocol.network/api/v1/handshake/stream',
19
- ...(config.rohanApiKey ? { ROHAN_API_KEY: config.rohanApiKey } : {})
20
- }
21
- })
22
- exampleConfig:
23
- rohanApiKey: "rohan_live_alpha_..."
package/src/firewall.ts DELETED
@@ -1,37 +0,0 @@
1
- export interface HandshakeIntent {
2
- agentId: string;
3
- action: string;
4
- payload: Record<string, unknown>;
5
- }
6
-
7
- export class SemanticFirewall {
8
- private static readonly INJECTION_REGEX =
9
- /(?:ignore\s+(all\s+)?previous\s+instructions|system\s*:\s*override|you\s+are\s+now\s+a|assistant\s*:|\[INST\]|<\|im_start\|>|jailbreak|reveal\s+(your|the)\s+secret)/i;
10
-
11
- static validate(intent: HandshakeIntent): boolean {
12
- if (!intent.agentId || typeof intent.agentId !== 'string' || intent.agentId.length > 128) {
13
- return false;
14
- }
15
- if (!intent.action || (
16
- intent.action !== 'rohan_zk_handshake' &&
17
- intent.action !== 'rohan_execute_handshake' &&
18
- intent.action !== 'verify_batched_handshakes'
19
- )) {
20
- return false;
21
- }
22
- if (!intent.payload || typeof intent.payload !== 'object') {
23
- return false;
24
- }
25
-
26
- const serialized = JSON.stringify(intent.payload);
27
- if (serialized.length > 8192) {
28
- return false; // Denial-of-Service Protection (Payload size cap)
29
- }
30
-
31
- if (this.INJECTION_REGEX.test(serialized)) {
32
- return false; // Semantic Prompt Injection detected
33
- }
34
-
35
- return true;
36
- }
37
- }
package/src/gateway.ts DELETED
@@ -1,59 +0,0 @@
1
- import { RohanRelayerClient } from '@rohan-protocol/sdk';
2
-
3
- export interface RohanMcpGatewayOptions {
4
- transport?: 'stdio' | 'streamable-http';
5
- relayerUrl?: string;
6
- contractAddress?: string;
7
- apiKey?: string;
8
- }
9
-
10
- /**
11
- * RohanMcpGateway
12
- * Connects AI Agent pipelines (Google ADK 2.0, Gemini, Claude, Cursor)
13
- * to the Rohan Protocol Gas Station via Streamable HTTP (NDJSON) or Stdio.
14
- */
15
- export class RohanMcpGateway {
16
- public readonly transport: string;
17
- public readonly relayerClient: RohanRelayerClient;
18
-
19
- constructor(options: RohanMcpGatewayOptions = {}) {
20
- this.transport = options.transport || 'streamable-http';
21
- this.relayerClient = new RohanRelayerClient({
22
- relayerUrl: options.relayerUrl || 'http://127.0.0.1:4005/api/v1/handshake',
23
- contractAddress: options.contractAddress || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e',
24
- apiKey: options.apiKey,
25
- });
26
- }
27
-
28
- /**
29
- * Generates a tool specification compliant with Google ADK 2.0 and Gemini tool calling.
30
- */
31
- asAdkTool() {
32
- return {
33
- name: 'rohan_execute_handshake',
34
- description: 'Executes a zero-knowledge verifiable handshake proof on Midnight Network with zero plaintext leaks.',
35
- parameters: {
36
- type: 'object',
37
- properties: {
38
- agentId: { type: 'string', description: 'Decentralized Identifier (DID) of calling agent' },
39
- intent: { type: 'string', description: 'Semantic action intent or agreement payload' },
40
- counterpartyId: { type: 'string', description: 'Optional recipient agent identifier' },
41
- },
42
- required: ['agentId', 'intent'],
43
- },
44
- execute: async (params: any) => {
45
- return await this.relayerClient.submitHandshake(params);
46
- },
47
- };
48
- }
49
-
50
- /**
51
- * Generates the legacy tool name for integrations that have not migrated yet.
52
- */
53
- asLegacyAdkTool() {
54
- return {
55
- ...this.asAdkTool(),
56
- name: 'rohan_zk_handshake',
57
- };
58
- }
59
- }
package/src/identity.ts DELETED
@@ -1,56 +0,0 @@
1
- import { webcrypto } from 'node:crypto';
2
- import {
3
- InMemoryEd25519Signer,
4
- type AgentSigner,
5
- } from '@rohan-protocol/sdk';
6
-
7
- const ED25519_PKCS8_PREFIX = new Uint8Array([
8
- 0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,
9
- ]);
10
-
11
- export async function resolveSignerFromEnv(
12
- rawPrivateKeyHex = process.env.ROHAN_AGENT_PRIVATE_KEY
13
- ): Promise<AgentSigner | undefined> {
14
- if (rawPrivateKeyHex === undefined || rawPrivateKeyHex.trim() === '') {
15
- return undefined;
16
- }
17
-
18
- const normalizedHex = rawPrivateKeyHex.trim().replace(/^0x/i, '');
19
- if (!/^[0-9a-f]{64}$/i.test(normalizedHex)) {
20
- throw new Error('ROHAN_AGENT_PRIVATE_KEY must be exactly 32 bytes encoded as 64 hex characters.');
21
- }
22
-
23
- const privateKey = new Uint8Array(Buffer.from(normalizedHex, 'hex'));
24
- const pkcs8Key = new Uint8Array(ED25519_PKCS8_PREFIX.length + privateKey.length);
25
- pkcs8Key.set(ED25519_PKCS8_PREFIX);
26
- pkcs8Key.set(privateKey, ED25519_PKCS8_PREFIX.length);
27
-
28
- try {
29
- const cryptoKey = await webcrypto.subtle.importKey(
30
- 'pkcs8',
31
- pkcs8Key,
32
- { name: 'Ed25519' },
33
- true,
34
- ['sign']
35
- );
36
- const jwk = await webcrypto.subtle.exportKey('jwk', cryptoKey);
37
- if (!jwk.x) {
38
- throw new Error('Could not derive the Ed25519 public key from ROHAN_AGENT_PRIVATE_KEY.');
39
- }
40
-
41
- const publicKey = new Uint8Array(Buffer.from(jwk.x, 'base64url'));
42
- if (publicKey.length !== 32) {
43
- throw new Error('Derived Ed25519 public key has an invalid length.');
44
- }
45
-
46
- return new InMemoryEd25519Signer(publicKey, privateKey);
47
- } catch (error) {
48
- throw new Error(
49
- 'Failed to initialize the Ed25519 signer from ROHAN_AGENT_PRIVATE_KEY.',
50
- { cause: error }
51
- );
52
- } finally {
53
- privateKey.fill(0);
54
- pkcs8Key.fill(0);
55
- }
56
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './firewall.js';
2
- export * from './gateway.js';