Sharing technical posts, make money online, ...

Monday, November 6, 2017

Bitcoin Mining



What is Bitcoin Mining?

Simply put; Bitcoin mining is the process whereby new Bitcoins are generated. When fiat coins are minted, metal sheets are fed through a machine that presses out blank coins. Those coins are then impressed with a design that designates their value. Because Bitcoin does not exist as cash, new Bitcoins must be created through a different process. That process is mining. Bitcoin mining serves an additional purpose, as well: it is the process whereby transactions are verified and added to the public ledger.

The first Bitcoin block — the Genesis block — was mined by Satoshi Nakamoto on January 3, 2009. Since then, thousands upon thousands of blocks have been mined, leading to millions of Bitcoins being in circulation. There is an upper limit to how many Bitcoins can be in circulation; only 21 million can be produced, and that cap is expected to be reached in about the year 2140.

How Bitcoin Mining Works

To work properly, the Bitcoin network needs a lot of people. If only a handful of people were operating the network, those few people could collude together to manipulate all of the data in the blockchain and make themselves rich. Bitcoin would quickly become an oligarchy rather than a peer-to-peer currency.

Additionally, it would functionally revert back to the client-server model that is prone to hacking and security breaches, the very thing that blockchain was created to prevent.

The diagram below illustrates the difference between the traditional client-server model and the peer-to-peer network that Bitcoin uses.

In the first picture, you see that all of the computers must connect to a central server to receive their information. What happens if the server is somehow corrupted (say that it contains a virus or has been hacked so that all of the information in it is being siphoned off to someone)? Well, all of the computers connected to that server will fall prey, in some way, to whatever has occurred within the server.

Blockchains such as Bitcoin operate as a peer-to-peer network, as seen in the second picture. This means that instead of connecting to a central server, the users connect to each other. While there may certainly be some unscrupulous individuals on the network who are trying to find weaknesses to exploit, their missions will fail unless they can convince every single other person on the network to join in on their shenanigans. It would take every single user on the network to override the verification process and retroactively manipulate any of the information contained in the blockchain’s digital ledger.

Enter the process of mining, a built-in fail-safe mechanism that enhances the verification process. Users all over the globe connect their computers to the Bitcoin network, thereby actually contributing their computer’s power and resources to upholding the blockchain. These computers store the entire blockchain on special software for the purpose of validating new transactions. The entire network must agree on new transactions that have occurred to prevent a problem known as double-spending. Double-spending is what happens when someone attempts to spend the same value twice. For example, imagine that Bob has $10 in his bank account, and he owes both Jim and Joe $10 each. Bob thinks of an easy solution: simultaneously write two checks, each for $10, and the bank will refuse to cash the one that is brought last.

With Bitcoin, there is no central bank to refuse the second check (or transaction), so how can the network ensure that no one spends a Bitcoin value twice? When creating Bitcoin, Satoshi Nakamoto implemented a process called proof-of-work to ensure against double spending. Proof-of-work is, as the name implies, a process that ensures that work was done to carry out the transaction. Remember that all of the information contained within a block of transactions must be verified before it can become a part of the Bitcoin blockchain. The information is combined with the hash of the previous block to create a new hash, a cryptographic puzzle that must be solved for the block to be verified. If a shred of information within the block is changed, if so much as a comma is added or space is deleted, the entire hash will change. Things will get really messy for the rest of the blockchain because that hash value is used to generate the hash value of the next block. Everyone on the network will know that someone tried to tamper with that information, and the attempt to manipulate it will fail.

Miners, people whose computers are connected to the Bitcoin network to verify the transactions, use their computing power to solve the puzzle. Basically, their computers generate a series of random guesses. It takes about 10^21 number of guesses to generate the correct answer, which equals a lot of computing power! It actually takes about 10 minutes for a computer to generate the answer, meaning that transactions take about 10 minutes to process. Some new computer chips and programs have been generated, which increase the speed at which the computer can find the answer. More computing power means the ability to generate more of these random guesses, thereby increasing the probability that one of those guesses will be correct. Whoever comes up with the correct answer first wins a reward of new Bitcoins, which are generated through the process of verification. As technology evolves and miners are able to come up with the answer faster, the difficulty level of the algorithms increases. This is to ensure that a certain amount of work is still done to verify the transactions and that only a certain number of Bitcoins are in circulation.

Mining isn't free. It can be a great way for people to earn extra money, as long as their computers are incredibly efficient regarding power. For mining to be cost-effective, the cost of the energy used to power the computer must be less than the amount of money generated by the rewards. Let's go back for a minute to the idea of retroactively changing information in a block. Remember that if any information is changed, even just a measly period or apostrophe, the entire hash will change, which therefore changes the hash of every subsequent block in the blockchain. What this means is that you would have to go back and re-mine every single block! If mining one block takes 10 full minutes and a whole lot of computational power (read: money in the form of energy), then even if you could find a way to go back and retroactively change the information, the process would be cost-prohibitive.

So, how does this process of mining and verifying blocks prevent the problem of double spending? Consider that it takes about 10 minutes to verify a single block of transactions. A naive user might assume that he has 10 minutes to spend that amount as many times as he wants. Imagine that Emil has a total of one Bitcoin in his account. He buys a used car from Emily using that one Bitcoin. A split-second later, he uses that same Bitcoin to buy a riding lawnmower from Emilia. Each of those transactions will be sent to every single node on the network; given the sheer size of the network and latency involved, it is entirely feasible that the second transaction will get delivered before the first one and therefore be verified first. The other transaction will not be able to be verified, and unfortunately, Emily will have to find someone else to buy her clunker.

Mastering Bitcoin for Beginners - Neil Hoffman

No comments:

Post a Comment