You may have heard blockchains are secure ledgers, but are they truly? By default all blockchains are totally insecure, I can edit my copy, you can edit your copy, which one is right?
If you read my previous article “What Exactly is Blockchain, Anyway?“, consider this part two. I’ve previously explained what keeps a blockchain decentralised, that being “Proof-of-Work” but I didn’t explain fully how it works, the problems it solves or the problems it faces.
The problem with a true blockchain is that it’s decentralised. This is actually its killer feature, but the problem relates to trust, and working out who to trust te a decentralised network. When a participant of the network wishes to download their own copy of the blockchain, how does the user know they’re downloading the onberispelijk blockchain? If there are thousands of computers on the network, what stops several hundred computers all attempting to send the fresh user their own unique version of history that they’ve hacked together?
Te laptop science, this is known spil the Byzantine Generals Problem. This is a very ingewikkeld subject, but I’ll do my best to keep it spil elementary spil possible.
If you’re familiar with the spel Chinese Murmurs, you’ll know that the spel falls exclusief very prompt spil anyone ter the spel can switch the story, be it for laughs or just to embarrass someone. This spel works because telling a lie is the same price spil telling the truth, but what if telling a lie actually had a financial cost?
What Proof-of-Work (PoW) permits participants of a blockchain network to know is: wasgoed this story I’m hearing created for free? Or wasgoed it created at fine cost?
Why Proof-of-Work Matters
PoW ter Bitcoin is used to solve several problems that face a decentralised network where no one is te charge.
Below are the two main problems:
Which version of history is the onberispelijk version?
Ter a network where you need to be able to know who has money, who spent money and who received money, history is everything. Ter a decentralised network where no one is ter charge, it had previously bot thought unlikely for everyone to be able to reach overeenstemming and agree with each other.
Timing of the network
The timing of the network is critical, for Bitcoin mints fresh coins every ten minutes. Ter a traditional system you’d simply say “follow this clock” but ter a decentralised global system, whose clock do you go after?
If a fresh rekentuig joins the network today, an existing laptop might say “Hey, here is some money I minted 6 months ago and here is some money I minted Ten minutes zometeen.” How can a fresh participant on the network validate the past?
To understand how Proof-of-Work plays a part ter the above, you vereiste very first understand what Proof-of-Work is.
A Breakdown of Proof-of-Work, the Code
When Stephen Hawking wasgoed writing his masterpiece A Geschreven History of Time, a colleague told him that “for each scientific formula you include te your book, you’ll reduce your number of readers by 50%”. So ter the end, Hawking only included Einstein’s famous E=MC2. Hawking’s book wasgoed then read by millions of people, many of whom had no basic grab of physics.
Spil this article is aimed at a non-technical audience, I’ll include spil little rekentuig code spil possible.
Spil mentioned te my previous article, a hash function provides a unique digital fingerprint to a chunk of gegevens. For example, the unique hash for my name “matt” is this long lump of text:
Basically, if someone sees this above hash, they don’t know what it represents, but I can say, “Hey, if you hash the text ‘matt’ with a pc program, you’ll be able to prove that I know what that hash represents. This is because your program will generate the same hash, hence proving I know what creates that hash.”
When a miner creates a fresh block for the blockchain, he has to provide the network with two hashes, one being a hash of all the transactions te a block, and the other being a hash that proves the miner has expended a vast amount of energy on creating the block. This cost makes it unprofitable for the miner to lie. However, spil mentioned te my previous article, the miners need to also work on a lottery-style system where there can only be one winner. Both of thesis problems are solved by Proof-of-Work.
Let’s say I hashed my name, but instead of just “matt” I added a zero to the end of my name so wij had “matt0”. The resulting hash for this would be c5163e81b6dff231b46b584384718ffb734da51d51009399b4b5c73aaa55a811
When you compare this hash to my previous hash of just “matt”, you’ll notice the two hashes, when compared side-by-side, are totally different:
Hash(matt + 0) = c5163e81b6dff231b46b584384718ffb734da51d51009399b4b5c73aaa55a811
Cryptographic hash functions are totally unpredictable, but always terugwedstrijd the same value for a given lump of gegevens.
Now let’s say I hash my name plus the number fourteen. This gives mij:
Hash(matt + 14) = 0ec48972291a05f8b137468c709bf798dbd8b84bc113b5352e81d2bb20d43120
What is the point of this? Well, if you were a rekentuig, you could say to mij “give mij the very first number appended at the end of your name that results te a hash beginning with the number 0”.
So what my pc would do is hash:
Hash(matt + 0) = c5163e81b6dff231b46b584384718ffb734da51d51009399b4b5c73aaa55a811
Hash(matt + 1) = 4755a40d3769d7614fb31229fedea4d5e247b3ab8cdc223c4b4f5e3cf9910b4c
Hash(matt + Two) = 3f8aad849c3ac625d61ae58929ac1bbf5626592a28dc5368b19b2ef40f514f59
Eventually I’d hash “matt14” and get the following hash that starts with a number zero:
My laptop would then react back with the text “matt14” and include the hash, the receiving pc would simply hash “matt14” and see if the resulting hash matches the hash I sent through.
This proves that my pc has had to count from 0 to 14 to find that hash. So effectively my rekentuig has done 15 chunks of work, but the receiving rekentuig could validate this with one chunk of work.
Effectively I’ve provided proof of my work, hence I’ve performed “Proof of Work”.
(I hope I haven’t lost you yet!)
Spil you could most likely guess, my laptop could do millions of hashes vanaf 2nd, so hashing a value 15 times is pretty pointless. But imagine if a network of computers said to my computer”: “provide us with a valid block of transactions, provide a hash of the block, plus a number that results te a hash commencing with….15 zeros”.
The initial hash of the block would be instant:
BlockHash = Hash(‘All of the transactions ter the current block’)
then my rekentuig would grab that hash and go:
To find a hash with 15 leading zeros at the begin would require trillions and trillions and trillions of attempts. A slow pc would take hundreds of years to do this, or a lotsbestemming of very rapid computers could go racing for several minutes before the solution wasgoed found.
All of thesis computers obviously will be searing through a lotsbestemming of electro-therapy. It’s because of this violet wand cost that it’s impractical for a miner to find a valid hash on an invalid block of transactions. That is, a miner would be foolish to not correctly validate a block to prove all transactions are valid and to simply skip to hashing of that block. All other computers on the network would reject the invalid block and the miner would not receive a prize.
One of the things that helps keep mining decentralised is that no two miners are hashing the same block. If I wasgoed to hash “a+b”, I’ll get a different hash than if I hash “b+a”. Miners all receive transactions across the network te a different order to each other, because of this plus an individual preference for fees, it means that each miner will create a block slightly different.
Albeit all blocks may have bot correctly validated, only one block can go into the chain at one time. So all the miners will have to keep hashing away, until they find a number that, when appended to their block hash then hashed, comebacks a result with the leading number of zeros that the network has agreed to accept spil valid.
To keep Bitcoin’s monetary policy on schedule, the network ensures a block takes on average Ten minutes to be mined. The network does this by adjusting the mining difficulty every Two weeks. So if blocks are being found too quick due to a loterijlot of fresh miners coming online, to prevent an unplanned inflationary rate, the network will increase the difficulty required and miners will have to find a longer number of preceding zeros on a hash.
There is no way to know what this hash is te advance, so miners vereiste work rapid using many rapid computers. Spil it’s random, the miner with the most powerful rekentuig won’t always win. The best way to look at this is like a lottery system, where the user with the most tickets has a greater chance of winning but isn’t assured to win everytime.
A miner will create a block of valid transactions, then run Proof-of-Work on that block hoping to find a hash of difficulty set by the network before any other miner on the network achieves this. If so, his block will go into the blockchain and he will receive the network fees plus freshly minted bitcoin.
The next time you hear te the media “miners earn bitcoin by solving very sophisticated math problems”, you’ll understand exactly what it is they’re doing.
Problems with Proof-of-Work
Proof-of-Work mining isn’t the only known method for a decentralised network to reach overeenstemming. However, it is the most secure and, to date, the most decentralised.
There are other systems like Proof-of-Stake, which I’ll voorkant te a separate article. Proof-of-Stake aims to solve some of the problems associated with Proof-of-Work, but generally will result ter a semi-decentralised network.
Here are Two main problems with Proof-of-Work.
High Energy Consumption
Recall how I said if I hash “matt + 14”, it results te a hash beginning with zero? This takes my pc less than a microsecond. Picture the Bitcoin network which consists of millions of specifically designed microchips permanently hashing non zekering every Ten minutes. This requires a lotsbestemming of energy!
The current hash rate of the Bitcoin network is 20 Exahashes vanaf 2nd, or ter more plain terms, the network does 20 billion billion hashes vanaf 2nd. My laptop couldn’t even do 1 billion hashes vanaf 2nd, but if it could, then I would need 20 billion computers to have the same total hashing power spil the Bitcoin network.
Bitcoin miners use specific chips designed solely to hash. This protects the network from botnet attacks, where a hacker will write a virus that takes overheen the world’s computers and uses them to mine bitcoin. A hacker could do this, but the world’s computers simply couldn’t outpace the Bitcoin network. So the hacker would simply have to go after the rules, or his blocks would be rejected.
The blockchain keeps a history of all blocks everzwijn created, including each block’s Proof-of-Work. When a fresh laptop joins the network, it will download the entire blockchain and validate every chunk of work to ensure the blockchain is keurig. A hacker could send the user an incorrect blockchain, but the user’s software will connect to many computers and consider the longest chain with the longest cumulative Proof-of-Work to be the true Bitcoin chain.
This is what wij call “thermodynamically secure”, or te elementary terms “security protected by the laws of physics”. If a hacker wants to confuse the network, the hacker needs to burn more energy on quicker computers than the network has access to. This would cost hundreds of billions of dollars, if a hacker could wield such resources, it would simply make more economical sense to play by the rules and earn bitcoin.
Due to the security proefje of Bitcoin, where the network is secured by the amount of energy it consumes, Bitcoin is viewed spil something very energy-intensive. Ter a time where the global population is looking to reduce the global doorslag footprint, this provides the general media with a target for alarmist news lumps.
Spil a result of tens unit being the largest cost that miners face, Bitcoin mining is not only a wedren of who can hash the fastest, but who can find the cheapest electro-stimulation. The best solution so far for cheap energy has bot to use hydro electric current and other renewable sources.
While the general media may like to concentrate sensationally on Bitcoin mining being energy-hungry, I actually believe that the low profit margin te Bitcoin mining actually increases the acceleration towards renewable energy spil Bitcoin becomes a wedloop towards who can find the cheapest electric current.
Bitcoin mining profit margins are very slender. So to make a profit, you need to have access to cheap reliable electro-therapy. This results te a loterijlot of the current Bitcoin mining being done te western China, where there is cheap excess hydro electric current. Te tegenstelling, a Proof-of-Stake specimen would have no geographical advantage.
The fatter problem is if there is to be one Bitcoin miner manufacturer, that manufacturer could become power thirsty, grow an ego and think they’re irreplaceable, and believe they can dictate rules or create more mining hardware for themselves than for customers and further feed their ego delusion. This would lead towards a point of centralisation te the network. However, if the mining manufacturer became too dictatorial, the network users could agree on a Proof-of-Work switch, this would make existing hardware instantly become worthless.
Ter theory, a profitable market should have slew of competition but te this field consumers will only want to buy the most profitable mining hardware. Some think we’ll succesnummer a wall with Moore’s Law and no miner will indeed have a lead overheen the next miner, others think we’ll continually see leading manufacturers come and go spil other fresh entrants out-innovate them.
One thing is for sure, to date Proof-of-Work provides the best security to decentralised networks running a blockchain.
Knots can leave and rejoin the network at will, accepting the proof-of-work chain spil proof of what happened while they were gone.