EIP-7212
Adds support for secp256r1
signature verification via a new precompile contract.
secp256r1
(or P-256
) is a
common elliptic curve used in signature schemes, including by
Apple’s Secure Enclave,
Webauthn,
Android Keystore,
and Passkeys.
EIP-7212/RIP-7212
adds a new P256VERIFY
precompile contract at address(0x100)
, enabling
signature verification at a cost of 3450
gas.
EIP-7212 enables transaction signing support for Passkeys and other keystores, hardware-based signing keys, and improved UX.
EIP Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 and RFC 8174.
As of FORK_TIMESTAMP
in the integrated EVM chain, add precompiled contract
P256VERIFY
for signature verifications in the “secp256r1” elliptic curve at
address PRECOMPILED_ADDRESS
in 0x100
(indicates
0x0000000000000000000000000000000000000100
).
Elliptic Curve Information
“secp256r1” is a specific elliptic curve, also known as “P-256” and “prime256v1” curves. The curve is defined with the following equation and domain parameters:
Elliptic Curve Signature Verification Steps
The signature verifying algorithm takes the signed message hash, the signature components provided by the “secp256r1” curve algorithm, and the public key derived from the signer private key. The verification can be done with the following steps:
Required Checks in Verification
The following requirements MUST be checked by the precompiled contract to verify signature components are valid:
- Verify that the
r
ands
values are in(0, n)
(exclusive) wheren
is the order of the subgroup. - Verify that the point formed by
(x, y)
is on the curve and that bothx
andy
are in[0, p)
(inclusive 0, exclusive p) wherep
is the prime field modulus. Note that many implementations use(0, 0)
as the reference point at infinity, which is not on the curve and should therefore be rejected.
Precompiled Contract Specification
The P256VERIFY
precompiled contract is proposed with the following input and
outputs, which are big-endian values:
-
Input data: 160 bytes of data including:
- 32 bytes of the signed data
hash
- 32 bytes of the
r
component of the signature - 32 bytes of the
s
component of the signature - 32 bytes of the
x
coordinate of the public key - 32 bytes of the
y
coordinate of the public key
- 32 bytes of the signed data
-
Output data:
- If the signature verification process succeeds, it returns 1 in 32 bytes format.
- If the signature verification process fails, it does not return any output data.
Precompiled Contract Gas Usage
The use of signature verification cost by P256VERIFY
is 3450
gas.