---
eip: 7619
label: EIP-7619
title: Precompile Falcon512 generic verifier
status: Draft
type: Standards Track
category: Core
created: 2023-07-03
official: https://eips.ethereum.org/EIPS/eip-7619
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7619.md
canonical: https://eips.huatuo.xyz/zh/eip-7619/
lang: zh
tldr: 提议在 0x65 处添加预编译，以低成本验证 Falcon-512 后量子签名，使智能合约和智能账户能够使用抗量子密钥对用户进行认证。
tags: [precompile, post-quantum, signatures, falcon, cryptography]
---

# EIP-7619: Precompile Falcon512 generic verifier

> Add precompiled contract that allows generic signature verifications using Falcon512 postquantum algorithm

**TL;DR:** 提议在 0x65 处添加预编译，以低成本验证 Falcon-512 后量子签名，使智能合约和智能账户能够使用抗量子密钥对用户进行认证。

## 它解决什么问题？

以太坊账户由 secp256k1 上的 ECDSA 保护。运行 Shor 算法的足够大的量子计算机可以从公钥恢复私钥，从而破解 ECDSA 及类似方案。后量子签名算法已经存在，但在 Solidity 中验证它们非常昂贵：作者报告称，他们用 Solidity 实现的 Falcon 验证器因 gas 成本而无法扩展，主要原因在于 Falcon 所依赖的 SHAKE256 哈希。

EIP-7619 提议为 **Falcon-512** 提供原生预编译。Falcon-512 是 NIST 后量子标准化流程中的一种基于格的方案，达到 NIST 安全等级 I，密钥和签名相对较小。有了低成本的链上验证，智能合约钱包（例如 [ERC-4337](/eip-4337/) 账户）就可以要求 Falcon 签名，以取代 ECDSA 或与 ECDSA 并用。

## 它如何运作

- **地址：** `0x65`。
- **输入：** 拼接的字节 `[public key: 897][signature: 666][message: rest]`。实现取自 PQClean 项目。
- **输出：** 一个 32 字节的字，签名有效时为 `...01`，否则为 `...00`。
- **失败行为：** 调用只会因 gas 不足而失败。长度错误、数据格式错误和无效签名都返回 `0`，而不是 revert。
- **Gas：** `1465 + 6 × (输入中 32 字节字的数量)`，通过与 `ecrecover` 对比基准测试得出。

该预编译只做验证。密钥生成和签名在链下进行。

## 示例代码

按规范示例编写的、包装该预编译的 Solidity 封装：

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

library Falcon512 {
    address constant PRECOMPILE = address(0x65);

    /// publicKey: 897 bytes, signature: 666 bytes (per EIP-7619 encoding)
    function verify(bytes memory publicKey, bytes memory signature, bytes memory message)
        internal view returns (bool)
    {
        (bool ok, bytes memory out) =
            PRECOMPILE.staticcall(abi.encodePacked(publicKey, signature, message));
        return ok && out.length == 32 && uint8(out[31]) == 1;
    }
}
```

32 字节消息的 gas 估算：

```text
input = 897 + 666 + 32 = 1595 bytes -> ceil(1595 / 32) = 50 words
gas   = 1465 + 6 * 50 = 1765
```

## 需要注意

- 状态为 **Draft**，该预编译尚未在以太坊主网激活。在没有它的链上，对 `0x65` 的调用会碰到空账户并且不返回数据，因此务必像上面那样检查输出长度。
- Falcon 签名长度可变，最长 666 字节，而输入布局使用固定的 666 字节槽位。规范没有说明较短的签名如何填充；依赖之前请对照参考实现澄清这一点。
- 地址 `0x65` 在任何升级中都尚未最终确定，规范指出它可能会被更改。
- 后续的 Falcon 支持提案 [EIP-8052](/eip-8052/)，以及 [EIP-8051](/eip-8051/) 等 ML-DSA 验证提案，涉及重叠的领域。选择基于哪一个构建之前请先比较。
- 后量子签名只有在账户不能同时被 ECDSA 密钥控制时才有帮助，所以它主要对智能合约账户有用。


---

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