Dissolving the Myths of Crypto Mining
#PandaBlogs — What Mining Is and Isn’t, Part 2
Rufus Wright and Panda team
What we refer to as “Mining” is often inaccurately referred to as a security mechanism responsible for securing transactions of cryptocurrencies. However, the truth is that mining has nothing to do with the security of transactions and is actually something called a “consensus mechanism” named Proof of Work. That is to say that miners aren’t necessary or even responsible for verifying transactions, rather their function is to create a consensus around which transactions have taken place and at when these transactions occurred. Peer-to-Peer (P2P) encrypted transactions are innately very secure and without cracking the underlying encryption, which is pseudo-impossible, there are only a limited number of attacks that can theoretically be executed on such a network. In fact the only real weakness of such a network arise from how to form a consensus around what is true and what isn’t.
The way Bitcoin and other cryptocurrencies are designed all transactions take place on a P2P network. This eliminates the need for middlemen, as any transaction that is cryptographically signed can be mathematically verified. This is due to digital signatures, which function similarly to normal signatures: if someone signs a check, so long as you know that their signature is real, you know that the check is real. This means that the value transfers can easily be confirmed and it is nearly impossible for someone to gain access to another person’s coins without having access to his/her private key. So, if transactions and ownership can be so easily verified why do we even need mining at all? The problem isn’t determining who did what, the problem is determining who did what when.
Thus Blockchain was created as a means to record what happens and in what order it happened. The Blockchain can be thought of as a big book where each page is filled with all the transactions that happened during a set time-period. Everyone has a copy of this book and whenever a transaction occurs they record it in their book. However, having this book isn’t enough, since everyone has their own copy of the book and can make new and/or fake copies at any time, how do we determine whose book is the real book. This is where mining comes in, mining is the way to determine who’s book is the real book at any given time. Mining doesn’t prevent people from changing or manipulating the book, but it does create a measurable cost to doing so.
The problem that mining solves is called the Byzantine Generals Problem (BGP). Here is an example of the BGP: Let’s say we have 4 people; Tom who has 100 coins and knows everyone else, Mary who washes cars for 12 coins and knows Tom and Sally, John who sells widgets for 100 coins and knows Tom and Sally, and finally Sally who sells sprockets for 1 coin each and knows everyone.
Now let’s say Tom pays Mary 12 coins. He shows her a copy of his book and since their copies are identical, both showing that Tom has 100 coins, Mary verifies Tom’s transaction. Both of them then note the transaction in their books and Mary starts washing his car. While Mary is washing his car Tom erases the transaction from his book and goes over to John and asks for a widget. Since John doesn’t know Mary he didn’t know to add the new transaction to his book, so when Tom shows John his book their copies are identical and John believes that Tom still has all 100 coins. So, John accepts the transaction, records it and gives Tom the widget. Now Tom, who is really greedy, goes back to Mary picks up his car and erases all the transactions from his book.
Now Tom has spent 112 coins, but he only had 100, so at least one of these transactions must not be authentic. Mary’s book shows she has 12 coins and John’s book shows that he has 100, so both of them decide to go buy some sprockets from Sally. When they get to Sally’s sprocket shop, they find Tom there buying some sprockets for himself. Now they all compare their books, and lo-and-behold both Mary’s and John’s books have transactions that neither Sally nor Tom have. Consequently, Sally says that she can’t accept either Mary’s or John’s coins since they don’t match with what she has in her book, and they don’t match with each other either, leaving her in a position where she doesn’t know who to believe. Since her book and Tom’s book do match she might be willing to accept his coins, but since Sally can verify Tom’s signature next to the transactions in both Mary’s and Tom’s books she decides that she can’t trust Tom either.
This is called the Byzantine Generals Problem and is the biggest issue in creating a decentralized or distributed system — without a central locus of control how can we establish a consensus around what happens when? In the world of crypto, what Tom did above is called a double spend attack, indicating that he spent the same coins more than once. Technically speaking, Mining is a means to form a consensus around what happens when, using computational work to guarantee the finality of transactions. The reason mining is called Proof of Work (PoW) is because the finality derived from mining is fundamentally ensured by the work that is done through mining. In the above example, what we need is a way to agree on what transactions happened when and make sure no one can change this record later on.
In order to solve the Byzantine Generals Problem, crypto currencies use mining and the longest chain rule. Let’s imagine that there is a driving range, where people go to hit golf balls, and this particular driving range is filled with holes. Anytime someone makes it into one of the holes a new hole appears further away, and if it was the furthest hole on the range then they get a reward and can add a page to their book. By saying that we will accept the book with the most pages as the correct one we can now create a method to determine what is real — this is called the longest chain rule. Each page now has an amount of work attached to it, so while someone could theoretically make their own book from scratch, by hitting balls into every hole starting from the first one, they would never have as many pages as they could get by just copying the person with the most pages and then just trying to hit the ball into the furthest hole.
This is essentially how mining works, each block has a complex problem attached to it, the only way to solve this problem is to input numbers and then see if you get the solution. Millions of computers try to solve this problem by inputting random numbers and trying them. Once someone successfully solves the problem she/he produces a new block, gets paid, and then the problem gets a little harder. Using the longest chain rule we can say that the Blockchain (book) with the most “blocks” (pages) is always considered to be the most “true”. Since whoever finds this new block gets paid they have an incentive to broadcast it, and everyone else has an incentive to accept it, assuming it’s authentic, since not doing so would make their chains shorter than that of those miners who do accept it.
Mining is the most proven method for establishing a consensus on a blockchain. The main responsibility of Miners is to validate (not necessarily verify) transactions. This implies that miners determine which transactions occurred and in what order they did. Since mining takes lots of work, and since the Blockchain with the most work is always considered to be the valid one (longest-chain rule), if anyone ever wanted to control the blockchain or alter it they would have to do more work than all the other miners put together. Thus, it is this work and the cost associated with it that allows mining to solve the Byzantine Generals Problem.
© Panda Analytics, Inc.
2018