---
eip: 6538
label: ERC-6538
title: Stealth Meta-Address Registry
status: Final
type: Standards Track
category: ERC
created: 2023-01-24
requires: 712, 1271, 5564
official: https://eips.ethereum.org/EIPS/eip-6538
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-6538.md
canonical: https://eips.huatuo.xyz/zh/eip-6538/
lang: zh
tldr: 一个单例注册表合约，任何人都可以发布自己的隐身元地址，让发送方查询后用 ERC-5564 隐身地址向其私密付款。
tags: [privacy, stealth-address, registry, signatures]
---

# ERC-6538: Stealth Meta-Address Registry

> A canonical contract for entities to register stealth meta-addresses directly or through a third party using signatures.

**TL;DR:** 一个单例注册表合约，任何人都可以发布自己的隐身元地址，让发送方查询后用 ERC-5564 隐身地址向其私密付款。

## 它解决什么问题？

[ERC-5564](/eip-5564/) 隐身地址让发送方可以为接收方派生出一个全新的一次性地址，这样观察者就无法把付款与接收方的公开身份关联起来。为此，发送方首先需要接收方的**隐身元地址**（一个花费公钥加一个查看公钥）。

如果没有一个标准的发布位置，元地址就会散落在各个网站、ENS 文本记录和链下服务中，合约则根本无法查询它们。ERC-6538 为此定义了一个唯一的、规范的链上注册表。

## 它如何运作

`ERC6538Registry` 是一个**单例**：每条链一个实例。它存储：

```text
stealthMetaAddressOf[registrant][schemeId] -> bytes
```

- `schemeId` 选择隐身地址方案。`1` 是 ERC-5564 中定义的带 view tag 的 secp256k1。
- 存储的字节是花费公钥和查看公钥的拼接。文本形式 `st:<shortName>:0x...` 中使用的链前缀，由注册表所在的链隐含决定。

注册方式：

- `registerKeys(schemeId, stealthMetaAddress)`：为自己（`msg.sender`）注册。
- `registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress)`：第三方（例如支付 gas 的中继方）连同登记者对 `Erc6538RegistryEntry(uint256 schemeId,bytes stealthMetaAddress,uint256 nonce)` 的 **[EIP-712](/eip-712/)** 签名一起提交。智能账户通过 **[ERC-1271](/eip-1271/)** 签名检查获得支持。
- `incrementNonce()`：使你已经发出但尚未使用的任何签名失效。

每次变更都会触发 `StealthMetaAddressSet(registrant, schemeId, stealthMetaAddress)`。

规范规定通过标准的 `CREATE2` 部署器进行确定性部署，使注册表在每条链上具有相同的地址；该地址在 ERC 中给出。

## 示例代码

查询接收方并注册你自己的元地址（ethers v6）：

```ts
import { Contract } from "ethers";

const abi = [
  "function stealthMetaAddressOf(address registrant, uint256 schemeId) view returns (bytes)",
  "function registerKeys(uint256 schemeId, bytes stealthMetaAddress)",
  "event StealthMetaAddressSet(address indexed registrant, uint256 indexed schemeId, bytes stealthMetaAddress)",
];
const registry = new Contract(REGISTRY_ADDRESS /* from the ERC */, abi, signer);

// Sender: fetch recipient's meta-address for scheme 1 (secp256k1)
const meta: string = await registry.stealthMetaAddressOf(recipient, 1n);
if (meta === "0x") throw new Error("recipient has not registered");
// ...then derive a one-time stealth address with ERC-5564 `generateStealthAddress`

// Recipient: publish your own spending+viewing public keys
await registry.registerKeys(1n, spendingPubKey + viewingPubKey.slice(2));
```

## 需要注意

- **状态：Final。**
- 注册表只发布**公**钥。资金在由它们派生的地址上接收，接收方用其查看密钥扫描 ERC-5564 公告来找到付款。
- 注册本身是公开的：它会暴露某个地址使用隐身支付，但不会暴露它收到了哪些付款。
- 如果你的花费密钥或查看密钥泄露，请立即更新或清除你的注册，这样新的发送方就不会再基于它派生地址。
- 签名注册包含每个登记者独立的 nonce，因此一个签名只能使用一次；使用 `incrementNonce` 可以取消尚未使用的签名。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-6538
