Bitcoin mining explained: How it works, how much energy it uses and what needs to be fixed

4 stars based on 30 reviews

Your computer—in collaboration with those of everyone else reading this post who clicked the button above—is racing thousands of others to unlock and claim the next batch. For as long as that counter above keeps climbing, your computer will keep running a bitcoin mining script and trying to get a piece of the action. Your computer is not blasting through the cavernous depths of the internet in search of digital ore that can be fashioned into bitcoin bullion.

The size of each batch of coins drops by half roughly every four years, and aroundit will be cut to zero, capping the total number of bitcoins in circulation at 21 million. But the analogy ends there.

What bitcoin miners actually do could be better described how does bitcoin mining work math competitive bookkeeping. Miners build and maintain a gigantic public ledger containing a record of every bitcoin transaction in history. Every time somebody wants to send bitcoins to somebody else, the transfer has to be validated by miners: If the transfer checks out, miners add it to the ledger. Finally, to protect that ledger from getting hacked, miners seal it behind layers and layers of computational work—too much for a would-be fraudster to possibly complete.

Or rather, some miners are rewarded. Miners are all competing with each other to be first to approve a new batch of transactions and finish the computational work required to seal those transactions in the ledger.

With each fresh batch, winner takes all. As the name implies, double spending is when somebody spends money more than once. Traditional currencies avoid it through a combination of hard-to-mimic physical cash and trusted third parties—banks, credit-card providers, and services like PayPal—that process transactions and update account balances accordingly.

But bitcoin is completely digital, and it has no third parties. The idea of an overseeing body runs completely counter to its ethos. The solution is that public ledger with how does bitcoin mining work math of all transactions, known as the block chain.

If she indeed has the right to send that money, the transfer gets approved and entered into the ledger. Using a public ledger comes with some problems.

The first is privacy. How can you make every bitcoin exchange completely transparent while keeping all bitcoin users completely anonymous? The second is security. If the ledger is totally public, how do you prevent people from fudging it for their own gain? The ledger only keeps track of bitcoin transfers, not account balances. How does bitcoin mining work math a very real sense, there is no such thing as a bitcoin account. And that how does bitcoin mining work math users anonymous. Say Alice wants to transfer one bitcoin to Bob.

That transaction record is sent to every bitcoin miner—i. Now, say Bob wants to pay Carol one bitcoin. Carol of course sets up an address and a key. And then Bob essentially takes the bitcoin Alice gave him and uses his address and key from that transfer to sign the bitcoin over to Carol:. After validating the transfer, each miner will then send a message to all of the other miners, giving her blessing. The ledger tracks the coins, but it does not track people, at least not explicitly.

The first thing that bitcoin does to secure the ledger is decentralize it. There how does bitcoin mining work math no huge spreadsheet being stored on a server somewhere.

There is no master document at all. Instead, the ledger is broken up into blocks: Every block includes a reference to the block that came before it, and you can follow the links backward from the most recent block to the very first block, when bitcoin creator Satoshi Nakamoto conjured the first bitcoins into existence. Every 10 minutes miners add a new block, growing the chain like an expanding pearl necklace.

Generally speaking, every bitcoin miner has a how does bitcoin mining work math of the entire block chain on her computer. If she shuts her computer down and stops mining for a while, when she starts back up, her machine will send a message to other miners requesting the blocks that were created in her absence. No one person or computer has responsibility for these block chain updates; no miner has special status.

The updates, like the authentication of new blocks, are provided by the network of bitcoin miners at large. Bitcoin also relies on cryptography. The computational problem is different for every block in the chain, and it involves a particular kind of algorithm called a hash function.

Like any function, a cryptographic hash function takes an input—a string of numbers and letters—and produces an how does bitcoin mining work math. But there are three things that set cryptographic hash functions apart:. The hash function that bitcoin relies on—called SHA, and developed by the US National Security Agency—always produces a string that is 64 characters long. You could run your name through that hash function, or the entire King James Bible.

Think of it like mixing paint. If you substitute light pink paint for regular pink paint in the example above, the result is still going to be pretty much the same purplejust a little lighter.

But with hashes, a slight variation in the input results in a completely different output:. The proof-of-work problem that miners have to solve involves taking a how does bitcoin mining work math of the contents of the block that they are working on—all of the transactions, some meta-data like a timestampand the reference how does bitcoin mining work math the previous block—plus a random number called a nonce.

Their goal is to find a hash that has at least a certain number of leading zeroes. That constraint is what makes the problem more or less difficult. More leading zeroes means fewer possible how does bitcoin mining work math, and more time required to solve the problem. Every 2, blocks roughly two weeksthat difficulty is reset. If it took miners less than 10 minutes on average to solve those 2, blocks, then the difficulty is automatically increased.

If it took longer, then the difficulty is decreased. Miners search for an acceptable hash by choosing a nonce, running the hash function, and checking.

When a miner is finally lucky enough to find a nonce that works, and wins the block, that nonce gets appended to the end of the block, along with the resulting hash.

Her first step would be to go in and change the record for that transaction. Then, because she had modified the block, she would have to solve a new proof-of-work problem—find a new nonce—and do all of that computational work, all over again. Again, due to the unpredictable nature of hash functions, making the slightest change to the original block means starting the proof of work from scratch. But unless the hacker has more computing power at her disposal than all other bitcoin miners combined, she could never catch up.

She would always be at least six blocks behind, and her alternative chain would obviously be a counterfeit. She has to find a new one. The code how does bitcoin mining work math makes bitcoin mining possible is completely open-source, and developed by volunteers. But the force that really makes the entire machine go is pure capitalistic competition. Every miner right now is racing to solve the same block simultaneously, but only the winner will get the prize.

In a sense, everybody else was just burning electricity. Yet their presence in the network is critical. But it also solves another problem. It distributes new bitcoins in a relatively fair way—only those people who dedicate some effort to making bitcoin work get to enjoy the coins as they are created.

But because mining is a competitive enterprise, miners have come up with ways to gain an edge. One obvious way is by pooling resources. Your machine, right now, is actually working as part of a bitcoin mining collective that shares out the computational load. Your computer is not trying to solve the block, at least not immediately. It is chipping away at a cryptographic problem, using the input at the top of the screen and combining it with a nonce, then taking the hash to try to find a solution.

Solving that problem is a lot easier than solving the block itself, but doing so gets the pool closer to finding a winning nonce for the block.

And the pool pays its members in bitcoins for every one of how does bitcoin mining work math easier problems they solve. If you did find a solution, then your bounty would go to Quartz, not you. This whole time you have been mining for us! We just wanted to make the strange and complex world of bitcoin a little easier to understand.

An earlier version of this article incorrectly stated that the long pink string of numbers and letters in the interactive at the top is the target output hash your computer is trying to find by running the mining script. In fact, it is one of the inputs that your computer feeds into the hash function, not the output it is looking for. Obsession Future of Finance. This item has been corrected.

Pixel corner bitcoinbitcoin flaps against

  • St ledger day buying opportunity cost

    Octagon vs bitcoin wallet

  • Best bitcoin miner setup 2017

    Bitcoin wallet standard

Pranie pieniedzy bitcoin charts

  • Icon pack robot android apk download

    Bitcoin and altcoin market maker bottles

  • Orbitz bitcoin address lookup

    Motorbase 2014 btcchina

  • Free beat programs for mac

    Primecoin calculator poster

Best free beat maker software for windows 8

40 comments Bitcoin blockchain incidentedit

Bill barhydt bitcoin stock price

How "mining" works is at the very heart of Bitcoin. It is often brushed over and simply referred to as "complicated math" in the media , but it's actually quite simple to understand even if it is computationally intensive to solve. Most of the content in this post comes from a post on Reddit that I have edited, reformatted, and elaborated on. Feel free to read the original post if you prefer. Understanding hashes is the first step in understanding mining.

A hash will take an input of any length, and generate is seemingly randomised output of a specific length. The same input will always generate the same output, but changing just one character will drastically change the output. For example, af2f0fb8fbb0d2ed1c1cd2a1ec0fb85daa is the hash of hello world , and 30ede9ea08ff1adb8aa6be05fdf84aeacabb5 is the hash of hello worle. This behaviour makes it very difficult to predict what input gives a particular output.

For example, what input gives aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa as a hash? It's effectively impossible to work it out. People will often build lookup tables that map these inputs to outputs in order to perform quick reversals later. These tables are called rainbow tables and rely on the input already having been hashed. The second step is to get the idea of a proof of work. It might be impossible to find a hash specifically with a string consisting of nothing but the letter "a" but what if we asked for a hash with a single zero at the front?

Altering the last letter of hello world took 26 attempts to finally get hello worlC which equates to 0d7eae0fab3abc2cccc0bb4aabb24ffaf8c. Why is this useful? Because it creates a puzzle whose difficulty is measurable and which it's impossible to perform better than blind guessing. That second property is important because it's the only way to create a fair "mining" system. Miners solve such puzzles as above but which are far more difficult.

For example, find a hash that looks like this: Each hash is can be considered to be just a number. For example, the hash ab3abc2cccc0bb4aabb24ffaf8c has a numeric value of So in mining, the miners have to achieve a hash with a numeric value lower than a specified number.

This number is called the target. If your hash attempt gives you a number less than the target, which is the same thing as having a bunch of zeros at the front of the hash, then you win and you get to "mine the block".

To find such a small hash takes millions of attempts, or more accurately, the whole mining network, with everyone trying at the same time, needs millions of billions of tries to get it right. The part of the content that they are hashing and are allowed to change, a single number, in order to try and get a hash beginning with zeros, is called the nonce.

The current block reward of 25 Bitcoins is given to the miner who successfully "mines the block" finds the appropriate hash. It's not really that mining "generates" the Bitcoin in any sense, it's just that it's written into Bitcoin code that a transaction block starts with a unique transaction called a "coinbase" transaction, which is the only type of transaction with no inputs.

It only has an output, consisting of the reward plus the transaction fees. To make any sense of Bitcoin's solution to this problem, you need to understand also what is meant by "distributed timestamp server" and how proof of work hashes can be used to construct this. It is, very briefly, explained in Sections 3 and 4 of the bitcoin whitepaper. You're creating a sequence of blocks, tied to each other by including the hash of the last one in the next one. This proves that the next block knew about the last block remember, hashes are totally unpredictable , which proves that it came afterwards.

However, that's not enough; you might know that block 8 comes after block 7, but what if a different block 8, put in by a different miner, also comes after block 7? Worse still, what if these two competing blocks, 8a and 8b contain different transactions, spending money to different places? Which one is the "true" block of transactions? The reason miners did the complicated proof of work process above is exactly to solve this problem.

In bitcoin, the chain of blocks with the largest total proof of work embedded in it is the "winner". The reason this is such a good way of deciding is that it makes it incredibly difficult for an attacker someone, say, who wants to spend the same Bitcoins twice to create an alternative single block or chain of blocks and try to convince everyone else on the network that theirs is the right one.

Since everyone else is working on the "true" chain, they have an enormous amount of CPU power working together to create it.

Lastly, here is Satoshi's explanation of the Byzantine Generals' problem. Hopefully you can see how it connects. The math problem that these mining computers solve serves no purpose other than to secure Bitcoin's network from attackers wishing to "double spend". Miners are not creating a massive rainbow table or computing the human genome. As more computers are thrown at the problem, and hardware advances, the problem is artificially made more difficult to compensate.

This seems incredibly wasteful to me as we start to read about the electrical costs of the Bitcoin network and think about the fact that Bitcoin could easily run on just 3 computers to be considered distributed. This is why I have high hopes for alternative cryptocurrencies, such as Peercoin , that implement proof-of-stake. The network could run on multi-purpose devices, such as people's phones and tablets rather than purpose-built and costly ASICs that will be redundant in a few years.

Programster's Blog Tutorials focusing on Linux, programming, and open-source. Bitcoin's Mathematical Problem bitcoin mining. We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.