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
//! Identity types for the Tenzro Decentralized Identity Protocol (TDIP)
//!
//! This module defines foundation types used by the `tenzro-identity` crate
//! and throughout the Tenzro Network for unified human and machine identity.
use serde::{Deserialize, Serialize};
/// KYC (Know Your Customer) verification tiers for identities
///
/// Tiers are ordered by verification strength. `PartialOrd` enables
/// comparisons like `tier >= KycTier::Enhanced`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum KycTier {
/// No verification performed (Tier 0)
Unverified = 0,
/// Basic email verification (Tier 1)
Basic = 1,
/// Enhanced verification with ID document (Tier 2)
Enhanced = 2,
/// Full verification with biometric + institutional verification (Tier 3)
Full = 3,
}
impl KycTier {
/// Returns the tier as a human-readable string
pub fn as_str(&self) -> &str {
match self {
KycTier::Unverified => "unverified",
KycTier::Basic => "basic",
KycTier::Enhanced => "enhanced",
KycTier::Full => "full",
}
}
/// Returns the numeric tier level
pub fn level(&self) -> u8 {
*self as u8
}
}
/// Payment protocol identifiers for supported payment rails
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PaymentProtocolId {
/// Machine Payments Protocol (Stripe/Tempo)
Mpp,
/// x402 protocol (Coinbase)
X402,
/// Direct on-chain settlement (Tenzro native)
Direct,
/// Micropayment channel (off-chain)
Channel,
/// Custom protocol
Custom(String),
}
impl PaymentProtocolId {
/// Returns the protocol name as a string
pub fn as_str(&self) -> &str {
match self {
PaymentProtocolId::Mpp => "mpp",
PaymentProtocolId::X402 => "x402",
PaymentProtocolId::Direct => "direct",
PaymentProtocolId::Channel => "channel",
PaymentProtocolId::Custom(name) => name,
}
}
}
impl std::fmt::Display for PaymentProtocolId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_str())
}
}
/// Type of identity in the Tenzro Decentralized Identity Protocol.
///
/// The protocol recognises three identity classes — the enum collapses
/// the two machine classes into a single tag, distinguished at runtime
/// by the `controller_did` field on `IdentityData::Machine`:
///
/// - **Human** (`did:tenzro:human:{uuid}`)
/// - **Delegated agent** — machine with a human controller
/// (`did:tenzro:machine:{controller}:{uuid}`)
/// - **Autonomous agent** — machine with no controller
/// (`did:tenzro:machine:{uuid}`)
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum IdentityType {
/// Human identity
Human,
/// Machine/Agent identity (delegated or autonomous)
Machine,
}
impl IdentityType {
/// Returns the type as a string
pub fn as_str(&self) -> &str {
match self {
IdentityType::Human => "human",
IdentityType::Machine => "machine",
}
}
}
impl std::fmt::Display for IdentityType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_str())
}
}