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

After EIP-665

Who is affected

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.

Original EIP · ← EIPs