---
eip: 1895
label: EIP-1895
title: Support for an Elliptic Curve Cycle
status: Stagnant
type: Standards Track
category: Core
created: 2018-03-31
official: https://eips.ethereum.org/EIPS/eip-1895
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1895.md
canonical: https://eips.huatuo.xyz/zh/eip-1895/
lang: zh
tldr: 提议在 MNT4 曲线上提供加法、乘法和配对的 EVM 预编译，它是配对友好曲线环的一部分，可让 SNARK 递归地验证其他 SNARK。
tags: [precompile, cryptography, zk-snark, elliptic-curves, core]
---

# EIP-1895: Support for an Elliptic Curve Cycle

> The EVM currently supports elliptic curves operations for curve alt-bn128 thanks to precompiles ecadd and ecmul and ecpairing. The classes MNT4 and 6 contain cycles of curves. Those cycles enable doing operations on one curve inside a SNARK on the other curve (and reversely).

**TL;DR:** 提议在 MNT4 曲线上提供加法、乘法和配对的 EVM 预编译，它是配对友好曲线环的一部分，可让 SNARK 递归地验证其他 SNARK。

## 它解决什么问题？

EVM 的椭圆曲线预编译（[EIP-196](/eip-196/) 的加法/乘法和 [EIP-197](/eip-197/) 的配对）只支持 alt_bn128（BN254）曲线。这足以验证单个 zk-SNARK，但在链上验证成千上万个证明则会过于昂贵。

**递归 SNARK** 通过在另一个证明内部证明“我验证了这些证明”来解决这个问题，使许多证明合并成一个。要高效地做到这一点，需要一个配对友好曲线的*环（cycle）*，其中每条曲线的群阶与另一条曲线的域大小相匹配。BN254 没有这样的搭档。MNT4 和 MNT6 家族是已知能形成这种环的配对友好曲线，因此 EIP-1895 提议为 EVM 增加 MNT4 支持。

## 它如何运作

- 三个新的预编译：**MNT4** 上的 `ecadd`、`ecmul` 和 `ecpairing`，与现有的 BN254 那一套相对应。
- 规范列出了曲线参数：约 298 位的素数域 `p` 和群阶 `q`，曲线 `Y^2 = X^3 + aX + b`（`a = 2`），以及 G1 和 G2 的生成元（G2 位于二次扩域上）。
- 点将使用压缩编码：X 坐标加上一个字节 `s`，用来标记无穷远点（`0x00`），或表示 Y 是偶数（`0x02`）还是奇数（`0x03`）。
- gas 成本在等待基准测试期间保留为“待估算”。

## 示例代码

合约会如何调用这样的预编译。下面的地址和输入布局只是占位符，因为规范从未分配过它们：

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

contract Mnt4Caller {
    // Placeholder only: EIP-1895 did not assign a precompile address.
    address constant MNT4_ADD = address(0);

    function add(bytes calldata p1, bytes calldata p2) external view returns (bytes memory out) {
        (bool ok, bytes memory ret) = MNT4_ADD.staticcall(abi.encodePacked(p1, p2));
        require(ok, "precompile failed");
        return ret;
    }
}
```

## 需要注意

- 状态：**Stagnant**。这些预编译从未被加入以太坊。
- 规范并不完整：缺少预编译地址、输入编码细节和 gas 价格，G2 域定义的一部分被标注为“待补全”。
- 作者指出，所提议的 MNT4 曲线只提供约 80 位的安全性，而且域元素超过 256 位。
- [EIP-1962](/eip-1962/) 提出了一种涵盖多种曲线的通用方案。以太坊最终采用的曲线预编译是通过 [EIP-2537](/eip-2537/) 加入的 BLS12-381。


---

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