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;
|
|
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
|
-
//
|
|
12
|
-
const
|
|
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(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
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:
|
|
25
|
-
consensus_reached:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|
|
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;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAyB;IAEzB,IAAI,CAAC;QACH,MAAM,EACJ,OAAO,EACP,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,mBAAmB,GAAG,IAAI,GAC3B,GAAG,IAAI,CAAC;QAET,iCAAiC;QACjC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACjD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAEtD,2CAA2C;QAC3C,MAAM,MAAM,GAAoB,EAAE,CAAC;QACnC,KAAK,MAAM,WAAW,IAAI,iBAAiB,EAAE,CAAC;YAC5C,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW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