By Milly Bitcoin – May 16, 2013
One of the most common questions about Bitcoin mining. What are they doing? What problem are they trying to solve? Can it be solved with pen and paper? Are they wasting resources? Are they using the computer power to hack something? This post deals with the problem being solved. See Bitcoin Mining: What’s it All About? for more info about mining.
The problem being solved is cryptography. It turns one string into another string. A simple cipher would be multiplying by 6.
1 >> 6
3 >> 18
You input one string and you get another one out. The are are problems with using “multiplying 6″ as scheme. The biggest problem is that it is pretty easy to figure out the original number by just diving by 6! Also, the number will get larger and larger.
To get around this all kinds of complicated mathematical operations are done on very long strings of numbers. It would take a very long explanation of the algorithm used and below is diagram of one step of one hash. Those things on the right are special mathematical functions that are tedious to calculate and require a computer.
The new Bitcoin miners do the step above below many times to do one hash. Then it does about 65,000,000 hashes per second so it might not be worth while to use pen and paper.
You can try it yourself at a web site http://www.xorbin.com/tools/sha256-hash-calculator. Put in a value in the top and you will see a string come up in the bottom. Then you have to keep changing the input by adding stuff until the answer starts with a zero.
With Bitcoin is more complicated because certain information has to be included, including the hash from the last block. That way the current block depends on all the blocks before it. The “difficulty” is changed by simply increasing the number of zeros in the start of answer (0h4fgs64j…, 00h3uyf8h…, 000yheofle… ) so it is harder to find the answer. As more people mine, the problem becomes more difficult and it adjusts so the problem is solved every 10 minutes on average.
The Proof of Work (PoW) ideas goes back to a concept called HashCash which was meant as a deterrent to spam. When an e-mail is sent another value must be sent with it. When you take this value, add it to the message, and then take a cryptographic hash you must have a hash value with certain characteristics.
For instance, take a cryptographic hash using the SHA256 hashing algorithm of the term “message” (without quotes) and you get:
Now if the rules say you must have a hash that starts with a zero you can start adding stuff until you get a hash that works:
After going through the numbers sequentially 51 was the first one that worked. As long as ”51″ is sent along with the message the receiver can quickly verify it meets the requirements by performing the hash and accept the message. The added portion, in this case”51,” is called a “nonce.”
Bitcoin mining works by compiling the transactions, the value that depends on all previous blocks, and then finding a “nonce” that meets the criteria.
As more people mine Bitcoin the problem gets harder and harder so that a block is created every 10 minutes on average. This is done by increasing the number of zeros. So a has that starts with “0…” easy, one that starts with “00…” is a bit harder and so forth.
The purpose of solving this problem is merely to show that work was done to get the answer. It comes from a problem called the “Byzantine General’s problem.” You have general who is giving orders to “attack” or “retreat” and he sends those orders to his underlings. These underlings then relay the orders to troops. The problem is that a small number of underlings are traitors and will relay false orders. In order to prevent the traitors from causing catastrophic results an order is not accepted unless it is received from multiple sources. To recreate the false message a traitor would have to do a tremendous amount of work. The purpose of all the extra work is to prevent the traitors from sending false messages.