BorisTheSpider, hope this helps
Hello everyone,
I'm trying to understand this stratum exploit better, and something is confusing me.
The lowest difficulty is defined by the biggest target. So if we look at the nBits of the genesis block, we then convert to hex (from the compact representation) to get the diff 1 targets.
In BTC, genesis.nBits = 0x1d00ffff;
https://en.bitcoin.it/wiki/Difficulty suggests we convert to a hex representation like:
so the hex target is
0x00ffff * 2**(8*(0x1d - 3))
or
0000 0000 ffff 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Which matches
https://github.com/Crypto-Expert/stratum-mining/blob/master/lib/template_registry.py where for sha256
diff1 = 0x00000000ffff0000000000000000000000000000000000000000000000000000
Now looking at a scrypt coin, eg LTC:
0x1e0ffff0 is the genesis block nbits
so the hex target is
0x0ffff0 * 2**(8*(0x1e - 3))
or
0000 0fff f000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Which doesn't match stratum-mining
if settings.COINDAEMON_ALGO == 'scrypt' or 'scrypt-jane':
diff1 = 0x0000ffff00000000000000000000000000000000000000000000000000000000
ie. the stratum-mining code has 4 leading zeros in the 64 byte hex representation of the target, wheras I get 5 leading zeros when doing the conversion from the compact to the full hex representation of the max difficulty.
I'm sure stratum-mining must be correct - where am I going wrong?
Quote from pooler
Hi,
The definition of difficulty in Litecoin is exactly the same as in
Bitcoin, that is, it uses the minimum difficulty of Bitcoin, not of
Litecoin. Litecoin's minimum difficulty is just that, and plays no role in
difficulty/target conversions. That is one important thing to understand.
Then, there is the fact that (for historical reasons which still upset me
to this day, basically boiling down to cgminer not supporting non-integer
difficulties back in the day) in the Stratum protocol understood by LTC
miners the difficulty is multiplied by a factor of 65536 (2^16). So when
in sgminer you read diff 65536, that is actually diff 1. This should
answer your question.
Cheers,
pooler