What is Blockchain Technology? A Step-by-Step Guide For Beginners

Aashish Sharma
Entrepreneuryork
Published in
12 min readFeb 28, 2019

INTRODUCTION TO BLOCKCHAIN TECHNOLOGY

Everyone has heard about blockchain, yet very few people can explain how it works;) Here is the blockchain tutorial if you are looking to become a blockchain developer.

A blockchain is actually very simple elements that can be explained in a few minutes. We will do it in a very visual way, using blockchaindemo.io and anders.com/blockchain to illustrate each principle separately.

We will see that the blockchain is, in fact, a very intelligent assembly of cryptographic technical bricks that already exist for many years, even several decades for some. All the beauty of the blockchain is to have been able to organize these bricks consistently to create a decentralized and secure data exchange system.

BLOCKCHAIN TECHNOLOGY

1- HASH

Let’s start with the basics, the hash. A hash is an often hexadecimal number calculated from a datum. It is a kind of fingerprint for quickly identifying the initial data. There are several hash functions. The most common is SHA256, used among others by Bitcoin. The SHA256 algorithm transforms any string into a hexadecimal number of 64 characters (or 256 bits). For example, FIG. 1 shows the hash of the very short chain “OCTO” and FIG. 2 shows the hash of a much longer chain, the 1200 word article on OCTO’s business sector. Note that the two hashes are totally different, but always 64 characters long. In the same way, you could type all the works of a library, or nothing at all (empty string), and you would have a hash of 64 characters. Note that for two identical strings you will always have the same hash, and for two different strings you will always have two different hashes (with a few collisions, but this is extremely unlikely). This allows you to quickly verify that the original data has not been modified.

2- BLOCK

A block is simply a structure containing its block number, data, an arbitrary number called NONCE (diminutive of Number used ONCE ), and the hash of all this data. Fig. 3 represents an example of a block. Note that the hash begins with 27f. This block is considered unsigned. Why? There are different validation rules for a block depending on the blockchain considered. Most blockchains use proof of work which is to prove that a validation job has been performed on the block.

For example, a widely used validation rule is that the hash must start with 000. The block will have to be mined, that is to say, it will be necessary to find a NONCE such that the hash of the block starts with 000. Note that this choice is totally arbitrary. For example, the designers of a blockchain can choose whether the hash should start with 123 or that the base hash should be less than 1000 (Ethereum case). You just need a rule that proves that a validation job has been done on the block. When the rule is validated, the block is then signed.

In our example fig. 4, we will simply increment NONCE and recalculate the hash until we get a hash starting with 000. This process is not fixed in time, it can be very short or very long because each test of NONCE is equiprobable. In this case, we must increment the NONCE until 2958. The block is now signed.

Miner, therefore, consists of calculating the hash again and again until the validation rule is validated. This is why it is possible to create the Application Specific Integrated Circuit (ASIC) optimized for mining. For Bitcoin, ASICs incorporate chips specifically designed to make SHA256 find NONCE very quickly.

Finally, note that if you try to modify anything in a signed block, it loses its signature, because the hash changes and it is necessary to undermine the block to find a new hash beginning with 000.

3- BLOCKCHAIN

You now understand what a blockchain technology is. It is simply a list of blocks for which each block contains a reference to the previous block: its hash. They are, therefore “linked”. In fig. 5, you can see that block # 2 contains its data, its NONCE, its block number and in addition the hash of the previous block # 1. To sign block # 2, we mine it to find a hash beginning with 000, then the hash is used by block # 3 that we mine, etc.

So you understand that if we change anything in a block, this block and all subsequent blocks lose their signature. For example, if I change super by the top in the block # 2 data, its hash changes and the block is no longer signed. Since the list is linked, the new hash of block # 2 is found in block # 3 which in turn changes the hash. Block # 3 is no longer signed, etc. All the blocks that follow are no longer signed (see Fig. 6). It is therefore very easy to know if the least information of a blockchain has been changed and in which block.

However, it is possible to undermine these unsigned blocks from the last signed block and re-validate the entire chain (see Figure 7). But then, if we can resign the blocks, can we alter a blockchain? No, already because undermining a block is very demanding in computing power. For Bitcoin, mining a block would take several years for your desktop. Especially since you go back in time and modify an old block and you will have more blocks to mine.

However, it is mainly thanks to its distributed aspect that the blockchain is truly safe and immutable.

4- DISTRIBUTION

Every blockchain is distributed, that is to say, that all the signed blocks are replicated on all the nodes of the network.

Like everyone else, you can, if you wish, use your computer to make a node. For this, you must download all the blocks signed so far. For bitcoin, this already represents more than 180 gigabytes.

When a node is able to sign a new block first, it is added to the blockchain of all other nodes in the network so that it always has a blockchain up to date anywhere on the network. There are so many nodes in the world and they all have a complete copy of the blockchain.

When one of them decides to fraudulently modify a block, for example, block # 2 of the node C of FIG. 8, this can be seen immediately by the other nodes (A and B) because the hash of the last block of their chain is different from the hash of the last block of C. Even if the node C indicates all of its blocks, the final hash will still be different from other nodes. There is no way to change the data of a block while preserving the same hash as the rest of the network. The incorrect blockchain no longer corresponds to the majority of other blockchains mined by other nodes, this block will become orphaned, and will not be integrated into the general registry.

One way to corrupt a blockchain is through the famous “51% attack” that you may have heard about. This is for a pirate to own more than 50% of the world’s mining power. It then becomes the majority during the control operation of the block relative to the rest of the network. The corrupt block will become official and the hacker will be able to manipulate the blockchain to perform fraudulent transactions.

Fortunately, getting 51% of the world’s mining power for popular blockchains is very difficult (it would cost several billion for Bitcoin). However, for less popular blockchains (with fewer nodes), this is quite feasible and occurs quite regularly. Some blockchains trying to solve this problem by implementing different consensus algorithms that implies it not mining.

That’s it, you now know how a blockchain works!

Blockchain Nodes

5- TOKENS

When we talk about blockchain, we do not necessarily talk about cryptocurrencies. Note that until now, the data stored in the blocks of our examples were simple strings. Any type of data can be stored: identities, electronic documents, insurance contracts, etc. However, if one store there financial transactions as in Figs. 9, 10 and 11, we then have a cryptocurrency and we can exchange money, in the form of tokens. But the opposite is not true. You can really store any type of data in a blockchain. So you imagine that there are many areas of application for the blockchain. Whenever it is necessary to have a secure exchange and data-tracing system between parties with no confidence in an unsecured network, you should be wondering about the possible use of a blockchain.

Note that there are public blockchains (Bitcoin, Ethereum, …) and private blockchains, called DLTs for Distributed Ledger Technology, because they do not always commit a Blockchains data structure per se, but only a few key components, such as the electronic signature.

At OCTO, we use the Ethereum, Corda and Hyperledger Fabric blockchains extensively to track, track, share and secure not only financial transactions, but also manufacturing processes, supply chains, insurance and banking contracts, and any other process of complex exchanges between several actors.

In the rest of this article, we will only consider a Bitcoin cryptocurrency blockchain.

Note in figs. 9, 10 and 11 that the data contains transactions of the type “$ 40.27 from Elizabeth to Jane”. $Denotes a monetary value that is not necessarily dollar but could be any token, such as Bitcoin, Ethereum, etc.

However, in our example, how do we know that Elizabeth has enough money to send $ 40.27 to Jane?

The Bitcoin blockchain does not contain a register showing the balance of each account at any time. Instead, when Elizabeth tries to make a transaction, the process will go back in time in the blockchain and calculate the difference between all her incoming transactions and all her outbound transactions in order to deduce the maximum amount of money that Elizabeth can to send.

BlockChain Node

6- COINBASE

You now understand how the blockchain is able to calculate the balance of each person and allow or not his transactions. However, where does all this “stored” money come from in the blockchain? If we went up the blockchain completely to the first block, there would be a time when money was introduced for the first time. If the amounts were only calculated from transactions between users, there would be no creation of a new token. There would be 0 bitcoin …

In fact, new bitcoins are generated by the blockchain when a new block is signed and these new tokens are given to the first miner who signed the block. In fig. 12, you can see that $ 100 is created from scratch and given to Anders to thank him for having invested his computing power to undermine a block. This is called a reward or coinbase. Anders is then able to spend this money as if he had received it from another user. It is this process that makes it possible to put new tokens into circulation, in the same way, that a central bank is able to print new notes. The advantage of a blockchain over a central bank is that the process is completely autonomous and unalterable. It is not possible to have overinflation.

However, there is still a big problem in our blockchain scheme. Are you at this stage able to identify it? Knowing that Elizabeth has a positive balance of $ 50, could Jane add the transaction “$ 40.27 from Elizabeth to Jane” herself to a new block without Elizabeth agreeing? At this point, anyone seems to be able to spend money on anyone else!

7- KEYS

It is essential for the proper operation of the blockchain that only Elizabeth is able to send the transaction “$ 40.27 from Elizabeth to Jane”. For this, we will need a cryptographic mechanism of the private key and public key.

Fig. 13 shows a pair of keys. The private key is a very long hexadecimal number generated randomly (you can do it yourself). A public key is a hexadecimal number that is calculated from the private key. It is possible to calculate the public key from the private key, but the opposite is not true. It is almost impossible to find a private key from the public key.

As the name implies, the private key must remain private. You must never communicate it to anyone. On the other hand, the public key must be public and accessible to all. Why?

8- SIGNATURES

The public key will allow us to verify our signatures. Indeed, our private key will be used to generate signatures for our data. Fig. 14 shows a signature generated by our private key for the message “Hello OCTOs”. Note that if we change the message, the signature changes.

Now, if we give someone our message and our signature, this person is able to verify the authenticity of the message. How? Simply by fetching our public key and applying the cryptographic verification algorithm on the message and its signature. Recall that the person does not have access to our private key, but using only the public key, the cryptographic algorithm will say “Yes, this message was indeed written by the person with the private key” (see fig. 15) and guarantees that it has not been modified by a third party, in which case the signature would no longer be valid (see figure 16).

9- TRANSACTIONS

Now, instead of using a simple string in the data, we will insert a transaction! The transaction will have our public key as issuer, and the recipient’s public key, and we sign that with our private key. See fig. 17 as an example.

The blockchain is now able to use our public key to verify that we are at the origin of this transaction (Fig 18), that we are the sender and that the transaction has not been tampered with by a third party.

10- BLOCKCHAIN COMPLETE

Let’s go back to our unsecured blockchain fig scheme. 10 except that now all transactions are signed by their respective sender (Figs 19, 20 and 21). Each transaction has the signature of the sender. Note that we no longer mark people’s names ($ 11.00 from Anders to Elizabeth) but public keys ($ 11.00 from bc8c66ac158de287272 to d3029db8bbb2db17de20)

If a hacker tries to change for example the value of the amount of a transaction, two things happen:

- the block is no longer signed because the hash has changed, as we saw in chapter 5

- the signature changes and no longer checks this transaction!

If we still mine the block, it will be signed again but the signature of this transaction remains invalid. It is not possible to re-validate the transaction without having the private key of the sender of the transaction.

This is how transactions in the blockchain are protected by allowing only the sender to sign transactions, and it works perfectly.

Finally, to receive and send money, you just need to generate a pair of keys, and that’s it! There is no need to open an account at a bank or prove its identity to a centralized entity, or any other approach that could be censored. The blockchain is resistant to censorship. Anyone can send and receive money!

CONCLUSION

Congratulations, you are now part of the 0.01% of the population able to explain how a blockchain works.

Source- Original Article Link

Originally published at Entrepreneur News and Startup Guide.

--

--

Aashish Sharma
Entrepreneuryork

Aashish Sharma is a Founder and Blogger at https//www.entrepreneuryork.com, specializing in Social Media and Digital Marketing.