I choosed to see how down-to-earth it would be to mine Bitcoin with pencil and paper.
It turns out that the SHA-256 algorithm used for mining is pretty basic and can in fact be done by hand. Not astonishingly, the process is excessively sluggish contrastd to challengingware mining and is enticount on imdown-to-earth. But carry outing the algorithm manuassociate is a outstanding way to understand exactly how it labors.
A pencil-and-paper round of SHA-256
The mining process
Bitcoin mining is a key part of the security of the Bitcoin system. The idea is that Bitcoin miners group a bunch of Bitcoin transactions into a block, then repeatedly carry out a cryptodetailed operation called hashing zillions of times until someone discovers a one-of-a-kind excessively unwidespread hash appreciate. At this point, the block has been mined and becomes part of the Bitcoin block chain. The hashing task itself doesn’t accomplish anyskinnyg beneficial in itself, but because discovering a prosperous block is so difficult, it secures that no individual has the resources to obtain over the Bitcoin system. For more details on mining, see my Bitcoin mining article.
A cryptodetailed hash function obtains a block of input data and produces a petiteer, unpredicted output. The hash function is scheduleed so there’s no “low cut” to get the desired output – you fair have to shield hashing blocks until you discover one by brute force that labors. For Bitcoin, the hash function is a function called SHA-256. To supply insertitional security, Bitcoin applies the SHA-256 function twice, a process understandn as double-SHA-256.
In Bitcoin, a prosperous hash is one that begins with enough zeros.[1] Just as it is unwidespread to discover a phone number or license ptardy finishing in multiple zeros, it is unwidespread to discover a hash begining with multiple zeros. But Bitcoin is exponentiassociate challenginger.
Currently, a prosperous hash must begin with approximately 17 zeros, so only one out of 1.4×1020 hashes will be prosperous. In other words, discovering a prosperous hash is challenginger than discovering a particular grain of sand out of all the grains of sand on Earth.
The folloprosperg diagram shows a block in the Bitcoin blockchain alengthened with its hash. The yellow bytes are hashed to produce the block hash. In this case, the resulting hash begins with enough zeros so mining was prosperous. However, the hash will almost always be unprosperous. In that case, the miner changes the nonce appreciate or other block satisfieds and tries aget.
Structure of a Bitcoin block
The SHA-256 hash algorithm used by Bitcoin
The SHA-256 hash algorithm obtains input blocks of 512 bits (i.e. 64 bytes), unites the data cryptodetailedassociate, and produces a 256-bit (32 byte) output.
The SHA-256 algorithm consists of a relatively basic round repeated 64 times. The diagram below shows one round, which obtains eight 4-byte inputs, A thraw H, carry outs a scant operations, and produces new appreciates of A thraw H.
Diagram produced by kockmeyer, CC BY-SA 3.0.
The blue boxes unite up the appreciates in non-licforfeit ways that are challenging to study cryptodetailedassociate. Since the algorithm uses disjoinal contrastent functions, uncovering an strike is challenginger. (If you could figure out a mathematical lowcut to produce prosperous hashes, you could obtain over Bitcoin mining.)
The Ma transport inantity box sees at the bits of A, B, and C. For each position, if the transport inantity of the bits are 0, it outputs 0. Otherrational it outputs 1. That is, for each position in A, B, and C, see at the number of 1 bits. If it is zero or one, output 0. If it is two or three, output 1.
The Σ0 box rotates the bits of A to create three rotated versions, and then sums them together modulo 2. In other words, if the number of 1 bits is odd, the sum is 1; otherrational, it is 0. The three appreciates in the sum are A rotated right by 2 bits, 13 bits, and 22 bits.
The Ch “pick” box picks output bits based on the appreciate of input E. If a bit of E is 1, the output bit is the correplying bit of F. If a bit of E is 0, the output bit is the correplying bit of G. In this way, the bits of F and G are shuffled together based on the appreciate of E.
The next box Σ1 rotates and sums the bits of E, aappreciate to Σ0 except the shifts are 6, 11, and 25 bits.
The red boxes carry out 32-bit insertition, generating new appreciates for A and E.
The input Wt is based on the input data, sweightlessly processed. (This is where the input block gets fed into the algorithm.)
The input Kt is a constant depictd for each round.[2]
As can be seen from the diagram above, only A and E are changed in a round. The other appreciates pass thraw unchanged, with the greater A appreciate becoming the new B appreciate, the greater B appreciate becoming the new C appreciate and so forth.
Although each round of SHA-256 doesn’t change the data much, after 64 rounds the input data will be finishly scrambled.[3]
Manual mining
The video below shows how the SHA-256 hashing steps portrayd above can be carry outed with pencil and paper. I carry out the first round of hashing to mine a block. Completing this round took me 16 minutes, 45 seconds.
To elucidate what’s on the paper:
I’ve written each block A thraw H in hex on a split row and put the binary appreciate below. The maj operation eunites below C, and the shifts and Σ0 eunite above row A.
Likerational, the pick operation eunites below G, and the shifts and Σ1 above E. In the drop right, a bunch of terms are inserted together, correplying to the first three red sum boxes. In the upper right, this sum is used to produce the new A appreciate, and in the middle right, this sum is used to produce the new E appreciate. These steps all correply to the diagram and converseion above.
I also manuassociate carry outed another hash round, the last round to finish hashing the Bitcoin block. In the image below, the hash result is highweightlessed in yellow. The zeroes in this hash show that it is a prosperous hash. Note that the zeroes are at the finish of the hash. The reason is that Bitcoin inhandyly reverses all the bytes produced by SHA-256.[4]
Last pencil-and-paper round of SHA-256, shoprosperg a successfilledy-mined Bitcoin block.
What this uncomfervents for mining challengingware
Each step of SHA-256 is very effortless to carry out in digital logic – basic Boolean operations and 32-bit insertition.
(If you’ve studied electronics, you can probably envision the circuits already.)
For this reason, custom ASIC chips can carry out the SHA-256 algorithm very effectively in challengingware, putting hundreds of rounds on a chip in parallel. The image below shows a mining chip that runs at 2-3 billion hashes/second; Zeptobars has more pboilingos.
In contrast, Litecoin, Dogecoin, and aappreciate altcoins use the scrypt hash algorithm, which is intentionassociate scheduleed to be difficult to carry out in challengingware. It stores 1024 contrastent hash appreciates into memory, and then unites them in unpredicted ways to get the final result. As a result, much more circuitry and memory is needd for scrypt than for SHA-256 hashes. You can see the impact by seeing at mining challengingware, which is thousands of times sluggisher for scrypt (Litecoin, etc) than for SHA-256 (Bitcoin).
Conclusion
The SHA-256 algorithm is astonishingly basic, effortless enough to do by hand. (The elliptic curve algorithm for
signing Bitcoin transactions would be very hurtful to do by hand since it has lots of multiplication of 32-byte integers.)
Doing one round of SHA-256 by hand took me 16 minutes, 45 seconds. At this rate, hashing a filled Bitcoin block (128 rounds)[3] would obtain 1.49 days, for a hash rate of 0.67 hashes per day (although I would probably get speedyer with rehearse).
In comparison, current Bitcoin mining challengingware does disjoinal terahashes per second, about a quintillion times speedyer than my manual hashing. Needless to say, manual Bitcoin mining is not at all down-to-earth.[5]
A Reddit reader asked about my energy consumption. There’s not much physical exertion, so assuming a resting metabolic rate of 1500kcal/day, manual hashing labors out to almost 10 megajoules/hash. A normal energy consumption for mining challengingware is 1000 megahashes/joule. So I’m less energy effective by a factor of 10^16, or 10 quadrillion.
The next ask is the energy cost. A affordable source of food energy is donuts at $0.23 for 200 kcalories. Electricity here is $0.15/kilowatt-hour, which is affordableer by a factor of 6.7 – shutr than I predicted. Thus my energy cost per hash is about 67 quadrillion times that of mining challengingware. It’s evident I’m not going to produce my fortune off manual mining, and I haven’t even take partd the cost of all the paper and pencils I’ll necessitate.
2017 edit: My Bitcoin mining on paper system is part of the book The Objects That Power the Global Economy, so obtain a see.
Follow me on Twitter
to discover out about my tardyst blog posts.
Notes
[1]
It’s not exactly the number of zeros at the begin of the hash that matters. To be accurate, the hash must be less than a particular appreciate that depfinishs on the current Bitcoin difficulty level.
[4]
Obviously I didn’t fair have incredible outstanding fortune to finish up with a prosperous hash.
I begined the hashing process with a block that had already been successfilledy mined. In particular I used the one dispercreateed earlier in this article, #286819.