Cryptocurrencies, bitcoin and blockchain have been all over the news lately. From my mechanical engineering background, the descriptions I read online left me with a lot of questions...
Why are they so popular? What does 'mining' involve? What do they offer over traditional currencies? And why are there so many news articles of mass theft in the currencies from exchanges?
So, whilst waiting for a house transaction to go through, I decided to write my own blockchain and learn what they are all about. This is hopefully a guide for those in a similar position to me, with more interesting technical details to help illuminate the way. It is not a comprehensive article into all types and implementations of blockchains out there, but it should give a good indication of what is going on.
To start with, you need to understand the idea of a hash code, this is the key to the entire thing. A hash code is the output of a maths equation, which takes data (e.g. a date, a number and some data) and creates a seemingly random code from this. If you change the input data by any amount it will produce an entirely different code. The nature of the equations means you cannot go backwards easily, the only way known is to try every option out there until you find it (read about SHA256 if you wish to know more).
For example, here is the following
What you can see is a single small change has led to a very different output. The principal is you cannot easily go from the hash code back to the original data. For simple data you can look it up, however this is where a blockchain gets formed. By using the hash code of the previous block when generating a new one you make this problem far more difficult to figure out what that data was. Now the key is not to try to hide the data, but use this to validate the chain and discover tampering.
You now create a block, which is just a collection of bits of data. It contains its position number in the chain, the data you want to store, the hash of the previous block and the hash of this block made from the data, index and previous hash (you can’t include its own hash).
When a new block is made, it is transmitted to the entire network. These are other machines or programs which store a copy of the chain. With their information they contain, they can check the block you are sending is valid, if not they can reject it. Now issues can come up as all these programs (called Nodes) could also make blocks, and with natural delays in things it might go out of sync, where some Nodes contain different chains to others. To fix this, first they can request the entire chain from a Node, and very quickly check its entire contents are valid. If there is something wrong, you know someone has tampered with the data.
Clearly, they do not match up. As the new block is unknown and you have done the calculations yourself on the rest of the chain, you can be 100% certain that the new block 70 is a lie. Someone has tampered with something, and they have been caught out, but it has been an easy process to catch the lie.
This is the principle of a blockchain. It is easy to detect when someone has tampered with the data in there, so you know what is the truth and valid. As the blockchain is not only stored by one Node, but by many if one goes down, the data is not lost as all the Nodes keep a record and it is easy to tell if someone has altered it. The strength is that more than one person holds the data, there is a record kept which is easy to verify it is valid and not tampered with.
However, this doesn’t explain a cryptocurrency, the process of mining and why is it so power hungry. This is a bit harder to explain and needs some details removing for clarity.
Previously the data in a block could be anything, but now the data is a record of a transaction (or a list of transactions). It contains two main pieces of information, the first is where the transaction comes from, the second is who it was given to and how much. Now anyone could add to the blockchain, so to stop tampering a signature is added to the information defining who sent the transaction through in the first place, which is where keys come into it.
This signature is created using public-key cryptography. In this system you have two keys (very big numbers), a public one you share with the world and a private key only you know. When you create a transaction, you sign it using your private key. Anyone else can then confirm it is you by using your public key to validate the signature is correct. Providing only you know your private key, no one can make a transaction on your behalf, not without going through a very long time consuming process to find out what your private key is. It is far simpler and quicker to hack into any system that is storing your private key (and preferably others), which is usually behind a simpler password.
So now, to send money, you make a transaction, sign it off with your key so no one can pretend to be you and get it added to the blockchain. The addition of the transaction to the blockchain verifies the transaction and it can’t be undone, else it will invalidate the chain. If someone tampers with it their fraud will be picked up!
Job done, you have a cryptocurrency! Except you are missing the start of the transaction, how is money added to the chain in the first place? You can only send money you receive, so where does it all come from in the first place? This is mining!
Going back to the blockchain, who would become a Node? Who would take on this task to verify transactions and add them to the chain? This is where mining comes into it.
Mining is a reward for those who verify transactions, and is principally used to create coins in the system and generate value in the currency. The process of mining can’t be simple and trivial, else everyone would do it all the time and there would be no value in the currency.
If you create a new block you can add a transaction to yourself for some “coins”. However, generating a hash code is easy to do, you just need data. To make it a worthwhile pursuit you introduce a concept of difficulty. The hash code you generate needs to fulfil this criterion, if not then it is not a valid block. For example, this could be the hash code needs to be below a certain value, or it must start with a certain number of zeros. If it meets this criterion you have a valid block and are rewarded with some lovely coins you can then carry out transactions with.
However, if the data in the block is fixed, how can you mine if the hash created does not fulfil the criteria set? This is done by adding in a new bit of information which helps create the hash code. For example, this can be a number, you include this in the hash code, if it is not valid you just go up one number and try again. You keep going until you get a valid block and can then collect your reward! This is where mining becomes energy intensive, as it can require a lot of processing time to find the next valid block, which is being replicated across the world by all other nodes trying to do the exact same task.
But what sets the difficulty of the system, or stops it becoming so easy to mine new blocks with custom pieces of silicon specific for the task? Well this is determined by a predefined agreement at the start of the blockchain on how often blocks should be mined. If blocks are being mined too quickly, the difficulty level goes up, and the level can be reduced if it becomes too hard. This would make the system open to manipulation as it leaves the question of if you have two chains, which one do you accept as the truth? The resolution is to accept whichever chain is has the highest cumulative difficulty (known as the “Nakamoto consensus”).
So, if you cheat and create a block that is too easy, it risks being quickly uncovered as someone else might make the harder one and wipe out your block. If you spend ages crunching the numbers and make a super hard block, but fall behind the rest of the chain, you lose again as your chain won’t be suitably difficult in its entirety for other to accept it. As the chain gets longer, the risk of it being invalidated goes down, so why risk it?
You have succeeded! You have a cryptocurrency. All the wallets and everything else are user interfaces to make it easy, but fundamentally who would put money into this? Why should I put my hard-earned cash there? It goes back to the fundamental question of currency and checks and balances.
You now have a working cryptocurrency, and hopefully understand what it involves. But why is it worth so much? Fundamentally it is just a random number which others value, is it not?
Well let's go back to currency and cash. This is now back in my world, outside the world of bits and bytes.
Open your wallet and take out a note (if you have one with contactless payments taking off). It should say something like “I PROMISE THE BEARER ON DEMAND THE SUM OF FIVE POUNDS” signed by the “GOVENOR AND COMPANY OF THE BANK OF ENGLAND” (I’m moving house, and it is expensive). If I took a train down to the Bank of England and presented this I would get … nothing. The pound is not backed by anything physical, neither is the dollar or any other major currency out there.
So what is it worth? Nothing. Like a bitcoin the worth is not tangible or something you can touch, unlike the olden days. It is built on a mutual perception of value, with this I can change the money for goods and services someone agrees is equal to the value of that pound. It goes all the way back to the start of currency, where people wrote on pieces of bark that they would pay the bearer of that bark the sum stated in some physical means. It is a leap of faith, built on the understanding that someone out there will value it. If you take that away it is worthless, a piece of code of cloth with some random numbers or ink on it saying it is valuable. Only the person getting this can determine if it is of value to them and accept the transaction.
To complete the circle
With all this in mind, there is nothing to say a Cryptocurrency is doomed to fail and a waste of money. If people believe it has value, it has value as they will put their money where their mouth is.
However, I will not put my money where my mouth is. I won’t be putting any of my hard-earned cash into buying these pieces of numbers. Some have done so and won; some have done so and lost. But it's down to a few issues I have with the currency and the idea of a Cryptocurrency.
- First, having a transaction validated by a large group of people takes time. Visa/Mastercard handles transactions several orders of magnitude larger than bitcoin because they don’t need to send this information around to thousands of others.
- Secondly, it’s a green issue. Why are we spending lots of power in chips in data banks to not only verify transactions but also transmit them around the place? There is a gradual move away from mining (which has the primary purpose of issuing coins) to transaction fees, but this starts looking similar to the existing systems out there.
- Thirdly, fraud! Cryptocurrencies are great because if a single node fails, others will fill their place, but they have a single flaw. If someone hacks your private key they can create havoc for you. Yes, you can’t fake a transaction, but who says it was a reasonable transaction to do? Who believes a property in the centre of London or New York or Hong Kong is the same value as $1? No one, as it lacks context and an interpreter of saying “something is fishy there”, maybe I should question this. There is no check and balance to ask "does this transaction make sense", only that it is valid. You are trading off two mutually exclusive points, you either know where your money is, or accept you may lose it but someone will pick up fishy activities. As fishy activities are on the rise and getting worse, I go with that as my driver.
- Fourthly, they are too easy to setup and are not a working currency. Presently, the fluctuations in value in bitcoin screams at me that this not a working currency, it is too illiquid and prone to huge value swings and looks like a bubble. Here people are speculating on the value of what they have, not the underlying value of what they own and what is going on. I do have a strong belief that bitcoin will either stabilize and become a useful, valid, viable currency, or crash and be worthless. It is too early to tell, but I am not gambling at this late stage.
- Fifthly, population and size. In the history of mankind since the Roman times, the average life span for a currency not backed by physical gold is 27 years, we are now an outlier of this rule at 87 years. Our entire currency method is now backed by being loosely based against the US dollar. I have faith in this as for the US to go down, there will literally be blood in the street (there and here), a population of over 300 million people can’t go away or change faith without some form of cataclysmic disaster (in which case who cares about currency, we will go back to a barter economy like every example in history when hyperinflation takes hold). When you analyse our planet, somewhere in the region of 5-7 billion people rely on a currency related to the USD, it will take a lot to shift this which seems to be why this system has lasted when others have failed in the past. Cryptocurrencies are a rounding error compared to this and need to get to this level to inspire confidence they are not like the previous examples but join the rare one of the USD.
So for those reasons it is a no for me, I will put my £5 hard earned cash back into my wallet, even though the reasons to why that has value is the same as why a bitcoin has value for other people. For myself, it is just not worth the risk.
Useful applications of blockchains
There is a lot of hype and expectation around everything blockchain and CyrptoCurrency related, with a company’s stock price jumping up with the mere mention of their name (Long Island Ice Tea soared over 280% by changing their name to Long blockchain Corp). The underlying technology of blockchain is a fascinating new development, but a currency is not the best application.
Many companies out there are now considering how to use blockchains to enhance their business and make improvements, whether it is from supply chain management, to validation of software distributions. There are many different other ways of implementing blockchains to that mentioned here which offer different benefits and drawbacks. Some of these ideas won’t work and others may take off in unexpected ways, technological trends are notoriously difficult to predict, however the idea of having this distributed storage of data, where deliberate manipulation of the data is easy to detect has strong benefits.
Blockchains will not be uninvented, but as with many previous inventions, perhaps their true potential is in a different field, the key is to understand how it works so you can best implement it to your needs.