EIP-8151 · Draft · Core · 2026-02-09
EIP-8151: Account Code Restricted ecRecover
Makes the ecRecover precompile refuse to return an address whose account now holds real contract code, so an old ECDSA key cannot keep authorizing permits after an account migrates to post-quantum control.
What problem does it solve?
With EIP-7702 an ordinary account (EOA) can install code. One proposed path to post-quantum security is for an EOA to migrate to code that checks a quantum-safe signature instead. Once the account's code is no longer a plain 7702 delegation, EIP-3607 already stops the old ECDSA key from sending transactions.
But the ecRecover precompile (address 0x01) does not look at state. Any contract that authorizes actions with ecRecover, most notably ERC-20 permit (ERC-2612), would still accept a signature from the old key. An attacker who derives that key with a quantum computer could drain tokens through permits. Many of those contracts are immutable, so the fix has to happen in the protocol.
How it works
After recovering an address from (hash, v, r, s), ecRecover now reads that address's raw account code (it does not follow a delegation):
- code is empty, or exactly the 23-byte 7702 delegation
0xef0100 || delegate→ return the address as before; - anything else → return empty output with
success = 1, exactly what it already returns for a bad signature.
Empty output (not 32 zero bytes, not a revert) was chosen so existing callers treat a blocked account the same as an invalid signature and do not accidentally match the zero address.
Gas changes on successful recovery, because the precompile now reads state with EIP-8038 pricing:
| Case | Old | New |
|---|---|---|
| Recovery fails | 3000 | 3000 |
| Success, address cold | 3000 | 6100 (3000 + 3000 cold access + 100 code read) |
| Success, address warm | 3000 | 3200 (3000 + 100 + 100) |
The address is added to the warm set after the fee is paid, and with EIP-7928 block access lists the read is recorded even if the check rejects it or an outer call reverts.
Sample code
The account check, from the reference implementation:
DELEGATION_PREFIX = b"\xef\x01\x00"
def permits_ecrecover(state, recovered_address) -> bool:
code = state.get_raw_code(recovered_address) # absent account == empty code
return len(code) == 0 or (len(code) == 23 and code[:3] == DELEGATION_PREFIX)
A Solidity caller that stays safe under the new rules: forward enough gas and treat zero/empty as failure.
function verify(bytes32 h, uint8 v, bytes32 r, bytes32 s, address expected) internal view returns (bool) {
require(expected != address(0), "zero signer");
address signer = ecrecover(h, v, r, s); // returns address(0) on empty output
return signer == expected;
}
Things to know
- Status: Draft. Details, including gas costs, may still change.
- Fixed-gas callers break. Code like
staticcall(3000, 0x01, ...)will run out of gas on every valid signature after activation, and raising the transaction gas limit does not help. Libraries and contracts that hard-code 3000 gas need review. - Only the precompile is affected. ECDSA recovery written in pure Solidity or other application code bypasses the check.
ecRecoverstops being a pure function of its input. L2s and fault-proof systems that re-execute it elsewhere must apply the code check against their own state, or use a separate secp256k1 implementation.- Contracts that already fail to reject
address(0)fromecrecoverremain vulnerable to invalid signatures, as they are today.