Blockchain/Level II · Mechanics/2.3 Blocks and the chain/Lesson 4
Proof-of-work and the target
The lottery ticket that costs energy to buy and a hash to verify
MaterialsA block explorer interfaceA hexadecimal calculator or programming environment capable of SHA-256The Bitcoin Developer Reference documentation
Wonder
- Why does a lower numerical target make finding a valid hash harder?
- How can a four-byte value encode a number large enough to constrain 2^256 possibilities?
- What happens to the expected block time when hashing power doubles but the target remains unchanged?
Explore
- A block is accepted only if it solves a computational puzzle. A miner must find an 80-byte header whose double SHA-256 hash is numerically less than or equal to a specific threshold, known as the target. This constraint transforms the block creation process into a search for a rare number within an enormous space of 2^256 possible hashes. The validity of any candidate block depends entirely on this single mathematical inequality.
- The target itself is not stored in its full 32-byte form because that would consume excessive header space. Instead, it is compressed into four bytes called ‘nBits’ using a mantissa-exponent encoding scheme. The format is lossy, keeping only a three-byte mantissa, so the target is slightly rounded, which costs nothing in practice. Decoding these four bytes reconstructs the massive 256-bit number that defines the upper limit for acceptable hash values.
- To find a valid hash, miners iterate through variations of the header fields. The primary variable is the 32-bit nonce, which offers roughly 4.3 billion distinct values per attempt cycle. When hardware speed exhausts these combinations instantly, miners modify the extra-nonce within the coinbase transaction or adjust the timestamp to generate new Merkle roots and header configurations. Each change produces a completely different hash output, effectively creating a fresh lottery ticket.
- Expected work rises in direct proportion to difficulty, while the target moves the other way: when the network retargets after hashing power has grown, the target falls, requiring more leading zeros in binary representation for a valid solution. The expected number of hashes to find one block approximates difficulty multiplied by 2^32. This scaling ensures that regardless of whether mining is done on laptops or industrial farms, the average interval between blocks remains stable at approximately ten minutes.
- Verification is asymmetrical with creation. While finding a valid hash may require billions of trials, checking it takes a single double-SHA-256 of the header and a comparison with the target. The proof-of-work check is therefore instant, although full validation of a block still means checking every transaction in it. The security model relies on this disparity: creating work is expensive, but trusting that work is cheap.
- The genesis block was mined at difficulty 1, the easiest the rules allow; even then a valid hash needed about 32 leading zero bits, roughly one success in 4.3 billion attempts. Recent blocks need many more leading zeros, because global hashing power has grown by many orders of magnitude. Comparing the hex representation of block 1’s hash with that of a current block reveals this dramatic shift from an open field to a tightly constrained search space.
Key facts
- A valid Bitcoin block header hash must be numerically less than or equal to its difficulty target.
- The target is stored compactly in four bytes as ‘nBits’ using mantissa-exponent encoding.
- Miners vary the 32-bit nonce, coinbase extra-nonce, and timestamp to generate new hash candidates.
- Difficulty is defined as the maximum possible target divided by the current target.
- Verifying a block’s proof of work takes one double-SHA-256 of the header and a comparison.
- The genesis block was mined at difficulty 1.
Exercise nine, six, three, one
9CollectList 9 distinct components or variables involved in the proof-of-work calculation for a Bitcoin block header.
6ClusterGroup these 9 items into 6 categories based on whether they are fixed, variable per attempt, variable per cycle, encoded compactly, derived from transactions, or used for verification.
3DistillReduce the 6 groups to 3 core principles that govern how difficulty scales with network hashing power.
1CrystallizeWrite 1 sentence explaining why proof-of-work is hard to produce but easy to verify.
Fact check
Dates, figures and claims checked against the published sources listed below.