{"eip":8051,"title":"Precompile for ML-DSA signature verification","description":"Precompiled contracts for FIPS-204 ML-DSA signature verification and an EVM-optimized variant","authors":["Renaud Dubois (@rdubois-crypto)","Simon Masson (@simonmasson)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2025-10-15","requires":[7932],"discussionsTo":"https://ethereum-magicians.org/t/eip-8051-ml-dsa-verification/25857","repo":"EIPs","label":"EIP-8051","officialUrl":"https://eips.ethereum.org/EIPS/eip-8051","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8051.md","url":"https://eips.huatuo.xyz/eip-8051/","tldr":{"en":"Proposes two precompiles that verify ML-DSA (Dilithium, FIPS-204) post-quantum signatures for 4500 gas each: one strictly NIST-compliant and one EVM-optimized variant that uses Keccak instead of SHAKE256.","ja":"ML-DSA（Dilithium、FIPS-204）のポスト量子署名を、それぞれ 4500 gas で検証する 2 つのプリコンパイルを提案する。1 つは NIST に厳密準拠、もう 1 つは SHAKE256 の代わりに Keccak を使う EVM 最適化版。","ko":"ML-DSA(Dilithium, FIPS-204) 양자 내성 서명을 각각 4500 gas에 검증하는 두 개의 프리컴파일을 제안한다. 하나는 NIST를 엄격히 준수하고, 다른 하나는 SHAKE256 대신 Keccak을 쓰는 EVM 최적화 변형이다.","zh":"提出两个用于验证 ML-DSA（Dilithium，FIPS-204）后量子签名的预编译，各为 4500 gas：一个严格符合 NIST 标准，另一个是针对 EVM 优化的变体，使用 Keccak 而非 SHAKE256。"},"tags":["precompile","post-quantum","signatures","ml-dsa","cryptography"],"explainers":{"en":{"lang":"en","tldr":"Proposes two precompiles that verify ML-DSA (Dilithium, FIPS-204) post-quantum signatures for 4500 gas each: one strictly NIST-compliant and one EVM-optimized variant that uses Keccak instead of SHAKE256.","tags":["precompile","post-quantum","signatures","ml-dsa","cryptography"],"related":[7885,7932,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8051/","markdown":"## What problem does it solve?\n\nEthereum's signatures (secp256k1 ECDSA) would be breakable by a sufficiently large quantum computer. Moving applications to new signature schemes takes years, so the infrastructure needs to exist well before any such machine does.\n\nML-DSA (formerly CRYSTALS-Dilithium) is the main lattice-based signature standardized by NIST as FIPS-204. Verifying it in Solidity costs millions of gas. EIP-8051 adds native verification so smart accounts, and potentially transactions, can use post-quantum keys at a practical cost.\n\n## How it works\n\nTwo precompiles, both for NIST security level II (ML-DSA-44: `n = 256`, `q = 8380417`, `k = l = 4`):\n\n| Precompile | Proposed address | Hashing | Gas |\n| --- | --- | --- | --- |\n| `VERIFY_MLDSA` | `0x12` | SHAKE256, FIPS-204 compliant | 4500 |\n| `VERIFY_MLDSA_ETH` | `0x13` | Keccak256-based counter-mode PRNG | 4500 |\n\n- **Input:** 32-byte message, 2420-byte signature, then a 20,512-byte *expanded* public key (the full matrix `A_hat`, `tr`, and `t1` already in the NTT domain). Storing the key expanded means the verifier skips the expensive derivation and one NTT.\n- **Output:** 32-byte `1` on success, `0` on failure. Malformed input lengths, out-of-range coefficients, bad hints or norm-bound violations all fail.\n- **The ETH variant** deviates from FIPS-204 only in its hash/XOF and encodings, so it can be checked cheaply by EVM code too; signatures from standard ML-DSA libraries will not verify under it.\n- **Transaction signatures:** the spec also defines how ML-DSA plugs into [EIP-7932](/eip-7932/) algorithmic transactions (`ALG_TYPE` `0xD1` for standard, `0xD2` for the ETH variant), with the account address derived as the last 20 bytes of `keccak256(pubkey)`.\n\n## Sample code\n\nCalling the proposed precompile from Solidity (address not final):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary MLDSA {\n    address internal constant VERIFY_MLDSA = address(0x12); // proposed\n\n    /// @param pubkey 20,512-byte expanded public key (A_hat || tr || t1_ntt)\n    /// @param sig    2,420-byte FIPS-204 signature\n    function verify(bytes32 message, bytes memory sig, bytes memory pubkey)\n        internal view returns (bool)\n    {\n        require(sig.length == 2420 \u0026\u0026 pubkey.length == 20512, \"bad length\");\n        (bool ok, bytes memory out) =\n            VERIFY_MLDSA.staticcall(abi.encodePacked(message, sig, pubkey));\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## Things to know\n\n- Status is **Draft**. Addresses, gas cost and the `GAS_PENALTY` for EIP-7932 (suggested around 3000) are subject to benchmarking, and the security considerations section is still mostly TBD.\n- The proposed addresses `0x12`/`0x13` overlap with those used in the prototype for the generic NTT precompile, [EIP-7885](/eip-7885/); final numbering is not settled.\n- Keys are large: about 20 KB in the expanded form used here (1312 bytes in compact form), and signatures are 2.4 KB. Storing and passing them on-chain has a real calldata and storage cost.\n- [EIP-7885](/eip-7885/) takes a more generic route (NTT building blocks for any lattice scheme); [EIP-7951](/eip-7951/) is the analogous, already-final precompile for classical P-256 signatures.\n"},"ja":{"lang":"ja","tldr":"ML-DSA（Dilithium、FIPS-204）のポスト量子署名を、それぞれ 4500 gas で検証する 2 つのプリコンパイルを提案する。1 つは NIST に厳密準拠、もう 1 つは SHAKE256 の代わりに Keccak を使う EVM 最適化版。","tags":["precompile","post-quantum","signatures","ml-dsa","cryptography"],"related":[7885,7932,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8051/","markdown":"## 何を解決するのか\n\nEthereum の署名（secp256k1 ECDSA）は、十分に大規模な量子コンピューターがあれば破られてしまいます。アプリケーションを新しい署名方式へ移行するには何年もかかるため、そうしたマシンが登場するずっと前にインフラを整えておく必要があります。\n\nML-DSA（旧 CRYSTALS-Dilithium）は、NIST が FIPS-204 として標準化した主要な格子ベースの署名です。Solidity で検証すると数百万 gas かかります。EIP-8051 はネイティブな検証を追加し、スマートアカウント、そして場合によってはトランザクションが、現実的なコストでポスト量子鍵を使えるようにします。\n\n## 仕組み\n\nどちらも NIST セキュリティレベル II（ML-DSA-44: `n = 256`、`q = 8380417`、`k = l = 4`）向けの 2 つのプリコンパイルです。\n\n| プリコンパイル | 提案アドレス | ハッシュ | Gas |\n| --- | --- | --- | --- |\n| `VERIFY_MLDSA` | `0x12` | SHAKE256、FIPS-204 準拠 | 4500 |\n| `VERIFY_MLDSA_ETH` | `0x13` | Keccak256 ベースのカウンターモード PRNG | 4500 |\n\n- **入力:** 32 バイトのメッセージ、2420 バイトの署名、続いて 20,512 バイトの*展開済み*公開鍵（完全な行列 `A_hat`、`tr`、NTT ドメインにある `t1`）。鍵を展開した形で保存することで、検証側は高コストな導出処理と NTT 1 回を省略できます。\n- **出力:** 成功なら 32 バイトの `1`、失敗なら `0`。入力長の不正、範囲外の係数、不正なヒント、ノルム境界違反はすべて失敗となります。\n- **ETH バリアント** は、FIPS-204 からハッシュ／XOF とエンコーディングだけが異なるため、EVM コードでも安価に検証できます。標準の ML-DSA ライブラリで作った署名は、これでは検証を通りません。\n- **トランザクション署名:** 仕様では、ML-DSA が [EIP-7932](/eip-7932/) のアルゴリズム型トランザクションにどう組み込まれるかも定義しています（標準版は `ALG_TYPE` が `0xD1`、ETH バリアントは `0xD2`）。アカウントアドレスは `keccak256(pubkey)` の末尾 20 バイトとして導出されます。\n\n## サンプルコード\n\nSolidity から、提案中のプリコンパイルを呼び出す例（アドレスは未確定）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary MLDSA {\n    address internal constant VERIFY_MLDSA = address(0x12); // proposed\n\n    /// @param pubkey 20,512-byte expanded public key (A_hat || tr || t1_ntt)\n    /// @param sig    2,420-byte FIPS-204 signature\n    function verify(bytes32 message, bytes memory sig, bytes memory pubkey)\n        internal view returns (bool)\n    {\n        require(sig.length == 2420 \u0026\u0026 pubkey.length == 20512, \"bad length\");\n        (bool ok, bytes memory out) =\n            VERIFY_MLDSA.staticcall(abi.encodePacked(message, sig, pubkey));\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。アドレス、gas コスト、EIP-7932 向けの `GAS_PENALTY`（約 3000 が提案されています）はベンチマークによって変わる可能性があり、セキュリティに関する考慮事項のセクションもほとんどが TBD のままです。\n- 提案されているアドレス `0x12`／`0x13` は、汎用 NTT プリコンパイル [EIP-7885](/eip-7885/) のプロトタイプで使われているアドレスと重なっています。最終的な番号付けは決まっていません。\n- 鍵は大きく、ここで使う展開形では約 20 KB（コンパクト形では 1312 バイト）、署名は 2.4 KB です。これらをオンチェーンで保存・受け渡しすると、calldata とストレージに実際のコストがかかります。\n- [EIP-7885](/eip-7885/) はより汎用的なアプローチ（あらゆる格子方式のための NTT の構成要素）を取ります。[EIP-7951](/eip-7951/) は、従来型の P-256 署名向けの、同様でありながらすでに Final のプリコンパイルです。\n"},"ko":{"lang":"ko","tldr":"ML-DSA(Dilithium, FIPS-204) 양자 내성 서명을 각각 4500 gas에 검증하는 두 개의 프리컴파일을 제안한다. 하나는 NIST를 엄격히 준수하고, 다른 하나는 SHAKE256 대신 Keccak을 쓰는 EVM 최적화 변형이다.","tags":["precompile","post-quantum","signatures","ml-dsa","cryptography"],"related":[7885,7932,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8051/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움의 서명(secp256k1 ECDSA)은 충분히 큰 양자 컴퓨터가 나오면 깨질 수 있습니다. 애플리케이션을 새 서명 방식으로 옮기는 데는 몇 년이 걸리므로, 그런 기계가 등장하기 훨씬 전에 인프라가 갖춰져 있어야 합니다.\n\nML-DSA(구 CRYSTALS-Dilithium)는 NIST가 FIPS-204로 표준화한 주요 격자 기반 서명입니다. Solidity에서 검증하면 수백만 gas가 듭니다. EIP-8051은 네이티브 검증을 추가해 스마트 계정, 그리고 잠재적으로 트랜잭션이 현실적인 비용으로 양자 내성 키를 사용할 수 있게 합니다.\n\n## 어떻게 동작하나요?\n\n두 프리컴파일 모두 NIST 보안 레벨 II(ML-DSA-44: `n = 256`, `q = 8380417`, `k = l = 4`)용입니다.\n\n| 프리컴파일 | 제안 주소 | 해싱 | Gas |\n| --- | --- | --- | --- |\n| `VERIFY_MLDSA` | `0x12` | SHAKE256, FIPS-204 준수 | 4500 |\n| `VERIFY_MLDSA_ETH` | `0x13` | Keccak256 기반 카운터 모드 PRNG | 4500 |\n\n- **입력:** 32바이트 메시지, 2420바이트 서명, 그다음 20,512바이트의 *확장된* 공개 키(전체 행렬 `A_hat`, `tr`, 이미 NTT 도메인에 있는 `t1`). 키를 확장된 형태로 저장하면 검증기가 비싼 도출 과정과 NTT 한 번을 건너뛸 수 있습니다.\n- **출력:** 성공하면 32바이트 `1`, 실패하면 `0`. 입력 길이가 잘못되었거나, 계수가 범위를 벗어났거나, 힌트가 잘못되었거나, 노름 한계를 위반하면 모두 실패합니다.\n- **ETH 변형**은 FIPS-204와 해시/XOF 및 인코딩만 다르므로 EVM 코드로도 저렴하게 검증할 수 있습니다. 표준 ML-DSA 라이브러리가 만든 서명은 이 변형에서 검증되지 않습니다.\n- **트랜잭션 서명:** 사양은 ML-DSA가 [EIP-7932](/eip-7932/)의 알고리즘 트랜잭션에 어떻게 연결되는지도 정의합니다(표준은 `ALG_TYPE` `0xD1`, ETH 변형은 `0xD2`). 계정 주소는 `keccak256(pubkey)`의 마지막 20바이트로 도출됩니다.\n\n## 샘플 코드\n\nSolidity에서 제안된 프리컴파일 호출하기(주소는 확정 아님):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary MLDSA {\n    address internal constant VERIFY_MLDSA = address(0x12); // proposed\n\n    /// @param pubkey 20,512-byte expanded public key (A_hat || tr || t1_ntt)\n    /// @param sig    2,420-byte FIPS-204 signature\n    function verify(bytes32 message, bytes memory sig, bytes memory pubkey)\n        internal view returns (bool)\n    {\n        require(sig.length == 2420 \u0026\u0026 pubkey.length == 20512, \"bad length\");\n        (bool ok, bytes memory out) =\n            VERIFY_MLDSA.staticcall(abi.encodePacked(message, sig, pubkey));\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 주소, gas 비용, EIP-7932용 `GAS_PENALTY`(약 3000 제안)는 벤치마크에 따라 달라질 수 있으며, 보안 고려 사항 섹션도 대부분 TBD입니다.\n- 제안된 주소 `0x12`/`0x13`은 범용 NTT 프리컴파일 [EIP-7885](/eip-7885/)의 프로토타입에서 쓰는 주소와 겹칩니다. 최종 번호는 정해지지 않았습니다.\n- 키가 큽니다. 여기서 사용하는 확장 형태는 약 20 KB(압축 형태는 1312바이트)이고 서명은 2.4 KB입니다. 이를 온체인에 저장하고 전달하는 데는 실제 calldata 및 스토리지 비용이 듭니다.\n- [EIP-7885](/eip-7885/)는 더 범용적인 접근(모든 격자 방식을 위한 NTT 구성 요소)을 택하며, [EIP-7951](/eip-7951/)은 기존 P-256 서명에 대한 유사하면서 이미 Final인 프리컴파일입니다.\n"},"zh":{"lang":"zh","tldr":"提出两个用于验证 ML-DSA（Dilithium，FIPS-204）后量子签名的预编译，各为 4500 gas：一个严格符合 NIST 标准，另一个是针对 EVM 优化的变体，使用 Keccak 而非 SHAKE256。","tags":["precompile","post-quantum","signatures","ml-dsa","cryptography"],"related":[7885,7932,7951],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8051/","markdown":"## 它解决什么问题？\n\n以太坊的签名（secp256k1 ECDSA）可能被足够大的量子计算机破解。让应用迁移到新的签名方案需要数年时间，因此基础设施必须在这样的机器出现之前很久就准备就绪。\n\nML-DSA（前身为 CRYSTALS-Dilithium）是 NIST 以 FIPS-204 标准化的主要基于格的签名方案。在 Solidity 中验证它需要数百万 gas。EIP-8051 增加了原生验证，使智能账户乃至交易可以用可接受的成本使用后量子密钥。\n\n## 它如何运作\n\n两个预编译，均面向 NIST 安全级别 II（ML-DSA-44：`n = 256`，`q = 8380417`，`k = l = 4`）：\n\n| 预编译 | 提议地址 | 哈希 | Gas |\n| --- | --- | --- | --- |\n| `VERIFY_MLDSA` | `0x12` | SHAKE256，符合 FIPS-204 | 4500 |\n| `VERIFY_MLDSA_ETH` | `0x13` | 基于 Keccak256 的计数器模式 PRNG | 4500 |\n\n- **输入：** 32 字节消息、2420 字节签名，然后是 20,512 字节的*展开*公钥（完整矩阵 `A_hat`、`tr`，以及已处于 NTT 域的 `t1`）。以展开形式存储密钥，验证方就可以跳过昂贵的推导和一次 NTT。\n- **输出：** 成功时为 32 字节的 `1`，失败时为 `0`。输入长度不合法、系数超出范围、hint 错误或违反范数界限，都会导致失败。\n- **ETH 变体** 与 FIPS-204 的区别仅在于哈希/XOF 和编码，因此 EVM 代码也能以较低成本检查；标准 ML-DSA 库生成的签名无法通过它的验证。\n- **交易签名：** 规范还定义了 ML-DSA 如何接入 [EIP-7932](/eip-7932/) 的算法化交易（标准版 `ALG_TYPE` 为 `0xD1`，ETH 变体为 `0xD2`），账户地址取 `keccak256(pubkey)` 的最后 20 字节。\n\n## 示例代码\n\n在 Solidity 中调用拟议的预编译（地址尚未最终确定）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary MLDSA {\n    address internal constant VERIFY_MLDSA = address(0x12); // proposed\n\n    /// @param pubkey 20,512-byte expanded public key (A_hat || tr || t1_ntt)\n    /// @param sig    2,420-byte FIPS-204 signature\n    function verify(bytes32 message, bytes memory sig, bytes memory pubkey)\n        internal view returns (bool)\n    {\n        require(sig.length == 2420 \u0026\u0026 pubkey.length == 20512, \"bad length\");\n        (bool ok, bytes memory out) =\n            VERIFY_MLDSA.staticcall(abi.encodePacked(message, sig, pubkey));\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**。地址、gas 成本以及 EIP-7932 的 `GAS_PENALTY`（建议约 3000）有待基准测试确定，安全注意事项一节也大多仍是 TBD。\n- 提议的地址 `0x12`/`0x13` 与通用 NTT 预编译 [EIP-7885](/eip-7885/) 的原型所用地址重叠；最终编号尚未确定。\n- 密钥很大：此处使用的展开形式约 20 KB（紧凑形式为 1312 字节），签名为 2.4 KB。在链上存储和传递它们会带来实实在在的 calldata 和存储成本。\n- [EIP-7885](/eip-7885/) 走的是更通用的路线（为任何格方案提供 NTT 构件）；[EIP-7951](/eip-7951/) 则是针对经典 P-256 签名的类似预编译，且已经是 Final。\n"}}}
