Blockchains are everywhere at the moment, with pretty much every large tech company investigating whether they can practically use them for… well… “something, there must be something we can use them for?”.
So are Blockchains a solution looking for a problem? Or will they be truly revolutionary beyond the hype around virtual coins?
Here is everything you need to know about Blockchains, where they came from, how they work, and some of the potential use cases. Sit back, pop a virtual coin in your nearest digital beverage machine and let’s get to the bottom of it..
First Blockchain – what is it and where does it come from?
Blockchain was invented by Satoshi Nakamoto in 2008. Who is Satoshi? Well either a person or a group of people who developed the concept for use in the crypto-currency Bitcoin. Nobody really knows to be honest, or if they do they are not telling or proving it. Suffice to say it is not important to get a grip on the technology.
So what is Blockchain? As I just mentioned, it is the foundation for crypto-currencies, which, as John Oliver wisely said, are “everything you don’t understand about money, combined with everything you don’t understand about technology”. An ideal opportunity for a hype cycle if ever I saw one.
Before going into the technology of Blockchain, let’s look at the concept of crypto-currencies, of which Bitcoin is surely the most famous (and the focus of the Satoshi paper), and then onto blockchain which is essentially the underlying technology that allows crypto-currencies to exist.
Let’s break this down. Crypto – refers to cryptology (study of) or cryptography – the art or science of writing or solving codes (today, most associate this with mathematical techniques). So we are talking about codes associated with a currency to perform some function.
Currency – a system of money in general use (typically within a country, but in the case of crypto-currency there is no specific country associated with it, even though it’s worth is typically related to a more traditional currency like the dollar).
With that defined, let’s now ask a bigger question – why does money have value? Not going into too much detail on this, but essentially it provides a unit of account or value making it easier to exchange stuff, a medium if you will. Easier than bartering the value of goats for chickens or every item under the sun relative to one another. It gives a stored value to be applied to each of these things. The fun thing about money is it allows economic transactions over time, at any distance, for anything. The other thing to remember is that money is only worth what someone else is willing to give you for it (be that silver, gold, coins, paper, or virtual coin). Physically producing more money does not make everyone richer, but it can affect its value. If there is too much of it, it might be worth less, i.e. someone might give you less for a certain amount of it. We see this everyday in economic transactions, central banks, markets etc.
What is it about Crypto-currencies that are so appealing at first glance?
When you consider a currency that is not controlled by any government, corporation, bank, or individual, and is essentially just code, then maybe you see its appeal. When it first came on the scene it was viewed as a kind of virtual money Utopia. No bank in the middle to transact regardless of geography. There are technical challenges of course, but the concept itself is attractive. As such it is known as a de-centralised currency, in that the records (or ledger) of every transaction ever made can be stored in a de-centralised manner across many computers anywhere (not like a physical ledger sitting centrally in a vault). A distributed ledger, no central server, or repository of information, so better for security (no single place to attack), and potentially fast.
A secure, distributed database then. Who could see an advantage in that? Hence all large tech companies looking for uses around sharing data, securing transactions etc. If it works reliably (and time will tell as it is still very early days), it looks like a solution that might be applicable to numerous problems, not just crypto-currency.
The scramble has begun.
It is the Blockchain technology that enables this so let’s take a look.
What is it and how does it work?
The blockchain is the essential underlying technology that enables cryptocurrency.
A blockchain is a chain of blocks, and blocks are packages of information (a unit of data, value of money, anything really). Each block has three things essentially: the data, the hash, and the hash of the previous block. These are all linked together or ordered in a network where all the peers are not trusted. The block represents the record of a transaction (or group of transactions)..
Alice wants to send Bob some money. This transaction is represented as an input and output address with a value (which will be explained later), and sent or broadcast to every party in the network, who then approve this as a valid transaction. The transaction is ultimately validated by being included in a “block” that is added to the “chain” hence blockchain. This is a transparent and indelible ledger or record of transactions. The money flows and the transaction occurs between Alice and Bob. Every transaction is listed and linked to all previous transactions, and is there for all to see as a distributed ledger.
Sounds simple enough on the surface, but what is really going on here, and how is a secure distributed ledger achieved?
Consensus and proof of work together, are really the magic behind Blockchain technology (and Blockchain is the magic of crypto-currency)
Here’s a term for you, ‘Distributed Trustless Consensus’. How to achieve this through cryptographic means is pretty much the major innovation of Blockchain. From this term comes an understanding of transactions and makes mining easier to grasp.
Consensus – two parties (or indeed multiple parties) agree that something means something. We both agree on the meaning, and in addition we both know that the other agrees. With a currency this understanding or consensus not only applies to the transacting parties, but to everyone using the currency. When it comes to money there needs to be a consensus that there is not an unlimited supply (scarcity), and that everyone agrees on it as an accepted means of value exchange. What we are also implying is that there is a consensus around accepting these tokens as money of comparable value, and everyone sticks to it. Once there is consensus, we can transact.
In the physical world we are all familiar with the money supply, and that it is not unlimited, but controlled by a central bank, usually country specific. With digital money this can be mimicked by having a central database on a server which keeps track of who holds what money, and when transactions are performed so money is not overdrawn. Like digital banking. Where we are going with blockchain is towards a distributed database to achieve this, rather than centrally with today’s digital banking.
So this is consensus, and how you get there (either centrally or distributed) is a key concept underpinning blockchain.
First, achieving consensus with proof of work solves the infamous double spend problem explained below.
The double spend problem
In a central mint system, once a physical coin is replaced it goes out of circulation, is returned to the mint where possible (to be converted into new coin), and then not accepted as currency. This stops the double spend problem as there is only one unique coin in circulation at any one time and therefore you cannot spend the same coin twice. You can have 2 coins of course. Say there are 100 x 10 pence coins in circulation. You may own 2 of the 10 pence coins in circulation, but you cannot use the same coin twice, unless it has found its way back to you through a series of transactions – in which case it is a separate transaction and therefore not a double spend. You can’t give the shopkeeper 10 pence for some sweets, take the 10p back and buy the sweets again, as you have already exchanged it for some goods or service, so now you are stealing that 10 pence piece. As the 10 pence will have gone into the cash register, or the merchant’s hands, everyone knows you are trying to steal it back or double spend!
The UK’s national currency exists in 3 main forms, one is physical, the other two are electronic:
- Cash – banknotes and coins.
- Central bank reserves – reserves held by commercial banks at the Bank of England.
- Commercial bank money
With money represented online via your bank account, the commercial bank is the central point of control and the money is represented as currency in your account (e.g. pound sterling). There is still only so much money in circulation as far as the central bank is concerned (total physical cash, and total electronic cash held in the central reserves), but commercial banks themselves can actually create money too. They do this simply through lines of credit or loans. Whenever credit is issued or loans are deposited into a person’s account, the bank has literally created money. This all then needs to be squared off through the financial system so that, should the economy take a turn for the worse, and people want their money withdrawn from a bank either into either physical cash or into another electronic store (not stored in a commercial bank, or even a safer commercial bank) there are enough reserves in the system to account for these economic shocks. With the financial crisis it transpired that commercial banks were not holding enough in central bank reserves (money the central bank has “printed” which the commercial bank has acquired) to weather the economic storm. When people wanted their money back through this interdependent chain of loans, ultimately at the end of the chain, the reserve money simply wasn’t there in enough quantity in commercial banks to cover their liabilities.
This all gets rather complicated, but serves to illustrate a point with digital coin, in that creating it is analogous to a central bank that “prints” new physical or electronic money to add to the total circulation.
Digital coin acts like a central reserve system in that if you want more physical currency, or a “note” added to the system, then in the central reserve world the total amount of currency in the system (physical money in circulation and electronic money in the reserve) needs to go through a process – namely printing the note, having it all approved, and the corresponding amount deducted from the electronic total in the central reserve.
So creating digital coin (like bitcoin) is similar to creating a central reserve printed bank note. With a central reserve it is difficult to do, and there is a long central social process (with checks and balances) to make sure there is no double-spend when a new note is printed (i.e. the same bank note produced twice), whereas with digital currency there is a digital distributed proof or work process to achieve the same thing.
Bitcoin is both a store of value and a medium of exchange, and can act as a unit of account (i.e. related to some value in the real world, in the same way that the commodity price of gold could be compared to a weight of grain). As it takes electrical energy to produce a block, it could therefore be compared to a watt-hour for the initial unit of account, and it would be to this unit that initial value can be applied. Demand, of course, assigns any real-world comparative value to an existing currency, or an exchange rate.
The store of value is the IOU, and the medium of exchange are the linked transactions of the blockchain.
The trick is to make this a distributed system, and fortunately we know how to do this – through distributed databases. The only question is whether all the records on all the servers are updated immediately for strict consistency, or there is a lag while everyone gets up to date, which is called eventual consistency. With eventual consistency there needs to be a small safety net so transactions can be cancelled if things get out of synch, or a conflict elsewhere on the network to get things lined up again. As long as this can be achieved and everyone agrees, we have ourselves a system.
Now we have explained the concept of consensus and how it roughly relates to existing currencies, we need to look at how this is implemented in a distributed system through proof of work.
Byzantine Generals Problem
A good lead-in to proof or work, and framing of the distributed system problem it solves around consensus, is a very brief explanation of the Byzantine Generals Problem.
Say there are two armies who need to work together to invade an armed city, and they are sitting ready and waiting on opposite sides of the city. The Generals of each army would like to agree an attack day and time, as they know if they both attack at the same time they will win, but will certainly lose if only one army attacks.
General A wants to send a message that says to General B, “agree to attack at 4pm on Thursday?” General B then replies “Thursday is bad as that is the day we hold our army’s mindfulness yoga session. How about Friday at 12pm?” General A replies “ok, agreed”, and General B replies saying “Sorted then, agreed”.
In order to get the message across, each General dispatches a lieutenant with the messages. The problem is the messenger travels through the city to get to the other side and could be compromised, so how do you believe the message? Or what if the message gets changed to “agreed Thurs at 4pm”?.. meaning only one army attacks and they get slaughtered. This extends with more parties and more messages so there is a need to ensure the integrity of all the messages, and timings.
In our Blockchain story this is where the linked hashes and proof of work come in, so keep this Byzantine Generals Problem in mind as we walk through the components and onto proof of work and timestamps.
Blockchain uses eventual consistency to achieve consensus and achieves this through proof of work. In order to step our way to proof of work, let’s see how the Blockchain is built up and how the underlying technology works – this makes proof of work simpler to understand.
The meat and potatoes – how the components come together
What we are trying to achieve is consensus around the validity of the transactions and the record of transactions, namely the ledger. For this the crypto hash is a very handy tool.
What is a hash? Think of a hash as a one-way scrambler, where you get the same scrambled egg pattern every time you scramble that specific egg. Any other egg would produce a different pattern, but the same individual egg will always produce the same pattern of scrambled egg. This mathematical magic is very useful as it can provide a virtual fingerprint.
Technically with a hash you can take an arbitrarily long string of bits and produce a fixed sized result, where it becomes unfeasible to construct two different strings or messages that hash to the same value. Good hashes require properties such as being truly one-way, so once scrambled it is pretty much impossible to tell what the egg looked like in the first place. It can be computed but not inverted. Secondly it must have good collision resistance, which means that two messages that are different are exceedingly unlikely to produce the same hash value when put through the hash function. It is this property that makes hash functions useful in signature schemes. If you have a value or word like “blockchain” and put it through a hash, then the hash value might end up at the number 241, (for simplicity’s sake – the real values are much bigger of course), but if you add an ‘s‘, then the word “blockchains” might end up at the value of 162. Different messages should never end up at the same value, as that is known as a hash collision.
This way, if anything changes about a string or value you are interested in, then it produces a different hash value. This way you know it has been altered. Equally, if the value stays the same according to the algorithm (it is therefore what you expect), you know it has not been altered. If I put the word “blockchain into the same hash algorithm, I will get the same value every time, and nothing else will ever produce that value.
Actual Sha-256 Hash of “blockchain”
Sha-256 Hash of “blockchains”
Result = completely different fingerprint
How does all of this relate to a chain of transactions? Well the humble hash is used as linking method from one block to the next, a bit like a linked-list.
Blockchain as a kind of linked list
For those who have done a bit of Computer Science or coding, and know your data structures, you will be familiar with the concept of a “linked list” – a data structure of no fixed number of elements which allows insertion and deletion in a less expensive way than, say, arrays. It took me a little while to get my head around coding the various forms of linked list when I was at University, but the concept is simple enough, and no need to code them for this explanation. You can see the association with blockchains in the ‘link’ between elements (see below). In a linked list you have the data element, and then a pointer to the next element.
This is similar to Blockchain except that each block has a hash of the previous block, which could be looked at as a pointer to the previous block. The reason I have included this explanation is because you will often hear people saying Blockchain is basically a singly linked-list.
The data structure itself is a little more complicated than a linked-list and this is where Merkle trees come in
Raplph Merkel of Berkeley and Stanford university patented the concept of hash trees in 1979, and a quick Google search will find his thesis on Merkle trees. Ralph Merkle is famous of course for his contributions to both public key cryptography and the Diffie-Hellman key exchange, with Hellman in 2002 suggesting it should be called the Diffie–Hellman–Merkle exchange to recognise the contributions made by Merkle.
What is a Merkle tree?
Merkle trees are constructed bottom up starting, therefore, at the bottom by hashing individual transactions (typically a SHA-2 hash function). You then add a timeline, whereby each node (or non-leaf node) is a hash of previous transactions up the tree (like a linked list with a pointer to the previous node). As you are combining transactions you need an even number of leaf-nodes, so if the number of transactions is odd you duplicate the last hash to produce an even number of leaves.
Take a look at the below which might make it easier to understand. Each transaction is hashed and stored in a node. A node in the tree sense is simply a point of intersection/connection within the tree (a node in Bitcoin is similar but involves a few other things described later when we come to users, nodes and miners).
Consecutive pairs or nodes are then hashed (e.g. A B), and summarised in a parent. This keeps going until you have a hash of all the transactions summarised in a single root hash (ABCD). If someone changes something anywhere in the tree, or it is not in sequence, the root has a different hash and you have an invalid block (remember the unique properties of a hash fingerprints mentioned earlier).
So ultimately a Merkle tree can summarise all of the transactions in the tree in a single fingerprint or hash. Powerful stuff. A user can now look at a transaction and verify whether it is included in a chain of blocks, or chain of transactions.
Through this method you can now prove whether a log or ledger is consistent – a general distributed ledger. In each instance you need to verify that no previous records have been tampered with, namely the integrity and validity of the previous data. Simple answer, compare the root hash and away you go. All data or logs are stored chronologically, so any later versions simply need to check out with root hash to be considered valid. This shows whether any previous versions of the ledger have 1) all the data/transactions recorded, and 2) whether chronological order of the log has been maintained.
One other thing to note, as opposed to a hash-list, is that a branch of a Merkle tree can be downloaded individually, and therefore the integrity of individual branches can validated immediately. This means small data blocks can be downloaded and you don’t have to download large entire data blocks if the original has become damaged somehow. Therefore only tiny amounts of information need to be transmitted over the network, thus proving integrity and validity is fast and doesn’t take up much disk space or compute power.
Merkle trees then, in short, help prove that a log or ledger is complete and consistent. Nothing has been altered or tampered with, nothing added, and the tree hasn’t been branched or forked.
Think of a block as the thing added to the chain that enables new coin to be awarded and the currency to expand (adds coins or currency into circulation). Once a block is created by winning a puzzle competition, coin is deposited into the winner or miner’s wallet (created), and then into circulation to be used for transactions thereon in. It also validates transactions.
A block essentially consists of: a unique identifier to the block (this is the result of the mathematical puzzle), previous block reference, the list of transactions, and a nonce or random guess.
A block (or group of transactions bundled into a block), represents a value of virtual coin effectively (confusing isn’t it). Once a block is created and added to the network, coin has been produced. The blocks have been given a value as some work is needed to be done to produce them, and they are unique. It is the blocks that are theoretically worth something as there are only so many blocks in the system (like a currency – only so many 10 pence coins in the system).
Fundamentally if you have been successful at adding a block to the chain, you have added money into circulation, as you are rewarded with virtual coin deposited in your wallet for your efforts (12.5 coins per block today). This is the only way to add new coin to the currency. There has to be a starting point for the currency and this is it. From here you can exchange coin, give it away, use it in transactions etc. but you are not adding to the total currency in circulation from this point on. You must wait another 10 mins for someone else to solve the puzzle and add another block for more currency to be added.
Think of a “blockchain” as a list of all solved blocks. What does that mean? A solved block contains a list or ledger of valid transactions that have been completed. When a transaction is published to be processed on the digital currency network, it goes onto a list of unconfirmed transactions waiting to be validated. Miners then have to solve a hashing puzzle which will, in turn, “solve” a block and add it to the ledger. Basically they will take a bunch of transactions on the “waiting to be approved” list, bundle them together and work out a hash. This hash need to check out all the way up to the root. If the chained hash checks out, the transactions are valid.
When Alice sends money to Bob, she hashes the transaction, creating a transaction-id. At this point the transaction is not valid, but Alice announces the transaction to the digital currency network. It then waits for a “miner” to validate the transaction. Miners do this by including the transaction in a “block” when they create a block of transactions. The transaction-id is a hash and linked to all previous transactions, and this feeds into a block which is a hash of a bunch of transactions which, when combined with other block hashes, form part of a hash tree all the way back to a root hash. If this combination of linked hashes of all previous transactions is out of order or changed at any point, including block hashes, the chain is not validated and the chain not extended with a new block.
At this point we know the transaction is not fake and Alice indeed has £10 in her account and that the account can be reduced by £10, while Bob’s increased by £10.
Each block contains up to 500 transaction on average in the example of Bitcoin.
If we are saying that virtual coins are merely a chain of digital signatures, therefore each link in the chain represents a coin value, then there has to be a way of tying them together, and making sure a previous owner of a transaction block has not already signed another block or coin (leading to double spend, or two coins in the system with the same characteristics signed by the same owner – like two £10 notes with the same serial number). So in order to know of an absence of a Block in the system for the same thing signed by the same owner, we need to know about all the transactions. The network needs to know about all the transactions.
This is quite difficult to do once the chain has started as the hashes are all linked, so we only need concern ourselves with the first transaction. Each transaction is linked to previous transactions through a hash and in turn linked all the way back to the first transaction.
Components of transactions
Let’s now talk about transactions themselves, and frame this discussion by first understanding some of the component parts of the crypto-currency network, namely: users, nodes, miners, wallets, addresses and finally the transaction itself:
Consider that a crypto-currency network typically involves three main things:
- Users enact transactions.
- Nodes validate mined blocks making sure they follow the rules and participate in network consensus, as well as relaying blocks to other full nodes.
- Miners are rewarded with new coin for the hard work they have done solving a puzzle in order to add a new Block to the chain and in turn validate a bunch of transactions.
With this in mind let’s see how this relates to wallets, addresses and the transaction itself.
The idea of a wallet with crypto currency is an important one and has an analog in the real world. This terminology causes a problem as the real world analogy leads people to think of their physical wallet with cash or credit cards etc., but a Bitcoin wallet is essentially just a software program where addresses that are tied to coin values are stored. Technically Bitcoins are not stored anywhere. Instead there is a private key or secret number associated with every Bitcoin address saved in the wallet of the person owning the balance. So in essence the wallet is a balance, but not in your traditional sense as there is no such thing as a transaction “balance”.
First, consider a wallet as a collection of private keys that correspond to addresses. Addresses are tied to values of crypto coin. Value in the Bitcoin world is created by miners who, upon solving the puzzle and winning the lottery-style competition, form a new block and are assigned coin or value for their effort. This is essentially an address in their Bitcoin wallet. Value is transferred from miners to others through the transaction process, so that other addresses can “own” some of this value. The address corresponds to a value of cryptocurrency.
A wallet and an address are not the same thing.
A wallet is a collection of private keys that correspond to addresses. You need a private key to spend from an address. These are typically stored in a file on disk, and have features such as encryption or address labeling.
What is an address?
An address is therefore a place to send crypto coin from or to. An address is a set of arbitrary letters and numbers (digits) that represent a particular user’s balance. You would own a wallet, within which you have addresses. You can send and receive crypto-coin as many times as you like to other users, with your own address being the source.
An address is a Bitcoin public key to which transactions can be sent. In fact it is a hash of a public key that can then be published. So given the address is essentially a public key there is no problem in distributing this publicly. I can advertise the address and anyone can send me coin. If you open up your wallet and send coin to my address, as I am the only one with the private key I am the only one who can receive the coin. If you want to make sure I am who you think I am, you could ask me to sign a message associated with the address with my private key and then verify with the public key.
You can see from the below diagram how electronic coin is defined as a chain of digital signatures. You can also see how each transactions is linked to the previous transactions in the chain and where addresses fit:
The Transaction itself
Transactions occur between users
When users transact coin there are 3 components.
- Transaction Input – which is the address (described above) from which the money was sent.
- Transaction output – the address to which the money was sent. Remember the discussion on wallets? This is the address in your wallet where you receive the money.
- Amount – which is the amount of money (coin) that was sent.
There is a transaction chain of events or a ledger, which means that any money you send to someone was originally received by you from someone else in the chain. These addresses are registered on the blockchain (public keys), so when coin was sent to you, that address was registered on the blockchain as a transaction input, and when you sent it your address was registered as a transaction output….and onward as part of a chain.
As all the transactions are recorded in the distributed ledger and chained, you can see how balances are always up to date and accurate, without a central authority or interconnected banking system acting as a point of control with their own ledgers to keep track of balances. If there is a transaction input linked to an output and a value, then the balance of the addresses where money was sent to and from is easily recorded. If you spend coin, the value of coin your address represents goes down, and the value of the address to which you send coin correspondingly goes up. All recorded in the chained ledger.
Through the ability to check a transaction chain quickly you get to avoid the double spending problem, whereby if Alice pays Bob £10, you need to be sure that Alice hasn’t also used that exact same money to pay someone else. If Alice has a valid transaction in the blockchain then the network can go ahead and update Alice and Bob’s account by subtracting and adding the £10.
This brings us on to the important topic of consensus by proof of work. Proof of work which has been mentioned many times in the article, is the key to Blockchains. That is, how to actually add a block to the network and then be rewarded for it with coin to increase the amount of coin in circulation, which can then be transferred from wallet to wallet through transactions. Account to account transactions.
Bitcoin seems to be worth real money now (sounds good), so say I want to participate and add another block to the chain, how can I do this? Well there is work to be done…
Proof of work (or essentially proof of time)
Think of proof of work as a distributed clock that allows consensus on timings, making sure that all transactions or blocks (and new coins) are added to the crypto-currency correctly, in order, with no cheating or fraud. This timestamp is at the heart of Blockchain so we are going to spend a little time on it.
Timing is everything.
Bitcoin mints new coin every 10 minutes, and it does this by starting the puzzle race. Solving the puzzle is the proof of work, which conveniently also provides our timing and the distributed clock.
How are new coins created? As I mentioned earlier there is no central bank controlling the digital coin money supply. Instead there is a finite limit to the number of coins that can come into existence (in the case of Bitcoin this is 21 million coins). How are new coins created? What is stopping all these coins being created at once by one person and verified?
How do I get hold of digital coin? Well you can buy or trade them, or you can actually mine for them (a bit like mining for gold – you get your tools out, find where to look, do some work and find some gold).
Suppose you want to be a part of this puzzle solving network with your own computer resource (add blocks, get coin in your wallet, and make money!). Well you can, and this is called mining. If your compute power solves the puzzle to add the next block to the transaction ledger then you win! You are then rewarded with 12.5 shiny new Bitcoin which now enter circulation.
But how is this actually done?
I have talked about Merkle trees which has blocks added to it linked by hashes, but there needs to be a way to actually create this store of value or block. Once the block is created it must be related to previous blocks so it hashes out correctly.
So I need to create a block that somehow is allowed to contain the hash of a previous block and extend the chain. Do I go and ask someone for this? There is no-one to ask, so there must be a way of verifying that any new block is allowed to include the hashed link to an old block. This is where proof of work comes in. In order to create a new block I must solve a puzzle.
Essentially we give all the computers a puzzle to solve and start a race. First you solve the puzzle, then once solved, in lottery style fashion, one of the puzzle solvers is chosen to add a new transaction to the blockchain.
The puzzle – Proof or Work
You need to solve a puzzle, and how hard that puzzle is dictates how hard it is to produce Bitcoin or any other coin based on this method. What we are essentially saying is that to create a new store of value (the block), we need to have it as part of the chain.
When a new Block is added to the chain by a miner, the network is provided with 2 hashes. The first is a hash of all the transactions in the block (as tied in with the transactions chains already discussed), and the second is a hash to prove that the miner has done a heap of work in order to create the block. As the amount of work (CPU, energy etc.) is large it makes it unprofitable to do all this work under false pretences.
At each tick of the Blockchain clock a new Block is added, and for this there can be only one winner. So it is part lottery and part puzzle. Lottery in the sense that regardless of computing power you can get lucky and find the required hash result of the puzzle, but in the main it requires a good deal of computing power to get the answer. Whoever gets the answer first is the winner and gets to add a block to the chain, then are rewarded with digital coin in their wallet. Coin is added to the currency at this point. The rate at which blocks are added is dictated by the clock tick, which in turn, is dictated by how long it typically it takes to solve the puzzle with lots of computers working on it.
So what is the puzzle?
A hash (as mentioned earlier) is a unique digital fingerprint. Put some information through a hash and you get a fingerprint for that information or data.
Take the following Sha 256 hash of the string “blockchaintest”,
you end up with:
Of course if you receive that hash value you have no idea what the original text was, or what it means, but if I ask you to hash the same original text you will get the same value using the same algorithm – a unique fingerprint for that text.
Now I give you a computational puzzle. I could say, “add a number to the end of the string and hash the string. When you have the first number that makes the hash result start with a ‘0’ you have won”.
So first you try:
but no dice
Then you append each sequential number and retry, and in this case 25 is the first number appended that make the hash result begin with “0”.
What this tells me is that I have done 25 pieces of work in order to get to the result, so have expended computational energy.
As you can imagine this example does not take much computational power, but say I ask for the first number appended that makes the hash result begin with fifteen “0”s? Now this takes some power and time to hit the number. In effect I am asking you to guess the number that will produce a certain hash output, and that number is a nonce (number used once). So in order to solve the puzzle I need to guess a number, the hash of which meets certain conditions. The puzzle is to guess a nonce that satisfies this condition, and the level of difficultly of guessing the nonce is fixed across the network, so much so that it takes a typical length of time to guess (in Bitcoin this is 10 mins currently). So every 10 mins a new block is added and therefore new “coin” is added to the currency which can then be transferred like money across the network (wallets, addresses, all that good stuff).
Everyone could start this puzzle at 0 and increment from there, but this leads to a definitive race condition where, whoever has the most compute power will certainly win every time. You have the freedom to start guessing from wherever you like of course, and the puzzle remains sufficiently difficult wherever you start from. Probability dictates that on average it takes a certain amount of compute power and hash guesses to solve the puzzle, so typically the entire blockchain network will make a successful guess once every 10 minutes, and whoever guesses correctly first within this network gets to add a block and make coin. You therefore have a network of compute power that can throw as many random guesses at the problem as possible, which on average takes a certain amount of work, and whoever guesses first in the entire network gets to add a block. Of course, if you are very lucky you can guess the nonce that produces the correct hash in double quick time with low compute power at your disposal, but in general you need to be very lucky indeed as it is governed by probability. This is a lottery style win to add a block.
The best bit about this system is it might take me millions and millions of pieces of work to get the answer to the puzzle, but once I have the hash and forward my answer it only takes one piece of work validate that it is correct. It essentially proves that whoever wins has done a pre-requisite amount work, yet only a tiny amount of work is needed on the validating side.
This “work” therefore equates to time. By varying the probability of finding the value with a qualifying hash you can adjust the difficulty of the puzzle dynamically so that, on average, the qualifying hash can only be found once every 10 mins. The nature of the puzzle makes it easy to add difficulty and simply negates progress in compute power solving puzzles ever faster, which would otherwise top out the max coin in circulation in seconds. Therefore a block (and ultimately new coin) is added to the chain once every 10 minutes, limiting the amount of currency available.
The tick of the blockchain clock moves forward one block at a time, every 10 minutes, and this clever cryptographic chaining of transactions, combined with incentive based mining both validates the ledger, adds to the currency, and provides the distributed clock. Clever and powerful stuff.
Nb. A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours.
So when the blockchain paper refers to a timestamp, it is talking about linking a cryptographic chain with a puzzle that acts as a timestamp based on distributed consensus, where everyone agrees on the timing of the ticking of the clock (and therefore the sequential order of the blocks in the chain) by how hard it is to solve a puzzle. To labour the point, the difficulty of finding a qualifying or conforming hash acts as the clock.
It doesn’t matter that this clock is not nanosecond precise, just that everyone agrees with the timing. The clock is universal, meaning the difficulty of the puzzle is universally hard enough that no matter who it is, you have to do a certain amount of work to solve it, CPU cycles etc. When it takes around 10 minutes for everyone working on it to typically find the magic answer and win, everyone agrees.
Technically the clock is dictated by multi-exahash rate of an unknown number of completely independent but collective participants across the planet.
Nb. There is also 51% problem whereby if someone can control over half of the compute power in the world working on the puzzle they are much more likely to win every time, and in turn cheat the system. The system, however, also has a canny way of highlighting this as an anomaly and shutting it down, but maybe that detail is for another time.
It has taken a while for us to get here, but with all these components making up a distributed and validated time-stamp linked to transactions, we have ourselves a crypto-currency. Let the games begin.
It should be noted that for all it’s potential it is still very early days for cryptocurrency and blockchains. A good deal of research needs to be, and is being done to bottom this out. Barely a week goes by without yet another large tech headline around a potential use-case or product (this week’s was VMware around Enterprise blockchain services). There are adverts on television with talking washing machines proudly boasting blockchain capabilities. The term is firmly becoming part of the lexicon, if often incorrectly used and massively over-hyped.
Hopefully this article gives a good enough starting point to see through some of the hype and evaluate use-cases more realistically.
Recent events show how this hype, over-exposure, and acceptance of terminology which most don’t really understand, can gloss over any potential pitfalls so they no longer seem news-worthy. Bithumb, South Korea’s largest crypto-currency exchange, lost $30 million to hackers, and it barely hit any headlines, even in Tech news. In addition to this, Bitcoin, Ripple, Ethereum and Litecoin only dropped around 2% in the immediate aftermath, which is significant but hardly a crippling loss of confidence.
There is also a rash of speculation over Initial Coin Offerings (ICOs), which are similar in concept to IPOs (Initial Public Offering – a process by which companies can raise capital), but instead of shares, the investor gets tokens or coin in return for investment. Much like a normal investment but without the pesky regulation providing safeguards for your money. Remember if a new coin offering introduces a new crypto-coin (i.e. a brand-new crypto-currency – let’s call it NebulousCoin), there is no guarantee that this will be worth anything in future. The value is entirely based on market hype and speculation. Delve into some of these ICOs and they are literally thin air – a few words for planned product, much hype and no substance. My advice would be to do some serious homework before thinking of investing. China has in fact banned ICOs, and although it goes against the ethos of crypto-currency Utopia, more and more noise is being made around regulation being a necessary evil if ICOs are to survive?
Then there are the security concerns. Crypto-currencies turbo-charged the Ransomware industry. Legitimate mining seems to be on the decline as hackers target companies to take advantage of their army of CPU resources to win more often. The real security issue of hacking for mining rewards with an army of compute makes it hard to compete with a garage computing rig. The odds and costs look less and less attractive. Then there is the risk that after all this hard work your system is compromised and your wallet hacked and emptied. Taking advantage of a software vulnerability is much lower hanging fruit than targeting Crypto. As ever, where there is money there is opportunity for nefarious profitable activities. The bigger the reward, the bigger the incentive, and crazy market valuations only add to this problem.
To sum up..
In this article we have looked at Currency in general and how it relates to crypto-currencies like Bitcoin. We have looked at what Blockchain is and how it underpins the system. We have looked at how blocks are added, the concepts of hashing, how transactions are validated, and how this leads to a digital currency based on distributed consensus with timestamps as the ticking of a distributed clock through proof of work. It is fair to say we have covered a good deal.
Hopefully from this you can start to see other applications of blockchain technology, particularly around linked validated records of information and secure distributed databases. Equally I hope you have noted that although the concepts are clever, there is a need for caution, understanding, and research, before blanket acceptance of anything associated with “blockchain” is seen as inherently good or ‘better’. There is great power here but, as a well known super-hero says, “with great power comes great responsibility”.
So there you have it, crypto-currencies laid bare. Who knows, the next time you hear someone throwing the term “blockchain” around to save the world, you might just start thinking…