{"eip":5988,"title":"Add Poseidon hash function precompile","description":"Add a precompiled contract which implements the hash function used in the Poseidon cryptographic hashing algorithm","authors":["Abdelhamid Bakhta (@abdelhamidbakhta)","Eli Ben Sasson (@Elistark)","Avihu Levy (@avihu28)","David Levit Gurevich (@DavidLevitGurevich)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2022-11-15","discussionsTo":"https://ethereum-magicians.org/t/eip-5988-add-poseidon-hash-function-precompile/11772","repo":"EIPs","label":"EIP-5988","officialUrl":"https://eips.ethereum.org/EIPS/eip-5988","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-5988.md","url":"https://eips.huatuo.xyz/eip-5988/","tldr":{"en":"Proposes a precompile for the Poseidon hash, a ZK-friendly hash used by many rollups, with parameters supplied by the caller so different projects' variants can share it.","ja":"多くのロールアップが使う ZK フレンドリーなハッシュ、Poseidon のプリコンパイルを提案する。パラメーターは呼び出し側が渡すため、プロジェクトごとの異なるバリアントで共有できる。","ko":"많은 롤업이 사용하는 ZK 친화적 해시인 Poseidon을 위한 프리컴파일을 제안한다. 파라미터는 호출자가 제공하므로 프로젝트마다 다른 변형이 함께 쓸 수 있다.","zh":"提议为 Poseidon 哈希添加预编译合约。Poseidon 是许多 rollup 使用的对零知识友好的哈希，参数由调用者提供，因此不同项目的变体可以共用。"},"tags":["precompile","cryptography","zk","rollups","hash"],"explainers":{"en":{"lang":"en","tldr":"Proposes a precompile for the Poseidon hash, a ZK-friendly hash used by many rollups, with parameters supplied by the caller so different projects' variants can share it.","tags":["precompile","cryptography","zk","rollups","hash"],"related":[152,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5988/","markdown":"## What problem does it solve?\n\nZero-knowledge proof systems are expensive when they have to prove Keccak or SHA-256, because those hashes are built from bit operations. **Poseidon** is an \"arithmetic\" hash designed to work natively over a prime field, which makes it far cheaper inside SNARK and STARK circuits. Many ZK rollups and ZK applications use it for Merkle trees and commitments.\n\nThe EVM has no native Poseidon, so contracts that need to recompute a Poseidon hash (to check a Merkle root built off-chain, for example) must implement it in Solidity, which costs a lot of gas. EIP-5988 proposes a precompile to make this cheap.\n\n## How it works\n\nDifferent projects use different Poseidon parameters (field, rounds, state width), so instead of fixing one variant the precompile takes the parameters as input:\n\n| Field | Bytes | Meaning |\n| --- | --- | --- |\n| `p` | 32 | Prime field modulus |\n| `security_level` | 2 | Security level in bits (`M`) |\n| `alpha` | 1 | S-box power |\n| `input_rate` | 2 | Number of input elements |\n| `t` | 1 | State size |\n| `full_round` | 1 | Full rounds (`R_F`) |\n| `partial_round` | 1 | Partial rounds (`R_P`) |\n| `input` | `input_rate × 32` | Field elements to hash |\n\nThe fields are concatenated in that order and passed to the precompile, which computes the hash as defined in the Poseidon paper and returns the output. The draft lists the address as `0xA` and leaves the activation block and gas cost as `TBD`.\n\nThe security section stresses that parameter choice matters, especially the MDS mixing matrix, and points to published cryptanalysis of Poseidon.\n\n## Sample code\n\nIllustrative only: how a contract would build the input and call the precompile *if* it existed at the draft address. No such precompile is live.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary PoseidonDraft {\n    address constant POSEIDON = address(0x0A); // draft value, not deployed\n\n    function hash(\n        uint256 p, uint16 securityLevel, uint8 alpha, uint8 t,\n        uint8 fullRounds, uint8 partialRounds, uint256[] memory inputs\n    ) internal view returns (bytes memory out) {\n        bytes memory data = abi.encodePacked(\n            p, securityLevel, alpha, uint16(inputs.length), t, fullRounds, partialRounds\n        );\n        for (uint256 i; i \u003c inputs.length; ++i) data = abi.encodePacked(data, inputs[i]);\n        (bool ok, bytes memory ret) = POSEIDON.staticcall(data);\n        require(ok, \"poseidon failed\");\n        return ret;\n    }\n}\n```\n\n## Things to know\n\n- **Status: Stagnant.** The proposal is incomplete (gas cost, fork block and rationale are `TBD`) and has not been scheduled for any upgrade. Today, contracts that need Poseidon use Solidity or Yul implementations.\n- Address `0xA` was later used by the KZG point-evaluation precompile from [EIP-4844](/eip-4844/), so the address in this draft could not be used as written.\n- Poseidon is much younger than Keccak or SHA-256; its security rests on more recent and less battle-tested analysis, which the spec itself acknowledges.\n- A configurable precompile shifts responsibility for safe parameters onto callers.\n"},"ja":{"lang":"ja","tldr":"多くのロールアップが使う ZK フレンドリーなハッシュ、Poseidon のプリコンパイルを提案する。パラメーターは呼び出し側が渡すため、プロジェクトごとの異なるバリアントで共有できる。","tags":["precompile","cryptography","zk","rollups","hash"],"related":[152,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5988/","markdown":"## 何を解決するのか\n\nゼロ知識証明システムは、Keccak や SHA-256 を証明しなければならないとコストが高くなります。これらのハッシュはビット演算で構成されているためです。**Poseidon** は素体上でネイティブに動作するよう設計された「算術」ハッシュで、SNARK や STARK の回路内でははるかに安くなります。多くの ZK ロールアップや ZK アプリケーションが、Merkle ツリーやコミットメントにこれを使っています。\n\nEVM にはネイティブの Poseidon がないため、Poseidon ハッシュを再計算する必要があるコントラクト（たとえば、オフチェーンで作られた Merkle ルートを検証する場合）は、Solidity で実装しなければならず、多くのガスがかかります。EIP-5988 は、これを安くするプリコンパイルを提案します。\n\n## 仕組み\n\nプロジェクトごとに Poseidon のパラメーター（体、ラウンド数、状態幅）が異なるため、プリコンパイルは 1 つのバリアントに固定せず、パラメーターを入力として受け取ります。\n\n| フィールド | バイト数 | 意味 |\n| --- | --- | --- |\n| `p` | 32 | 素体の法 |\n| `security_level` | 2 | ビット単位のセキュリティレベル（`M`） |\n| `alpha` | 1 | S-box のべき |\n| `input_rate` | 2 | 入力要素の数 |\n| `t` | 1 | 状態サイズ |\n| `full_round` | 1 | フルラウンド数（`R_F`） |\n| `partial_round` | 1 | パーシャルラウンド数（`R_P`） |\n| `input` | `input_rate × 32` | ハッシュする体の要素 |\n\nフィールドはこの順に連結されてプリコンパイルに渡され、プリコンパイルは Poseidon の論文で定義されたとおりにハッシュを計算して出力を返します。ドラフトはアドレスを `0xA` としており、有効化ブロックとガスコストは `TBD` のままです。\n\nセキュリティの節は、パラメーターの選択、特に MDS 混合行列が重要であることを強調し、公開されている Poseidon の暗号解析を参照しています。\n\n## サンプルコード\n\n説明のためだけのものです。ドラフトのアドレスにプリコンパイルが*存在すれば*、コントラクトがどのように入力を組み立てて呼び出すかを示します。そのようなプリコンパイルは稼働していません。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary PoseidonDraft {\n    address constant POSEIDON = address(0x0A); // draft value, not deployed\n\n    function hash(\n        uint256 p, uint16 securityLevel, uint8 alpha, uint8 t,\n        uint8 fullRounds, uint8 partialRounds, uint256[] memory inputs\n    ) internal view returns (bytes memory out) {\n        bytes memory data = abi.encodePacked(\n            p, securityLevel, alpha, uint16(inputs.length), t, fullRounds, partialRounds\n        );\n        for (uint256 i; i \u003c inputs.length; ++i) data = abi.encodePacked(data, inputs[i]);\n        (bool ok, bytes memory ret) = POSEIDON.staticcall(data);\n        require(ok, \"poseidon failed\");\n        return ret;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** この提案は未完成（ガスコスト、フォークブロック、根拠が `TBD`）で、どのアップグレードにも予定されていません。現在、Poseidon が必要なコントラクトは Solidity や Yul の実装を使っています。\n- アドレス `0xA` は、のちに [EIP-4844](/eip-4844/) の KZG ポイント評価プリコンパイルで使われたため、このドラフトのアドレスはそのままでは使えませんでした。\n- Poseidon は Keccak や SHA-256 よりはるかに新しく、その安全性はより新しく実戦での検証が少ない解析に基づいています。仕様自体もこれを認めています。\n- 設定可能なプリコンパイルは、安全なパラメーターを選ぶ責任を呼び出し側に移します。\n"},"ko":{"lang":"ko","tldr":"많은 롤업이 사용하는 ZK 친화적 해시인 Poseidon을 위한 프리컴파일을 제안한다. 파라미터는 호출자가 제공하므로 프로젝트마다 다른 변형이 함께 쓸 수 있다.","tags":["precompile","cryptography","zk","rollups","hash"],"related":[152,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5988/","markdown":"## 어떤 문제를 해결하나요?\n\n영지식 증명 시스템은 Keccak이나 SHA-256을 증명해야 할 때 비용이 큽니다. 이 해시들은 비트 연산으로 구성되어 있기 때문입니다. **Poseidon**은 소수 체(prime field) 위에서 네이티브로 동작하도록 설계된 \"산술\" 해시로, SNARK와 STARK 회로 안에서 훨씬 저렴합니다. 많은 ZK 롤업과 ZK 애플리케이션이 Merkle 트리와 커밋먼트에 이를 사용합니다.\n\nEVM에는 네이티브 Poseidon이 없으므로, Poseidon 해시를 다시 계산해야 하는 컨트랙트(예: 오프체인에서 만든 Merkle 루트 검증)는 Solidity로 구현해야 하며 가스가 많이 듭니다. EIP-5988은 이를 저렴하게 만드는 프리컴파일을 제안합니다.\n\n## 어떻게 동작하나요?\n\n프로젝트마다 Poseidon 파라미터(체, 라운드 수, 상태 너비)가 다르므로, 프리컴파일은 하나의 변형으로 고정하지 않고 파라미터를 입력으로 받습니다.\n\n| 필드 | 바이트 | 의미 |\n| --- | --- | --- |\n| `p` | 32 | 소수 체의 모듈러스 |\n| `security_level` | 2 | 비트 단위 보안 수준(`M`) |\n| `alpha` | 1 | S-box 거듭제곱 |\n| `input_rate` | 2 | 입력 요소의 개수 |\n| `t` | 1 | 상태 크기 |\n| `full_round` | 1 | 전체 라운드(`R_F`) |\n| `partial_round` | 1 | 부분 라운드(`R_P`) |\n| `input` | `input_rate × 32` | 해시할 체의 원소 |\n\n필드는 이 순서대로 이어 붙여 프리컴파일에 전달되며, 프리컴파일은 Poseidon 논문에 정의된 대로 해시를 계산해 출력을 반환합니다. 초안은 주소를 `0xA`로 적고 활성화 블록과 가스 비용은 `TBD`로 남겨 두었습니다.\n\n보안 절에서는 파라미터 선택, 특히 MDS 혼합 행렬이 중요함을 강조하며 공개된 Poseidon 암호 분석을 가리킵니다.\n\n## 샘플 코드\n\n설명용일 뿐입니다. 초안 주소에 프리컴파일이 *존재한다면* 컨트랙트가 입력을 만들고 호출하는 방식을 보여 줍니다. 그런 프리컴파일은 운영 중이지 않습니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary PoseidonDraft {\n    address constant POSEIDON = address(0x0A); // draft value, not deployed\n\n    function hash(\n        uint256 p, uint16 securityLevel, uint8 alpha, uint8 t,\n        uint8 fullRounds, uint8 partialRounds, uint256[] memory inputs\n    ) internal view returns (bytes memory out) {\n        bytes memory data = abi.encodePacked(\n            p, securityLevel, alpha, uint16(inputs.length), t, fullRounds, partialRounds\n        );\n        for (uint256 i; i \u003c inputs.length; ++i) data = abi.encodePacked(data, inputs[i]);\n        (bool ok, bytes memory ret) = POSEIDON.staticcall(data);\n        require(ok, \"poseidon failed\");\n        return ret;\n    }\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 이 제안은 미완성(가스 비용, 포크 블록, 근거가 `TBD`)이며 어떤 업그레이드에도 예정되어 있지 않습니다. 오늘날 Poseidon이 필요한 컨트랙트는 Solidity나 Yul 구현을 사용합니다.\n- 주소 `0xA`는 이후 [EIP-4844](/eip-4844/)의 KZG 포인트 평가 프리컴파일이 사용했으므로, 이 초안의 주소는 그대로는 쓸 수 없었습니다.\n- Poseidon은 Keccak이나 SHA-256보다 훨씬 젊으며, 안전성은 더 최근의 실전 검증이 적은 분석에 기반합니다. 명세 자체도 이를 인정합니다.\n- 설정 가능한 프리컴파일은 안전한 파라미터를 고를 책임을 호출자에게 넘깁니다.\n"},"zh":{"lang":"zh","tldr":"提议为 Poseidon 哈希添加预编译合约。Poseidon 是许多 rollup 使用的对零知识友好的哈希，参数由调用者提供，因此不同项目的变体可以共用。","tags":["precompile","cryptography","zk","rollups","hash"],"related":[152,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5988/","markdown":"## 它解决什么问题？\n\n零知识证明系统在需要证明 Keccak 或 SHA-256 时成本很高，因为这些哈希由位运算构成。**Poseidon** 是一种“算术”哈希，设计上原生运行于素数域之上，因此在 SNARK 和 STARK 电路中便宜得多。许多 ZK rollup 和 ZK 应用把它用于 Merkle 树和承诺。\n\nEVM 没有原生的 Poseidon，所以需要重新计算 Poseidon 哈希的合约（例如验证链下构建的 Merkle 根）必须用 Solidity 实现，这会花费大量 gas。EIP-5988 提议用一个预编译合约让它变得便宜。\n\n## 它如何运作\n\n不同项目使用不同的 Poseidon 参数（域、轮数、状态宽度），因此预编译不固定某一种变体，而是把参数作为输入：\n\n| 字段 | 字节数 | 含义 |\n| --- | --- | --- |\n| `p` | 32 | 素数域模数 |\n| `security_level` | 2 | 以位为单位的安全级别（`M`） |\n| `alpha` | 1 | S-box 的幂 |\n| `input_rate` | 2 | 输入元素的数量 |\n| `t` | 1 | 状态大小 |\n| `full_round` | 1 | 完整轮数（`R_F`） |\n| `partial_round` | 1 | 部分轮数（`R_P`） |\n| `input` | `input_rate × 32` | 要哈希的域元素 |\n\n这些字段按此顺序拼接后传给预编译，预编译按 Poseidon 论文中的定义计算哈希并返回输出。草案将地址列为 `0xA`，激活区块和 gas 成本留作 `TBD`。\n\n安全部分强调参数的选择很重要，尤其是 MDS 混合矩阵，并指向已发表的 Poseidon 密码分析。\n\n## 示例代码\n\n仅作说明：*假如*预编译存在于草案地址，合约会如何构造输入并调用它。目前并没有这样的预编译上线。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary PoseidonDraft {\n    address constant POSEIDON = address(0x0A); // draft value, not deployed\n\n    function hash(\n        uint256 p, uint16 securityLevel, uint8 alpha, uint8 t,\n        uint8 fullRounds, uint8 partialRounds, uint256[] memory inputs\n    ) internal view returns (bytes memory out) {\n        bytes memory data = abi.encodePacked(\n            p, securityLevel, alpha, uint16(inputs.length), t, fullRounds, partialRounds\n        );\n        for (uint256 i; i \u003c inputs.length; ++i) data = abi.encodePacked(data, inputs[i]);\n        (bool ok, bytes memory ret) = POSEIDON.staticcall(data);\n        require(ok, \"poseidon failed\");\n        return ret;\n    }\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 该提案并不完整（gas 成本、分叉区块和设计理由均为 `TBD`），也没有被安排进任何升级。目前需要 Poseidon 的合约使用 Solidity 或 Yul 实现。\n- 地址 `0xA` 后来被 [EIP-4844](/eip-4844/) 的 KZG 点评估预编译占用，所以这个草案中的地址无法按原样使用。\n- Poseidon 比 Keccak 或 SHA-256 年轻得多；它的安全性建立在更新、经受实战检验更少的分析之上，规范本身也承认这一点。\n- 可配置的预编译把选择安全参数的责任转移到了调用者身上。\n"}}}
