---
eip: 3030
label: EIP-3030
title: BLS Remote Signer HTTP API
status: Stagnant
type: Standards Track
category: Interface
created: 2020-09-30
official: https://eips.ethereum.org/EIPS/eip-3030
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3030.md
canonical: https://eips.huatuo.xyz/zh/eip-3030/
lang: zh
tldr: 提议一个仅含三个端点的极简 HTTP API，让共识层验证者客户端可以向独立的远程签名器请求 BLS 签名，使验证者密钥不必存放在验证者主机上。
tags: [validator, bls, remote-signer, staking, api]
---

# EIP-3030: BLS Remote Signer HTTP API

> This EIP defines a HTTP API standard for a BLS remote signer, consumed by validator clients to sign block proposals and attestations in the context of Ethereum 2.0 (eth2).

**TL;DR:** 提议一个仅含三个端点的极简 HTTP API，让共识层验证者客户端可以向独立的远程签名器请求 BLS 签名，使验证者密钥不必存放在验证者主机上。

## 它解决什么问题？

权益证明验证者用 BLS12-381 私钥对区块提案和证明（attestation）签名，这把密钥必须在每个 epoch 都可用。客户端通常把该密钥放在与验证者客户端相同的机器上。在锁定严密的服务器上这没问题，但在云虚拟机或 Kubernetes 集群中就有风险，恶意的运维人员或被攻陷的节点可以读取磁盘或内存。

EIP-3030 标准化了**远程签名器**：一个独立的、严格受控的服务，只有它持有密钥，并通过简单的 HTTP API 返回签名。支持该 API 的验证者客户端就可以运行在任何地方。

## 它如何运作

按设计只有三个端点（规范称之为 UNIX 哲学）：

| 方法 | 路径 | 返回 |
| --- | --- | --- |
| `GET` | `/upcheck` | `{"status": "OK"}` |
| `GET` | `/keys` | 签名器持有的公钥 |
| `POST` | `/sign/:identifier` | 针对给定公钥（十六进制，不带 `0x`）的 `{"signature": "0x…"}` |

签名请求的请求体包含：

- `bls_domain`：`beacon_proposer`、`beacon_attester` 或 `randao`
- `data`：要签名的区块、证明或 epoch
- `fork`：`Fork` 对象（先前版本和当前版本）
- `genesis_validators_root`：用于跨链的域分隔

未知字段会被忽略。错误码为：请求有误时返回 `400`，找不到密钥时返回 `404`。

其他一切都刻意不在范围内：身份验证（例如请求头令牌加 TLS，或网络 ACL）、密钥的创建与删除，以及传输加密，都交由实现者或放在签名器前面的代理来处理。

## 示例代码

从验证者一侧的脚本调用签名器（TypeScript，`fetch`）：

```ts
const SIGNER = "http://localhost:9000";

const keys: { keys: string[] } = await (await fetch(`${SIGNER}/keys`)).json();
const pubkey = keys.keys[0]; // hex, no 0x prefix

const res = await fetch(`${SIGNER}/sign/${pubkey}`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    bls_domain: "beacon_attester",
    data: attestationData,            // AttestationData object
    fork: currentFork,                // { previous_version, current_version, epoch }
    genesis_validators_root: gvr,     // 0x-prefixed 32-byte hash
  }),
});
if (!res.ok) throw new Error((await res.json()).error);
const { signature } = await res.json(); // 0x-prefixed 96-byte BLS signature
```

## 需要注意

- **状态：Stagnant。** 提案本身没有推进，但远程签名已成为常见做法。规范列出了 Sigma Prime、PegaSys（Web3Signer）和 Prysmatic Labs 的实现，并指出 Web3Signer 使用不同的路径（例如 `/api/v1/eth2/sign`）。请查阅你所用签名器自己的文档，不要假定就是这些路由。
- **惩罚（slashing）风险转移到签名器。** 能访问该 API 的攻击者可能请求一个相互冲突的签名。威胁模型指出，运营方必须在签名器内部或前面增加校验（slashing 保护）。
- 密钥绝不应能通过任何签名器接口写入；尽可能把它们存放在 HSM 或密钥管理服务中。
- 切勿把签名器暴露在公网上；应把身份验证与 TLS 和网络限制结合使用。
- 相关的密钥标准：[EIP-2333](/eip-2333/) 密钥派生和 [EIP-2335](/eip-2335/) 密钥库。


---

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