1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! # Agentic Payments - Autonomous Multi-Agent Ed25519 Signature Verification
//!
//! A production-ready implementation of distributed cryptographic signature verification
//! with Byzantine fault tolerance, self-healing agent coordination, and AP2 (Agent Payments
//! Protocol) integration.
//!
//! ## Features
//!
//! - **Autonomous Verification**: Multi-agent consensus with BFT voting (⅔+ quorum)
//! - **Self-Healing**: Automatic agent recovery with <2s downtime
//! - **High Performance**: 10,000+ verifications/second with 100-agent pools
//! - **Byzantine Tolerance**: Survives up to f malicious agents in 2f+1 pools
//! - **AP2 Integration**: Verifiable Credentials and mandate-based authentication
//! - **Zero SPOF**: Mesh topology eliminates single points of failure
//!
//! ## Architecture
//!
//! The system uses 6 types of autonomous agents:
//! 1. **Verification Agents**: Parallel Ed25519 signature validation
//! 2. **Trust Chain Validators**: Certificate chain traversal with DFS
//! 3. **Authority Coordinators**: Multi-issuer quorum management
//! 4. **Key Management Agents**: Secure key lifecycle with HSM support
//! 5. **Anomaly Detection Agents**: Statistical threat detection
//! 6. **Recovery Agents**: Self-healing with automatic respawning
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use agentic_payments::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! // Initialize the agentic verification system
//! let system = AgenticVerificationSystem::builder()
//! .pool_size(5)
//! .consensus_threshold(0.67)
//! .build()
//! .await?;
//!
//! // Create agent identity
//! let identity = AgentIdentity::generate()?;
//!
//! // Sign a message
//! let message = b"Autonomous payment authorization";
//! let signature = identity.sign(message)?;
//!
//! // Verify with multi-agent consensus
//! let result = system.verify_with_consensus(
//! signature,
//! message,
//! identity.verifying_key()
//! ).await?;
//!
//! assert!(result.is_valid());
//! println!("Consensus: {}/{} agents agreed", result.votes_for, result.total_votes);
//!
//! Ok(())
//! }
//! ```
use Result;
/// Library version
pub const VERSION: &str = env!;
/// Maximum number of agents in a verification pool
pub const MAX_POOL_SIZE: usize = 100;
/// Minimum number of agents for BFT consensus (2f+1 where f=1)
pub const MIN_POOL_SIZE: usize = 3;
/// Default verification timeout in milliseconds
pub const DEFAULT_TIMEOUT_MS: u64 = 100;
/// Default consensus threshold (⅔+ = 0.67)
pub const DEFAULT_CONSENSUS_THRESHOLD: f64 = 0.67;
/// Initialize the agentic payments system with tracing