{"eip":7885,"title":"Precompile for NTT operations","description":"Proposal to add a precompiled contract that performs number theoretical transformation (NTT) and inverse (InvNTT).","authors":["Renaud Dubois (@rdubois-crypto)","Simon Masson (@simonmasson)","Yoon Hyoung Lee (@yhl125)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2025-02-12","discussionsTo":"https://ethereum-magicians.org/t/eip-7885-precompile-for-ntt-operations/22895","repo":"EIPs","label":"EIP-7885","officialUrl":"https://eips.ethereum.org/EIPS/eip-7885","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7885.md","url":"https://eips.huatuo.xyz/eip-7885/","tldr":{"en":"Proposes precompiles for the Number Theoretic Transform (NTT), its inverse and vectorized modular add/multiply, so lattice-based post-quantum signatures and STARK verifiers become affordable on-chain.","ja":"数論変換（NTT）、その逆変換、ベクトル化されたモジュラー加算・乗算のプリコンパイルを提案する。格子ベースのポスト量子署名と STARK 検証をオンチェーンで現実的なコストにする。","ko":"수론 변환(NTT), 그 역변환, 벡터화된 모듈러 덧셈/곱셈 프리컴파일을 제안한다. 격자 기반 양자 내성 서명과 STARK 검증기를 온체인에서 감당할 만한 비용으로 만든다.","zh":"提议新增数论变换（NTT）、其逆变换以及向量化模加/模乘的预编译，使基于格的后量子签名和 STARK 验证器在链上变得负担得起。"},"tags":["precompile","post-quantum","cryptography","ntt","stark"],"explainers":{"en":{"lang":"en","tldr":"Proposes precompiles for the Number Theoretic Transform (NTT), its inverse and vectorized modular add/multiply, so lattice-based post-quantum signatures and STARK verifiers become affordable on-chain.","tags":["precompile","post-quantum","cryptography","ntt","stark"],"related":[8051,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7885/","markdown":"## What problem does it solve?\n\nEthereum accounts are secured by ECDSA, which a large enough quantum computer could break. The leading replacements, such as the lattice-based signatures FALCON and Dilithium (ML-DSA), spend most of their verification time multiplying polynomials. Done in Solidity, that is very expensive: the spec measures about 1.8M gas for one FALCON verification in hand-optimized Yul.\n\nRather than adding one precompile per signature scheme, EIP-7885 adds the shared building block: the NTT, the polynomial equivalent of an FFT. With NTT in the EVM, polynomial multiplication drops from O(n²) to O(n log n), and many schemes (FALCON, Dilithium, Kyber, and STARK verifiers over fields like BabyBear, Goldilocks or M31) can be built on top cheaply.\n\n## How it works\n\nPolynomials live in the ring `F_q[X]/(X^n + 1)`, where `n` is a power of two and the prime `q` satisfies `q ≡ 1 mod 2n`. Four precompiles are proposed:\n\n| Precompile | Operation |\n| --- | --- |\n| `NTT_FW` | Forward NTT (negative-wrapped convolution), output in bit-reversed order |\n| `NTT_INV` | Inverse NTT, back to standard order |\n| `NTT_VECMULMOD` | Element-wise `a[i] * b[i] mod q` |\n| `NTT_VECADDMOD` | Element-wise `a[i] + b[i] mod q` |\n\nMultiplying two polynomials `f` and `g` then becomes:\n\n```\nf × g = NTT_INV( VECMULMOD( NTT_FW(f), NTT_FW(g) ) )\n```\n\nThe input carries the ring degree, the modulus and the coefficients, so the same precompile serves different schemes. Gas is calibrated per scheme from benchmarks, aiming at roughly the same throughput (about 50–55 Mgas/s) as `ECRECOVER`; vector operations scale linearly with `n`.\n\n## Sample code\n\nIllustrative pseudocode for verifying a lattice signature with the precompiles (addresses are not final in the spec):\n\n```python\n# Polynomial product in Z_q[X]/(X^n + 1) using the proposed precompiles\ndef poly_mul(f, g, n, q):\n    F = call(NTT_FW,  encode(n, q, f))\n    G = call(NTT_FW,  encode(n, q, g))\n    H = call(NTT_VECMULMOD, encode(n, q, F + G))\n    return call(NTT_INV, encode(n, q, H))\n\n# e.g. FALCON-512: n = 512, q = 12289\n# A verifier computes s2 * h with poly_mul, adds c with VECADDMOD,\n# then checks the result's norm in ordinary EVM code.\n```\n\n## Things to know\n\n- Status is **Draft**. Precompile addresses are marked TBD in the specification, and the gas numbers and input encoding are still evolving. The security considerations section is unfinished.\n- The prototype in op-geth uses addresses `0x12`–`0x15`, but these are not assigned on mainnet.\n- The spec reports end-to-end tests on an OP-Stack testnet where a FALCON-512 verification fell from about 1.8M gas to under 480K gas.\n- A scheme-specific alternative is [EIP-8051](/eip-8051/), a precompile that verifies ML-DSA signatures directly. [EIP-7951](/eip-7951/) shows the precompile route for a classical (non-post-quantum) curve.\n"},"ja":{"lang":"ja","tldr":"数論変換（NTT）、その逆変換、ベクトル化されたモジュラー加算・乗算のプリコンパイルを提案する。格子ベースのポスト量子署名と STARK 検証をオンチェーンで現実的なコストにする。","tags":["precompile","post-quantum","cryptography","ntt","stark"],"related":[8051,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7885/","markdown":"## 何を解決するのか\n\nEthereum のアカウントは ECDSA で保護されていますが、十分に大きな量子コンピューターがあればこれを破れる可能性があります。格子ベースの署名 FALCON や Dilithium（ML-DSA）など、有力な代替方式は、検証時間の大半を多項式の乗算に費やします。これを Solidity で行うと非常に高価で、仕様では、手作業で最適化した Yul での FALCON 検証 1 回に約 1.8M ガスかかると計測しています。\n\nEIP-7885 は、署名方式ごとにプリコンパイルを 1 つ追加するのではなく、共通の構成要素を追加します。FFT に相当する多項式版の NTT です。EVM に NTT があれば、多項式の乗算は O(n²) から O(n log n) に下がり、多くの方式（FALCON、Dilithium、Kyber、そして BabyBear、Goldilocks、M31 などの体上の STARK 検証）をその上に安価に構築できます。\n\n## 仕組み\n\n多項式は環 `F_q[X]/(X^n + 1)` の上にあり、`n` は 2 のべき乗、素数 `q` は `q ≡ 1 mod 2n` を満たします。4 つのプリコンパイルが提案されています。\n\n| プリコンパイル | 演算 |\n| --- | --- |\n| `NTT_FW` | 順方向 NTT（negative-wrapped convolution）、出力はビット反転順 |\n| `NTT_INV` | 逆 NTT、標準の順序に戻す |\n| `NTT_VECMULMOD` | 要素ごとの `a[i] * b[i] mod q` |\n| `NTT_VECADDMOD` | 要素ごとの `a[i] + b[i] mod q` |\n\n2 つの多項式 `f` と `g` の乗算は次のようになります。\n\n```\nf × g = NTT_INV( VECMULMOD( NTT_FW(f), NTT_FW(g) ) )\n```\n\n入力には環の次数、法、係数が含まれるため、同じプリコンパイルでさまざまな方式に対応できます。ガスは方式ごとにベンチマークから調整され、`ECRECOVER` とほぼ同じスループット（約 50〜55 Mgas/s）を目指します。ベクトル演算は `n` に比例してスケールします。\n\n## サンプルコード\n\nプリコンパイルを使って格子署名を検証する説明用の擬似コード（アドレスは仕様では未確定）:\n\n```python\n# Polynomial product in Z_q[X]/(X^n + 1) using the proposed precompiles\ndef poly_mul(f, g, n, q):\n    F = call(NTT_FW,  encode(n, q, f))\n    G = call(NTT_FW,  encode(n, q, g))\n    H = call(NTT_VECMULMOD, encode(n, q, F + G))\n    return call(NTT_INV, encode(n, q, H))\n\n# e.g. FALCON-512: n = 512, q = 12289\n# A verifier computes s2 * h with poly_mul, adds c with VECADDMOD,\n# then checks the result's norm in ordinary EVM code.\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。仕様ではプリコンパイルのアドレスは TBD とされ、ガスの数値と入力のエンコーディングもまだ変わりつつあります。セキュリティ考慮事項の節は未完成です。\n- op-geth のプロトタイプはアドレス `0x12`〜`0x15` を使っていますが、メインネットでは割り当てられていません。\n- 仕様は、OP-Stack テストネットでのエンドツーエンドのテストで、FALCON-512 の検証が約 1.8M ガスから 480K ガス未満に下がったと報告しています。\n- 方式固有の代替案が [EIP-8051](/eip-8051/) で、ML-DSA 署名を直接検証するプリコンパイルです。[EIP-7951](/eip-7951/) は、従来型（ポスト量子ではない）の曲線に対するプリコンパイルの道筋を示しています。\n"},"ko":{"lang":"ko","tldr":"수론 변환(NTT), 그 역변환, 벡터화된 모듈러 덧셈/곱셈 프리컴파일을 제안한다. 격자 기반 양자 내성 서명과 STARK 검증기를 온체인에서 감당할 만한 비용으로 만든다.","tags":["precompile","post-quantum","cryptography","ntt","stark"],"related":[8051,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7885/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움 계정은 ECDSA로 보호되는데, 충분히 큰 양자 컴퓨터는 이를 깰 수 있습니다. 격자 기반 서명인 FALCON과 Dilithium(ML-DSA) 같은 유력한 대체 방식은 검증 시간의 대부분을 다항식 곱셈에 씁니다. 이를 Solidity로 하면 매우 비쌉니다. 명세는 손으로 최적화한 Yul에서 FALCON 검증 한 번에 약 1.8M 가스가 든다고 측정했습니다.\n\nEIP-7885는 서명 방식마다 프리컴파일을 하나씩 추가하는 대신, 공통 구성 요소를 추가합니다. FFT에 해당하는 다항식 버전인 NTT입니다. EVM에 NTT가 있으면 다항식 곱셈이 O(n²)에서 O(n log n)으로 줄어들고, 많은 방식(FALCON, Dilithium, Kyber, 그리고 BabyBear, Goldilocks, M31 같은 체 위의 STARK 검증기)을 그 위에 저렴하게 구축할 수 있습니다.\n\n## 어떻게 동작하나요?\n\n다항식은 환 `F_q[X]/(X^n + 1)` 위에 있으며, `n`은 2의 거듭제곱이고 소수 `q`는 `q ≡ 1 mod 2n`을 만족합니다. 네 가지 프리컴파일이 제안됩니다.\n\n| 프리컴파일 | 연산 |\n| --- | --- |\n| `NTT_FW` | 순방향 NTT(negative-wrapped convolution), 출력은 비트 반전 순서 |\n| `NTT_INV` | 역 NTT, 표준 순서로 복원 |\n| `NTT_VECMULMOD` | 요소별 `a[i] * b[i] mod q` |\n| `NTT_VECADDMOD` | 요소별 `a[i] + b[i] mod q` |\n\n두 다항식 `f`와 `g`의 곱셈은 다음과 같이 됩니다.\n\n```\nf × g = NTT_INV( VECMULMOD( NTT_FW(f), NTT_FW(g) ) )\n```\n\n입력에는 환의 차수, 법(modulus), 계수가 담기므로 같은 프리컴파일로 서로 다른 방식을 지원할 수 있습니다. 가스는 방식별로 벤치마크를 바탕으로 보정되며, `ECRECOVER`와 거의 같은 처리량(약 50–55 Mgas/s)을 목표로 합니다. 벡터 연산은 `n`에 선형으로 늘어납니다.\n\n## 샘플 코드\n\n프리컴파일로 격자 서명을 검증하는 설명용 의사 코드입니다(명세의 주소는 확정되지 않았습니다).\n\n```python\n# Polynomial product in Z_q[X]/(X^n + 1) using the proposed precompiles\ndef poly_mul(f, g, n, q):\n    F = call(NTT_FW,  encode(n, q, f))\n    G = call(NTT_FW,  encode(n, q, g))\n    H = call(NTT_VECMULMOD, encode(n, q, F + G))\n    return call(NTT_INV, encode(n, q, H))\n\n# e.g. FALCON-512: n = 512, q = 12289\n# A verifier computes s2 * h with poly_mul, adds c with VECADDMOD,\n# then checks the result's norm in ordinary EVM code.\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 명세에서 프리컴파일 주소는 TBD로 표시되어 있고, 가스 수치와 입력 인코딩도 아직 바뀌고 있습니다. 보안 고려 사항 절은 미완성입니다.\n- op-geth의 프로토타입은 주소 `0x12`–`0x15`를 사용하지만, 메인넷에서는 할당되지 않았습니다.\n- 명세는 OP-Stack 테스트넷에서의 엔드투엔드 테스트에서 FALCON-512 검증이 약 1.8M 가스에서 480K 가스 미만으로 줄었다고 보고합니다.\n- 방식 특화 대안은 [EIP-8051](/eip-8051/)로, ML-DSA 서명을 직접 검증하는 프리컴파일입니다. [EIP-7951](/eip-7951/)은 고전적(양자 내성이 아닌) 곡선에 대한 프리컴파일 경로를 보여 줍니다.\n"},"zh":{"lang":"zh","tldr":"提议新增数论变换（NTT）、其逆变换以及向量化模加/模乘的预编译，使基于格的后量子签名和 STARK 验证器在链上变得负担得起。","tags":["precompile","post-quantum","cryptography","ntt","stark"],"related":[8051,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7885/","markdown":"## 它解决什么问题？\n\n以太坊账户由 ECDSA 保护，而足够大的量子计算机有可能破解它。主要的替代方案，例如基于格的签名 FALCON 和 Dilithium（ML-DSA），验证时间的大部分都花在多项式乘法上。在 Solidity 中执行成本非常高：规范测得，用手工优化的 Yul 验证一次 FALCON 大约需要 1.8M gas。\n\nEIP-7885 没有为每种签名方案各加一个预编译，而是加入共享的基础构件：NTT，即多项式版本的 FFT。有了 EVM 中的 NTT，多项式乘法从 O(n²) 降到 O(n log n)，许多方案（FALCON、Dilithium、Kyber，以及基于 BabyBear、Goldilocks 或 M31 等域的 STARK 验证器）都可以在其上低成本构建。\n\n## 它如何运作\n\n多项式位于环 `F_q[X]/(X^n + 1)` 中，其中 `n` 是 2 的幂，素数 `q` 满足 `q ≡ 1 mod 2n`。提议了四个预编译：\n\n| 预编译 | 运算 |\n| --- | --- |\n| `NTT_FW` | 正向 NTT（negative-wrapped convolution），输出为位反转顺序 |\n| `NTT_INV` | 逆 NTT，恢复为标准顺序 |\n| `NTT_VECMULMOD` | 逐元素 `a[i] * b[i] mod q` |\n| `NTT_VECADDMOD` | 逐元素 `a[i] + b[i] mod q` |\n\n两个多项式 `f` 和 `g` 的乘法于是变为：\n\n```\nf × g = NTT_INV( VECMULMOD( NTT_FW(f), NTT_FW(g) ) )\n```\n\n输入中带有环的次数、模数和系数，因此同一个预编译可服务于不同的方案。gas 按方案根据基准测试校准，目标是与 `ECRECOVER` 大致相同的吞吐量（约 50–55 Mgas/s）；向量运算随 `n` 线性增长。\n\n## 示例代码\n\n使用这些预编译验证格签名的示意伪代码（规范中的地址尚未最终确定）：\n\n```python\n# Polynomial product in Z_q[X]/(X^n + 1) using the proposed precompiles\ndef poly_mul(f, g, n, q):\n    F = call(NTT_FW,  encode(n, q, f))\n    G = call(NTT_FW,  encode(n, q, g))\n    H = call(NTT_VECMULMOD, encode(n, q, F + G))\n    return call(NTT_INV, encode(n, q, H))\n\n# e.g. FALCON-512: n = 512, q = 12289\n# A verifier computes s2 * h with poly_mul, adds c with VECADDMOD,\n# then checks the result's norm in ordinary EVM code.\n```\n\n## 需要注意\n\n- 状态为 **Draft**。规范中预编译地址标注为 TBD，gas 数值和输入编码仍在演进。安全考虑部分尚未完成。\n- op-geth 中的原型使用地址 `0x12`–`0x15`，但这些地址在主网上并未分配。\n- 规范报告了在 OP-Stack 测试网上的端到端测试，其中一次 FALCON-512 验证从约 1.8M gas 降到了 480K gas 以下。\n- 针对特定方案的替代方案是 [EIP-8051](/eip-8051/)，这是一个直接验证 ML-DSA 签名的预编译。[EIP-7951](/eip-7951/) 展示了针对经典（非后量子）曲线的预编译路线。\n"}}}
