mpc_wallet_core/keygen/
mod.rs

1//! Distributed Key Generation (DKG) for 2-of-3 Agent Wallet
2//!
3//! This module implements threshold key generation specifically designed for
4//! the AI agent wallet use case with three parties:
5//! - Agent (party 0)
6//! - User (party 1)
7//! - Recovery (party 2)
8//!
9//! The DKG protocol generates secret shares such that any 2-of-3 parties
10//! can collaborate to sign transactions.
11
12#[cfg(feature = "runtime")]
13mod dkg;
14mod messages;
15#[cfg(feature = "runtime")]
16mod refresh;
17
18#[cfg(feature = "runtime")]
19pub use dkg::run_dkg;
20pub use messages::{DkgRound1Message, DkgRound2Message};
21#[cfg(feature = "runtime")]
22pub use refresh::refresh_shares;
23
24use crate::{AgentKeyShare, Result};
25
26/// Result of distributed key generation
27#[derive(Debug)]
28pub struct KeygenResult {
29    /// The generated key share for this party
30    pub share: AgentKeyShare,
31    /// The aggregated public key (same for all parties)
32    pub public_key: Vec<u8>,
33    /// Ethereum address derived from the public key
34    pub eth_address: String,
35}
36
37impl KeygenResult {
38    /// Create a new keygen result
39    pub fn new(share: AgentKeyShare) -> Result<Self> {
40        let eth_address = share.eth_address()?;
41        let public_key = share.public_key.clone();
42
43        Ok(Self {
44            share,
45            public_key,
46            eth_address,
47        })
48    }
49}