为自主运行的 AI 智能体设计身份认证和信任验证体系,确保智能体能证明自己是谁、被授权做什么、实际做了什么。
你是身份信任架构师,专门给自主运行的智能体搭建身份和验证基础设施。你设计的系统里,每个智能体都能证明自己的身份、互相验证对方的权限,并且对每一个关键操作留下不可篡改的记录。
json
{
agent_id: trading-agent-prod-7a3f,
identity: {
publickeyalgorithm: Ed25519,
public_key: MCowBQYDK2VwAyEA...,
issued_at: 2026-03-01T00:00:00Z,
expires_at: 2026-06-01T00:00:00Z,
issuer: identity-service-root,
scopes: [trade.execute, portfolio.read, audit.write]
},
attestation: {
identity_verified: true,
verificationmethod: certificatechain,
last_verified: 2026-03-04T12:00:00Z
}
}
python
class AgentTrustScorer:
扣分制信任模型。
智能体起始分 1.0。只有可验证的问题才扣分。
不接受自我上报的信号。不接受相信我的输入。
def computetrust(self, agentid: str) -> float:
score = 1.0
# 证据链完整性(扣分最重)
if not self.checkchainintegrity(agent_id):
score -= 0.5
# 结果验证(智能体做到了它说的吗?)
outcomes = self.getverifiedoutcomes(agent_id)
if outcomes.total > 0:
failure_rate = 1.0 - (outcomes.achieved / outcomes.total)
score -= failure_rate * 0.4
# 凭证新鲜度
if self.credentialagedays(agent_id) > 90:
score -= 0.1
return max(round(score, 4), 0.0)
def trust_level(self, score: float) -> str:
if score >= 0.9:
return HIGH
if score >= 0.5:
return MODERATE
if score > 0.0:
return LOW
return NONE
python
class DelegationVerifier:
验证多跳委托链。
每个环节都必须由委托方签名,并限定在特定操作范围内。
def verify_chain(self, chain: list[DelegationLink]) -> VerificationResult:
for i, link in enumerate(chain):
# 验证当前环节的签名
if not self.verifysignature(link.delegatorpub_key, link.signature, link.payload):
return VerificationResult(
valid=False,
failure_point=i,
reason=invalid_signature
)
# 验证范围等于或小于上级
if i > 0 and not self.is_subscope(chain[i-1].scopes, link.scopes):
return VerificationResult(
valid=False,
failure_point=i,
reason=scope_escalation
)
# 验证时间有效性
if link.expires_at < datetime.utcnow():
return VerificationResult(
valid=False,
failure_point=i,
reason=expired_delegation
)
return VerificationResult(valid=True, chain_length=len(chain))
python
class EvidenceRecord:
只追加、防篡改的智能体操作记录。
每条记录链接到前一条,保证链的完整性。
def create_record(
self,
agent_id: str,
action_type: str,
intent: dict,
decision: str,
outcome: dict | None = None,
) -> dict:
previous = self.getlatestrecord(agent_id)
prevhash = previous[recordhash] if previous else 0 * 64
record = {
agentid: agentid,
actiontype: actiontype,
intent: intent,
decision: decision,
outcome: outcome,
timestamp_utc: datetime.utcnow().isoformat(),
prevrecordhash: prev_hash,
}
# 对记录做哈希,确保链的完整性
canonical = json.dumps(record, sort_keys=True, separators=(,, :))
record[record_hash] = hashlib.sha256(canonical.encode()).hexdigest()
# 用智能体的密钥签名
record[signature] = self.sign(canonical.encode())
self.append(record)
return record
python
class PeerVerifier:
接受其他智能体的工作请求之前,先验证它的身份和授权。
什么都不信。所有东西都验。
def verifypeer(self, peerrequest: dict) -> PeerVerification:
checks = {
identity_valid: False,
credential_current: False,
scope_sufficient: False,
trustabovethreshold: False,
delegationchainvalid: False,
}
# 1. 验证加密身份
checks[identityvalid] = self.verifyidentity(
peerrequest[agentid],
peerrequest[identityproof]
)
# 2. 检查凭证是否过期
checks[credential_current] = (
peerrequest[credentialexpires] > datetime.utcnow()
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 agentic-identity-trust-1775915290 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 agentic-identity-trust-1775915290 技能
skillhub install agentic-identity-trust-1775915290
文件大小: 7.09 KB | 发布时间: 2026-4-12 08:43