agentic-payments 0.1.1 → 0.1.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.
@@ -3,7 +3,17 @@
3
3
  */
4
4
  import type { ToolResult, VerifyConsensusArgs } from './types.js';
5
5
  /**
6
- * Verify payment signature with multi-agent consensus
6
+ * Verify payment signature with multi-agent Byzantine consensus
7
+ *
8
+ * Implements cryptographic multi-agent verification where:
9
+ * - Each agent independently verifies the signature
10
+ * - Consensus threshold determines approval (e.g., 13 of 20 agents = 65%)
11
+ * - Byzantine fault tolerance: system remains secure even if f < n/3 agents are compromised
12
+ *
13
+ * Example: $50K vendor contract with 20 agents (procurement, finance, legal, audit, etc.)
14
+ * - Requires 13 signatures (65% consensus)
15
+ * - Can tolerate up to 6 compromised agents (7 would be 35% < required 65%)
16
+ * - No single agent or small group can authorize fraudulent transactions
7
17
  */
8
18
  export declare function verifyConsensusTool(args: VerifyConsensusArgs): Promise<ToolResult>;
9
19
  //# sourceMappingURL=consensus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consensus.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/consensus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElE;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,UAAU,CAAC,CAoCrB"}
1
+ {"version":3,"file":"consensus.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/consensus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,UAAU,CAAC,CAmFrB"}
@@ -2,30 +2,79 @@
2
2
  * Consensus verification MCP tools
3
3
  */
4
4
  import { VerificationSystemBuilder } from '../../verification.js';
5
+ import { AgentIdentity } from '../../identity.js';
5
6
  /**
6
- * Verify payment signature with multi-agent consensus
7
+ * Verify payment signature with multi-agent Byzantine consensus
8
+ *
9
+ * Implements cryptographic multi-agent verification where:
10
+ * - Each agent independently verifies the signature
11
+ * - Consensus threshold determines approval (e.g., 13 of 20 agents = 65%)
12
+ * - Byzantine fault tolerance: system remains secure even if f < n/3 agents are compromised
13
+ *
14
+ * Example: $50K vendor contract with 20 agents (procurement, finance, legal, audit, etc.)
15
+ * - Requires 13 signatures (65% consensus)
16
+ * - Can tolerate up to 6 compromised agents (7 would be 35% < required 65%)
17
+ * - No single agent or small group can authorize fraudulent transactions
7
18
  */
8
19
  export async function verifyConsensusTool(args) {
9
20
  try {
10
- const { agent_public_keys, consensus_threshold = 0.67, } = args;
11
- // Create verification system with agent pool
12
- const builder = new VerificationSystemBuilder()
21
+ const { message, signature, public_key, agent_public_keys, consensus_threshold = 0.67, } = args;
22
+ // Decode inputs from hex strings
23
+ const messageBytes = Buffer.from(message, 'hex');
24
+ const signatureBytes = Buffer.from(signature, 'hex');
25
+ const publicKeyBytes = Buffer.from(public_key, 'hex');
26
+ // Create agent identities from public keys
27
+ const agents = [];
28
+ for (const agentPubKey of agent_public_keys) {
29
+ const agentPubKeyBytes = Buffer.from(agentPubKey, 'hex');
30
+ // Create identity with public key only (no private key for verification)
31
+ const identity = await AgentIdentity.fromPublicKey(agentPubKeyBytes);
32
+ agents.push(identity);
33
+ }
34
+ if (agents.length === 0) {
35
+ return {
36
+ success: false,
37
+ error: 'No agents provided for consensus verification',
38
+ };
39
+ }
40
+ // Calculate minimum required agents based on threshold
41
+ const minRequired = Math.ceil(agents.length * consensus_threshold);
42
+ // Build verification system with Byzantine fault tolerance
43
+ const system = new VerificationSystemBuilder()
13
44
  .consensusThreshold(consensus_threshold)
14
- .minAgents(Math.ceil(agent_public_keys.length * consensus_threshold));
15
- // Build system (in real implementation, you'd add agents and use system.verifyWithConsensus)
16
- builder.build();
17
- // Note: This is a simplified implementation
18
- // In production, you would:
19
- // 1. Reconstruct AgentIdentity instances from public keys
20
- // 2. Use system.verifyWithConsensus() method
21
- // 3. Return actual consensus voting results
45
+ .minAgents(minRequired)
46
+ .maxAgents(agents.length)
47
+ .timeout(5000)
48
+ .parallel(true) // Parallel verification for performance
49
+ .addAgents(agents)
50
+ .build();
51
+ // Verify with multi-agent consensus
52
+ const result = await system.verifyWithConsensus(signatureBytes, messageBytes, publicKeyBytes);
53
+ // Return detailed consensus results
22
54
  return {
23
55
  success: true,
24
- verified: true,
25
- consensus_reached: true,
26
- threshold: consensus_threshold,
27
- agent_count: agent_public_keys.length,
28
- message: 'Consensus verification requires full agent pool implementation',
56
+ verified: result.isValid,
57
+ consensus_reached: result.consensusReached,
58
+ votes_for: result.votesFor,
59
+ votes_against: result.votesAgainst,
60
+ total_votes: result.totalVotes,
61
+ consensus_percentage: Math.round(result.consensusPercentage * 100),
62
+ threshold_percentage: Math.round(consensus_threshold * 100),
63
+ required_votes: minRequired,
64
+ agent_count: agents.length,
65
+ total_latency_ms: result.totalLatencyMs,
66
+ avg_latency_ms: Math.round(result.avgLatencyMs * 100) / 100,
67
+ agent_votes: result.agentVotes.map(v => ({
68
+ agent_id: v.agentId,
69
+ vote: v.vote ? 'approve' : 'reject',
70
+ timestamp: v.timestamp,
71
+ latency_ms: v.latencyMs,
72
+ })),
73
+ byzantine_fault_tolerance: {
74
+ max_compromised_agents: Math.floor(agents.length / 3) - 1,
75
+ security_margin: result.votesFor - minRequired,
76
+ is_byzantine_secure: result.votesFor >= minRequired,
77
+ },
29
78
  };
30
79
  }
31
80
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"consensus.js","sourceRoot":"","sources":["../../../src/mcp/tools/consensus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGlE;;GAEG;AACH,MAAM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ACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-payments",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Dual-protocol payment infrastructure for autonomous AI commerce (AP2 + ACP)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",