Skip to main content

confium_patterns/escrow/
metadata.rs

1//! Escrow metadata.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// Metadata about an escrowed key.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct EscrowMetadata {
9    /// When the key was escrowed.
10    pub escrowed_at: DateTime<Utc>,
11    /// Who escrowed it (actor ID).
12    pub escrowed_by: String,
13    /// Identifier for the escrowed key.
14    pub key_id: String,
15    /// Type of key (e.g., "Ed25519", "ECDSA-P256", "OpenPGP-private-key").
16    pub key_type: String,
17    /// Number of custodians holding shares (N).
18    pub custodian_count: u32,
19    /// Threshold T required for recovery.
20    pub threshold: u32,
21    /// Optional: human-readable description.
22    #[serde(default)]
23    pub description: Option<String>,
24}
25
26impl EscrowMetadata {
27    /// Construct new metadata with current timestamp.
28    pub fn new(
29        escrowed_by: impl Into<String>,
30        key_id: impl Into<String>,
31        key_type: impl Into<String>,
32        custodian_count: u32,
33        threshold: u32,
34    ) -> Self {
35        Self {
36            escrowed_at: Utc::now(),
37            escrowed_by: escrowed_by.into(),
38            key_id: key_id.into(),
39            key_type: key_type.into(),
40            custodian_count,
41            threshold,
42            description: None,
43        }
44    }
45}