Introduction to Blockchain and Bitcoin
Every once in a while, a technology claims to be the best thing ever and makes us believe that it can change the world. Well, blockchain is no different. Even though the technology has been here for a while, it is just starting to become more mainstream. Is blockchain going to pass the test or fizzle away with a few learnings? In this blog, we will touch on some of the features of this technology and the potential value it brings. In the later blogs, we will explore detailed use cases, specific players in the ecosystem and run our imagination wild on what the future could look like.
We have all heard of blockchain thanks to the recent boom in Bitcoin. Indeed, the associated buzz around it, ranging from the crypto millionaires on Instagram driving their Lamborghinis to billboards around every major city proudly announcing, "if you have seen Bitcoin on a bus, it is time to invest". It seems like every other person you meet is a crypto "guru" or "investor" telling you about their successes. This is fantastic, no doubt about it. Still, this blog and its writers would like to focus more on the technology underpinning Bitcoin, the blockchain and distributed ledger technology (DLT) and imagine its applications to day-to-day life. Every blockchain influencer will shout from the rooftops; we are at the start of the blockchain journey, and the opportunities are endless. Comparisons to the beginnings of social media, the birth of eCommerce and the internet itself will pop up across the radar. What we hope to achieve in this blog to really understand these claims and work out together whether this technology is genuinely going to change the way we live.
However, before we begin this journey, let's define some of the key terms and separate the hype from the technology. The two words "blockchain" and "DLT" are often used interchangeably, and to understand blockchain; it's essential to comprehend Distributed Ledger Technology (DLT). DLT is a decentralised database managed by multiple participants across multiple nodes. Blockchain is a specific type of DLT where the transactions are recorded with an immutable cryptographic signature called a hash. The transactions are then grouped into blocks, and each new block includes a hash of the previous one, chaining them together, hence why distributed ledgers are often called blockchains. Now do not worry if that all sounds very foreign. In the first few blog posts, we will try to explain these in simpler terms, but we must distinguish the two at this stage. Finally, Bitcoin is an application of blockchain technology, where the transactions are stored and transferred on the blockchain.
Source: Cambridge University
We will focus today's blog on Transactional Data in the form of Bitcoins (and in later blogs, we can explore property rights, digital identities and so forth).
How does the blockchain ledger work?
The Bitcoin blockchain is the oldest (first) blockchain in existence, and it is essential to note the Bitcoin blockchain is built primarily to be used for the exchange of bitcoin as money. As the technology developed and more blockchains popped up, more functionality like Smart Contracts was built in. Currently, the Ethereum blockchain network is the most famous blockchain built around this concept of smart contracts.
A blockchain is built up of blocks of data. In the bitcoin blockchain, for example, a block consists of approximately 1Mb of data. There were 678222 blocks already mined at the time of writing, meaning there is about 678,222Mb of data on the current blockchain or 678Gb. This is essentially a giant track record of every transaction on the blockchain since the beginning of time (or 2009 when the first transaction was). If you think about it what that really means, it's not a lot of data and would easily fit on most modern computers nowadays, but the technology behind each of these blocks is even more impressive.
If you think of a block as simple transactional data, perhaps you want to imagine it on Excel as a couple of rows. For example, Ravi has paid Gaurav 100 BTC, and Gaurav has paid Gareth 50 BTC and so forth. The block is filled up till it reaches 1Mb worth of transactions, and then any transactions after would end up on the next block.
Two clever features make this technology so powerful.
Firstly, each block has its own unique signature, which only exists with that particular combination of inputs, i.e. the transactions and some other information we will cover later
Secondly, each block includes the unique signature of the block before it as part of the block. Hence, when the unique signature for every block after the first block is created, it includes the one previous to it. Therefore, the input variables to generate the unique signature is now the transactional data + the unique signature of the block before it.
In your imagined excel sheet, we currently have transactional data. Now add an extra row that states the unique signature of the block before it. If you do ANYTHING to the block, i.e. change a name or even some punctuation, the entirety of the unique key changes, and thus the blocks in the chains ahead will no longer recognise the block will be rejected.
Hopefully, that makes sense so far. Each block so far has transactions and a unique signature to the block before
What is the Cryptographic Hash function all about?
Now naturally, the next question is, how do you make a genuinely unique signature for each block? Thanks to some clever technology called the Cryptographic Hash function, a complicated formula, the blockchain can create a truly unique signature for any block.
How does it work? Well, the function takes ANY alphanumeric input (i.e. our excel sheet of transactions) or a sentence, or even a poem and turns it into a unique 64-digit string of output. A cryptographic hash function always gives the same output for the same input but always a different output for different input.
The hashing mechanism used by Bitcoin is called SHA256, and if you click here, you can have a play with this Hash function in which you can put any input, and it will create a hash output.
I have put in as input the line “Ravi has paid Gaurav 100 BTC and Gaurav has paid Gareth 50 BTC”. The hash function inputs a result in a completely unique output.if I was to change ANYTHING i.e. the 50 BTC to 100 BTC the hash becomes a different output..
Totally different, right? You wouldn't know that all I have changed is two digits...
The next block, if we say it is a simple as "Gareth pays Ravi 25 BTC", and it will also include the Hash Function of the previous block to create the new hash function output
Some of you may be asking yourself, well, we have pretty good computers these days and we know the SHA256 formula; why can we not just update a previous block and then recalculate all the subsequent blocks with new unique signatures pretty quickly. This is where the magic happens, and well, I guess all the environmental problems you see in the press stem from.
What is bitcoin mining and the nonce?
An important fact is that: a signature for a block does not automatically qualify; to make the blockchain secure, it will accept a particular type of signature. In the case of bitcoin, it needs to start with consecutive 0s, and the number of 0s changes as the blockchain gets bigger, but let's say for now, you need seven 0s at the start of the hash to be qualified.
However, we know every string has only one output, so how do we create a hash with seven 0s for these transactions we have? If you recall earlier, I mentioned the input into the hash function:
- the transactions
- the hash function of the previous block
- the third input is something called the nonce.
The nonce (abbreviation for “number only used once”)is an entirely random string of values that you add to the input, allowing you to get the hash output to be seven consecutive 0s. However, it's a pretty complex procedure. Hence, there are HUGE computational and electrical requirements in just running random values in a block till you find a combination that returns the correct input. These computers are essentially solving a complex maths problem repeatedly until they finally get a hash they require. It is trial and error in its truest form.
So how does it work? Whenever someone makes a transaction, they send it out to be processed by the miners, and miners essentially pick transactions to fill up their block. Not all miners choose the same transactions, and you can pay a miners reward to push your transaction to the top.
Then the miners take their chosen transactions (Tx), the hash of the previous block, and then have to solve for the Nonce so that it becomes a valid number to be used for hashing the value of the block. For the perfect nonce to be found miners run these complex cryptography problem-solving machines to find the perfect combination of random variables that will produce a hash with seven 0s.
To put it simply, it is a race to be first. Whichever miner solves it first wins. Others verify their block on the blockchain, as they can check it's not tampered with because it is easy to test whether the proposed block (Transactions + Previous Hash + Nonce = Hash key they are presenting) is correct. If correct, the block gets verified and added to the chain, increasing the height of the blockchain by 1 and thus starting the process again for the next block. Whether seconds from completion or hours, all other miners will lose all their work and must start again with the new block.
Why must they start again? Well, it is for two reasons:
- The transaction they selected to form their block have likely already been picked up and processed
- The hash of the previous block is now different as it will now be the hash that has just been published
The key takeaway message here is that finding an eligible Hash function is really hard
The next couple articles will cover:
- Continuation of Blockchain introduction: What makes the blockchain immutable
- Blockchain application (principals and use cases) and Future of Blockchain
Here are some articles to read for more info