Skip to main content

tenzro_identity/
lib.rs

1//! Tenzro Decentralized Identity Protocol (TDIP)
2//!
3//! A unified identity protocol for humans and machines on the Tenzro Network.
4//! TDIP provides W3C DID-compatible decentralized identifiers with verifiable
5//! credentials, delegation scopes, and automatic wallet provisioning.
6//!
7//! # Overview
8//!
9//! TDIP is the identity standard for the Tenzro Network. It recognises
10//! three identity classes:
11//!
12//! - **Human** (`did:tenzro:human:{uuid}`) — KYC-tiered, credential-holding
13//! - **Delegated agent** (`did:tenzro:machine:{controller}:{uuid}`) — machine
14//!   under a human controller, scoped by `DelegationScope`
15//! - **Autonomous agent** (`did:tenzro:machine:{uuid}`) — self-sovereign machine,
16//!   no controller
17//!
18//! # Key Features
19//!
20//! - **Unified identity type** — `TenzroIdentity` covers both humans and machines
21//! - **W3C DID Documents** — Export/import identities as standard DID Documents
22//! - **Verifiable Credentials** — Issue, inherit, and verify W3C VC-compatible credentials
23//! - **Delegation Scopes** — Fine-grained control over machine permissions including
24//!   payment protocol restrictions and chain allowlists
25//! - **Auto-provisioned wallets** — Every identity gets an MPC wallet automatically
26//! - **Cascading revocation** — Revoking a human revokes all controlled machines
27//!
28//! # Examples
29//!
30//! ```no_run
31//! use tenzro_identity::registry::IdentityRegistry;
32//! use tenzro_identity::delegation::DelegationScope;
33//! use tenzro_types::identity::KycTier;
34//!
35//! # async fn example() -> tenzro_identity::error::Result<()> {
36//! let registry = IdentityRegistry::new();
37//!
38//! // Register a human identity
39//! let human = registry.register_human_with_fee(
40//!     vec![1; 32],
41//!     "Alice".to_string(),
42//!     KycTier::Enhanced,
43//! ).await?.identity;
44//!
45//! // Register a machine under the human
46//! let machine = registry.register_machine_with_fee(
47//!     &human.did_string(),
48//!     vec![2; 32],
49//!     vec!["inference".to_string()],
50//!     DelegationScope::unrestricted()
51//!         .with_max_transaction_value(10_000)
52//!         .with_allowed_payment_protocols(vec!["mpp".to_string()]),
53//! ).await?.identity;
54//!
55//! println!("Human DID: {}", human.did_string());
56//! println!("Machine DID: {}", machine.did_string());
57//! # Ok(())
58//! # }
59//! ```
60
61pub mod car;
62pub mod credential;
63pub mod delegation;
64pub mod derivation;
65pub mod did;
66pub mod document;
67pub mod envelope;
68pub mod erc7683;
69pub mod erc8004;
70pub mod erc8004_daml;
71pub mod erc8004_svm;
72pub mod error;
73pub mod identity;
74pub mod ivms101;
75pub mod keri;
76pub mod kya;
77pub mod registry;
78pub mod verification;
79pub mod w3c;
80pub mod wallet_binding;
81
82// Re-export commonly used types
83pub use car::IdentityCarBundle;
84pub use credential::{
85    sign_credential_hybrid, CredentialProof, TenzroCredentialType, VerifiableCredential,
86};
87pub use delegation::{DelegationEntry, DelegationScope, TimeBound};
88pub use derivation::{
89    evm_address, stellar_strkey, xrpl_classic_address, ChainDerivation, DerivationError,
90    TargetChain, TargetCurve,
91};
92pub use did::{DidType, TenzroDid};
93pub use envelope::{
94    canonical_preimage, params_hash, verify_envelope, EnvelopeError, TenzroDidEnvelope,
95};
96pub use document::{DidDocument, DidService, VerificationMethod};
97pub use erc8004::{
98    agent_id_from_uint256_be, agent_id_to_uint256_be, AgentRecord, Erc8004Adapter,
99    Erc8004Addresses, Erc8004Transport, EthAddress, FeedbackEntry, MetadataEntry,
100    OnChainAgentRegistry, ValidationRequest, ValidationResult,
101};
102pub use erc8004_daml::{
103    DamlAgentRecord, DamlPackageIds, Erc8004DamlTransport, OnChainAgentDamlRegistry, PackageId,
104    PartyId,
105};
106pub use erc8004_svm::{
107    Erc8004SvmTransport, OnChainAgentSvmRegistry, SolPubkey, SvmAgentRecord,
108};
109pub use error::{IdentityError, Result};
110pub use identity::{
111    validate_username, IdentityData, IdentityStatus, KeyPurpose, PublicKeyInfo, RevocationEntry,
112    ServiceEndpoint, TenzroIdentity,
113};
114pub use kya::{
115    compute_kya_level, is_kya_service_type, AuthenticatorBinding, KyaLevel, KyaRecord,
116    SERVICE_TYPE_MASTERCARD_KYA, SERVICE_TYPE_STRIPE_SPT, SERVICE_TYPE_TEMPO_ACCOUNT,
117    SERVICE_TYPE_VISA_TAP,
118};
119pub use registry::{
120    DelegationPolicy, DidResolutionBackend, IdentityRegistry, RegistrationResult,
121    RevocationBroadcaster, SignedRevocationEntry,
122};
123pub use verification::{IdentityVerifier, TrustChainResult};
124pub use w3c::{extract_public_keys_from_document, identity_to_did_document};
125pub use wallet_binding::{WalletBinder, WalletBinding};