Bitcoin a síť

SHA-256: the hash function every bitcoin miner computes

Author: Updated 8 min read

SHA-256: the hash function – PC Praha

SHA-256 is a hash function that turns any data into a "fingerprint" exactly 256 bits long – and it is what every bitcoin ASIC miner computes non-stop. The same data always gives the same fingerprint, the slightest change gives a completely different one, and the data cannot be recovered from the fingerprint. Bitcoin uses it to hash the block header twice in a row, looking for a result lower than the network target.

Summary

  • SHA-256 belongs to the SHA-2 family and is specified in the NIST FIPS 180-4 standard: 256-bit output, 512-bit blocks, 64 rounds.
  • Bitcoin computes SHA-256(SHA-256(block header)), SHA256d for short. The header is 80 bytes long.
  • As of 26 Nov 2026, an average of about 5.8 × 1023 attempts is needed per block. Every hash has the same chance.
  • An ASIC miner can do only this one thing, but extremely quickly and efficiently – the Antminer S21 XP manages 270 trillion hashes per second.
  • Full SHA-256 has not been broken; the best practical attack handles 31 of 64 rounds.
Explanation:

Simple: SHA-256 as a blender you can't get the fruit back out of

Imagine a blender. You put fruit in and get a smoothie out. You can't reassemble the apple and banana from the smoothie. But if you put in exactly the same fruit, you get exactly the same smoothie – and add just one blueberry and both the colour and the taste will be completely different. SHA-256 is that kind of blender for data: from a text, a file or a block it produces a string of 64 characters that works like a fingerprint.

Mining is then a lottery with this blender. The miner takes the block "template", adds a number to it, runs it through the blender and checks whether the result starts with enough zeros. It almost never does. It changes the number and tries again – trillions of times a second. Whoever hits the right result first gets the block reward. Everyone else can check it with a single blend.

What this means for you:

  • A bitcoin miner can do just one thing – compute SHA-256. That is why it cannot be switched to Kaspa or Litecoin, which use different algorithms.
  • Performance is measured in hashes per second (TH/s = trillions per second). More hashes = more lottery tickets.
  • Every hash has the same chance. No trick brings a win closer; all that matters is the number of attempts and what the electricity for them costs.
  • Other coins run on SHA-256 too (Bitcoin Cash, eCash…), and the same machine can mine them as well.

Example: as of 26 Nov 2026, the whole network needs on average about 580 sextillion attempts per block (5.8 × 1023). An Antminer S21 XP with 270 TH/s would on its own wait roughly 68 years on average for a block. That is why people mine in a pool, where hashrate is combined and the machine receives its share every day – according to our data about 171 Kč before the pool fee and electricity. This is not investment advice.

You will find details with figures and tables in the technical explanation.

What SHA-256 is according to the standard

SHA-256 (Secure Hash Algorithm, 256 bits) is part of the SHA-2 family defined by the US standard NIST FIPS 180-4. Key parameters:

Parameter Value
Output length 256 bits (32 bytes, 64 hex characters)
Message block size 512 bits (64 bytes)
Word size 32 bits
Number of rounds (steps) 64, with 64 constants K0–K63
Maximum message length less than 264 bits
Padding a "1" bit, zeros and the 64-bit message length

The message is padded to a multiple of 512 bits and processed block by block by the compression function; its output (the state) feeds into the processing of the next block. Test vector from the standard: SHA-256("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad.

Three properties mining relies on

  • One-wayness: the input cannot reasonably be computed from the fingerprint. The only way to find an input with a particular result is to keep trying.
  • Collision resistance: collisions (two different inputs with the same fingerprint) exist mathematically, but nobody has found one for full SHA-256.
  • Avalanche effect: changing a single bit of the input changes roughly half of the output bits. Our example: "PC Praha" gives ea0305c6…b2dc7ea3, "PC praha" gives 8cb0a7db…133520f5 – 133 of 256 bits differ (52%).

Thanks to these properties, the hash result is as unpredictable for a miner as a roll of the dice, yet anyone can verify it instantly.

How Bitcoin hashes a block: SHA256d

The miner does not hash the whole block, only its 80-byte header: version (4 B), previous block hash (32 B), Merkle root of the transactions (32 B), time (4 B), the encoded target bits (4 B) and the nonce (4 B). SHA-256 is applied to it twice: SHA-256(SHA-256(header)). The block is valid if the result, read as a number, is less than or equal to the target. We go through the header fields in detail in the article Nonce and the block header.

We checked this on the 2009 genesis block: the double SHA-256 of its header gives 6fe28c0a…190000000000. Bitcoin stores numbers in little-endian order, so block explorers display the hash reversed: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f. That is why block hashes "start with zeros".

Bitcoin also uses SHA256d for transaction IDs and Merkle tree nodes. Older addresses (P2PKH) use HASH160 = RIPEMD-160(SHA-256(public key)), while Taproot uses tagged hashes as defined in BIP 340. More about addresses in the article Bitcoin addresses.

What exactly an ASIC computes: the midstate

After padding, the 80-byte header is split into two 64-byte blocks. The first contains the version, the previous hash and the first 28 bytes of the Merkle root – it does not change when the nonce changes. Its result, the so-called midstate, is computed once and the chip receives it ready-made. For each nonce, the ASIC then computes only the second block of the header and the entire second SHA-256 – that is, two compression functions instead of three. Ken Shirriff described this as 128 rounds per nonce instead of 192.

AsicBoost (Timo Hanke, 2016) builds on this too: when a miner finds several variants of the first block with the same ending, it saves part of the computation in the loop – the author cites a gain of roughly 12.5–20%. Today it is used in the form of version rolling (BIP 320). Chip efficiency is compared in J/TH: how many joules a trillion hashes cost. According to Bitmain, the Antminer S21 XP achieves 13.5 J/TH.

The chance of a block in numbers (our calculation)

The expected number of hashes per block is difficulty × 232. At a difficulty of 134.82 trillion (mining.rates, source mempool.space, 26 Nov 2026):

Quantity Value as of 26 Nov 2026
Hashes per block (average) ≈ 5.79 × 1023
Chance of a single hash ≈ 1.73 × 10−24
Network hashrate corresponding to 10 min per block ≈ 965 EH/s (blocks are currently arriving faster; actual hashrate is around 1,000 EH/s)
Antminer S21 XP: hashes per second 2.7 × 1014
S21 XP solo: average time to a block ≈ 24,800 days (about 68 years)

This is the average of a memoryless random process: a block may come tomorrow or in a hundred years, and past unsuccessful attempts do not add up. That is why people mine in a mining pool; we cover the solo option in the article Solo mining. For perspective: Ken Shirriff calculated one round of SHA-256 with pencil and paper in 16 minutes 45 seconds, which works out at about 0.67 hashes per day.

Is SHA-256 secure?

  • Classical attacks: the best practical collision (Li, Liu, Wang et al., Asiacrypt 2024) handles a reduced version with 31 of 64 steps; a so-called semi-free-start collision reached 39 steps (Eurocrypt 2024). No practical attack exists against the full 64-step function.
  • Quantum computers: Grover's algorithm gives only a quadratic speed-up and requires a long serial computation that cannot easily be parallelised. Today this poses no practical threat to mining or to fingerprints. (Digital signatures are a different matter – they are not SHA-256.)
  • For miners: if someone found a shortcut for finding hashes faster, they would behave like a miner with a more powerful chip – the network would later even out the advantage through difficulty.

Which coins use SHA-256

Besides Bitcoin, Bitcoin Cash, Bitcoin SV and eCash run on SHA-256; Namecoin and Syscoin are merge-mined with BTC, and DigiByte uses it as one of several algorithms. You will find an overview in the article SHA-256 coins and a comparison with other algorithms in the article Mining algorithms.

What next

Sources

Frequently asked questions

What is SHA-256?
A cryptographic hash function from the SHA-2 family, specified in the US standard FIPS 180-4. It turns any data into a 256-bit fingerprint (64 hexadecimal characters). The original data cannot be recovered from the fingerprint.
Why does Bitcoin use SHA-256 twice?
The block header is hashed as SHA-256(SHA-256(header)), SHA256d for short. Transaction IDs and the Merkle tree are computed the same way. Double hashing protects, among other things, against the so-called length-extension attack.
Has SHA-256 been broken?
No. The best known attacks only handle a reduced version (31 of 64 rounds in practice). There is still no practical attack against the full function. Quantum computers would bring only a quadratic speed-up of the search.
How many hashes per second does an ASIC miner compute?
The Antminer S21 XP computes 270 TH/s, i.e. 270 trillion double SHA-256 hashes per second. At the difficulty as of 26 Nov 2026, it would find a block on its own on average roughly once every 68 years.
Which cryptocurrencies are mined with SHA-256?
Mainly Bitcoin, Bitcoin Cash, Bitcoin SV and eCash, plus for example Namecoin or Syscoin (merge-mined with BTC) and DigiByte as one of several algorithms. All of them can be mined with the same ASIC miners.

This text was prepared with the help of AI. Facts, figures and procedures were checked by Yegor.

More articles in Mining wiki