is target a 256 bit field or a 32 bit field

0

first, do we talk about fields or values. is it correct to say that it is a 32 or 256 bit value ? or should we call it a 32 or 256 bit field ?

Why do some authors like say that the size is 32 bit . The bitcoin wiki states that it is 256 bit. See https://en.bitcoin.it/wiki/Difficulty it says (target is a 256 bit number) .

who is correct and where in the core can i take a look at it ?

peter

Posted 2018-07-20T05:35:52.063

Reputation: 11

update: so some texts also misleading quote that pow is sha256 > = target for pow. but the code stipulates that sha256 (hash) > target. So equality is incorrect , correct ?peter 2018-07-20T05:54:57.907

Answers

2

The target is a 256 bit integer. However it is stored and represented in block headers as a 32 bit integer. This is a compact representation of the actual 256 bit value.

Operations involving the target are done as both 256 bit integers. However because the target is stored as a 32 bit integer in the block header, calculations involving the previous block use the 32 bit integer expanded out to the 256 bit representation. Unfortunately this compression is lossy so some data is lost in this process.

The code relevant to target adjustment can be found here: https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp

Andrew Chow

Posted 2018-07-20T05:35:52.063

Reputation: 40 910