Demo · 4 min
A chain you may break
Three blocks, real SHA-256 hashes, worked out in your browser. Change one letter and watch the hash jump and every following block turn invalid. With the mining button you look for a nonce yourself, and measure how slow a browser is against the bitcoin network.
Three blocks, real hashes
The more zeros required, the more attempts a valid block takes. Two zeros cost 256 attempts on average, three around 4,096, four around 65,536.
Ready. Change a text, or look for a new nonce with one of the buttons.
Block 1
valid0000000000000000000000000000000000000000000000000000000000000000
00039bed22273455bdc17ffeb7fab4b287f9422f3e7e2b2a804990a8e5e7c354
Block 2
valid00039bed22273455bdc17ffeb7fab4b287f9422f3e7e2b2a804990a8e5e7c354
0007947a93810d5542790e2e2b61eaf6099ee20157a6e5b992c1bc174208c962
Block 3
valid0007947a93810d5542790e2e2b61eaf6099ee20157a6e5b992c1bc174208c962
0008afe794a0d75134f289c77807790cba89ccf2ff604482376fb03aca930715
The browser measures its speed as soon as you mine a block.
Everything is worked out in your browser alone. Neither your texts nor the hashes leave this device.
This browser does not provide the hash function. The demo needs an encrypted connection and an up to date browser.
| Feature | This demo | Bitcoin |
|---|---|---|
| What gets hashed | number, text, previous hash, nonce | block header of 80 bytes: version, previous hash, Merkle root, timestamp, target, nonce |
| Method | SHA-256 once | SHA-256 twice in a row |
| Zeros required | 2 to 4 | around 19 at present |
| Who does the work | your browser, one core | machines around the world, at the same time |
| What is inside | one line of text | thousands of transactions, condensed into one value through a Merkle tree |
Note: The demo simplifies: SHA-256 once instead of twice, one text field instead of thousands of transactions, two to four zeros required instead of around 19. Not investment advice.
How the tool works it out
Each of the three blocks is assembled into a single string: block number, your text, the hash of the previous block and the nonce. That string goes through SHA-256, and out come 64 hexadecimal characters. The first block has no predecessor, so a line of 64 zeros stands there instead. The work is done with the hash function the browser brings along itself. Nothing goes to a server, neither your text nor the results.
A block counts as valid here when two things hold: its hash begins with the required number of zeros, and its field for the previous hash matches the hash of its predecessor. Change a letter in block 1 and both conditions fall over for block 2 and block 3 as well. That is exactly the point of the demo.
What a hash is and what proof of work means
SHA-256 is a one-way function, set out in standard FIPS 180-4 of the US standards institute NIST. The output is always 256 bits long, so 64 hexadecimal characters, whether you feed in three characters or three megabytes. The function cannot be reversed: the text cannot be recovered from the hash. And it is abrupt: a single changed character produces a completely different hash, with no resemblance to the previous one.
Because the hash cannot be steered, only trying is left. The whitepaper of 2008 describes exactly that in section 4: a nonce in the block is increased until the hash begins with the required number of zero bits. The effort is predictable: every additional hexadecimal digit required makes the search sixteen times more expensive on average. Two zeros cost around 256 attempts, three around 4,096, four around 65,536. Checking, by contrast, costs a single hash, and that is the real trick: hard to find, easy to verify.
What real bitcoin blocks do differently
Bitcoin does not hash the contents of a block but a header of exactly 80 bytes. It holds six fields: version, hash of the previous block header, Merkle root, timestamp, an encoded target called nBits, and the nonce. The Merkle root condenses all transactions in the block into a single value, so the header stays small. Hashing is SHA-256 twice in a row, not once.
A block is valid when the hash of the header is less than or equal to the target. That amounts to a minimum number of leading zeros, currently around 19 hexadecimal digits. In this demo your browser manages a few thousand to a few tens of thousands of hashes per second depending on the device, while the network sits at many hundreds of quintillion. The figure in the result field above comes from the chain data on this site and shows the gap honestly: it is not large, it is astronomical. That figure uses the speed measured here for a single SHA-256. A real block calls for two in a row, so the gap would be larger still.
Frequently asked questions
What is a hash anyway?
A fingerprint for data. SHA-256 turns text of any length into 64 hexadecimal characters. The same text gives the same hash, one changed character a completely different one. Backwards it does not work: the text cannot be reconstructed from the hash.
What is the nonce for?
It is the only number in the block that may be changed freely. Because the hash cannot be steered on purpose, the machine counts it up and hashes again until the result begins with enough zeros. The nonce is therefore the proof of the work done.
Why does the chain break when I change block 1?
Because block 2 holds the hash of block 1 as an input. If block 1 changes, its hash changes, and the value stored in block 2 no longer matches. Block 2 would have to be mined again, then block 3, and so on to the end.
Can I mine bitcoin with my browser?
Arithmetically yes, practically no. A real block calls for around 19 leading zeros instead of the two to four here. The result field works out how many years your browser would need for that. The number lies far beyond the age of the universe.
Do my entries leave the browser?
No. The hash function is part of the browser and the demo calls it directly. There is no connection to a server, no storage and no transfer. You can carry on using the page without a network connection.
Sources
- Bitcoin: A Peer-to-Peer Electronic Cash System, section 4 Proof-of-WorkSatoshi Nakamoto, 2008
- FIPS 180-4, Secure Hash Standard (SHA-256)NIST, the US standards institute
- Block Chain Reference, block header of 80 bytes and targetBitcoin Developer Reference
- Block hashing algorithmBitcoin Wiki

