{"eip":7951,"title":"Precompile for secp256r1 Curve Support","description":"Add precompiled contract for secp256r1 ECDSA signature verification with proper security checks","authors":["Carl Beekhuizen (@carlbeek)","Ulaş Erdoğan (@ulerdogan)","Doğan Alpaslan (@doganalpaslan)"],"status":"Final","type":"Standards Track","category":"Core","created":"2025-05-27","discussionsTo":"https://ethereum-magicians.org/t/eip-7951-precompile-for-secp256r1-curve-support/24360","repo":"EIPs","label":"EIP-7951","officialUrl":"https://eips.ethereum.org/EIPS/eip-7951","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7951.md","url":"https://eips.huatuo.xyz/eip-7951/","tldr":{"en":"Adds a P256VERIFY precompile at 0x100 that verifies secp256r1 (P-256) ECDSA signatures for 6900 gas, letting smart accounts use passkeys, Secure Enclave and WebAuthn keys directly on Ethereum L1.","ja":"0x100 に P256VERIFY プリコンパイルを追加し、secp256r1（P-256）の ECDSA 署名を 6900 ガスで検証する。スマートアカウントが、パスキー、Secure Enclave、WebAuthn の鍵を Ethereum L1 で直接使えるようになる。","ko":"0x100에 P256VERIFY 프리컴파일을 추가해 secp256r1(P-256) ECDSA 서명을 6900 가스로 검증한다. 스마트 계정이 패스키, Secure Enclave, WebAuthn 키를 이더리움 L1에서 직접 사용할 수 있게 한다.","zh":"在 0x100 新增 P256VERIFY 预编译，以 6900 gas 验证 secp256r1（P-256）ECDSA 签名，使智能账户可以在以太坊 L1 上直接使用通行密钥（passkey）、Secure Enclave 和 WebAuthn 密钥。"},"tags":["precompile","secp256r1","passkeys","webauthn","account-abstraction"],"explainers":{"en":{"lang":"en","tldr":"Adds a P256VERIFY precompile at 0x100 that verifies secp256r1 (P-256) ECDSA signatures for 6900 gas, letting smart accounts use passkeys, Secure Enclave and WebAuthn keys directly on Ethereum L1.","tags":["precompile","secp256r1","passkeys","webauthn","account-abstraction"],"related":[4337,7702,1271,7607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7951/","markdown":"## What problem does it solve?\n\nEthereum accounts sign with secp256k1, but the secure hardware in phones and laptops (Apple Secure Enclave, Android Keystore, FIDO2/WebAuthn passkeys, many HSMs) uses a different curve: secp256r1, also called P-256. Verifying a P-256 signature in Solidity is possible but costs hundreds of thousands of gas, which makes \"sign with Face ID\" style smart wallets expensive on L1.\n\nMany L2s already shipped a precompile for this under RIP-7212. EIP-7951 brings the same interface to L1 and fixes two edge-case bugs found in that earlier spec.\n\n## How it works\n\n- **Address:** `0x100`. **Gas:** 6900, charged whether verification succeeds or not.\n- **Input:** exactly 160 bytes: `hash (32) | r (32) | s (32) | qx (32) | qy (32)`.\n- **Output:** 32 bytes `0x…01` if the signature is valid; empty output for an invalid signature or any malformed input. The precompile never reverts.\n- It checks that `0 \u003c r, s \u003c n`, that the public key coordinates are below `p`, that the point is on the curve and is not the point at infinity.\n- Compared with RIP-7212 it adds a check that the computed point `R'` is not at infinity, and compares `R'.x ≡ r (mod n)` instead of plain equality.\n\nIt performs *verification*, not public-key recovery like `ECRECOVER`, because that is what P-256 hardware and the NIST standard provide. It was included in the Fusaka upgrade ([EIP-7607](/eip-7607/)).\n\n## Sample code\n\nVerifying a passkey signature from a contract:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary P256 {\n    address internal constant VERIFIER = address(0x100);\n\n    function verify(bytes32 hash, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy)\n        internal view returns (bool)\n    {\n        (bool ok, bytes memory out) =\n            VERIFIER.staticcall(abi.encodePacked(hash, r, s, qx, qy));\n        // Empty output means \"invalid\"; a chain without the precompile also returns empty.\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 **Final**.\n- Same address, input and output as RIP-7212, so contracts written for L2s work unchanged; only the gas cost differs (6900 on L1 versus 3450 in RIP-7212).\n- An empty return value is ambiguous: it also happens if the precompile does not exist on that chain. Check the chain supports it before relying on it.\n- P-256 signatures are malleable (both `s` and `n - s` verify). If your app uses signatures as unique identifiers, enforce low-`s` yourself.\n- WebAuthn wraps the signed challenge in `authenticatorData` and `clientDataJSON`; your wallet contract must rebuild that hash before calling the precompile. It pairs naturally with [ERC-4337](/eip-4337/) accounts and [EIP-7702](/eip-7702/) delegated EOAs.\n"},"ja":{"lang":"ja","tldr":"0x100 に P256VERIFY プリコンパイルを追加し、secp256r1（P-256）の ECDSA 署名を 6900 ガスで検証する。スマートアカウントが、パスキー、Secure Enclave、WebAuthn の鍵を Ethereum L1 で直接使えるようになる。","tags":["precompile","secp256r1","passkeys","webauthn","account-abstraction"],"related":[4337,7702,1271,7607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7951/","markdown":"## 何を解決するのか\n\nEthereum のアカウントは secp256k1 で署名しますが、スマートフォンやノート PC のセキュアなハードウェア（Apple の Secure Enclave、Android Keystore、FIDO2/WebAuthn のパスキー、多くの HSM）は別の曲線、secp256r1（P-256 とも呼ばれます）を使います。Solidity で P-256 署名を検証することは可能ですが、数十万ガスかかるため、「Face ID で署名する」タイプのスマートウォレットは L1 では高価になります。\n\n多くの L2 はすでに、RIP-7212 のもとでこのためのプリコンパイルを提供しています。EIP-7951 は同じインターフェースを L1 にもたらし、その以前の仕様で見つかった 2 つのエッジケースのバグを修正します。\n\n## 仕組み\n\n- **アドレス:** `0x100`。**ガス:** 6900。検証の成否にかかわらず課金されます。\n- **入力:** ちょうど 160 バイト。`hash (32) | r (32) | s (32) | qx (32) | qy (32)`。\n- **出力:** 署名が有効なら 32 バイトの `0x…01`。無効な署名や不正な形式の入力では空の出力です。このプリコンパイルは revert しません。\n- `0 \u003c r, s \u003c n` であること、公開鍵の座標が `p` 未満であること、点が曲線上にあり無限遠点でないことを確認します。\n- RIP-7212 と比べて、計算された点 `R'` が無限遠点でないことの確認を追加し、単純な等値比較の代わりに `R'.x ≡ r (mod n)` で比較します。\n\nこれは `ECRECOVER` のような公開鍵の復元ではなく*検証*を行います。P-256 のハードウェアと NIST 標準が提供するのがそれだからです。Fusaka アップグレード（[EIP-7607](/eip-7607/)）に含まれました。\n\n## サンプルコード\n\nコントラクトからパスキーの署名を検証する:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary P256 {\n    address internal constant VERIFIER = address(0x100);\n\n    function verify(bytes32 hash, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy)\n        internal view returns (bool)\n    {\n        (bool ok, bytes memory out) =\n            VERIFIER.staticcall(abi.encodePacked(hash, r, s, qx, qy));\n        // Empty output means \"invalid\"; a chain without the precompile also returns empty.\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Final** です。\n- アドレス、入力、出力は RIP-7212 と同じなので、L2 向けに書かれたコントラクトはそのまま動作します。違うのはガスコストだけです（L1 では 6900、RIP-7212 では 3450）。\n- 空の戻り値は曖昧です。そのチェーンにプリコンパイルが存在しない場合にも起こります。頼る前に、そのチェーンが対応していることを確認してください。\n- P-256 の署名は malleable です（`s` と `n - s` の両方が検証を通ります）。アプリが署名を一意の識別子として使う場合は、low-`s` を自分で強制してください。\n- WebAuthn は、署名されたチャレンジを `authenticatorData` と `clientDataJSON` で包みます。ウォレットコントラクトはプリコンパイルを呼ぶ前に、そのハッシュを再構築しなければなりません。[ERC-4337](/eip-4337/) アカウントや [EIP-7702](/eip-7702/) で委任された EOA と自然に組み合わせられます。\n"},"ko":{"lang":"ko","tldr":"0x100에 P256VERIFY 프리컴파일을 추가해 secp256r1(P-256) ECDSA 서명을 6900 가스로 검증한다. 스마트 계정이 패스키, Secure Enclave, WebAuthn 키를 이더리움 L1에서 직접 사용할 수 있게 한다.","tags":["precompile","secp256r1","passkeys","webauthn","account-abstraction"],"related":[4337,7702,1271,7607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7951/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움 계정은 secp256k1으로 서명하지만, 휴대폰과 노트북의 보안 하드웨어(Apple Secure Enclave, Android Keystore, FIDO2/WebAuthn 패스키, 많은 HSM)는 다른 곡선인 secp256r1을 씁니다. P-256이라고도 부릅니다. Solidity에서 P-256 서명을 검증하는 것은 가능하지만 수십만 가스가 들기 때문에, \"Face ID로 서명\"하는 식의 스마트 지갑은 L1에서 비쌉니다.\n\n많은 L2가 이미 RIP-7212 아래 이를 위한 프리컴파일을 내놓았습니다. EIP-7951은 같은 인터페이스를 L1에 가져오고, 그 이전 명세에서 발견된 두 가지 엣지 케이스 버그를 고칩니다.\n\n## 어떻게 동작하나요?\n\n- **주소:** `0x100`. **가스:** 6900이며, 검증 성공 여부와 관계없이 부과됩니다.\n- **입력:** 정확히 160바이트: `hash (32) | r (32) | s (32) | qx (32) | qy (32)`.\n- **출력:** 서명이 유효하면 32바이트 `0x…01`이고, 서명이 무효하거나 입력 형식이 잘못되면 빈 출력입니다. 이 프리컴파일은 revert하지 않습니다.\n- `0 \u003c r, s \u003c n`인지, 공개 키 좌표가 `p`보다 작은지, 점이 곡선 위에 있고 무한원점이 아닌지 확인합니다.\n- RIP-7212와 비교하면, 계산된 점 `R'`이 무한원점이 아닌지 확인하는 검사를 추가하고, 단순 동등 비교 대신 `R'.x ≡ r (mod n)`으로 비교합니다.\n\n`ECRECOVER`처럼 공개 키를 복구하는 것이 아니라 *검증*을 수행합니다. P-256 하드웨어와 NIST 표준이 제공하는 것이 그것이기 때문입니다. Fusaka 업그레이드([EIP-7607](/eip-7607/))에 포함되었습니다.\n\n## 샘플 코드\n\n컨트랙트에서 패스키 서명 검증하기:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary P256 {\n    address internal constant VERIFIER = address(0x100);\n\n    function verify(bytes32 hash, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy)\n        internal view returns (bool)\n    {\n        (bool ok, bytes memory out) =\n            VERIFIER.staticcall(abi.encodePacked(hash, r, s, qx, qy));\n        // Empty output means \"invalid\"; a chain without the precompile also returns empty.\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Final**입니다.\n- 주소, 입력, 출력이 RIP-7212와 같으므로 L2용으로 작성된 컨트랙트가 그대로 동작합니다. 다른 것은 가스 비용뿐입니다(L1에서는 6900, RIP-7212에서는 3450).\n- 빈 반환값은 모호합니다. 해당 체인에 프리컴파일이 없을 때도 발생합니다. 의존하기 전에 그 체인이 지원하는지 확인하세요.\n- P-256 서명은 가변적(malleable)입니다(`s`와 `n - s` 둘 다 검증을 통과합니다). 앱이 서명을 고유 식별자로 쓴다면 low-`s`를 직접 강제하세요.\n- WebAuthn은 서명된 챌린지를 `authenticatorData`와 `clientDataJSON`으로 감쌉니다. 지갑 컨트랙트는 프리컴파일을 호출하기 전에 그 해시를 다시 구성해야 합니다. [ERC-4337](/eip-4337/) 계정 및 [EIP-7702](/eip-7702/)로 위임된 EOA와 자연스럽게 어울립니다.\n"},"zh":{"lang":"zh","tldr":"在 0x100 新增 P256VERIFY 预编译，以 6900 gas 验证 secp256r1（P-256）ECDSA 签名，使智能账户可以在以太坊 L1 上直接使用通行密钥（passkey）、Secure Enclave 和 WebAuthn 密钥。","tags":["precompile","secp256r1","passkeys","webauthn","account-abstraction"],"related":[4337,7702,1271,7607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7951/","markdown":"## 它解决什么问题？\n\n以太坊账户使用 secp256k1 签名，但手机和笔记本电脑中的安全硬件（Apple Secure Enclave、Android Keystore、FIDO2/WebAuthn 通行密钥、许多 HSM）使用另一条曲线：secp256r1，也称 P-256。在 Solidity 中验证 P-256 签名是可行的，但要花费数十万 gas，这使得\"用 Face ID 签名\"这类智能钱包在 L1 上很昂贵。\n\n许多 L2 已经在 RIP-7212 之下上线了相应的预编译。EIP-7951 把同样的接口带到 L1，并修复了先前那份规范中发现的两个边缘情况漏洞。\n\n## 它如何运作\n\n- **地址：** `0x100`。**Gas：** 6900，无论验证成功与否都会收取。\n- **输入：** 恰好 160 字节：`hash (32) | r (32) | s (32) | qx (32) | qy (32)`。\n- **输出：** 签名有效时输出 32 字节的 `0x…01`；签名无效或任何格式错误的输入则输出为空。该预编译从不 revert。\n- 它会检查 `0 \u003c r, s \u003c n`，公钥坐标小于 `p`，该点在曲线上且不是无穷远点。\n- 与 RIP-7212 相比，它增加了对计算得到的点 `R'` 不是无穷远点的检查，并以 `R'.x ≡ r (mod n)` 取代简单的相等比较。\n\n它执行的是*验证*，而不是像 `ECRECOVER` 那样恢复公钥，因为 P-256 硬件和 NIST 标准提供的就是验证。它已被纳入 Fusaka 升级（[EIP-7607](/eip-7607/)）。\n\n## 示例代码\n\n在合约中验证通行密钥签名：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary P256 {\n    address internal constant VERIFIER = address(0x100);\n\n    function verify(bytes32 hash, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy)\n        internal view returns (bool)\n    {\n        (bool ok, bytes memory out) =\n            VERIFIER.staticcall(abi.encodePacked(hash, r, s, qx, qy));\n        // Empty output means \"invalid\"; a chain without the precompile also returns empty.\n        return ok \u0026\u0026 out.length == 32 \u0026\u0026 abi.decode(out, (uint256)) == 1;\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Final**。\n- 地址、输入和输出都与 RIP-7212 相同，因此为 L2 编写的合约无需修改即可使用；只有 gas 成本不同（L1 上为 6900，RIP-7212 中为 3450）。\n- 空返回值是有歧义的：如果该链上不存在该预编译，也会出现这种情况。依赖它之前，请确认该链支持它。\n- P-256 签名是可延展的（`s` 和 `n - s` 都能通过验证）。如果你的应用把签名当作唯一标识符，请自行强制要求 low-`s`。\n- WebAuthn 会把被签名的挑战包裹在 `authenticatorData` 和 `clientDataJSON` 中；你的钱包合约必须在调用预编译之前重建该哈希。它与 [ERC-4337](/eip-4337/) 账户以及经 [EIP-7702](/eip-7702/) 委托的 EOA 天然契合。\n"}},"requiredBy":[7607,8030]}
