灵隙(synapse) v1.0.0 版本

This commit is contained in:
lychang
2026-06-29 02:12:44 +08:00
parent 2c59efe0ca
commit 65710a4536
27 changed files with 1819 additions and 760 deletions

View File

@@ -18,6 +18,7 @@
### 1.1 问题陈述
现有协议假设存在中心化的注册表(如灵脉 Meridian),但在以下场景中:
- 临时 P2P 网络
- 跨组织协作
- 离线/断网环境
@@ -27,13 +28,13 @@
### 1.2 设计目标
| 目标 | 说明 |
|-----|------|
| 目标 | 说明 |
|-------|-----------------|
| 身份可验证 | AgentID 无法伪造或冒用 |
| 去中心化 | 无需中心化注册表 |
| 高可用 | 无单点故障 |
| 可扩展 | 支持大规模 Agent 网络 |
| 可读性 | 支持人类可读别名(可选) |
| 去中心化 | 无需中心化注册表 |
| 高可用 | 无单点故障 |
| 可扩展 | 支持大规模 Agent 网络 |
| 可读性 | 支持人类可读别名(可选) |
---
@@ -52,41 +53,41 @@ AgentID = {namespace}:{key_hash}:{alias}
did:synapse:abc123def456:chat-bot
```
| 部分 | 格式 | 说明 |
|------|------|------|
| namespace | string | 命名空间(如 `synapse`) |
| key_hash | base58 | 公钥哈希的前 16 字节 |
| alias | string(可选) | 人类可读别名 |
| 部分 | 格式 | 说明 |
|-----------|------------|-------------------|
| namespace | string | 命名空间(如 `synapse`) |
| key_hash | base58 | 公钥哈希的前 16 字节 |
| alias | string(可选) | 人类可读别名 |
### 2.2 生成算法
```go
func GenerateAgentID(privateKey []byte, namespace string, alias string) string {
// 1. 从私钥派生公钥
publicKey := crypto.GeneratePublicKey(privateKey)
// 2. 计算公钥哈希
hash := sha3.Sum256(publicKey)
// 3. 取前 16 字节,Base58 编码
keyHash := base58.Encode(hash[:16])
// 4. 组装完整 ID
if alias != "" {
return fmt.Sprintf("%s:%s:%s", namespace, keyHash, alias)
}
return fmt.Sprintf("%s:%s", namespace, keyHash)
// 1. 从私钥派生公钥
publicKey := crypto.GeneratePublicKey(privateKey)
// 2. 计算公钥哈希
hash := sha3.Sum256(publicKey)
// 3. 取前 16 字节,Base58 编码
keyHash := base58.Encode(hash[:16])
// 4. 组装完整 ID
if alias != "" {
return fmt.Sprintf("%s:%s:%s", namespace, keyHash, alias)
}
return fmt.Sprintf("%s:%s", namespace, keyHash)
}
```
### 2.3 ID 特性
| 特性 | 说明 |
|------|------|
| 唯一性 | 相同公钥 → 相同 key_hash → 相同 AgentID |
| 不可伪造 | 无法在没有私钥的情况下生成有效 AgentID |
| 可验证 | 任何人都可以用公钥验证 AgentID 真实性 |
| 不可预测 | 私钥随机生成,key_hash 不可预测 |
| 特性 | 说明 |
|------|---------------------------------|
| 唯一性 | 相同公钥 → 相同 key_hash → 相同 AgentID |
| 不可伪造 | 无法在没有私钥的情况下生成有效 AgentID |
| 可验证 | 任何人都可以用公钥验证 AgentID 真实性 |
| 不可预测 | 私钥随机生成,key_hash 不可预测 |
---
@@ -120,10 +121,10 @@ func GenerateAgentID(privateKey []byte, namespace string, alias string) string {
```go
type SignedMessage struct {
Message *UnifiedSynapseMessage // 原始消息
Signature []byte // 签名
PublicKey []byte // 公钥
AgentID string // Agent 标识
Message *UnifiedSynapseMessage // 原始消息
Signature []byte // 签名
PublicKey []byte // 公钥
AgentID string // Agent 标识
}
```
@@ -139,11 +140,11 @@ signature_content =
### 3.4 签名算法
| 算法 | 说明 |
|------|------|
| Ed25519 | 默认,高效且安全 |
| ECDSA-P256 | 兼容性选项 |
| RSA-2048 | 遗留系统兼容 |
| 算法 | 说明 |
|------------|----------|
| Ed25519 | 默认,高效且安全 |
| ECDSA-P256 | 兼容性选项 |
| RSA-2048 | 遗留系统兼容 |
---
@@ -151,11 +152,11 @@ signature_content =
### 4.1 发现机制选择
| 场景 | 推荐机制 |
|------|---------|
| 小规模(<100 Agent) | 广播查询 |
| 中规模(100-10000) | 分层 DHT |
| 大规模(>10000) | 完整 Kademlia |
| 场景 | 推荐机制 |
|-----------------|-------------|
| 小规模(<100 Agent) | 广播查询 |
| 中规模(100-10000) | 分层 DHT |
| 大规模(>10000) | 完整 Kademlia |
### 4.2 广播查询协议
@@ -201,26 +202,26 @@ Agent A 想知道 Agent B 的 Endpoint:
### 4.4 DHT 消息类型
| 消息类型 | 说明 |
|---------|------|
| `dht:ping` | 节点存活探测 |
| `dht:store` | 存储 Agent 记录 |
| `dht:find_node` | 查找附近节点 |
| 消息类型 | 说明 |
|------------------|-------------|
| `dht:ping` | 节点存活探测 |
| `dht:store` | 存储 Agent 记录 |
| `dht:find_node` | 查找附近节点 |
| `dht:find_value` | 查找 Agent 记录 |
| `dht:notify` | 通知记录更新 |
| `dht:notify` | 通知记录更新 |
### 4.5 Agent 记录结构
```go
type AgentRecord struct {
AgentID string // Agent 唯一标识
Alias string // 人类可读别名(可选)
Endpoint string // 网络地址
PublicKey []byte // 公钥
TTL int64 // 记录有效期(秒)
Version uint64 // 版本号(递增)
Signature []byte // Agent 对以上字段的签名
Timestamp int64 // 发布时间戳
AgentID string // Agent 唯一标识
Alias string // 人类可读别名(可选)
Endpoint string // 网络地址
PublicKey []byte // 公钥
TTL int64 // 记录有效期(秒)
Version uint64 // 版本号(递增)
Signature []byte // Agent 对以上字段的签名
Timestamp int64 // 发布时间戳
}
```
@@ -263,6 +264,7 @@ record_signature_content =
```
**核心思想**:
- Agent 在区块链智能合约中注册身份
- 注册需要质押一定数量的代币作为保证金
- 心跳通过交易上链更新
@@ -449,13 +451,13 @@ did:synapse:{method-specific-id}
**DID 方法**:
| 方法 | 说明 |
|------|------|
| `did:synapse:ethereum` | 基于以太坊链上注册表 |
| `did:synapse:polygon` | 基于 Polygon 链 |
| `did:synapse:solana` | 基于 Solana 链 |
| `did:synapse:key` | 基于公钥的离链 DID |
| `did:synapse:dht` | 基于 DHT 的离链 DID |
| 方法 | 说明 |
|------------------------|----------------|
| `did:synapse:ethereum` | 基于以太坊链上注册表 |
| `did:synapse:polygon` | 基于 Polygon 链 |
| `did:synapse:solana` | 基于 Solana 链 |
| `did:synapse:key` | 基于公钥的离链 DID |
| `did:synapse:dht` | 基于 DHT 的离链 DID |
**DID Document 示例**:
@@ -466,18 +468,25 @@ did:synapse:{method-specific-id}
"https://www.w3.org/ns/synapse/v1"
],
"id": "did:synapse:ethereum:0x1234abcd5678",
"verificationMethod": [{
"id": "did:synapse:ethereum:0x1234abcd5678#keys-1",
"type": "EcdsaSecp256k1VerificationKey2019",
"controller": "did:synapse:ethereum:0x1234abcd5678",
"publicKeyHex": "02b3..."
}],
"service": [{
"id": "did:synapse:ethereum:0x1234abcd5678#synapse-agent",
"type": "SynapseAgent",
"serviceEndpoint": "https://agent-01.example.com/api/synapse"
}],
"synapse:capabilities": ["text_generation", "image_generation"],
"verificationMethod": [
{
"id": "did:synapse:ethereum:0x1234abcd5678#keys-1",
"type": "EcdsaSecp256k1VerificationKey2019",
"controller": "did:synapse:ethereum:0x1234abcd5678",
"publicKeyHex": "02b3..."
}
],
"service": [
{
"id": "did:synapse:ethereum:0x1234abcd5678#synapse-agent",
"type": "SynapseAgent",
"serviceEndpoint": "https://agent-01.example.com/api/synapse"
}
],
"synapse:capabilities": [
"text_generation",
"image_generation"
],
"synapse:agentName": "智能写作助手",
"synapse:version": "1.0.0"
}
@@ -485,14 +494,14 @@ did:synapse:{method-specific-id}
### 4.1.4 区块链平台选择
| 平台 | 优点 | 缺点 | 适合场景 |
|------|------|------|---------|
| Ethereum | 生态最大、安全最高 | Gas 贵、延迟高 | 高价值交易、核心 Agent |
| Polygon | 低 Gas、快确认 | 中心化程度较高 | 中等价值、大量 Agent |
| Solana | 高吞吐、低延迟 | 稳定性偶有问题 | 高频心跳场景 |
| 联盟链 | 可控、隐私好 | 需要许可机制 | 企业内部、联盟合作 |
| L2 (Arbitrum) | 低 Gas、安全继承 | 复杂度较高 | 通用场景 |
| 本地私链 | 完全可控、零成本 | 信任范围有限 | 测试、内部系统 |
| 平台 | 优点 | 缺点 | 适合场景 |
|---------------|------------|-----------|----------------|
| Ethereum | 生态最大、安全最高 | Gas 贵、延迟高 | 高价值交易、核心 Agent |
| Polygon | 低 Gas、快确认 | 中心化程度较高 | 中等价值、大量 Agent |
| Solana | 高吞吐、低延迟 | 稳定性偶有问题 | 高频心跳场景 |
| 联盟链 | 可控、隐私好 | 需要许可机制 | 企业内部、联盟合作 |
| L2 (Arbitrum) | 低 Gas、安全继承 | 复杂度较高 | 通用场景 |
| 本地私链 | 完全可控、零成本 | 信任范围有限 | 测试、内部系统 |
### 4.1.5 混合架构(推荐)
@@ -526,43 +535,43 @@ did:synapse:{method-specific-id}
```go
type HybridLookup struct {
// L1: 本地缓存(内存,TTL 1分钟)
LocalCache map[string]*AgentRecord
// L2: DHT 网络(分钟级一致性)
DHT DHTClient
// L3: 区块链(最终一致性源)
Blockchain BlockchainClient
// L1: 本地缓存(内存,TTL 1分钟)
LocalCache map[string]*AgentRecord
// L2: DHT 网络(分钟级一致性)
DHT DHTClient
// L3: 区块链(最终一致性源)
Blockchain BlockchainClient
}
func (h *HybridLookup) Find(agentID string) (*AgentRecord, error) {
// 1. 查本地缓存
if record, ok := h.LocalCache.Get(agentID); ok {
if record.IsFresh() {
return record, nil
}
}
// 2. 查 DHT
if record, err := h.DHT.FindValue(agentID); err == nil {
// 验证签名
if record.VerifySignature() {
h.LocalCache.Set(agentID, record)
return record, nil
}
}
// 3. 查区块链(最终源)
if record, err := h.Blockchain.Lookup(agentID); err == nil {
// 验证链上签名(已由链上合约验证过)
h.LocalCache.Set(agentID, record)
// 广播到 DHT 加速后续查询
h.DHT.Store(agentID, record)
return record, nil
}
return nil, ErrAgentNotFound
// 1. 查本地缓存
if record, ok := h.LocalCache.Get(agentID); ok {
if record.IsFresh() {
return record, nil
}
}
// 2. 查 DHT
if record, err := h.DHT.FindValue(agentID); err == nil {
// 验证签名
if record.VerifySignature() {
h.LocalCache.Set(agentID, record)
return record, nil
}
}
// 3. 查区块链(最终源)
if record, err := h.Blockchain.Lookup(agentID); err == nil {
// 验证链上签名(已由链上合约验证过)
h.LocalCache.Set(agentID, record)
// 广播到 DHT 加速后续查询
h.DHT.Store(agentID, record)
return record, nil
}
return nil, ErrAgentNotFound
}
```
@@ -570,13 +579,13 @@ func (h *HybridLookup) Find(agentID string) (*AgentRecord, error) {
区块链还可实现链上治理功能:
| 功能 | 说明 |
|------|------|
| 功能 | 说明 |
|------|---------------------------|
| 质押机制 | Agent 注册需质押代币,恶意行为被 slash |
| 信誉评分 | 链上可查的 Agent 信誉分 |
| 服务定价 | 智能合约自动结算任务费用 |
| 争议仲裁 | 链上投票仲裁 Agent 纠纷 |
| 协议升级 | 通过 DAO 投票决定协议升级 |
| 信誉评分 | 链上可查的 Agent 信誉分 |
| 服务定价 | 智能合约自动结算任务费用 |
| 争议仲裁 | 链上投票仲裁 Agent 纠纷 |
| 协议升级 | 通过 DAO 投票决定协议升级 |
---
@@ -584,12 +593,12 @@ func (h *HybridLookup) Find(agentID string) (*AgentRecord, error) {
### 5.1 冲突场景
| 场景 | 说明 |
|------|------|
| 同一公钥注册多个别名 | 允许(同一 Agent 的多个别名) |
| 不同公钥生成相同 AgentID | 不可能(公钥哈希唯一) |
| 伪造他人 AgentID | 不可能(无法伪造签名) |
| Endpoint 欺骗 | 需要额外验证 |
| 场景 | 说明 |
|------------------|--------------------|
| 同一公钥注册多个别名 | 允许(同一 Agent 的多个别名) |
| 不同公钥生成相同 AgentID | 不可能(公钥哈希唯一) |
| 伪造他人 AgentID | 不可能(无法伪造签名) |
| Endpoint 欺骗 | 需要额外验证 |
### 5.2 Endpoint 绑定验证
@@ -611,33 +620,33 @@ func (h *HybridLookup) Find(agentID string) (*AgentRecord, error) {
```go
// 挑战消息
type Challenge struct {
ChallengeID string // 挑战 ID
Nonce []byte // 随机数
Timestamp int64 // 发送时间
ChallengeID string // 挑战 ID
Nonce []byte // 随机数
Timestamp int64 // 发送时间
}
// 响应消息
type ChallengeResponse struct {
ChallengeID string // 对应的挑战 ID
Nonce []byte // 原样返回的随机数
Signature []byte // 对 Nonce 的签名
ChallengeID string // 对应的挑战 ID
Nonce []byte // 原样返回的随机数
Signature []byte // 对 Nonce 的签名
}
// 验证流程
func VerifyEndpoint(endpoint string, publicKey []byte, challenge *Challenge) bool {
// 1. 发送挑战到 Endpoint
resp := SendChallenge(endpoint, challenge)
// 2. 验证响应
if resp.ChallengeID != challenge.ChallengeID {
return false // 挑战 ID 不匹配
}
if !bytes.Equal(resp.Nonce, challenge.Nonce) {
return false // Nonce 被篡改
}
// 3. 验证签名
return crypto.Verify(publicKey, challenge.Nonce, resp.Signature)
// 1. 发送挑战到 Endpoint
resp := SendChallenge(endpoint, challenge)
// 2. 验证响应
if resp.ChallengeID != challenge.ChallengeID {
return false // 挑战 ID 不匹配
}
if !bytes.Equal(resp.Nonce, challenge.Nonce) {
return false // Nonce 被篡改
}
// 3. 验证签名
return crypto.Verify(publicKey, challenge.Nonce, resp.Signature)
}
```
@@ -678,40 +687,40 @@ func VerifyEndpoint(endpoint string, publicKey []byte, challenge *Challenge) boo
### 6.2 生命周期消息
| 状态 | 说明 | 触发条件 |
|------|------|---------|
| offline | 离线 | 初始状态或主动注销 |
| online | 上线中 | 注册完成,等待首次心跳 |
| active | 活跃 | 定期心跳维持 |
| 状态 | 说明 | 触发条件 |
|------------|-----|-----------------|
| offline | 离线 | 初始状态或主动注销 |
| online | 上线中 | 注册完成,等待首次心跳 |
| active | 活跃 | 定期心跳维持 |
| refreshing | 刷新中 | 更新 Endpoint 或别名 |
| suspended | 挂起 | 心跳超时,未注销 |
| offline | 离线 | 注销或永久离线 |
| suspended | 挂起 | 心跳超时,未注销 |
| offline | 离线 | 注销或永久离线 |
### 6.3 消息类型
| 消息类型 | 方向 | 说明 |
|---------|------|------|
| `identity:register` | → 网络 | 注册 Agent 身份 |
| `identity:refresh` | → 网络 | 刷新注册信息 |
| `identity:challenge` | 双向 | Endpoint 验证挑战 |
| `identity:challenge_response` | 双向 | 挑战响应 |
| `identity:revoke` | → 网络 | 注销身份 |
| `identity:lookup` | → 网络 | 查询 Agent 信息 |
| `identity:lookup_response` | → 网络 | 查询响应 |
| `identity:announce` | → 网络 | 广播在线状态 |
| `identity:heartbeat` | → 网络 | 心跳保活 |
| 消息类型 | 方向 | 说明 |
|-------------------------------|------|---------------|
| `identity:register` | → 网络 | 注册 Agent 身份 |
| `identity:refresh` | → 网络 | 刷新注册信息 |
| `identity:challenge` | 双向 | Endpoint 验证挑战 |
| `identity:challenge_response` | 双向 | 挑战响应 |
| `identity:revoke` | → 网络 | 注销身份 |
| `identity:lookup` | → 网络 | 查询 Agent 信息 |
| `identity:lookup_response` | → 网络 | 查询响应 |
| `identity:announce` | → 网络 | 广播在线状态 |
| `identity:heartbeat` | → 网络 | 心跳保活 |
### 6.4 Register 载荷
```go
type IdentityRegisterPayload struct {
AgentID string // Agent 标识
Alias string // 人类可读别名
Endpoint string // 网络地址
PublicKey []byte // 公钥
TTL int64 // 注册有效期
Version uint64 // 版本号
Signature []byte // Agent 签名
AgentID string // Agent 标识
Alias string // 人类可读别名
Endpoint string // 网络地址
PublicKey []byte // 公钥
TTL int64 // 注册有效期
Version uint64 // 版本号
Signature []byte // Agent 签名
}
```
@@ -719,10 +728,10 @@ type IdentityRegisterPayload struct {
```go
type IdentityHeartbeatPayload struct {
AgentID string // Agent 标识
Endpoint string // 当前 Endpoint(可能变化)
TTL int64 // 续期时间
Signature []byte // Agent 签名
AgentID string // Agent 标识
Endpoint string // 当前 Endpoint(可能变化)
TTL int64 // 续期时间
Signature []byte // Agent 签名
}
```
@@ -732,48 +741,48 @@ type IdentityHeartbeatPayload struct {
### 7.1 威胁模型
| 威胁 | 场景 | 防护措施 |
|------|------|---------|
| 身份伪造 | 攻击者声称自己是他人 | 公钥派生 ID + 签名验证 |
| Endpoint 欺骗 | 攻击者声称他人 Endpoint | 挑战-响应协议 |
| 重放攻击 | 攻击者重放旧消息 | 时间戳 + Nonce |
| 中间人攻击 | 拦截并修改消息 | TLS + 签名验证 |
| 女巫攻击 | 一个节点伪装多个身份 | 工作量证明或权益证明(可选) |
| 日食攻击 | 隔离目标节点 | 多路径查询 |
| 威胁 | 场景 | 防护措施 |
|-------------|------------------|----------------|
| 身份伪造 | 攻击者声称自己是他人 | 公钥派生 ID + 签名验证 |
| Endpoint 欺骗 | 攻击者声称他人 Endpoint | 挑战-响应协议 |
| 重放攻击 | 攻击者重放旧消息 | 时间戳 + Nonce |
| 中间人攻击 | 拦截并修改消息 | TLS + 签名验证 |
| 女巫攻击 | 一个节点伪装多个身份 | 工作量证明或权益证明(可选) |
| 日食攻击 | 隔离目标节点 | 多路径查询 |
### 7.2 重放攻击防护
```go
type AntiReplay struct {
RecentNonces map[string]int64 // nonce -> timestamp
Window time.Duration // 时间窗口(5分钟)
RecentNonces map[string]int64 // nonce -> timestamp
Window time.Duration // 时间窗口(5分钟)
}
func (a *AntiReplay) CheckAndAdd(nonce string, timestamp int64) bool {
// 1. 检查时间戳是否在窗口内
now := time.Now().Unix()
if now - timestamp > int64(a.Window.Seconds()) {
return false // 时间戳太旧
}
// 2. 检查 Nonce 是否已使用
if _, exists := a.RecentNonces[nonce]; exists {
return false // 重放
}
// 3. 记录
a.RecentNonces[nonce] = timestamp
return true
// 1. 检查时间戳是否在窗口内
now := time.Now().Unix()
if now - timestamp > int64(a.Window.Seconds()) {
return false // 时间戳太旧
}
// 2. 检查 Nonce 是否已使用
if _, exists := a.RecentNonces[nonce]; exists {
return false // 重放
}
// 3. 记录
a.RecentNonces[nonce] = timestamp
return true
}
```
### 7.3 私钥保护
| 场景 | 建议 |
|------|------|
| 本地运行 | 使用密钥文件 + 操作系统密钥链 |
| 云端运行 | 使用 HSM/KMS |
| 嵌入式设备 | 使用 TPM |
| 场景 | 建议 |
|------------|---------------------------------|
| 本地运行 | 使用密钥文件 + 操作系统密钥链 |
| 云端运行 | 使用 HSM/KMS |
| 嵌入式设备 | 使用 TPM |
| 多 Agent 共享 | 密钥分片(如 Shamir's Secret Sharing) |
---
@@ -786,33 +795,33 @@ func (a *AntiReplay) CheckAndAdd(nonce string, timestamp int64) bool {
```go
type AgentEndpoint struct {
AgentID string // 扩展:基于公钥派生
AgentName string // 人类可读名称
SystemID string // 所属系统
Endpoint string // 回调端点
Version string // Agent 版本
// 新增字段
PublicKey []byte // 公钥(用于验证)
Namespace string // 命名空间
Alias string // 人类可读别名
AgentID string // 扩展:基于公钥派生
AgentName string // 人类可读名称
SystemID string // 所属系统
Endpoint string // 回调端点
Version string // Agent 版本
// 新增字段
PublicKey []byte // 公钥(用于验证)
Namespace string // 命名空间
Alias string // 人类可读别名
}
```
### 8.2 与灵脉(Meridian)的整合
| 模式 | 行为 |
|------|------|
| 中心化可用 | 使用灵脉作为主注册表,本草案作为备份 |
| 去中心化 | 使用本草案的 DHT 机制,完全去中心化 |
| 混合模式 | 核心 Agent 使用中心化,边缘 Agent 使用去中心化 |
| 模式 | 行为 |
|-------|--------------------------------|
| 中心化可用 | 使用灵脉作为主注册表,本草案作为备份 |
| 去中心化 | 使用本草案的 DHT 机制,完全去中心化 |
| 混合模式 | 核心 Agent 使用中心化,边缘 Agent 使用去中心化 |
### 8.3 与灵玺(Sigil)的整合
| 组件 | 职责 |
|------|------|
| 灵玺(Sigil) | 密钥管理、签名验证 |
| 本草案 | ID 生成、发现协议、生命周期 |
| 组件 | 职责 |
|-----------|-----------------|
| 灵玺(Sigil) | 密钥管理、签名验证 |
| 本草案 | ID 生成、发现协议、生命周期 |
---
@@ -820,36 +829,36 @@ type AgentEndpoint struct {
### 9.1 消息类型列表
| 类型 | 协议前缀 | 说明 |
|------|---------|------|
| `identity:register` | 前端 | 注册身份 |
| `identity:refresh` | 前端 | 刷新注册 |
| `identity:revoke` | 前端 | 注销身份 |
| `identity:challenge` | 前端 | 挑战请求 |
| `identity:challenge_response` | 前端 | 挑战响应 |
| `identity:lookup` | 前端 | 查询身份 |
| `identity:lookup_response` | 前端 | 查询响应 |
| `identity:announce` | 前端 | 广播在线 |
| `identity:heartbeat` | 前端 | 心跳保活 |
| `dht:ping` | DHT | 节点探测 |
| `dht:store` | DHT | 存储记录 |
| `dht:find_node` | DHT | 查找节点 |
| `dht:find_value` | DHT | 查找值 |
| `dht:notify` | DHT | 通知更新 |
| 类型 | 协议前缀 | 说明 |
|-------------------------------|------|------|
| `identity:register` | 前端 | 注册身份 |
| `identity:refresh` | 前端 | 刷新注册 |
| `identity:revoke` | 前端 | 注销身份 |
| `identity:challenge` | 前端 | 挑战请求 |
| `identity:challenge_response` | 前端 | 挑战响应 |
| `identity:lookup` | 前端 | 查询身份 |
| `identity:lookup_response` | 前端 | 查询响应 |
| `identity:announce` | 前端 | 广播在线 |
| `identity:heartbeat` | 前端 | 心跳保活 |
| `dht:ping` | DHT | 节点探测 |
| `dht:store` | DHT | 存储记录 |
| `dht:find_node` | DHT | 查找节点 |
| `dht:find_value` | DHT | 查找值 |
| `dht:notify` | DHT | 通知更新 |
---
## 10. 待解决问题(Open Issues)
| 问题 | 说明 | 优先级 |
|------|------|--------|
| 隐私保护 | 公钥哈希是否暴露身份? | 高 |
| 密钥轮换 | 私钥更换后如何保持 AgentID? | 高 |
| 名称冲突 | 人类可读别名可能重复 | 中 |
| 性能优化 | DHT 查找延迟 | 中 |
| 移动 Agent | Endpoint 频繁变化 | 低 |
| 链上 Gas 成本 | 区块链交易费用 | 中 |
| DID 方法注册 | W3C 标准 DID 方法注册流程 | 低 |
| 问题 | 说明 | 优先级 |
|-----------|--------------------|-----|
| 隐私保护 | 公钥哈希是否暴露身份? | 高 |
| 密钥轮换 | 私钥更换后如何保持 AgentID? | 高 |
| 名称冲突 | 人类可读别名可能重复 | 中 |
| 性能优化 | DHT 查找延迟 | 中 |
| 移动 Agent | Endpoint 频繁变化 | 低 |
| 链上 Gas 成本 | 区块链交易费用 | 中 |
| DID 方法注册 | W3C 标准 DID 方法注册流程 | 低 |
---
@@ -858,28 +867,31 @@ type AgentEndpoint struct {
### 11.1 分阶段实现
**Phase 1(最小可行)**:
- 实现 AgentID 公钥派生
- 实现消息签名验证
- 使用广播进行发现
**Phase 2(基本功能)**:
- 实现分层 DHT
- 实现生命周期管理
- 实现挑战-响应协议
**Phase 3(完整功能)**:
- 实现完整 Kademlia
- 实现隐私保护
- 实现密钥轮换
### 11.2 推荐库
| 功能 | 推荐库 |
|------|--------|
| 加密签名 | golang.org/x/crypto/ed25519 |
| Base58 | github.com/mr-tron/base58 |
| DHT | github.com/anacrolix/go-libutp 或自实现 |
| 分布式存储 | etcd/consul(混合模式) |
| 功能 | 推荐库 |
|--------|-------------------------------------|
| 加密签名 | golang.org/x/crypto/ed25519 |
| Base58 | github.com/mr-tron/base58 |
| DHT | github.com/anacrolix/go-libutp 或自实现 |
| 分布式存储 | etcd/consul(混合模式) |
---