EIP-1485 TEthashV1: Ethash hash improvement (TEthashV1)

No call decision · Consensus & staking · EIP status Stagnant · created 2018-11-01

A proposal to replace the FNV0 hash inside Ethereum's Ethash mining algorithm with the more secure FNV1A, in order to neutralize existing dedicated mining hardware (ASICs).

Why it is needed

Ethash was designed to be mined with GPUs, but the emergence of dedicated mining hardware (ASICs), which became far more efficient than GPUs, concentrated mining among specific vendors. The FNV0 hash function used in Ethash's internal MIX operation and DAG generation is already a long-deprecated method, with the problem that even a 1 to 2 bit change in input does not significantly change the output, i.e. a weak avalanche effect. This proposal does not change the overall Ethash algorithm, but instead replaces only FNV0 with the more secure FNV1A, keeping the proven Ethash structure while rendering existing ASICs unusable.

What changes

Today

After EIP-1485

Who is affected

In depth

Where the FNV hash is used

In the Ethash algorithm, the FNV hash is used in the MIX process that follows hashing the header and nonce with Keccak, and in the process of randomly accessing DAG pages. It goes through 64 stages, Mix 0 through Mix 63, mixing with DAG page data to produce the final 32-byte mix digest. FNV is a core part of this mixing operation and the DAG generation process.

The problem with FNV0

The FNV-0 used by existing Ethash starts with hash=0 and, for every byte, multiplies by FNV_prime and then XORs. The source explains that FNV-0 is already a deprecated, outdated hash, and that even a 1 to 2 bit change in input produces only a small change in output, giving it a weak avalanche effect. Citing the FNV-Analysis reference, the source states that it needs to be replaced with a more modern FNV hash or a hash suited for short messages.

Replacement with FNV1A

FNV-1A is a variant of FNV-1 that only swaps the order of the multiplication and XOR operations. hash starts at FNV_offset_basis, and for every byte, XOR is applied first, followed by multiplication by FNV_prime. The source explains that this reordering and the offset application add one more operation but produce a more secure hashing effect than FNV-0, and that using a prime number helps values spread well even at boundary conditions such as zero or even numbers.

Actual implementation: fnv1a and fnv1c

Considering computational resources, TEthashV1 applies FNV1A to data aligned in 4-byte units. The reference implementation consists of the fnv1a(x,y) macro, which uses FNV_PRIME 0x01000193 and FNV_OFFSET_BASIS 0x811c9dc5, and fnv1a_reduce(a,b,c,d), which nests it four times to process the four inputs a, b, c, d. fnv1c(x,y), a variant applied byte-by-byte in alignment, is also presented, which sequentially mixes each byte of x via fnv1i(x) and then XORs with y.

Verification via FNV-Analysis

Citing the tao-foundation/FNV-Analysis reference, the source presents test results comparing the DF (number of bits changed) value, which indicates how many output bits change when a single input bit changes, across four methods: FNV, FNV1, FNV1A, and FNV1C. The source explains that a higher DF value indicates a better hash, and states that in the sample output presented, FNV1A and FNV1C show a larger bit change than the existing FNV.

ASIC resistance and its limits

The source acknowledges that the Ethash algorithm itself cannot permanently prevent the emergence of ASICs. However, it explains that since the current FNV function is already a deprecated method, upgrading it can render existing FNV0-based ASICs useless. The source notes that other proposals that significantly change the algorithm would require a long time for cryptanalysis and GPU code optimization, citing as evidence that it took about a year from the old ethminer to the claymore-optimized miner, and about two years from genoil ethminer to ethereum-mining/ethminer.

Performance impact and current status

According to test results disclosed in the source, TEthash miners require more core computation time, lowering GPU hashrate by 2 to 3%. This EIP was written on 2018-11-01 under the Standards Track Core category, and its current status is Stagnant. Discussion did not progress further, leaving adoption uncertain, and neither the source nor the call records mention any decision on fork inclusion.

Original EIP · ← EIPs