---
eip: 1962
label: EIP-1962
title: EC arithmetic and pairings with runtime definitions
status: Stagnant
type: Standards Track
category: Core
created: 2019-04-22
requires: 1109
official: https://eips.ethereum.org/EIPS/eip-1962
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1962.md
canonical: https://eips.huatuo.xyz/zh/eip-1962/
lang: zh
tldr: 提出一组通用的 EVM 预编译，用于椭圆曲线运算和配对，曲线参数在调用时传入，这样新增曲线就不需要硬分叉。
tags: [precompile, cryptography, elliptic-curves, pairings, core]
---

# EIP-1962: EC arithmetic and pairings with runtime definitions

> This proposal is an extension and formalization of EIP-1829 with an inclusion of pairings. EIP-1109 is required due to low cost of some operations compared to the STATICCALL opcode (more information in the corresponding section below).

**TL;DR:** 提出一组通用的 EVM 预编译，用于椭圆曲线运算和配对，曲线参数在调用时传入，这样新增曲线就不需要硬分叉。

## 它解决什么问题？

隐私和扩容协议依赖椭圆曲线运算和配对，但 EVM 只为一条曲线 BN254 提供了预编译（地址 `0x06`–`0x08`）。每增加一条曲线，例如 BLS12-381 或适合递归证明的曲线，都需要单独的 EIP 和一次硬分叉。

EIP-1962 提出的预编译把曲线作为**运行时输入**：调用者在传入点的同时，传入域模数、系数和扩域结构。这样开发者无需等待网络升级，就可以使用和试验新曲线。它在 [EIP-1829](/eip-1829/) 的基础上加入了配对。

## 它如何运作

该规范定义了十种运算：

- 基域上的曲线：点加法、标量乘法，以及对 N 个（标量，点）对的多标量乘法（multi-exponentiation）。
- 二次或三次扩域上曲线的同样三种运算（G2 需要）。
- 四个曲线族的配对：**BLS12**、**BN**、**MNT4** 和 **MNT6**。

主要设计选择：

- gas 根据传入的参数（模数大小、运算类型、配对数量）尽早估算，这样节点可以快速拒绝定价过高的调用。
- 多标量乘法单独作为一种运算，因为它比重复做标量乘法便宜得多。
- 不支持点解压缩，因为平方根的成本很难通用地定价。
- 它依赖 [EIP-1109](/eip-1109/)（`PRECOMPILEDCALL`），因为当时 `STATICCALL` 700 gas 的成本会在点加法这类廉价运算中占据主导。

作为备选方案，该规范建议先从一份固定的曲线白名单（BN254、BLS12-381、BLS12-377 等）开始。

## 示例代码

从 Solidity 调用一个通用预编译。地址和字节布局只是占位符：规范把 ABI 和 gas 计划交给了外部文档，并且没有分配地址：

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

contract GenericCurveCaller {
    address constant EC_PRECOMPILE = address(0); // not assigned by EIP-1962

    function call(bytes calldata curveParamsAndInput) external view returns (bytes memory) {
        // input = operation id || field modulus || A || B || group order || points/scalars ...
        (bool ok, bytes memory out) = EC_PRECOMPILE.staticcall(curveParamsAndInput);
        require(ok, "EC op failed");
        return out;
    }
}
```

## 需要注意

- 状态：**Stagnant**。它没有被纳入任何升级。
- 详细的二进制接口和 gas 计划位于 EIP 之外，即实现方的文档中，因此仅凭这份 EIP 并不是完整的规范。
- 以太坊最终通过 [EIP-2537](/eip-2537/) 采用了针对 BLS12-381 的固定曲线预编译，以灵活性换取更简单的实现和定价。
- 规范本身指出了实现、调试和定价这类通用运算的难度，并建议限制初始支持的曲线集合。


---

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