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
//! # MPC Wallet Core
//!
//! Core library for MPC-secured AI agent wallets using 2-of-3 threshold signing.
//!
//! ## Architecture
//!
//! This crate provides:
//! - **2-of-3 Threshold ECDSA**: AI agent holds 1 share, user holds 1 share, recovery guardian holds 1 share
//! - **Policy Engine**: Configurable rules enforced before signing (spending limits, whitelists, time bounds)
//! - **Key Share Storage**: Secure encrypted storage for key shares
//! - **Chain Adapters**: Unified interface for EVM and Solana chains
//! - **ERC-4337 Support**: Account abstraction with UserOperations and paymasters
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use mpc_wallet_core::{AgentWallet, PartyRole, PolicyConfig};
//! use mpc_wallet_core::chain::{ChainAdapter, EvmAdapter, EvmConfig};
//!
//! // Create a new wallet with policy configuration
//! let policy = PolicyConfig::default()
//! .with_daily_limit("1.0", "ETH")
//! .with_whitelist(vec!["0x..."]);
//!
//! let wallet = AgentWallet::create(policy).await?;
//!
//! // Generate key shares for all parties
//! let shares = wallet.generate_shares().await?;
//!
//! // Use chain adapter for transactions
//! let evm = EvmAdapter::new(EvmConfig::ethereum_mainnet())?;
//! let balance = evm.get_balance("0x...").await?;
//!
//! // Sign a transaction (requires AI + User or AI + Recovery)
//! let signature = wallet.sign_transaction(tx, &[PartyRole::Agent, PartyRole::User]).await?;
//! ```
//!
//! ## Security Model
//!
//! The 2-of-3 threshold ensures:
//! - AI agent cannot sign alone (prevents rogue AI)
//! - User maintains control (can approve/reject)
//! - Recovery possible if user loses access (with guardian)
//!
//! All signing operations pass through the policy engine before MPC execution.
// Runtime-dependent modules (require tokio)
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export chain types for convenience
pub use ;
pub use ;
pub use ;
pub use ;
/// Protocol version
pub const VERSION: &str = env!;
/// Fixed number of parties for AI agent wallet (AI, User, Recovery)
pub const N_PARTIES: usize = 3;
/// Fixed threshold (2-of-3)
pub const THRESHOLD: usize = 2;
/// Party IDs
pub const PARTY_AGENT: PartyId = 0;
pub const PARTY_USER: PartyId = 1;
pub const PARTY_RECOVERY: PartyId = 2;