EIPs Explained

ERC-7777 · Review(评审中) · ERC · 2024-09-29

ERC-7777: Governance for Human Robot Societies

定义两个合约接口:用于由硬件密钥支撑的机器人身份的 IUniversalIdentity,以及用于由人类和机器人组成、基于规则的社区的 IUniversalCharter,使它们可以在链上注册、同意规则并接受合规检查。

它解决什么问题?

作者预计,机器人和其他非人类代理将越来越多地与人类一起行动和交易。这类机器没有护照,没有决定适用哪国法律的出生地,也无法使用普通的银行服务。该提案认为,公共区块链是一个中立的场所,可以为它们赋予身份,并让人类和机器人自愿加入共同的规则集。

ERC-7777 为此标准化了合约接口:一个用于机器人的身份,另一个用于"章程"(charter,即拥有一套规则的社区),人类和机器人可以加入、遵守和退出。有了标准接口,工具就能与任何章程或身份合约配合使用,而不必让每个项目各自发明一套。

它如何运作

IUniversalIdentity(每个机器人一个合约):

  • getHardwareIdentity() 返回一个 HardwareIdentity 结构体:与硬件绑定的公钥、制造商、运营方、型号、序列号,以及初始和当前系统状态哈希(如固件)的签名。
  • generateChallenge() 和 verifyChallenge(challenge, signature) 实现挑战-应答:任何人都可以要求机器人用其安全元件(secure element)的密钥对一个新的挑战进行签名,以证明它就是自称的那台物理设备。
  • addRule(bytes) / removeRule(bytes) 记录机器人同意遵守哪些规则;规则是编码为 bytes 的纯文本,例如 "A robot must keep a 1m distance from humans."
  • checkCompliance(bytes rule) 报告机器人是否遵守某条规则。

IUniversalCharter(每个社区一个合约):

  • registerUser(UserType, bytes[] ruleSet),其中 UserType 为 Human 或 Robot。合约在注册前必须(MUST)检查合规性。
  • leaveSystem(),只有用户本人可以调用,同样要先进行合规检查。
  • checkCompliance(user, ruleSet),应该(SHOULD)在用户的身份合约上调用每条规则。
  • updateRuleSet(...) 和 terminateContract(),应该(SHOULD)限制为授权账户才能调用。

事件(UserRegistered、UserLeft、RuleSetUpdated、RuleAdded、SubscribedToCharter 等)让每一次变更对链下系统都可见。

示例代码

章程接口(来自规范):

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IUniversalCharter {
    enum UserType { Human, Robot }

    function registerUser(UserType userType, bytes[] memory ruleSet) external;
    function leaveSystem() external;
    function checkCompliance(address user, bytes[] memory ruleSet) external view returns (bool);
    function updateRuleSet(bytes[] memory newRuleSet) external;
    function terminateContract() external;

    event UserRegistered(address indexed user, UserType userType, bytes[] ruleSet);
    event UserLeft(address indexed user);
    event ComplianceChecked(address indexed user, bytes[] ruleSet);
    event RuleSetUpdated(bytes[] newRuleSet, address updatedBy);
}

机器人加入章程。在参考实现中,注册的地址是机器人的身份合约,因此注册要通过它进行(updateCompliance 和 subscribeAndRegisterToCharter 是参考实现的辅助函数,不属于接口):

import { Contract, toUtf8Bytes } from "ethers";

const rule = toUtf8Bytes("A robot must keep a 1m distance from humans.");
const identity = new Contract(IDENTITY, [
  "function addRule(bytes)",
  "function updateCompliance(bytes,bool)",
  "function subscribeAndRegisterToCharter(address,uint256)",
], ownerSigner);

await (await identity.addRule(rule)).wait();
await (await identity.updateCompliance(rule, true)).wait();
await (await identity.subscribeAndRegisterToCharter(CHARTER, 1n)).wait(); // rule set version 1

需要注意

  • 状态:Review。 在成为 Final 之前,接口仍可能变化。
  • "合规"的意义取决于设置它的人。在参考实现中,由身份合约的所有者设置合规状态,因此链上检查反映的是所有者的声明,而不是对行为的物理验证。它的硬件挑战检查也只是占位实现。
  • 规则管理和所有权对安全至关重要:请限制 addRule、removeRule、合规更新和 updateRuleSet 的调用权限,并防止可升级的初始化函数被重复执行。
  • 大型规则集在传递和检查时会消耗大量 gas;规范建议限制其大小。
  • 关于自主代理的链上身份和声誉的相关方案,请参见 ERC-8004。

#identity #robots #governance #interface

详细信息

作者
OpenMind, Jan Liphardt <[email protected]>, Shaohong Zhong (@ShaohongZ), Boyuan Chen (@bchen-dev), Paige Xu <[email protected]>, James Ball <[email protected]>, Thamer Dridi <[email protected]>
状态
Review(评审中)
类型
Standards Track / ERC
创建日期
2024-09-29

机器可读数据: Markdown · JSON