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
//! # dyolo-kya — Know Your Agent
//!
//! Cryptographic chain-of-custody for recursive AI agent delegation.
//!
//! ## The Problem
//!
//! When an AI agent delegates a task to another agent — which may delegate
//! further — the authorization chain breaks down. There is no irrefutable
//! proof that the action traces back to an original human authorization,
//! no guarantee that the delegated scope is a valid subset of the delegator's
//! own permissions, and no replay or revocation enforcement across hops.
//! This is the *Recursive Delegation Gap*.
//!
//! ## The Solution
//!
//! `dyolo-kya` closes every gap through a minimal, formally verifiable design:
//!
//! | Primitive | Role |
//! |---|---|
//! | [`IntentTree`] | Merkle tree over authorized actions; root is the scope commitment |
//! | [`SubScopeProof`] | Proof that a delegated scope is a strict subset of the parent's |
//! | [`DelegationCert`] | Signed, domain-separated record binding scope + temporal bounds + nonce |
//! | [`DyoloChain`] | Verifies all invariants in one pass, produces [`AuthorizedAction`] |
//! | [`AuthorizedAction`] | Type-level proof of authorization; the only valid execution token |
//!
//! ## Quick Start
//!
//! ```rust
//! use dyolo_kya::{
//! DyoloIdentity, DyoloChain, Intent,
//! CertBuilder, IntentTree, SubScopeProof, MerkleProof,
//! MemoryRevocationStore, MemoryNonceStore, SystemClock,
//! };
//!
//! // Identities
//! let human = DyoloIdentity::generate();
//! let agent_a = DyoloIdentity::generate();
//! let agent_b = DyoloIdentity::generate();
//!
//! // Human defines the authorized intent set.
//! let trade = Intent::new("trade.equity")
//! .param("symbol", "AAPL")
//! .param("limit_usd", "182.50")
//! .param("qty", "100")
//! .hash();
//! let query = Intent::new("query.portfolio").hash();
//! let tree = IntentTree::build(vec![trade, query]).unwrap();
//! let root = tree.root();
//!
//! // Human → Agent A (full scope).
//! let now = 1_700_000_000u64;
//! let expiry = now + 3600;
//! let cert_a = CertBuilder::new(agent_a.verifying_key(), root, now, expiry)
//! .sign(&human);
//!
//! // Agent A → Agent B (trade-only, depth-capped).
//! let sub_proof = SubScopeProof::build(&tree, &[trade]).unwrap();
//! let sub_root = dyolo_kya::IntentTree::build(vec![trade]).unwrap().root();
//! let cert_b = CertBuilder::new(agent_b.verifying_key(), sub_root, now, expiry)
//! .scope_proof(sub_proof)
//! .max_depth(0)
//! .sign(&agent_a);
//!
//! // Assemble and authorize.
//! let mut chain = DyoloChain::new(human.verifying_key(), root);
//! chain.push(cert_a).push(cert_b);
//!
//! let action = chain.authorize(
//! &agent_b.verifying_key(),
//! &trade,
//! &MerkleProof::default(),
//! &SystemClock,
//! &MemoryRevocationStore::new(),
//! &MemoryNonceStore::new(),
//! ).unwrap();
//!
//! println!("Authorized: depth={}", action.receipt.chain_depth);
//! ```
pub use ;
pub use ;
pub use KyaError;
pub use DyoloIdentity;
pub use ;
pub use ;