FUNDAMENTALS OF BLOCKCHAIN
FUNDAMENTALS OF BLOCKCHAIN: Blockchain is a Cryptographically secure hash functions
- Hash function: map any sized data to a fixed size; for example H(x)=x%n, where x and n are integers and % is the modular (remainder after division by n) operations. X can be of any arbitrary length, but H(x) is within the range[0,n-1].
- Cryptographically secured:
- One way, given an x, we can compute H(x), but given H(x), no deterministic algorithm can compute x
- For two different x1 and x2, H(x1) and H(x2) should be different
The concept is a cryptographically secure hash function. A hash function is a function that maps any sized data to a fixed size.
For example, if you define a hash function like H xx modulo n, where x and n are integers and this modulo is the modular operation; that means, remainder after division by n.
If we define a hash function like this way; that means, in this case, you can see that whatever be the value of x the value of H x will be in between 0 and n minus 1.
This type of function we call it a kind of a hash function. One advantage of this hash function is that we call them a one-way function; that means, given an x and n you can compute H x.
But if H x is given then you cannot say that what is the corresponding value of x, you cannot say it uniquely.
So, that is the property of a hash function and this concept of a hash function is widely used in the concept of blockchain or indeed blockchain is nothing, but on data structure which is built upon this concept of the hash function.
This hash function concept of a hash function is used widely in cryptographic context and then we call this kind of hash function as the cryptographically secure hash function.
Now the properties of this cryptographically secure hash function are step-first function is one way; that means, given an x you can compute H x, but given H x you cannot compute x with any deterministic algorithm.
And the second property is that for any 2 different x 1 and x 2, this H of x 1 and x 2 should be different; that means if x 1 equal to x2 then you should have an H of x 1 equal to x 2 for 2 different data set, but if x 1 not equal to x 2 then H of x 1 should not be equal to h of x 2.
x1 = x2
H(x1) = H(x2)
If x1 =/= x2
H(x1) =/= H(x2)
This kind of hash function we call it as a cryptographically secure hash function. This is kind of cryptographically secured.
Cryptographic Hash Functions
- Example: MD5, SHA256
- X is called the message and H(x ) is called the message digest
- A small change in the data results in a significant change in the output – called the avalanche effect
Cryptographically hash functions have another important property which is called the avalanche effect. The Avalanche effect is something like this.
So whenever we are defining a cryptographically secure hash function or sometimes we will call it a cryptographic hash function.
this x is called the message and H x is called a message digest. An example of a cryptographically secure hash function is MD5 or SHA256.
But the avalanche property of this cryptographically secure hash function or cryptographically hash function is as follows: given an input whenever you are computing the digest, if you make some little change in the input you will see a significant change in the digest.
For example, whenever the input is fox this is the digest, whenever you make the input as the red fox jumps over the blue dog, you get this one as the digest.
Now from move 2 to 3, you make a small change that the earlier one was that the red fox jumps over the blue dog.
You make it the red fox jumps o u e r, the blue doh; that means from over you are making a change at o u e r, then you can see that there is a significant change between the message digest.
So, the message digest is completely different. By looking into this message digest you cannot say that the original input was similar.
Then from o u e r if you make it o e v r, you will see above the 4th blue box is a completely different message digest again by looking into this 3 message (above image right side red box 2,3,4 ) digest will not be able to say what the original input takes to accept.
Similarly, o b o e v r if you make it o e r again a completely different message digest.
This particular effect in the cryptographically secure hash function it is known as the avalanche effect; avalanche effect ensures that just by looking into the digest it is nearly impossible to guess what was the input or even it is nearly impossible to guess that weather 2 inputs were similar by the just by looking whether 2 digests are similar or not.
that is an important aspect of the blockchain context. Let us now go back a little bit about history.
CRYPTOGRAPHICALLY SECURED CHAIN OF BLOCK
- The first use-time-stamp a digital document (Harber and stornetta, 1991)
- A sequence of timestamps [TS1, TS2, TS3,…] denoting when the document is created or edited.
- Whenever a client accesses a document, construct a block consisting of the sequence number of access, client ID, timestamp, a hash value from the previous request, and the entire thing is hashed to connect it to the previous blocks.
The use of this kind of cryptographically secure hash function in chains or blocks from where the concept of blockchain gradually evolved.
So the first use of this concept of a cryptographically secure chain of blocks came in 1991 in a paper by Harber and Stornetta.
they have developed a mechanism for time-stamping digital documents.
you have a digital document and that document is edited by multiple person people’s time to time.
One person has first created the document, then person 2 has edited the document then person 3 has edited the document and you want to maintain a list of timestamps when the document has been first created followed by when the document was edited in a subsequent way, but in a secure way.
Such that no people will be able to make a change in the timestamp value.
That is important from the document purpose because many of the time you want to see when the document was last edited or if some people claim that I have not made any editing in the document you want to see whether that person has actually made editing in the document or not.
To solve the particular problem of Harber and stornetta they have used this concept of chain of blocks.
They have not to palm this as a blockchain, but the concept is similar to blockchain.
So, they have taken a parameter like the initial number the initial say in what order the people have accessed.
it has started from 0 1 2 3 then corresponding change value of the constructs.
That block is something like that whenever client access a document you construct a block like this which contains the sequence number of access, this C1 C2 C3 C4 at the client ID where access the block then the corresponding timestamp value, the timestamp value, and the hash value from the previous request.
So this is important. So initially you have some hash value H 0 and whenever you’re having this block information you have this information, you make a hash of this entered information and get this value H 1.
This value of H 1 will be used in the next case when the client 2 will access or make an edit in the document.
Then again by taking the second value; that means that the sequence number the client who has made by editing the time stamp and hash value of the previous one, you again generate a hash value which is H 2 and this H 2 will be a used in the next iteration when client 3 will access the document or make editing in the document.
Then from the 3rd step, you generate H3 and this H 3 will be used when alien 4 will make some editing in the document. Now in the advantage of this hash chain is that if you want to make the same change in the time stamp value.
For example, if you want to make changes in the time stamp 1; that means, you have to change the value of H2 H3 H4 all the subsequent hash value and people will able to the observer that all these values have been changed, for example, client 2 will be able to change that his hash values that have been changed, and that way they will be able to detect that someone is trying to tamper the document, tampering the timestamp value which is there.
So that way this concept of chain of blocks by connecting them by the hash function, that was used to cryptographically securing the timestamp value of a digital document; so this particular architecture looks like something similar to blockchain, where you have multiple blocks of data and this blocks of data are connected by the hash value.
the second block is connected with the first block by H 1, then block 2 it is connected to it block 1 by the hash value, then block 3 it is connected to it block 4 it is connected to block 3 by the hash value.
that way this individual hash values are helping to connect the blocks one after another and making the block as temper proof.
That was the first use of this concept of the chain of blocks which was an earlier version of the blockchain in securing this digital document.
- Also known as hash tree
- Every leaf node is labeled with the hash of a data block
- Every non-leaf node is labeled with the cryptographic hash of the labels of its child node
Merkle tree is a next concept that is widely used in the foundation for the blockchain concept it is called the Merkle tree.
So Merkle tree is a tree structure where the leaf nodes will contain the hash of the document and every individual node or intermediate node will contain the hash of the combination of the left child under a right child.
Above an example of a Merkle tree. The leaf node contains the hash of the content of this document.
the 1st leaf node contains the hash of D 1, 2nd leaf node contains the hash of D 2, 3rd leaf node contains the hash of D 3, and 4th leaf node contains the hash of D 4 and then this level 1, the intermediate node it contains the hash of these H 00; that means the hash value of D 1 plus the hash value of D 2 and the and their combined hash value than the root level.
so, this is an example of a binary Markle tree is root level, the root contains the combined hash of its left child and right child.
That means, if you are making any change in this document, that change will get reflected in the overall hash value.
If you want to secure a number of documents together; so in the bottom of the image assume that you want to secure all these 4 documents together, then you have the advantage that you can propagate 1 block (in top) root value.
So the root value if there is any change in any one of these 4 documents together, then that change will get reflected in the root value and that way ah that way you have the advantage that you can collectively secure a number of documents together by using this concept of Merkle tree.
USE OF MERKLE TREES
- Bayer, herber and stornetta used merkle tree in 1992 for timestamping and verifying a digital document-improved the efficiently by combining timestamping of several documents into one block
- Other uses of merkle tree
- Peer to peer networks: data blocks received in undamaged and unaltered; other peers do not lie about a block
- Bitcoin implementation-shared information are unaltered; no one can lie about a transaction
Now, this concept of Merkle tree was actually used in 1992 by extending the work where the earlier people in 1991 they have developed a chain kind of architecture to secure the time stamp values in a digital document and there here in 1992, Bayer Herber and Stornetta they have developed a mechanism where they have used a Merkle tree to secure the timestamp values for a number of documents for a set of documents.
Now, there can be other uses of Merkle tree-like in a peer to peer network whenever you are sharing a set of data blocks you want to ensure that the data blocks are received in an unmanaged and an unaltered way.
So, and other peers they are not lying about a block like they are sharing a block, but that block is not an updated block.
in that case, if you share the root hash of the Merkle tree, which is called the Merkle root; if you share the Merkle root the Merkle root ensures that none of the documents have been altered.
Another use full of the Merkle tree is the implementation of the Bitcoin, which is the most popular cryptocurrency which actually worked as the foundation of this concept of this blockchain.
So, in case of a bit can also you want to find out that the shared information which is there, that information is unaltered and no one is lying about some old transaction.
there also you can construct a Merkle tree of all the transactions together and if the same one is just denying one particular transaction, your Merkle root will change and by looking into the Merkle root you will able to validate that whether the set of transactions have been transmitted from one node to another node in an unaltered way or not.
What is bitcoin Blockchain?
- Bitcoin blockchain is a completely decentralized, peer to peer, permissionless cryptocurrency put forth in 2009
Completely decentralized: no central party for ordering or recording anything
Peer-to-peer: software that runs on machines of all stakeholders to form the system
Permissionless: no identity; no need to sign up anywhere to use; no access control-anyone can participate in any role
Now, as Bitcoin blockchain worked as the foundation behind this white spilled popularity of blockchain concept, the concept Bitcoin is a complete decentralized peer to peer and permissionless cryptocurrency which was put forth in 2009 in a white paper by Satoshi Nakamoto in this paper Bitcoin a peer to peer electronic cash system, it was a white paper was Satoshi Nakamoto first proposed the concept of digital cryptocurrency.
So, the basic philosophy behind this Bitcoin architecture is that first of all, it is completely decentralized; that means, there cannot be any central party for ordering or recording or controlling your currency just like bank or government.
that was actually the concept which came from ah few mathematicians and the philosopher that, why my money will be controlled by a bank or a government agency, which is a centralized authority.
I do not want my asset to be controlled by any centralized authority that was a debatable philosophy.
So, we are not going to that particular philosophy, but that philosophy that actually gives this cryptocurrency and Satoshi Nakamoto through this Bitcoin paper he as given practical inflammation of digital currency or cryptocurrency, which is completely decentralized where no central authority like a bank or a government will have control over the currency.
The second property is the peer to peer that means the software the Bitcoin software it runs on the machines of all the stakeholders to form the system; that means, you do not have a central system with which all the peers are connected rather you have a complete decentralized system where individual peers are connected with each other and they share the information among themselves.
And third important philosophy behind is Bitcoin idea is that that it is permissionless; that means, you do not any identity you do not require any identity to join the Bitcoin network.
Anyone can join the Bitcoin network and perform a transaction.
So, this gives rise to a very important and interesting question, that whenever you are allowing multiple parties to join in our network to join in your financial transaction system, how will you ensure the security of the system because the persons who are joining because you are not authenticating them.
they can be malicious or they can perform malicious activity.
you have to develop a system which will sustain in the presence of such kind of malicious attack.
So, that was the interesting concept that was put forward in this Bitcoin architecture.
BITCOIN BLOCKCHAIN VALUE PROPOSITION
- The last few years have seen a lot of interest in bitcoin and cryptocurrencies in general.
- Used as a cross-country, untraceable currency which is not under the control of any government and hence free from regulation
- Current BTC price 1 BTC = $10,388.06(AS OF 14 SEP.2020 AT 10PM)
- The bitcoin blockchain size as of 285.06 gigabytes in size as of the end of June 2020
BITCOIN BLOCKCHAIN PRICE
So, just a kind of statistical information about Bitcoin that in the last few years we have seen a lot of interest in Bitcoin and cryptocurrencies in general.
it is used as a cross country untraceable currency because there is no government control or centralized control.
Then the current Bitcoin price I have just recorded it on 12th September 2020 at 10 pm and the value is fluctuating significantly over the days.
if you look it today in Google you will possibly find out something different.
So, on that day the currency one Bitcoin was some 10,698.20 dollar, the price was 10,698.20 dollar and if you look into the Bitcoin price increased that it reached on around 20,000 dollars in the earlier of in the last of last year and the first month of this year and then right now, we are just observing deep in the price.
And if you look into the blockchain size or blockchain worked as the backbone of this Bitcoin architecture.
So, if you look into the black blockchain as of December 2017, it is approximately 285.06 gigabytes in size as of the end of June 2020.
the size of the blockchain is actually growing exponentially.
if you look into this left-side graph, on the left side graph you will see that the growth of this blockchain size which actually stores the information of Bitcoin it is growing exponentially.
So, the technology behind Bitcoin is the blockchain.
THE TECHNOLOGY BEHIND BITCOIN BLOCKCHAIN
Now, we are storing this transaction information in a block.
So, every block contains the transaction information, those are the first black here contains the value that Alice poses; that means, there is a 100 with her, then she makes the transaction of this 50 to bob.
the next block contains that particular transaction, now Bob transacts say rupees 32 jane.
So, that is the third transaction and all these transactions are connected with each other through this concept of the hash chain, So, the concept that I discussed earlier in the context of digital documents that similar kind of architecture, where individually individual blocks are connected by a hash value.
this circles are nothing, but a hash value, which is connecting the individual blocks together.
So, that way this entire blockchain is coming into practice and the concept of decentralization comes into practice that, the copy of the blockchain is available to every individual party.
Alice has her copy of the blockchain Bob has his copy of the blockchain, Jane has his copy of the blockchain and Eve has her copy of the blockchain.
every individual party possesses its own copy of the blockchain, and whenever there is a transaction those transactions are get included in the existing blockchain.
Now, one notices here that in this example I have shown one transaction in one block, but in reality, there can be multiple transactions in a single block, indeed there can be more than a thousand transactions in a single block.
THE BITCOIN BLOCKCHAIN TRANSACTION LIFE CYCLE-THE SENDER
So, let us look into the Bitcoin transaction life cycle, whenever Alice wants to send some money to Bob, how it actually works.
initially, Alice sees opens her Bitcoin wallet and provides the address of Bob and the amount to transfer and the same step.
this is an example Bitcoin wallet. So, Alice gives the address of Bob here and then provides the money to transfer, and then he press the send button. So, once you press the send button.
THE BITCOIN BLOCKCHAIN TRANSACTION LIFE CYCLE-THE NETWORK
Then the wallet it constructs ah the transaction. So, it makes ah transactions like say Alice to Bob of rupees 50, a transaction like that, and this transaction is signed using Alices private key.
So, this concept of signing. this is the concept of digitally signing a document. So, we call it a digital signature.
by applying the digital signature techniques. By applying the digital signature technique so, Alice.
that wallet it signs the transaction made by Alice and broadcast it over the network.
So, as you look now that this enter note network is the kind of peer to peer network everyone is connected to it others to some means say this is Alice ah.
Alice wallet it makes or it broadcasts this transaction over the network.
So, all the nodes in the network, or at list the majority of the nodes in the network, ah receives that particular transaction.
Now, this network node validates the transaction based on the existing blockchain.
THE TECHNOLOGY BEHIND BITCOIN BLOCKCHAIN
Now that is another interesting fact about blockchain. we have seen that this blockchain individual blockchain, they contain the all the transaction records.
So, whenever Bob is sending this transaction of rupees 30 to Jane and this information is broadcasted to all the nodes.
the information also reaches to Eve that Bob has made a transaction to Jane of rupees 30. By looking into this blockchain Jane if can verify that whether this particular
the transaction is a valid transaction or not. So, she finds out that well Bob has received this 50 form, Alice. So, currently, Bob has rested 50 with him. So, Bob is legitimate to make a transaction of rupees 30 to Jane.
So, this transaction is a valid transaction. So, that way by looking into the exiting blockchain you can validate whether the transaction is a legitimate transaction or not.
Now once this transaction is validated, then this transaction is propagated to some special node call miners and the task of the miner is to include the transaction to the next block will be mined.
That means the task of the miner is collecting all the transactions from the client which was there for say last 10 minutes and their task is to construct a new block and then apply a mechanism called mining, to apply the mechanism of mining to connect that block with the existing blockchain.
So now, we are coming to the minors.
THE BITCOIN TRANSACTION LIFE CYCLE-THE MINERS
So, the miner they collect all the transactions for a time duration say for 10 minutes and the miners they construct a new block and tries to connect it with the existing blockchain through some kind of cryptographic hash computation.
in a blockchain concept as I have mentioned earlier that every block is connected to the next block through some cryptographic hash function say this is B1 and this is B 2.
So, B 1 is connected to B 2 with some hash function, and ideally what is there just to give you a hint that whenever your computing this hash function for B 2 this hash function will contain some parameter along with the hash value, which was there for B 1.
that way this B 1 connects the next block B 2 and the task of the miner is to solve this hash problem in a difficult to it.
So, this hash problem which is given to the miners, it is a computationally difficult problem and that computation is a difficult problem every miner needs to solve and one of the miners or sometimes more than one miner they solve that problem and they are able to connect that block with the existing blockchain.
this is a broad overview of the entire methodology, And once this mining is complete then the hash is obtained and the block is included in the existing blockchain and this updated blockchain is propagated in the network.
That means, every node every participating node in the network, they receive a copy of this updated blockchain.
THE BITCOIN TRANSACTION LIFE CYCLE-THE RECEIVER
And once they receive the copy of the updated blockchain then Bob also receives that copy of the updated blockchain and once Bob receives that copy of the updated blockchain.
So, best or by looking into the blockchain be Bob can find out well inside that updated block there is a transaction from Alice to Bob of saying it is 30.
Bob can view this transaction and once Bob is able to give this transaction, Bob can update this value to his wallet.
So, the current value of ah Bitcoin has been transferred from Alice to Bob that gets reflected in the wallet of Bob.
this transaction gets reflected by Bob, and Bob can validate the transaction. So, this way the entire ah Bitcoin transaction works that whenever Alice wants to make a transaction ah of rupees 30 to Bob and at the backbone the blockchain ensures that this particular transaction is a legitimate transaction or it is a valid transaction.
So, every individual user or individual node in the network they maintain their local copy of the blockchain, and as you understand that, you need a complicated mechanism to ensure that all these local copies which are available to the individual nodes they are indeed the updated copy of the legitimate copy. and or they are the kind of valid copy.
once every node trust that well has a valid copy of the blockchain and it receives a new transaction.
So, they can validate those new transactions against this copy of the blockchain and then the miners they collect all such transactions which are the valid transaction, and miners also have the capability to check the validity of a transaction.
once the minor checks the validity of the transaction, then the miner can apply this mining process where they solve up the computationally difficult cryptographic problem, where their task is to compute a hash function, but not a very simple hash function rather a difficult hash function and that difficulty level basically governs the complexity of the system.
So, once the miners solve that particular hash function, using this hash function the new block is added to the existing block.
And that way ah the blockchain size of the blockchain gradually increases. So, as the transaction comes in new blocks are generated and blocks are added to the blockchain and this updated copy of the blockchain is propagated to all the users.
And every user can see that whether there is any transaction that is intended for themself inside a block, and if there is any transaction that is intended for themself inside the block, they can include that transaction in their wallet.
that way the transactions are performed with the help of a blockchain.
So, you can see that there is no such centralized authority like a bank, which is controlling this entire transaction rather this enter transaction is controlled in ah complete distributed to a and there are many nice properties or interesting properties in this mechanism that will explain.
Interested by the bitcoin revolution, mainstream companies are trying to use the central blockchain idea and build alternative systems around it for use in industry, manufacturing, supply chain, finance, governance, IoT, etc
This movement of academia, industry, startups are termed Blockchain 2.0
So, based on this blockchain concept blockchain ah initial concept, there was this concept of blockchain 2, ah which was based on this bitcoin revolution.
So, the concept of blockchain gradually applied to multiple other sectors like ah the academy industry and many of the startups it is termed as blockchain 2.
BLOCKCHAIN 2.0 AND SMART CONTRACTS
- Blockchain is a powerful technology-capable of going much further than a financial transaction
- A decentralized platform-can be utilized to avoid intermediates(the middleman)
- Smart contract: an automated computerized protocol used for digitally facilitating, verifying, or enforcing the negotiation or performance of a legal contract by avoiding intermediates and directly validating the contract over a decentralized platform-faster, cheaper, and more secure
And this concept of blockchain 2 ah that was extended for another interesting application which is known as a smart contract.
So, a smart contract is that a smart contract basically provides a decentralized platform, which can be utilized to avoid ah the intermediary in a contract.
When 2 persons are coming to a contract, we have something like a legal advisor who is basically controlling this kind of contract.
So, there is some kind of middle man.
with the help of this kind of blockchain ah environment, you can avoid the intermediaries or the middlemen.
So, this concept we are known as smart contracts. these smart contracts provide on the faster cheaper and more secure way for executing the contracts in a decentralized environment.
READ MORE ARTICLE: R3 CORDA
follow us on facebook