Mining Bitcoin, what is it and how does it work?
The basics of Mining Bitcoin:
This is a continuation of the what is bitcoin series.
Mining bitcoin or other cryptocurrencies, which use proof of work algorithms to secure their blockchain (ledger), is a bit like mining for gold. It’s hard, requires work, and electricity to “mine” a bitcoin and there will only ever be a limited number of bitcoins produced, much like gold. But mining isn’t really like gold mining in the sense you need a pickaxe. What you need is a super powerful computer or ASIC to process transactions.
Mining is the process of adding new blocks (bundles of lots of different transactions between people, or blocks) to the blockchain. The blockchain serves to confirm transactions to everyone on the network, as it’s publicly available, downloaded by every miner, and cannot be edited after a new block is added to the chain. Bitcoin nodes (computers connected to the bitcoin network who are engaged in mining) use the blockchain to distinguish which blocks are legitimate and which are attempts to re-spend coins that have already been sent elsewhere.
Mining is designed to require electricity and time so it’s hard to make blocks and new blockchains to prevent conflicting chains. Each block found must contain proof of work to be considered a valid block. Each time a block is found it is checked against other nodes to see if a consensus is reached, if it is, then the block is added to the blockchain.
As mining requires energy and work the miners need to be paid for their time and electricity. The miners are paid with transaction fees and a bitcoin block reward. The block reward is slowly diminishing and will reach zero. But the block reward is also how new bitcoins are minted (not physically).
Mining bitcoin, the more technical version:
So above is the basics of mining bitcoin. However, if you want a little bit more technical and detailed version of what is happening to further your understanding then continue to read on.
Hashing:
Hashing is one-way encryption without a key, extremely challenging to find the input data. If you enter some input it will give you a random but length specific output. The hash function is a mathematical transformation of the inputs you give it. With SHA-256 (secure hash algorithm) any length input will output exactly a 256 bit or 64-character output. For example:
Input: “I want to go to the store today”
Output: “c38c56320a2e0bebf8986f246b9d5f05ccaf7e0621920370c8883690f83eea2b”
Input: “The Crypto-Division is an amazing website, I learn so much here!”
Output: “886103332d6874f7af259ae2eafe24cc9fae8de81b3607438d29a83d6c8bdcd0”
Three interesting things about hash functions are if you change even one letter of the input you’ll get a completely different output; two is they are consistent, given the exact same input, you’ll get out the same output; three hash functions hide the original information well. You can try it here with SHA-256. With these three properties, the randomness is what makes the bitcoin network secure.
How does a hash function make bitcoin secure?
Because it’s impossible to predict the outcome of a hash function, hash functions can be used for proof of work and validation. The aim of mining with a computer is having your computer make guesses at what the hash value will be. The reason it takes so much time is because the proof of work algorithm requires that a nonce be present. A nonce is a piece of data that changes one value in the input. The goal is to find the desired output with the correct number of zeros as proof of your work. The miners have no way of knowing which nonce will produce the correct number of zeros the protocol desires so they must try them all. For example if the system requires 40 zeros 2^40 is 1 trillion trails needed to be attempted to find the correct nonce.
With so many trials that is why it takes some time to process the blocks. And the value the system has in mind is always changing with the difficulty. The formula is as follows:
SHA-256(SHA-256(data+nonce) < difficulty
Further, each block that is created has some residual hash function and transaction data from the previous block, proving it came from the older blocks, thus creating a “blockchain”. The miner who has the longest proof of work (attempts at finding the nonce), the previous residual hash function, and the old transaction data, that block will be accepted and added to the blockchain.
Source: Bitcoin.org
This works to validate the blocks which are added to the blockchain and which are not. Everyone is working to mine the “true” block and you’d need to convince everyone on the network that you have the true block. You’d do this by getting a majority of the mining power on the network 51% and then creating a fake blockchain with the transactions you wanted. While in theory it could happen, in practice and with a network as big as bitcoin it couldn’t happen.
Putting it all together:
Miners are just looking for one specific output of the hash function that contains a specified number of zeros at the beginning as proof of work. They do this by the following process:
Taking two pieces of information from the old block ->> old transaction data, previous proof of work ->> running it though their computer hashing software to make guesses on the true block, with slight changes after every hash preformed using the nonce as the small change->>once the correct number of zeros is found the bitcoin protocol accepts this as proof of work->> finally the system rewards the miner with bitcoin as payment for putting their computing power towards the network.
Conclusion:
Mining can be simple but difficult. All you really need is to download the software for mining bitcoin and your computer will begin to compute guesses at the correct hash output. However, it can take tremendous amounts of time and energy to find the correct output. The difficulty (number of zeros required) is variable and depends on several factors, like network computing power. The miners use their computers, together with old transaction data, old proof of work, and nonce to produce the correct block. The system rewards them with a set number of bitcoins.
2 Replies to “Mining Bitcoin, what is it and how does it work?”
Woah! I’m really digging the template/theme
of this blog. It’s simple, yet effective. A lot of times it’s very
hard to get that “perfect balance” between user friendliness and visual
appeal. I must say that you’ve done a very good job
with this. In addition, the blog loads extremely fast for me on Firefox.
Excellent Blog! http://www.q-kingstore.it/?option=com_k2&view=itemlist&task=user&id=9737
Thanks for the input! I tried to keep this website simple and lean. My other websites loaded slowly so I decided to take a new approach with this one.