12

Looking over the sample genesis blocks, I notice that both nonce and mixhash values can be assigned independent values. Reading the yellow paper it's mentioned that:

  • mixhash: is a 256 - bit hash which proves combined with the nonce that a sufficient amount of computation has been carried out on this block
  • nonce: is a 64 - bit hash which proves combined with the mix-hash hat a sufficient amount of computation has been carried out on this block

meaning that these values together with the difficulty are used in mining. But why are they both used?

9

mixhash is actually calculated from nonce as intermediate value when validating PoW with Hashimoto algorithm. But this calculation is still pretty heavy and a node might be DDoSed by blocks with incorrect nonces. mixhash is included into block to perform lightweight PoW 'pre-validation' to avoid such attack, as generating a correct mixhash still requires at least some work for attacker

5

I'm not sure if I'm able to explain this correctly. But mixhash is a reduced form taken from the DAG data file during mining, and is a part of the Hashimoto algorithm. The applied mixhash is re-determined for each hash operation that a miner performs while searching for the correct nonce (cf. ASIC resistance, high IO). The final mixhash is the value leading to the valid Block. The reason why this value is part of the Block descriptor is that it becomes part of the //parentHash// of the next Block. By this, a potential attacker would need correct DAG data files to create illegal Blocks.

The combination of nonce and mixhash must satisfy a mathematical condition described in the yellowpaper, as we can see in the snapshot below. It verifies that the block has really been cryptographically mined, and thus, from this aspect, is valid.

taken from the yellow paper

  • 1
    But the DAG is the same for all clients. With pyethapp on Linux it is automatically downloaded into ~/.ethash, geth generates its own DAG as far as I know. I'm not sure what the exact correlation between the DAG and the genesis block is. I know that the DAG is used in the PoW algorithm but don't know exactly if it's universally applicable across ethereum networks (private nets more specifically). github.com/ethereum/wiki/wiki/Ethash-DAG and github.com/ethereum/wiki/wiki/Ethash are not that clear. – Sebi Jun 28 '16 at 21:18
0

use pyethereum for illustrative purpose, see check_pow function which validates the PoW result of a block. note that when running ethash, the main input is nonce (together with unchangeable header hash) and outputs are result and mixhash

to summarize, block is valid if

  1. result matches the block difficulty (result <= 2**256 // difficulty), and
  2. mixhash is the same as block mixhash

if mixhash is not in the block, we only need to meet the first requirement

see hashimoto function, result is basically sha256(sha256(header + nonce + mixhash)), and we only need to make it meet the block difficulty without running the whole ethash, thus the PoW hash algorithm degenerates to double sha256 by iterating nonce and mixhash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.