Blockchain from a technical perspective

Published 2 years ago

In today's article, we are going to dive deep into blockchain technology. If you've missed the introduction on blockchain and you are completely new to this topic I would suggest reading our previous article. In this article, we are going to discuss what exactly is a blockchain from a technical point of view in order to understand where we could apply this technology.

The name Blockchain comes from the explanation that this is a chain of blocks. In other words, blockchain is a list of blocks. A block contains some information and all these blocks of information are linked one by one in a chainA blockchain always starts with one block, called the genesis block. Each block has an index like the id in a SQL database. The genesis block has an index of 0. The next block will have an index of 1. And this is a part of the information contained in each block. In a block, we could store any information we want but another important piece is information about the previous block.

Before we move to the next piece of information stored in a block lets talk a little bit about hashing. A hash is a random string generated by a cryptographic function. This is an example of a hash string: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.  In blockchain, all blocks have their own unique hash generated by a cryptographic function called SHA256. So it doesn't matter how much information you put inside a block, the output will always be a string of the same length and the characters inside this hash will be unique only to that exact information. Now we know that each block has their own unique hash and this hash is used to create the chain. Apart from its own hash, a block will have information about the previous block hash, excluding genesis block - this one will have only information about its own hash which will be passed to the next block. When the next block will generate its own hash it will include the previous block hash. This idea is amazing in itself because it doesn't allow changing already created blocks. If somebody would want to change some information in this chain they would have to break the chain and generate or "mine" (will discuss this later) all the remaining blocks which in itself is a tough thing to do, but even if you do this you copy of database would be corrupted since all the rest of the participants will spot because if you remember from the previous article the blockchain is a distributed database.

Another piece of information contained in a block is the timestamp. The timestamp is the time when the block was mined.

What would be the reason to mine this blockchain without the actual data that is useful for us. So the data itself can be anything from transactions to business contracts to property ownership. Now imagine how big of the impact the blockchain technology can have in our lives.

The last part of information for generating a hash is the nonce. In order for a block to be valid it should be signed, this means that the hash should start with four zeros, for example: 000015783b764259d382017d91a36d206d0600e2cbb3567748f46a33fe9297cf. The nonce is that additional parameter which miners are finding in order to mine a signed hash

So the cryptographic function SHA256 which generates the hash of the blocks takes 5 input variables: block index, previous hash, timestamp, data, nonce. This function outputs a valid hash starting with four zeros. The number of zeros in front of hash is called difficulty. In Bitcoin, the data represent a transaction. Changing the data will change the hash and this hash will not have four leading zeros and the block itself becomes invalid. Because the hashing function takes the previous hash as input, every subsequent block becomes invalid. Therefore, a blockchain is resistant to change.

As you can see if done correctly blockchain technology can bring transparency and security in every aspect of our lives. Now it's up to us humans how we use it. Our goal is to make everybody benefit from it and use it for great causes.