In this video, we look at the “blockchain”. We understand “what a blockchain is” relating it back to a means for storing information and acting as a decentralised digital ledger. We look at blocks that are interconnected to form a blockchain network. We deep dive to gather more understanding about the various participants within the network such as miners and nodes while delving into blockchain’s characteristics such as immutability, consensus mechanism, decentralisation, faster settlements and security. The video explains security in the context of cryptographic hash function which makes the network secure and how a hash number is generated using nonce and difficulty target. The entire concept is explained through a diagrammatic representation to make it simple and easy.
Blockchain – Transforming the Financial Ecosystem
The blockchain industry is transforming the entire landscape. It’s a major transformation, although it started almost like ten years back, it’s still in its infancy. There is lots of interest that is getting generated now, especially with respect to cryptocurrency investing.
In today’s video we will talk about the blockchain but before we begin, I would like to introduce myself. I am Santo. I run thetwigg.com where we believe “Anyone Can Invest”. You can understand more about us and what we do by visiting thetwigg.com.
We are primarily focused on investing in shares. We provide educational and informational data around investing. If you want to know more about us you can visit our “about us” page. We have a single-minded mission to make investment simple. We believe “anyone can invest but most most of us don’t”.
The reason we started with this topic of “The blockchain” was to, first, really understand as to “What Blockchain Is” so that it’s easier for anybody wanting to get into investing in cryptocurrency. The first question that comes to the mind is “What’s Bitcoin or What’s Blockchain” and and that’s where lots of people are still in the mindset that it’s speculation. There’s lots of hype in the industry and there are lots of question marks with respect to what this is all about.
Before I delve deeper in, I would like to acknowledge the fact that I’m not a financial advisor; so you need to do your own research. You need to interact with the your own financial advisor if you want to take any decisions. This entire video and the content in the channel is for informational and educational purposes only.
So, What is Blockchain? I’ll give you an example of what a database is, so that you can relate to what a blockchain is all about with an example of an excel sheets. What you see in my screen is a couple of information that i’ve stored in excel, right. I’ve written “store” and “write”. Once I save this file, this information gets stored on this excel sheet. So from that perspective, blockchain is nothing but a database.
What a blockchain is, it’s essentially an extension of that concept on a larger scale, where we store information. As I said, information is nothing but data and that information once it gets stored, it resides on the blockchain. Let me expand this concept further. What i just said was blockchain is a database that collects and stores information.
So what kind of information does it store? If you take the example of a bank where you have a deposit or savings account, if you look at the statements that you get generated from the bank, you would see transaction activity along with the credits and debits. When technology was not there, people used to still record any transaction that used to happen between different parties, and that used to be written in books of paper. The concept that I was talking about of the paper ledger, that evolved to a digital ledger for a centralized bank, for example. And now comes blockchain which is an evolution of that digital ledger.
In summary, What is a blockchain? Blockchain is information captured in a database. It’s an underlying technology that enables it.
So there’s a complete framework or a protocol that is behind how it essentially works. It’s in the form of a digital laser where transactions made in bitcoin or digital currency is recorded.
Now, having understood what a blockchain is in its very simplistic form, let’s deep dive into understanding, “how a blockchain really functions?’
What I’ve done is depict a pictorial representation of a blockchain that you can see here on the left hand side.
At the core, I mean, the core or heart of a blockchain is data. So, I was talking about blockchain being a database, essentially a distributed ledger which records transactions; so where are these transactions stored?
These transactions are stored in these data blocks that you see; in these cubes that you see. Multiple transactions could potentially form a block. All right, so when transactions happen within the blockchain network each transaction gets added on top of each other and once it reaches a certain threshold it essentially forms a block. This block is fundamental to how how blockchain works.
What I’ll do here is I’ll try and connect this picture to what you see on the the five different characteristics of a blockchain which I have depicted here, because this will actually help you understand blockchain much better.
All right, now, going back to the previous diagram, let’s imagine that a number of records have come together to form a block. Now, what happens in blockchain is that there are multiple blocks like that, right, so 50 transactions could form a block; another 50 forms another block and so on. Now each of these blocks are connected to each other; so that’s where you see this connection between the first block and then this is the second block.
I’m calling the first block, “Genesis block” because it’s the first block in sequence and the first block is connected to the second block. I’ll come back to to how the connection works and the details and mechanics of it but just to keep it simple, for now, understand that whenever a transaction happens, the transactions get recorded in a sequential fashion, one after the other; and once it reaches a certain threshold, it forms a block. And that block is connected to the next block and so on. So, the second the second block is connected with the third block; third block is connected to the fourth block.
These blocks which are connected to each other, they form the ledger. Each of those blocks are connected to the next one in such a way that you can retrace the path. Going back to the characteristic that I was talking about, one of the key things that you see here is and the way the technology has been built is that you can not delete any transaction.
So anything that is recorded on the blockchain is permanent from that point of view, all right. I’ll just repeat, any transaction that is recorded on a blockchain cannot be deleted; it can be modified; it can be changed, you can add transactions but you cannot delete a transaction. Imagine a book. the moment you remove a page, it’s very easy to understand that the book has been tampered with; the moment there’s any tampering, any modification, any change that happens, it can be very well easily known because of the fact that each transaction is sequential in nature and every block is connected to each other. Just like, if you remove a page out of a book, it’s easy to find out that the book has been tampered with.
The other important thing to notice, is the facet of consensus and decentralization. As I said, this is a complete ledger that you see here which are multiple blocks of data connected to each other in a sequential fashion. Now this forms a blockchain, right and this blockchain is actually shared with the miners.
A copy of the blockchain is shared with the miners. A miner could be a server; it could be a computer it could be even a MacBook, essentially a device which can perform certain operations. This blockchain is shared with the miners and the data is also shared with the nodes.
The nodes are, again, nothing but computers who have a certain function. Any transaction that comes, in needs to be validated: by somebody to say that, yes, this transaction is right. And that validation, essentially, is done by these nodes. There are several nodes in the network. I mean, anybody can apply to be a node. Currently, there are multiple nodes like that and all of those nodes have to agree, which is where, the consensus mechanism comes in. You have to agree that the transaction is valid for the transaction to be included within that block and the consensus happens only when at least 50 percent or more of the nodes agree on that fact, right. This is an important concept that we need to understand.
Now this ledger or the entire blockchain as I said is shared with two different parties – the miners and then, the nodes. How does a miner or node essentially work? As I said, it could be a server or computer but they have specialized software which does certain functionality. At the end of the day any server, any computer, a group of computers or a large data center could function as either a miner or a node as long as they have a required software installed on their machines.
Now, what is the difference between a miner and a node. If you notice here, within this diagram, there are two set of things that we talked about, right. One is that any transaction that comes in, that gets added to the blockchain needs to be validated, right, and that validation is performed by the node.
How do they perform the validation? They perform the validation because they have a copy of the blockchain and each of them are able to verify that the transaction that has been entered is valid; and they agree on it and once they are agreed, that transaction gets added to the blockchain. Addition of transactions to the blocks is one concept and then, the creation of the block itself is another. Once, a set of transactions are added to a block and the block reaches its size limit, no more transactions can be added to it because the size limit has been crossed and that’s when a new block needs to be created.
This function of creating a new block is performed by what we call, a miner. Miner has a specialized software which enables them to create a new block. Now, why will somebody do these functions, right? So, when I say somebody, why will somebody deploy their computer or data center or large servers to perform the activities of the validator, which is the node or the miner for the creation of the block; unless somebody has an incentive or a reward for it.
And that is where the concept of rewards come in. The work that a minor does to enable the creation of the block is called “proof of work”. They have to do certain activity to ensure .. and I’ll come come to that as well in terms of how the block is created but, essentially, they have to perform a set of activities or solve a puzzle, I mean, to make it simple they solve a cryptographic puzzle to enable creation of a blog and for solving that puzzle and enabling the creation of the blog they are rewarded with a certain token which in the case of the first blockchain, it was bitcoin.
I’ll finally, come to the concept of security. We have talked about several things till now. We talked about the fact that data cannot be deleted. We talked about the fact that they are in a recorded in the chain; there’s a consensus which is required to ensure that the transactions are accepted and there’s also consensus required for a block to be created as well. So it’s not easy for any transaction to be accepted just like that because at least fifty percent of the miners and fifty percent of the nodes have to accept either a creation of a transaction or creation of the block.
But, the most important concept which provides the maximum security in a blockchain is the mechanism of creation of the block itself which is done through a cryptographic hash function. To get a better understanding of how cryptographic hash function is used to secure the entire blockchain network; how it’s used to create those blocks and the process of doing so, it’s important to understand what is data. So that’s what we’ll be talking next.
If you look at this representation, what we have shown is the various data elements within each of those blocks.
The first block we have called it as genesis block, which is the term used in blockchain because it’s the first block. It is the genesis block and then you have block one and block two.
Now, there are different elements within each of these block. I’ll explain a little bit more in detail in terms of what it is. The first one is a magic number. A magic number is a constant value. I mean, it tells us what that blockchain network is. It’s a constant across the blockchain network. It’s a constant value.
The second data element is the block’s size which determines how many transactions can be recorded within that block and once that block size limit is reached, the transactions will start getting recorded into the next block. So, that that’s what is block size is. Version is the version number of the bitcoin protocol that is running across all the nodes. As, I said earlier, the nodes are the ones who validate whether those transactions are accurate or not and they are the ones who accept the transactions. So all of those nodes need to be running on the same version of the bitcoin protocol so that there is one protocol to ensure that there is consistency and consensus across the network.
I’ll come back to the previous block hash and merkle root a little later. Timestamp is the date and time of the block creation. It provides a record of when the block was created. And then, we have the transactions. Transactions are recorded in a sequential faction. We also need to identify the number of transactions within a block because based on the size, the number of transactions within each block could be a little different; because the size of each of those transitions could be a little different as well.
So, we need to record the entire list of transactions and we also need to record the number of transactions which are within that block. What is merkel root. Merkel root – it’s a fingerprint, a digital fingerprint of all the transactions. It summarizes the transactions in a digital hash function format. I’ll not talk about how the merkle root is generated here but the important concept to understand is the hash function concept.
If you look at the genesis block since it’s the first block, there’s no previous block hash, what we call, the hash number. Because the hash number for a genesis block is zero zero zero. Now, for the second block, there are two numbers that is stored one is the hash of that block and the hash of the previous block and that’s how the first block and the second block is connected because within the block one you have the hash number of the genesis block similarly if you move to block two, block 2 has the hash number of its own block and it has the hash number of its previous block as well.
Now, what is this hash that we are talking about? What is this current block hash? What is this previous block hash? Hash is a cryptographic mathematical function.
The mathematical function can have an input and output. Whenever you provide an input to this mathematical function it generates a fixed size output. For any input of the same value the fixed size output is always a constant. The moment you change the input the fixed side output will change. So, this mathematical function has certain unique characteristics which makes it very important for security and it’s used across different networks to to secure information. One of the protocols followed in cryptographic hash functions secure hash algorithm – 256 (SHA-256).
I’ll shortly, show you an example of how that is created. It has four main features – one is, any certain input always produces the same output; so the input has the same output. The second thing, is its difficulty. It’s really, really difficult, if you know the output to figure out what that input might be. You have to do lots of permutation and combination to figure out what that input was that generated that output. This is because there’s no way to have the information about the input if you’re given the output. So, basically, if you have been provided the output, the output doesn’t have any information within it which can reveal the information about the input. The only way to get that information is through lots of permutations & combination figuring out multitude of inputs to see out which one generates the output.
That’s the third important characteristic of the cryptographic hash function and the fourth important characteristic is it’s essentially impossible for two inputs to create the same output. So no two input can generate the same output. You can learn more about the hash or the critical cryptographic hash mathematical function by referring to the investopedia article. I can provide a link down below. I’ll quickly show you an example of how the hash is calculated. This is a link where you can provide the input which is the data that i was talking about and this is where you’ll get the output. So, let’s say blockchain is fun.
Let me calculate the hash. So, what you see is a specific number that got generated. I’ll just capture this number that got generated and store in a text pad here. Now and also just for my reference, I’ll just capture this data as well.
If you look at it now if I enter this number as the data now and recalculate the hash it generates a completely different random number. So there’s no way I can figure out what was the source of the input data based on the output that I’m given. So if I’m given this output I don’t know what the input is right unless I do lots of permutations to figure out going through multiple such words/ sentences, to figure out what this input might be.
Now let me go back and instead of blockchain is fun I just write “I am crazy right”. What happens, it generates another number; It’s a completely different number but if i go back and enter this “blockchain is fun”, it gives me the same number. So, the blockchain is fun, it always gives me the same number.
So what it means is that there is a mechanism to validate through permutation and combination what the input is for a defined output but it requires lots of effort, lots of permutation to be able to generate, to be able to find what that input is for that particular output. This process is involved in the creation of that block which makes it really really difficult. How is this cryptographic hash function implemented to create the blocks.
I’ll explain through this diagrammatic representation here, which is through a link through an article on medium by, we have Kiran Vaidya; so, what you see here is three different things that is involved in generating the hash number. The first one is something called nounce which is a number which is generated only once. Whenever a block is created the block automatically generates a number which it uses to add with an input string to generate a hash output. So what you see is, for example, when the first block gets created what it will do is, it will randomly generate number one, it will add an input string; so, this input string is nothing but the data within that block. If you remember, once a block gets created and once the entire block is filled with the transactions up to the maximum size that is allowed within that block, that’s when the process of creating a hash for the block gets started. In that process of creating the hash what is used is the data within that block including all the transactions and the transaction counter and its digital fingerprint as well as the other details that I showed as being component of the data block.
So that’s what is the input string. The objective of adding this input string with the number one and hashing it to get a number is to find that number which meets the difficulty criteria. So, what you see, it starts off with a difficulty level of one which, essentially, means it needs to look for a hash function which has one leading zero. One leading zero means, it has to have one zero at the start of the hash function. When it starts with number one, it adds an input string and then it does hash on it. If I go back to the earlier example, I just say, 1Make; what was the data there, Make America, sorry, America Great Again. Uh, Was that right? And I do a hash function. So, I get this hash, right, which is which is the hash function that we see here. Now, this hash function will not be accepted by all the miners because it doesn’t have a leading zero. So, the expectancy of that block is that the hash function that is generated has to have a leading zero. What it does, then, it increases the nonce by one more and tries that process again. It adds 2 to Make America Great Again; tries the hash function again to see as to whether it gets a leading zero. And it continues to repeat that process multiple times until it finds the leading zero. Once, it found the leading zero, it announces, the basically announces it, broadcasts to the rest of the network saying that it has found the golden nonce.
It’s this number, that is called the golden nonce, when it finds the hash number with the required level of difficulty. It means that it has found that golden nonce. It announces to the broader network and they all accept as they are able to validate that yes this nonce with Make America Great Again gives this number which has the required difficulty. So, then the block gets created and when the block gets created the block has this as the hash number.
What happens once that block has been created? That becomes the hash number; then the process of creating the next block starts. Transactions starts getting inserted into the next block; once the transaction has reached the maximum size limit, then the miners have to start looking for the next hash number for the next block. How do they do that for the next block? The difficulty number is increased; the difficulty target is no longer one and that that makes the process of generating the next block much much more difficult. So as you see here, what happens is the system, the protocol automatically increases the difficulty level to two and then the next block starts adding the nonce from 21 because in the last block it had 20, when it found which was the golden nonce, so it starts with 21. Now, when we do this hash function, it needs to generate a number with leading zeros as two in this case so for example if i start with 21 here i do the calculate hash function, it doesn’t have the leading zero as two, so it will continue doing it until it generates, again, a number which is the golden nonce with two leading zeros and this becomes the hash number for the second block.
So, this process of generating the hash number using nonce and at the required level of difficulty is what is used to generate blocks (not nodes :)). What you notice here, is this process becomes very difficult because they have to go through lots of permutations to find the right hash with the right amount of leading zeros.
Now, as you see in this article at the end if you see, if they have found the second block and then the third third block once the difficulty level reaches four zeros, the the first such occurrence when the hash is reached with four zeros happens only after 69817 and it just keeps on increasing exponentially and that is why the process of generating a block is so so difficult.
Let’s come back to the structure that we talked about. I explained what the cryptographic function is. We talked about how the hash function is generated and it’s connected to the previous hash; so, essentially, the block has the hash of the current block and it has the hash of the previous block as well. How is it secure? The process of creating the block itself is very cumbersome, I mean, it’s , the miners have to solve a puzzle which is not easy to do; where they have to go through multiple permutations and combinations to reach a certain number. However, nowadays, the chips that is being manufactured is very fast, right. So, the computers are becoming very, very fast from that perspective. What the protocol has done is, they have defined a minimum time in minutes which is required for generating a block. No block can be generated within less than 10 minutes and that’s where the next bit of security comes in. For example when I talked about the fact that the transactions can be added but it cannot be deleted or changed, let’s assume a transaction gets changed within one particular block. The moment the transaction changes, that means the block has changed because the hash function is based on data within that block.
Assume for any block, there’s tampering or change that happens on any of them. Let’s say in this instance if the tampering happens with the second block; the moment the tampering happens the hash of the block has to be redone because if you have generated the hash that means it’s a finalized block; but the moment you tamper with it you make any change that means you have to redo the hash. And if you redo the hash you’re no longer connected with the other hashes because the hash number has changed.
For example, in this case the second block will not have this same hash number. So, if it doesn’t have the same hash number, it’s no longer connected to the third block because the third block had a hash number which was different from the hash number for the second block. In that case what happens, is that all the miners, I mean basically, if somebody has to tamper with the entire blockchain they have to ensure that every block gets generated within that blockchain and that process is difficult because generating one block takes 10 minutes. If there are multiple blocks within the blockchain to create the entire blockchain we’ll take 10 times the number of the number of blocks within that blockchain.
That’s why the process of tampering with the data within the blockchain is so so difficult and on top of this difficulty level, within the blockchain protocol, what it essentially does is, it uses a mechanism of double hashing so rather than a single hash it uses a double hash. The reason being: because the computer, the computers nowadays are much much more faster so there’s always a risk of two different miners at the same time finding the same hash which can create a situation where two miners are creating a blocks at the same time, because they have the found the same hash at the same point of time. To prevent this, there’s a mechanism of double hash instead of a single hash.
If you look at the entire cryptographic puzzle solving mechanism of generating the blocks, it’s almost impossible to tamper with the data for a blockchain and that is why the blockchain for the bitcoin network has never been tampered with for the last 10 years. It has never been hacked and that’s all for today in this topic of what is blockchain, demystifying blockchain.
I hope you liked the explanation. If you have any questions, any queries, happy for you to reach out to me at email@example.com or firstname.lastname@example.org.
Just to conclude and just to remind all of you I’m not a financial advisor. The content was provided for information and education purposes only and I would request you to look at your own financial advisor for your own personal circumstances and make the right investment decisions. Happy for all of you to connect with us at thetwigg
Looking forward to seeing you again, next time. If you like the video, do click on the thumbs up button and also click on the subscribe button so that you are subscribed to any new videos that comes from from us.