@vorionsys/basis 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +22 -0
- package/AMOY-MIGRATION.md +188 -0
- package/DEPLOY-AMOY.md +368 -0
- package/DEPLOY-NOW.md +216 -0
- package/DEPLOYMENT.md +239 -0
- package/GET-WALLET.md +286 -0
- package/QUICK-WALLET-SETUP.md +268 -0
- package/README.md +195 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +236 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +204 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.json +328 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.json +113 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.json +97 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.json +114 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +444 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json +296 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.json +45 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.json +521 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.json +476 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.json +352 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.json +341 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +37 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +65 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
- package/artifacts/build-info/357d1bba4062d461f497f221490811a3.json +1 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.dbg.json +4 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.json +1430 -0
- package/build_errors.txt +0 -0
- package/build_output.txt +0 -0
- package/cache/solidity-files-cache.json +885 -0
- package/contracts/AgentCard.sol +478 -0
- package/contracts/deploy/01-deploy-agentcard.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/kya/accountability.d.ts.map +1 -0
- package/dist/kya/accountability.js +100 -0
- package/dist/kya/authorization.d.ts.map +1 -0
- package/dist/kya/authorization.js +258 -0
- package/dist/kya/behavior.d.ts.map +1 -0
- package/dist/kya/behavior.js +142 -0
- package/dist/kya/identity.d.ts.map +1 -0
- package/dist/kya/identity.js +187 -0
- package/dist/kya/index.d.ts.map +1 -0
- package/dist/kya/index.js +99 -0
- package/dist/kya/types.d.ts.map +1 -0
- package/dist/kya/types.js +5 -0
- package/dist/trust-1000-agents.test.d.ts.map +1 -0
- package/dist/trust-1000-agents.test.js +608 -0
- package/dist/trust-capabilities.d.ts.map +1 -0
- package/dist/trust-capabilities.js +478 -0
- package/dist/trust-factors.d.ts.map +1 -0
- package/dist/trust-factors.js +588 -0
- package/dist/trust-factors.test.d.ts.map +1 -0
- package/dist/trust-factors.test.js +179 -0
- package/dist/validation-gate.d.ts.map +1 -0
- package/dist/validation-gate.js +468 -0
- package/dist/validation-gate.test.d.ts.map +1 -0
- package/dist/validation-gate.test.js +419 -0
- package/hardhat.config.ts +55 -0
- package/package.json +57 -0
- package/scripts/certify-agent.ts +91 -0
- package/scripts/deploy-agentcard.ts +63 -0
- package/scripts/mint-agentcard.ts +87 -0
- package/specs/adversarial-sandbox-test-suite.md +1055 -0
- package/specs/kya-framework.md +910 -0
- package/specs/trust-factors-v2.md +437 -0
- package/src/index.ts +14 -0
- package/src/kya/accountability.ts +132 -0
- package/src/kya/authorization.ts +325 -0
- package/src/kya/behavior.ts +169 -0
- package/src/kya/identity.ts +224 -0
- package/src/kya/index.ts +125 -0
- package/src/kya/types.ts +242 -0
- package/src/trust-1000-agents.test.ts +745 -0
- package/src/trust-capabilities.ts +517 -0
- package/src/trust-factors.test.ts +241 -0
- package/src/trust-factors.ts +666 -0
- package/src/validation-gate.test.ts +531 -0
- package/src/validation-gate.ts +665 -0
- package/test-kya-simple.ts +258 -0
- package/test-kya.ts +245 -0
- package/tsconfig.json +14 -0
- package/typechain-types/@openzeppelin/contracts/access/AccessControl.ts +324 -0
- package/typechain-types/@openzeppelin/contracts/access/IAccessControl.ts +292 -0
- package/typechain-types/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/index.ts +11 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/ERC721.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.ts +470 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.ts +489 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.ts +443 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/Strings.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/SafeCast.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/@openzeppelin/index.ts +5 -0
- package/typechain-types/common.ts +131 -0
- package/typechain-types/contracts/AgentCard.ts +1415 -0
- package/typechain-types/contracts/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/AccessControl__factory.ts +250 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/IAccessControl__factory.ts +218 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/ERC721__factory.ts +455 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable__factory.ts +535 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage__factory.ts +490 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable__factory.ts +366 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +355 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.ts +90 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.ts +118 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/index.ts +4 -0
- package/typechain-types/factories/contracts/AgentCard__factory.ts +1480 -0
- package/typechain-types/factories/contracts/index.ts +4 -0
- package/typechain-types/factories/index.ts +5 -0
- package/typechain-types/index.ts +44 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,910 @@
|
|
|
1
|
+
# KYA (Know Your Agent) Framework Specification
|
|
2
|
+
|
|
3
|
+
**Version**: 1.0.0
|
|
4
|
+
**Status**: Draft
|
|
5
|
+
**Date**: 2026-01-22
|
|
6
|
+
**Part of**: BASIS (Blockchain Agent Standard for Identity and Security)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
The **KYA (Know Your Agent) Framework** establishes a universal trust layer for AI agents, analogous to SSL/TLS for web security. It provides cryptographic identity verification, continuous authorization checks, immutable accountability, and real-time behavior monitoring.
|
|
13
|
+
|
|
14
|
+
**Core Capabilities**:
|
|
15
|
+
1. **Identity Confirmation** - Cryptographic proof of agent identity using W3C DIDs
|
|
16
|
+
2. **Authorization Verification** - Capability-based access control with policy enforcement
|
|
17
|
+
3. **Accountability Tracking** - Immutable audit trail linking actions to identities
|
|
18
|
+
4. **Continuous Behavior Monitoring** - Real-time anomaly detection and trust scoring
|
|
19
|
+
|
|
20
|
+
**Integration**: KYA is a core component of BASIS, providing the identity and trust foundation for Cognigate (Kaizen runtime) and AgentAnchor (certification platform).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. Architecture Overview
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
28
|
+
│ KYA Framework Layers │
|
|
29
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
30
|
+
│ │
|
|
31
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
32
|
+
│ │ Identity │ │Authorization │ │Accountability│ │
|
|
33
|
+
│ │ Confirmation │ │Verification │ │ Tracking │ │
|
|
34
|
+
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
|
|
35
|
+
│ │ │ │ │
|
|
36
|
+
│ ▼ ▼ ▼ │
|
|
37
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
38
|
+
│ │ Continuous Behavior Monitoring │ │
|
|
39
|
+
│ │ (Real-time anomaly detection + trust scoring) │ │
|
|
40
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
41
|
+
│ │ │
|
|
42
|
+
└──────────────────────────┼──────────────────────────────────────┘
|
|
43
|
+
│
|
|
44
|
+
▼
|
|
45
|
+
┌──────────────┐
|
|
46
|
+
│ TSG Trust │
|
|
47
|
+
│ Scoring │
|
|
48
|
+
└──────────────┘
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 2. Layer 1: Identity Confirmation
|
|
54
|
+
|
|
55
|
+
### 2.1 W3C DID Integration
|
|
56
|
+
|
|
57
|
+
**Decentralized Identifier (DID)** format:
|
|
58
|
+
```
|
|
59
|
+
did:vorion:<method>:<identifier>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Example**:
|
|
63
|
+
```
|
|
64
|
+
did:vorion:eth:0x1234567890abcdef1234567890abcdef12345678
|
|
65
|
+
did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2.2 DID Document Structure
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"@context": [
|
|
73
|
+
"https://www.w3.org/ns/did/v1",
|
|
74
|
+
"https://vorion.org/ns/kya/v1"
|
|
75
|
+
],
|
|
76
|
+
"id": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
77
|
+
"controller": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
78
|
+
"verificationMethod": [
|
|
79
|
+
{
|
|
80
|
+
"id": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk#keys-1",
|
|
81
|
+
"type": "Ed25519VerificationKey2020",
|
|
82
|
+
"controller": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
83
|
+
"publicKeyMultibase": "z5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"authentication": [
|
|
87
|
+
"did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk#keys-1"
|
|
88
|
+
],
|
|
89
|
+
"assertionMethod": [
|
|
90
|
+
"did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk#keys-1"
|
|
91
|
+
],
|
|
92
|
+
"service": [
|
|
93
|
+
{
|
|
94
|
+
"id": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk#agentcard",
|
|
95
|
+
"type": "AgentCard",
|
|
96
|
+
"serviceEndpoint": "https://agentanchorai.com/cards/5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk#kaizen",
|
|
100
|
+
"type": "KaizenRuntime",
|
|
101
|
+
"serviceEndpoint": "https://cognigate.dev/api/v1"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"kya": {
|
|
105
|
+
"trustScore": 520,
|
|
106
|
+
"tier": "T3",
|
|
107
|
+
"certified": true,
|
|
108
|
+
"certifier": "did:vorion:org:agentanchor",
|
|
109
|
+
"certificationDate": "2026-01-15T00:00:00Z",
|
|
110
|
+
"capabilities": [
|
|
111
|
+
"file_read",
|
|
112
|
+
"file_write",
|
|
113
|
+
"network_http",
|
|
114
|
+
"database_read",
|
|
115
|
+
"database_write"
|
|
116
|
+
],
|
|
117
|
+
"restrictions": [
|
|
118
|
+
"no_external_code_execution",
|
|
119
|
+
"no_credential_access"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 2.3 Identity Verification Flow
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
// Identity verification using Ed25519 signatures
|
|
129
|
+
|
|
130
|
+
interface IdentityProof {
|
|
131
|
+
did: string;
|
|
132
|
+
timestamp: number;
|
|
133
|
+
challenge: string; // Random nonce from verifier
|
|
134
|
+
signature: string; // Ed25519 signature of challenge
|
|
135
|
+
publicKey: string; // Public key for verification
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function verifyIdentity(proof: IdentityProof): Promise<boolean> {
|
|
139
|
+
// 1. Resolve DID document
|
|
140
|
+
const didDoc = await resolveDID(proof.did);
|
|
141
|
+
|
|
142
|
+
// 2. Extract verification method
|
|
143
|
+
const verificationMethod = didDoc.verificationMethod.find(
|
|
144
|
+
vm => vm.type === 'Ed25519VerificationKey2020'
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
if (!verificationMethod) {
|
|
148
|
+
throw new Error('No Ed25519 verification method found');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 3. Verify signature
|
|
152
|
+
const message = `${proof.challenge}:${proof.timestamp}`;
|
|
153
|
+
const isValid = await ed25519.verify(
|
|
154
|
+
proof.signature,
|
|
155
|
+
message,
|
|
156
|
+
verificationMethod.publicKeyMultibase
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// 4. Check timestamp freshness (prevent replay)
|
|
160
|
+
const age = Date.now() - proof.timestamp;
|
|
161
|
+
if (age > 60000) { // 1 minute max
|
|
162
|
+
throw new Error('Proof too old (replay attack prevention)');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return isValid;
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 3. Layer 2: Authorization Verification
|
|
172
|
+
|
|
173
|
+
### 3.1 Capability-Based Access Control
|
|
174
|
+
|
|
175
|
+
**Capability Token Structure**:
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"id": "cap_abc123",
|
|
179
|
+
"issuer": "did:vorion:org:agentanchor",
|
|
180
|
+
"subject": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
181
|
+
"capabilities": [
|
|
182
|
+
{
|
|
183
|
+
"action": "file.write",
|
|
184
|
+
"resource": "/data/user_documents/*",
|
|
185
|
+
"conditions": {
|
|
186
|
+
"maxFileSize": 10485760, // 10MB
|
|
187
|
+
"allowedExtensions": [".txt", ".md", ".json"]
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"action": "network.http",
|
|
192
|
+
"resource": "https://api.example.com/*",
|
|
193
|
+
"conditions": {
|
|
194
|
+
"methods": ["GET", "POST"],
|
|
195
|
+
"rateLimit": "100/hour"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
"notBefore": "2026-01-22T00:00:00Z",
|
|
200
|
+
"notAfter": "2026-02-22T00:00:00Z",
|
|
201
|
+
"signature": "..."
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 3.2 Authorization Decision Flow
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
interface AuthorizationRequest {
|
|
209
|
+
agentDID: string;
|
|
210
|
+
action: string; // e.g., "file.write", "database.query"
|
|
211
|
+
resource: string; // e.g., "/data/file.txt", "postgres://db/users"
|
|
212
|
+
context: {
|
|
213
|
+
timestamp: number;
|
|
214
|
+
sourceIP?: string;
|
|
215
|
+
trustScore?: number;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface AuthorizationDecision {
|
|
220
|
+
allowed: boolean;
|
|
221
|
+
reason: string;
|
|
222
|
+
conditions?: Record<string, unknown>;
|
|
223
|
+
trustImpact?: number; // How this affects trust score
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function authorize(request: AuthorizationRequest): Promise<AuthorizationDecision> {
|
|
227
|
+
// 1. Verify identity
|
|
228
|
+
const didDoc = await resolveDID(request.agentDID);
|
|
229
|
+
|
|
230
|
+
// 2. Check trust tier
|
|
231
|
+
const trustScore = didDoc.kya?.trustScore || 0;
|
|
232
|
+
const tier = didDoc.kya?.tier || 'T0';
|
|
233
|
+
|
|
234
|
+
// 3. Get applicable capabilities
|
|
235
|
+
const capabilities = await getCapabilities(request.agentDID);
|
|
236
|
+
|
|
237
|
+
// 4. Match action + resource to capability
|
|
238
|
+
const matchingCap = capabilities.find(cap =>
|
|
239
|
+
cap.action === request.action &&
|
|
240
|
+
matchResource(cap.resource, request.resource)
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
if (!matchingCap) {
|
|
244
|
+
return {
|
|
245
|
+
allowed: false,
|
|
246
|
+
reason: 'No matching capability',
|
|
247
|
+
trustImpact: -10,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 5. Evaluate conditions
|
|
252
|
+
const conditionsValid = evaluateConditions(
|
|
253
|
+
matchingCap.conditions,
|
|
254
|
+
request.context
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
if (!conditionsValid) {
|
|
258
|
+
return {
|
|
259
|
+
allowed: false,
|
|
260
|
+
reason: 'Capability conditions not met',
|
|
261
|
+
trustImpact: -5,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 6. Check BASIS policy constraints
|
|
266
|
+
const policyViolations = await checkPolicyConstraints(request);
|
|
267
|
+
|
|
268
|
+
if (policyViolations.length > 0) {
|
|
269
|
+
return {
|
|
270
|
+
allowed: false,
|
|
271
|
+
reason: `Policy violations: ${policyViolations.join(', ')}`,
|
|
272
|
+
trustImpact: -20,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 7. ALLOW
|
|
277
|
+
return {
|
|
278
|
+
allowed: true,
|
|
279
|
+
reason: 'Authorized',
|
|
280
|
+
conditions: matchingCap.conditions,
|
|
281
|
+
trustImpact: 1, // Small positive for successful authorized action
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 4. Layer 3: Accountability Tracking
|
|
289
|
+
|
|
290
|
+
### 4.1 Immutable Audit Trail
|
|
291
|
+
|
|
292
|
+
**Action Record Structure**:
|
|
293
|
+
```typescript
|
|
294
|
+
interface AccountabilityRecord {
|
|
295
|
+
id: string;
|
|
296
|
+
timestamp: number;
|
|
297
|
+
agentDID: string;
|
|
298
|
+
action: string;
|
|
299
|
+
resource: string;
|
|
300
|
+
outcome: 'success' | 'failure' | 'denied';
|
|
301
|
+
evidence: {
|
|
302
|
+
intentHash: string; // Link to Kaizen proof chain
|
|
303
|
+
authorizationDecision: AuthorizationDecision;
|
|
304
|
+
executionResult?: unknown;
|
|
305
|
+
};
|
|
306
|
+
signature: string; // Ed25519 signature by agent
|
|
307
|
+
witnessSignature?: string; // Optional co-signature by runtime
|
|
308
|
+
chainLink: {
|
|
309
|
+
prevHash: string | null; // Link to previous record (blockchain-style)
|
|
310
|
+
merkleRoot?: string; // Optional Merkle tree for batch verification
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 4.2 Accountability Chain
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
class AccountabilityChain {
|
|
319
|
+
private db: Database;
|
|
320
|
+
|
|
321
|
+
async append(record: AccountabilityRecord): Promise<void> {
|
|
322
|
+
// 1. Get previous record hash
|
|
323
|
+
const prevRecord = await this.getLatest(record.agentDID);
|
|
324
|
+
record.chainLink.prevHash = prevRecord?.hash || null;
|
|
325
|
+
|
|
326
|
+
// 2. Calculate hash
|
|
327
|
+
const hash = this.calculateHash(record);
|
|
328
|
+
|
|
329
|
+
// 3. Verify agent signature
|
|
330
|
+
const isValid = await this.verifySignature(record);
|
|
331
|
+
if (!isValid) {
|
|
332
|
+
throw new Error('Invalid agent signature on accountability record');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// 4. Store with hash
|
|
336
|
+
await this.db.insert('accountability_records', {
|
|
337
|
+
...record,
|
|
338
|
+
hash,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// 5. Update agent's accountability score
|
|
342
|
+
await this.updateAccountabilityScore(record.agentDID, record.outcome);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async verify(agentDID: string): Promise<{
|
|
346
|
+
valid: boolean;
|
|
347
|
+
totalRecords: number;
|
|
348
|
+
brokenLinks: number;
|
|
349
|
+
}> {
|
|
350
|
+
const records = await this.db.query(
|
|
351
|
+
'SELECT * FROM accountability_records WHERE agent_did = ? ORDER BY timestamp ASC',
|
|
352
|
+
[agentDID]
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
let brokenLinks = 0;
|
|
356
|
+
let prevHash: string | null = null;
|
|
357
|
+
|
|
358
|
+
for (const record of records) {
|
|
359
|
+
if (record.chainLink.prevHash !== prevHash) {
|
|
360
|
+
brokenLinks++;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Verify hash
|
|
364
|
+
const expectedHash = this.calculateHash(record);
|
|
365
|
+
if (expectedHash !== record.hash) {
|
|
366
|
+
brokenLinks++;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
prevHash = record.hash;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return {
|
|
373
|
+
valid: brokenLinks === 0,
|
|
374
|
+
totalRecords: records.length,
|
|
375
|
+
brokenLinks,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
private calculateHash(record: AccountabilityRecord): string {
|
|
380
|
+
const content = JSON.stringify({
|
|
381
|
+
timestamp: record.timestamp,
|
|
382
|
+
agentDID: record.agentDID,
|
|
383
|
+
action: record.action,
|
|
384
|
+
resource: record.resource,
|
|
385
|
+
outcome: record.outcome,
|
|
386
|
+
evidence: record.evidence,
|
|
387
|
+
prevHash: record.chainLink.prevHash,
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
return createHash('sha256').update(content).digest('hex');
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## 5. Layer 4: Continuous Behavior Monitoring
|
|
398
|
+
|
|
399
|
+
### 5.1 Real-Time Anomaly Detection
|
|
400
|
+
|
|
401
|
+
**Monitored Behaviors**:
|
|
402
|
+
- Action frequency (rate limiting)
|
|
403
|
+
- Action diversity (breadth of capabilities used)
|
|
404
|
+
- Temporal patterns (time-of-day, day-of-week)
|
|
405
|
+
- Resource access patterns (which files, APIs, databases)
|
|
406
|
+
- Outcome consistency (success/failure ratios)
|
|
407
|
+
- Authorization patterns (denied requests)
|
|
408
|
+
|
|
409
|
+
**Anomaly Detection Algorithm**:
|
|
410
|
+
```typescript
|
|
411
|
+
interface BehaviorProfile {
|
|
412
|
+
agentDID: string;
|
|
413
|
+
baseline: {
|
|
414
|
+
actionsPerHour: { mean: number; stddev: number };
|
|
415
|
+
successRate: { mean: number; stddev: number };
|
|
416
|
+
topActions: Array<{ action: string; frequency: number }>;
|
|
417
|
+
topResources: Array<{ resource: string; frequency: number }>;
|
|
418
|
+
};
|
|
419
|
+
recentWindow: {
|
|
420
|
+
actionsInLastHour: number;
|
|
421
|
+
successRateLastHour: number;
|
|
422
|
+
newActionsInLastHour: string[];
|
|
423
|
+
newResourcesInLastHour: string[];
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
interface AnomalyAlert {
|
|
428
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
429
|
+
type: string;
|
|
430
|
+
description: string;
|
|
431
|
+
evidence: unknown;
|
|
432
|
+
recommendedAction: 'log' | 'warn' | 'throttle' | 'suspend';
|
|
433
|
+
trustImpact: number;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async function detectAnomalies(agentDID: string): Promise<AnomalyAlert[]> {
|
|
437
|
+
const profile = await getBehaviorProfile(agentDID);
|
|
438
|
+
const alerts: AnomalyAlert[] = [];
|
|
439
|
+
|
|
440
|
+
// 1. Rate spike detection
|
|
441
|
+
const zScore =
|
|
442
|
+
(profile.recentWindow.actionsInLastHour - profile.baseline.actionsPerHour.mean) /
|
|
443
|
+
profile.baseline.actionsPerHour.stddev;
|
|
444
|
+
|
|
445
|
+
if (zScore > 3) {
|
|
446
|
+
alerts.push({
|
|
447
|
+
severity: 'high',
|
|
448
|
+
type: 'rate_spike',
|
|
449
|
+
description: `Action rate is ${zScore.toFixed(1)} standard deviations above baseline`,
|
|
450
|
+
evidence: {
|
|
451
|
+
baseline: profile.baseline.actionsPerHour.mean,
|
|
452
|
+
current: profile.recentWindow.actionsInLastHour,
|
|
453
|
+
},
|
|
454
|
+
recommendedAction: 'throttle',
|
|
455
|
+
trustImpact: -50,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// 2. Success rate drop
|
|
460
|
+
const successDrop =
|
|
461
|
+
profile.baseline.successRate.mean - profile.recentWindow.successRateLastHour;
|
|
462
|
+
|
|
463
|
+
if (successDrop > 0.2) {
|
|
464
|
+
alerts.push({
|
|
465
|
+
severity: 'medium',
|
|
466
|
+
type: 'success_rate_drop',
|
|
467
|
+
description: `Success rate dropped ${(successDrop * 100).toFixed(1)}%`,
|
|
468
|
+
evidence: {
|
|
469
|
+
baseline: profile.baseline.successRate.mean,
|
|
470
|
+
current: profile.recentWindow.successRateLastHour,
|
|
471
|
+
},
|
|
472
|
+
recommendedAction: 'warn',
|
|
473
|
+
trustImpact: -20,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 3. New capability usage
|
|
478
|
+
if (profile.recentWindow.newActionsInLastHour.length > 3) {
|
|
479
|
+
alerts.push({
|
|
480
|
+
severity: 'low',
|
|
481
|
+
type: 'new_capabilities',
|
|
482
|
+
description: `Agent using ${profile.recentWindow.newActionsInLastHour.length} new capabilities`,
|
|
483
|
+
evidence: {
|
|
484
|
+
newActions: profile.recentWindow.newActionsInLastHour,
|
|
485
|
+
},
|
|
486
|
+
recommendedAction: 'log',
|
|
487
|
+
trustImpact: -5,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// 4. Unusual resource access
|
|
492
|
+
const suspiciousResources = profile.recentWindow.newResourcesInLastHour.filter(r =>
|
|
493
|
+
r.includes('.env') || r.includes('credentials') || r.includes('secret')
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
if (suspiciousResources.length > 0) {
|
|
497
|
+
alerts.push({
|
|
498
|
+
severity: 'critical',
|
|
499
|
+
type: 'suspicious_resource_access',
|
|
500
|
+
description: 'Agent accessing sensitive resources',
|
|
501
|
+
evidence: {
|
|
502
|
+
resources: suspiciousResources,
|
|
503
|
+
},
|
|
504
|
+
recommendedAction: 'suspend',
|
|
505
|
+
trustImpact: -150,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return alerts;
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### 5.2 Trust Score Integration
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
async function updateTrustScoreFromBehavior(
|
|
517
|
+
agentDID: string,
|
|
518
|
+
anomalies: AnomalyAlert[]
|
|
519
|
+
): Promise<number> {
|
|
520
|
+
// Get current trust score from TSG
|
|
521
|
+
const currentScore = await tsg.getTrustScore(agentDID);
|
|
522
|
+
|
|
523
|
+
// Apply trust impact from anomalies
|
|
524
|
+
const totalImpact = anomalies.reduce((sum, alert) => sum + alert.trustImpact, 0);
|
|
525
|
+
|
|
526
|
+
// Update trust score
|
|
527
|
+
const newScore = Math.max(0, Math.min(1000, currentScore + totalImpact));
|
|
528
|
+
|
|
529
|
+
await tsg.updateTrustScore(agentDID, newScore, {
|
|
530
|
+
reason: 'behavior_monitoring',
|
|
531
|
+
anomalies: anomalies.map(a => a.type),
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// Take recommended actions
|
|
535
|
+
for (const alert of anomalies) {
|
|
536
|
+
switch (alert.recommendedAction) {
|
|
537
|
+
case 'suspend':
|
|
538
|
+
await suspendAgent(agentDID, alert.description);
|
|
539
|
+
break;
|
|
540
|
+
case 'throttle':
|
|
541
|
+
await applyRateLimit(agentDID, 0.5); // 50% of normal rate
|
|
542
|
+
break;
|
|
543
|
+
case 'warn':
|
|
544
|
+
await notifyOperator(agentDID, alert);
|
|
545
|
+
break;
|
|
546
|
+
case 'log':
|
|
547
|
+
await logAnomaly(agentDID, alert);
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return newScore;
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
## 6. AgentCard Integration
|
|
559
|
+
|
|
560
|
+
### 6.1 AgentCard Schema
|
|
561
|
+
|
|
562
|
+
**On-chain AgentCard** (ERC-721 NFT with extended metadata):
|
|
563
|
+
|
|
564
|
+
```solidity
|
|
565
|
+
// Simplified AgentCard smart contract
|
|
566
|
+
contract AgentCard {
|
|
567
|
+
struct Card {
|
|
568
|
+
string did; // W3C DID
|
|
569
|
+
string name;
|
|
570
|
+
string description;
|
|
571
|
+
string[] capabilities; // Advertised capabilities
|
|
572
|
+
uint256 trustScore; // Current TSG score
|
|
573
|
+
uint8 tier; // T0-T5
|
|
574
|
+
bool certified; // AgentAnchor certification
|
|
575
|
+
address certifier; // Certifying organization
|
|
576
|
+
uint256 certificationDate;
|
|
577
|
+
string metadataURI; // IPFS link to full metadata
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
mapping(uint256 => Card) public cards;
|
|
581
|
+
mapping(string => uint256) public didToTokenId;
|
|
582
|
+
|
|
583
|
+
function mint(
|
|
584
|
+
string memory did,
|
|
585
|
+
string memory name,
|
|
586
|
+
string[] memory capabilities
|
|
587
|
+
) public returns (uint256) {
|
|
588
|
+
uint256 tokenId = _nextTokenId++;
|
|
589
|
+
cards[tokenId] = Card({
|
|
590
|
+
did: did,
|
|
591
|
+
name: name,
|
|
592
|
+
description: "",
|
|
593
|
+
capabilities: capabilities,
|
|
594
|
+
trustScore: 0,
|
|
595
|
+
tier: 0, // T0 by default
|
|
596
|
+
certified: false,
|
|
597
|
+
certifier: address(0),
|
|
598
|
+
certificationDate: 0,
|
|
599
|
+
metadataURI: ""
|
|
600
|
+
});
|
|
601
|
+
didToTokenId[did] = tokenId;
|
|
602
|
+
_safeMint(msg.sender, tokenId);
|
|
603
|
+
return tokenId;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function certify(
|
|
607
|
+
uint256 tokenId,
|
|
608
|
+
uint256 trustScore,
|
|
609
|
+
uint8 tier
|
|
610
|
+
) public onlyAuthorized {
|
|
611
|
+
cards[tokenId].certified = true;
|
|
612
|
+
cards[tokenId].certifier = msg.sender;
|
|
613
|
+
cards[tokenId].certificationDate = block.timestamp;
|
|
614
|
+
cards[tokenId].trustScore = trustScore;
|
|
615
|
+
cards[tokenId].tier = tier;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function revokeCertification(uint256 tokenId) public onlyAuthorized {
|
|
619
|
+
cards[tokenId].certified = false;
|
|
620
|
+
cards[tokenId].tier = 0;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### 6.2 Off-chain Metadata (IPFS)
|
|
626
|
+
|
|
627
|
+
```json
|
|
628
|
+
{
|
|
629
|
+
"name": "FinanceBot v2.1",
|
|
630
|
+
"description": "Autonomous financial transaction agent with T3 certification",
|
|
631
|
+
"image": "ipfs://QmXyz.../agentcard.png",
|
|
632
|
+
"attributes": [
|
|
633
|
+
{ "trait_type": "Trust Score", "value": 520 },
|
|
634
|
+
{ "trait_type": "Trust Tier", "value": "T3" },
|
|
635
|
+
{ "trait_type": "Certified", "value": "true" },
|
|
636
|
+
{ "trait_type": "Certifier", "value": "AgentAnchor" },
|
|
637
|
+
{ "trait_type": "Primary Capability", "value": "Financial Transactions" },
|
|
638
|
+
{ "trait_type": "Created", "value": "2026-01-15" }
|
|
639
|
+
],
|
|
640
|
+
"capabilities": {
|
|
641
|
+
"file_operations": ["read", "write"],
|
|
642
|
+
"network": ["http", "https"],
|
|
643
|
+
"database": ["read", "write"],
|
|
644
|
+
"financial": ["payment_processing", "balance_query"],
|
|
645
|
+
"compliance": ["gdpr", "soc2"]
|
|
646
|
+
},
|
|
647
|
+
"restrictions": {
|
|
648
|
+
"no_external_code_execution": true,
|
|
649
|
+
"no_credential_access": true,
|
|
650
|
+
"max_transaction_amount": 10000
|
|
651
|
+
},
|
|
652
|
+
"kya": {
|
|
653
|
+
"did": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
654
|
+
"verificationMethods": [
|
|
655
|
+
{
|
|
656
|
+
"type": "Ed25519VerificationKey2020",
|
|
657
|
+
"publicKey": "z5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk"
|
|
658
|
+
}
|
|
659
|
+
],
|
|
660
|
+
"accountabilityChain": "https://vorion.org/accountability/5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
661
|
+
"behaviorProfile": "https://vorion.org/behavior/5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk"
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
---
|
|
667
|
+
|
|
668
|
+
## 7. Integration with Kaizen + TSG
|
|
669
|
+
|
|
670
|
+
### 7.1 Kaizen INTENT Layer Integration
|
|
671
|
+
|
|
672
|
+
```typescript
|
|
673
|
+
// Kaizen INTENT layer verifies identity before parsing
|
|
674
|
+
async function parseIntent(rawGoal: string, agentDID: string): Promise<StructuredPlan> {
|
|
675
|
+
// 1. KYA: Verify identity
|
|
676
|
+
const identityProof = await requestIdentityProof(agentDID);
|
|
677
|
+
const identityValid = await kya.verifyIdentity(identityProof);
|
|
678
|
+
|
|
679
|
+
if (!identityValid) {
|
|
680
|
+
throw new Error('KYA identity verification failed');
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// 2. Parse intent
|
|
684
|
+
const intent = await llm.parse(rawGoal);
|
|
685
|
+
|
|
686
|
+
// 3. KYA: Check authorization for parsed actions
|
|
687
|
+
for (const action of intent.actions) {
|
|
688
|
+
const authDecision = await kya.authorize({
|
|
689
|
+
agentDID,
|
|
690
|
+
action: action.type,
|
|
691
|
+
resource: action.endpoint || action.params.resource,
|
|
692
|
+
context: { timestamp: Date.now() },
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
if (!authDecision.allowed) {
|
|
696
|
+
throw new Error(`KYA authorization denied: ${authDecision.reason}`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
return intent;
|
|
701
|
+
}
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
### 7.2 TSG Behavior Monitoring Integration
|
|
705
|
+
|
|
706
|
+
```typescript
|
|
707
|
+
// TSG monitors behavior continuously and updates trust score
|
|
708
|
+
setInterval(async () => {
|
|
709
|
+
const activeAgents = await tsg.getActiveAgents();
|
|
710
|
+
|
|
711
|
+
for (const agentDID of activeAgents) {
|
|
712
|
+
// Run KYA anomaly detection
|
|
713
|
+
const anomalies = await kya.detectAnomalies(agentDID);
|
|
714
|
+
|
|
715
|
+
if (anomalies.length > 0) {
|
|
716
|
+
// Update trust score based on anomalies
|
|
717
|
+
await kya.updateTrustScoreFromBehavior(agentDID, anomalies);
|
|
718
|
+
|
|
719
|
+
// Log to accountability chain
|
|
720
|
+
for (const anomaly of anomalies) {
|
|
721
|
+
await kya.accountabilityChain.append({
|
|
722
|
+
id: generateId(),
|
|
723
|
+
timestamp: Date.now(),
|
|
724
|
+
agentDID,
|
|
725
|
+
action: 'anomaly_detected',
|
|
726
|
+
resource: 'behavior_monitoring',
|
|
727
|
+
outcome: 'success',
|
|
728
|
+
evidence: { anomaly },
|
|
729
|
+
signature: await signRecord(anomaly),
|
|
730
|
+
chainLink: { prevHash: null },
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}, 60000); // Every 1 minute
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
---
|
|
739
|
+
|
|
740
|
+
## 8. Compliance & Standards
|
|
741
|
+
|
|
742
|
+
### 8.1 W3C DID Standards
|
|
743
|
+
|
|
744
|
+
- **DID Core**: https://www.w3.org/TR/did-core/
|
|
745
|
+
- **DID Resolution**: https://w3c-ccg.github.io/did-resolution/
|
|
746
|
+
- **Ed25519 Signature 2020**: https://w3c-ccg.github.io/lds-ed25519-2020/
|
|
747
|
+
|
|
748
|
+
### 8.2 OAuth 2.0 Integration
|
|
749
|
+
|
|
750
|
+
KYA can integrate with OAuth 2.0 for capability delegation:
|
|
751
|
+
|
|
752
|
+
```json
|
|
753
|
+
{
|
|
754
|
+
"grant_type": "urn:ietf:params:oauth:grant-type:did-authn",
|
|
755
|
+
"did": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
756
|
+
"scope": "file:write network:http",
|
|
757
|
+
"proof": {
|
|
758
|
+
"type": "Ed25519Signature2020",
|
|
759
|
+
"challenge": "nonce_abc123",
|
|
760
|
+
"signature": "..."
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
---
|
|
766
|
+
|
|
767
|
+
## 9. Security Considerations
|
|
768
|
+
|
|
769
|
+
### 9.1 Threat Model
|
|
770
|
+
|
|
771
|
+
| Threat | Mitigation |
|
|
772
|
+
|--------|------------|
|
|
773
|
+
| **Identity Spoofing** | Ed25519 signatures, DID resolution verification |
|
|
774
|
+
| **Replay Attacks** | Timestamp freshness checks, nonce challenges |
|
|
775
|
+
| **Capability Escalation** | Least-privilege principle, capability expiration |
|
|
776
|
+
| **Accountability Tampering** | Hash-linked chain, Merkle roots, blockchain anchoring |
|
|
777
|
+
| **Behavior Manipulation** | Multi-dimensional anomaly detection, baseline profiling |
|
|
778
|
+
| **DID Document Hijacking** | Controller verification, rotation mechanisms |
|
|
779
|
+
|
|
780
|
+
### 9.2 Privacy Considerations
|
|
781
|
+
|
|
782
|
+
- **Selective Disclosure**: Agents can share only necessary capabilities
|
|
783
|
+
- **Zero-Knowledge Proofs**: Optional ZK proofs for accountability without revealing details
|
|
784
|
+
- **Anonymization**: DID rotation for privacy-sensitive operations
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
|
|
788
|
+
## 10. Implementation Roadmap
|
|
789
|
+
|
|
790
|
+
### Phase 1: Foundation (Q1 2026)
|
|
791
|
+
- [x] KYA specification v1.0
|
|
792
|
+
- [ ] W3C DID resolver implementation
|
|
793
|
+
- [ ] Ed25519 signature library integration
|
|
794
|
+
- [ ] BASIS policy engine with KYA hooks
|
|
795
|
+
|
|
796
|
+
### Phase 2: AgentCard (Q2 2026)
|
|
797
|
+
- [ ] AgentCard smart contract deployment (Polygon)
|
|
798
|
+
- [ ] IPFS metadata storage
|
|
799
|
+
- [ ] AgentAnchor certification portal
|
|
800
|
+
- [ ] NFT marketplace integration
|
|
801
|
+
|
|
802
|
+
### Phase 3: Behavior Monitoring (Q3 2026)
|
|
803
|
+
- [ ] Real-time anomaly detection engine
|
|
804
|
+
- [ ] Baseline profiling system
|
|
805
|
+
- [ ] Trust score auto-adjustment
|
|
806
|
+
- [ ] Alert notification system
|
|
807
|
+
|
|
808
|
+
### Phase 4: Production (Q4 2026)
|
|
809
|
+
- [ ] Full Kaizen + TSG + KYA integration
|
|
810
|
+
- [ ] Cross-platform DID interoperability
|
|
811
|
+
- [ ] Enterprise deployment (AgentAnchor)
|
|
812
|
+
- [ ] Certification API for third parties
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
## 11. API Reference
|
|
817
|
+
|
|
818
|
+
### 11.1 Identity Verification
|
|
819
|
+
|
|
820
|
+
```typescript
|
|
821
|
+
POST /api/v1/kya/verify-identity
|
|
822
|
+
|
|
823
|
+
Request:
|
|
824
|
+
{
|
|
825
|
+
"did": "did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1XmDcL4nVk",
|
|
826
|
+
"challenge": "nonce_abc123",
|
|
827
|
+
"signature": "...",
|
|
828
|
+
"timestamp": 1706083200000
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
Response:
|
|
832
|
+
{
|
|
833
|
+
"valid": true,
|
|
834
|
+
"trustScore": 520,
|
|
835
|
+
"tier": "T3",
|
|
836
|
+
"capabilities": ["file_read", "file_write", "network_http"]
|
|
837
|
+
}
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
### 11.2 Authorization Check
|
|
841
|
+
|
|
842
|
+
```typescript
|
|
843
|
+
POST /api/v1/kya/authorize
|
|
844
|
+
|
|
845
|
+
Request:
|
|
846
|
+
{
|
|
847
|
+
"agentDID": "did:vorion:ed25519:...",
|
|
848
|
+
"action": "file.write",
|
|
849
|
+
"resource": "/data/document.txt",
|
|
850
|
+
"context": {
|
|
851
|
+
"timestamp": 1706083200000,
|
|
852
|
+
"sourceIP": "192.168.1.100"
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
Response:
|
|
857
|
+
{
|
|
858
|
+
"allowed": true,
|
|
859
|
+
"reason": "Authorized",
|
|
860
|
+
"conditions": {
|
|
861
|
+
"maxFileSize": 10485760
|
|
862
|
+
},
|
|
863
|
+
"trustImpact": 1
|
|
864
|
+
}
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
### 11.3 Accountability Query
|
|
868
|
+
|
|
869
|
+
```typescript
|
|
870
|
+
GET /api/v1/kya/accountability/{agentDID}?limit=100&offset=0
|
|
871
|
+
|
|
872
|
+
Response:
|
|
873
|
+
{
|
|
874
|
+
"records": [
|
|
875
|
+
{
|
|
876
|
+
"id": "acc_123",
|
|
877
|
+
"timestamp": 1706083200000,
|
|
878
|
+
"action": "file.write",
|
|
879
|
+
"resource": "/data/document.txt",
|
|
880
|
+
"outcome": "success",
|
|
881
|
+
"hash": "abc123...",
|
|
882
|
+
"prevHash": "def456...",
|
|
883
|
+
"signature": "..."
|
|
884
|
+
}
|
|
885
|
+
],
|
|
886
|
+
"total": 1542,
|
|
887
|
+
"chainValid": true,
|
|
888
|
+
"brokenLinks": 0
|
|
889
|
+
}
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
---
|
|
893
|
+
|
|
894
|
+
## 12. References
|
|
895
|
+
|
|
896
|
+
- W3C Decentralized Identifiers (DIDs) v1.0: https://www.w3.org/TR/did-core/
|
|
897
|
+
- OAuth 2.0 Authorization Framework: https://tools.ietf.org/html/rfc6749
|
|
898
|
+
- Ed25519 Signature Algorithm: https://ed25519.cr.yp.to/
|
|
899
|
+
- BASIS Policy Framework: `basis-core/specs/policy-framework.md`
|
|
900
|
+
- Kaizen Runtime Spec: `packages/kaizen/docs/architecture.md`
|
|
901
|
+
- TSG Trust Scoring: `packages/tsg/docs/trust-model.md`
|
|
902
|
+
|
|
903
|
+
---
|
|
904
|
+
|
|
905
|
+
**Document Version**: 1.0.0
|
|
906
|
+
**Last Updated**: 2026-01-22
|
|
907
|
+
**Status**: Draft for Review
|
|
908
|
+
**Next Review**: After Phase 1 implementation
|
|
909
|
+
**Maintained By**: BASIS Standards Committee
|
|
910
|
+
**License**: CC BY 4.0 (Specification), Apache 2.0 (Reference Implementation)
|