EIP-665 Ed25519 signature verification precompile (Add precompiled contract for Ed25519 signature verification)
No call decision · Security & privacy · EIP status Stagnant · created 2018-03-25
A proposal to add a dedicated precompiled contract, ED25519VFY, to the EVM at address 0x9, so smart contracts can verify Ed25519 digital signatures cheaply and quickly.
Why it is needed
Ed25519 signature verification is possible with EVM bytecode as well, but Ed25519 operations, which involve many wide-word operations, do not fit the EVM bytecode model well, making gas costs very high and execution slow. Ed25519, on the other hand, is a signature scheme already widely used in many external systems such as TLS, DNSSEC, OpenSSH, GPG, and OpenBSD Signify. If a smart contract wants to link an Ethereum address to such an external system or account, or to process data from an Ed25519-based proof-of-stake (PoS) blockchain within a contract, it needs a way to verify Ed25519 signatures on-chain. Currently, only ECRECOVER (secp256k1) is natively supported, so using Ed25519 requires implementing expensive bytecode operations by hand every time.
What changes
Today
- Verifying an Ed25519 signature in EVM bytecode incurs very high gas costs and heavy computation.
- There is no standard way for smart contracts to connect to Ed25519-based external systems (TLS, DNSSEC, OpenSSH, GPG, etc.).
- Only ECRECOVER (secp256k1) is natively supported, making other signature schemes inefficient.
After EIP-665
- A dedicated precompile at address 0x9 verifies Ed25519 signatures for 2000 gas.
- Given a message, public key, and signature as input, you immediately get back 0x00000000 (success) or any other value (failure).
- A contract can prove that the sender holds both an Ethereum key and an Ed25519 key simultaneously, linking the Ethereum address to the external account.
Who is affected
- Wallet & app developers: Contracts linking on-chain accounts to external services that use Ed25519 keys (DNS, SSH, GPG, etc.) can be built easily and cheaply.
- Client teams: libsodium bindings must be added to each of geth, parity, pyethereum, and cpp-ethereum, matching the implementations exactly to avoid consensus errors.
- Smart contract developers: Data coming from external Ed25519-based PoS chains can be verified cheaply within a contract.
In depth
Input and output format
ED25519VFY takes 128 octets as input: the signed 32-octet message, the signer's 32-octet Ed25519 public key, and the 64-octet signature. The output is 4 octets: 0x00000000 if the signature is valid, and any other value means verification failure. The design leaves room for distinguishing different errors through the nonzero return values.
Address, gas cost, and activation condition
The precompile address is 0x9, and the call gas cost is fixed at 2000. The specification proposes adding this precompile when block.number is greater than or equal to CONSTANTINOPLE_FORK_BLKNUM. Address 0x9 is explained to have been reserved but unused at the time, among numbers 255 and below, so there is no backward compatibility issue with existing contracts.
Why the public key is taken as input
The author explains that while ECRECOVER can recover the signer's public key (address) from just the signature and message, Ed25519 cannot recover the public key from just the signature and message. That is why ED25519VFY must separately receive the public key as a third input.
Basis for gas pricing
The gas cost of ECRECOVER is 3000. Ed25519 verification is considered less computationally expensive than secp256k1 signature recovery, so this proposal suggests a lower gas cost of 2000.
Implementation unification: libsodium recommended
To reduce the risk of consensus failure (clients disagreeing on verification results), all clients are recommended to use libsodium, the same Ed25519 implementation. libsodium is considered a mature, security-audited C implementation. Per client, geth is proposed to use C libsodium via cgo, Parity to use Rust's sodiumoxide, PyEthereum to use Python's PyNaCl, and cpp-ethereum to use libsodium directly. The formally verified HACL implementation was also considered as an alternative, but was judged riskier than libsodium as an unproven new implementation.
Motivation: linking on-chain and off-chain accounts, and handling external chains
When a smart contract receives Ed25519-signed data (for example, the current block number), it proves that the sender holds both an Ethereum private key and the corresponding Ed25519 private key. This could serve as the foundation for various applications that bind Ethereum accounts to external systems or accounts such as DNS servers, DNS domains, or cluster nodes. Another motivation is processing data from Ed25519-based proof-of-stake blockchains inside an Ethereum contract.
Current status
This proposal's status is Stagnant; it was not included in a fork and was not activated. No record remains in call notes or related debate materials of a decision on this EIP.