In the Ethereum blockchain, the difficulty is used to calculate a target.
Here are the ethminer logs for block number 1257006:
ℹ 35:02:42.89 ethminer Solution found; Submitting to http://192.168.4.120:8545 ...
ℹ 35:02:42.89 ethminer Nonce: ff4136b6b6a244ec
ℹ 35:02:42.89 ethminer Mixhash: 47da5e47804594550791c24331163c1f1fde5bc622170e83515843b2b13dbe14
ℹ 35:02:42.89 ethminer Header-hash: f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445
ℹ 35:02:42.89 ethminer Seedhash: 1730dd810f27fdefcac730fcab75814b7286002ecf541af5cdf7875440203215
ℹ 35:02:42.89 ethminer Target: 00000000000baef6895d630131521d65d984555906990f43f352be4350291f92
ℹ 35:02:42.89 ethminer Ethash: 0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74
ℹ 35:02:42.89 ethminer B-) Submitted and accepted.
Here is a snippet of Java to compute the difficulty from the target:
import java.math.BigInteger;
public class DifficultyDemo {
public static void main(String[] args) {
BigInteger numTwoPow256 = new BigInteger("2").pow(256);
BigInteger target = new BigInteger("00000000000baef6895d630131521d65d984555906990f43f352be4350291f92", 16);
BigInteger difficulty = numTwoPow256.divide(target);
System.out.println(difficulty.toString());
}
}
And the difficulty is calculated as 24091770185844 which corresponds to the difficulty in the blockchain explorer screen.
We can use ethminer --check-pow <headerHash> <seedHash> <difficulty> <nonce> to check the proof-of-work for validity as follows:
beefee@Rasterbator:~$ ethminer --check-pow f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445 1730dd810f27fdefcac730fcab75814b7286002ecf541af5cdf7875440203215 24091770185844 ff4136b6b6a244ec
VALID :-)
0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74 < 00000000000baef6895d630131521d65d984555906990f43f352be4350291f93
where 00000000000baef6895d630131521d65d984555906990f43f352be4350291f93 = 2^256 / 24091770185844
and 0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74 = ethash(f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445, ff4136b6b6a244ec)
with seed as 1730dd810f27fdefcac730fcab75814b7286002ecf541af5cdf7875440203215
(mixHash = 47da5e47804594550791c24331163c1f1fde5bc622170e83515843b2b13dbe14)
SHA3( light(seed) ) = 35ded12eecf2ce2e8da2e15c06d463aae9b84cb2530a00b932e4bbc484cde353
The miner's GPU would iterate through a range of random Nonces. This Nonce, combined with the Seedhash and Header-hash using a hash function need to calculate a number below the Target. If this calculated number is below the target, the miner has successfully mined a block and the block details will be submitted to the Ethereum network nodes.
In the example above, the calculated hash Ethash is larger than the Target and is therefore an incorrectly mined block (which is mentioned in the bug report).
In Bitcoin, the target is the block hash. As difficulty rises, you will see the number of leading zeroes increase.
Block 405390 has 17 leading zeroes.
Block 40539 has 8 leading zeroes (mined in 2010).
The Ethereum Target is sort of equivalent to the Bitcoin block hash.