As the name suggests, it is a chain of blocks. Each block consists of a block identifier, a header, and a body.
There are plenty of different blockchain technologies, but the most known and popular ones are Bitcoin chain, BNB (BSC) Chain, ETH and many more
Before we go into the details and confuse you, let us try to create our block from the scratch and see which problems we will face at each iteration and how we will fix them, ending with the real-world Bitcoin’s Block structure.
HASH FUNCTION
Hashing is turning an input of any length into an input with a fixed length, in the case of Bitcoin, 64 alphanumeric (letters + numbers) value. A hash is like a digital fingerprint of the data. It starts with a bunch of zeros. The number of zeros depends on the Difficulty Target (more about this will be discussed below).
Data “Chocolate” has a hash a61c25 and so on. If I delete it and input it again, the hash will be the same a61c25 and so on. It is the digital fingerprint of the data “Chocolate”.
But if I change something even for a bit, like add a period “Chocolate.” or write “chocolate” without capital C, the hash will be completely different each time.
The hash with added period to the data is now 27f829 and so on.
The hash without capital C is now 7499ac and so on.
SHA-256 AND SECURITY
The way we get a hash is by using a SHA-256 (Secure Hashing Algorithm). 256 means a 256-bit value. In simple terms, range of numbers 0-9 and letters A-F.
It is infeasible to get the data back from the hash, not impossible, but infeasible. In other words, if you pick any hash, it would be hard to find out what the data was in the first place.
It is so secure that the best way, is just to guess and check random messages. There are 2256 possible guesses. That is 115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
or 1,15 * 1077
For comparison,
there are 200,000,000,000,000,000,000,000 stars in the universe. That is 0.000000000000000000000000000000000000000000000000000001x of our possible guesses
7,500,000,000,000,000,000 sand grains of Earth. That is 0.00000000000000000000000000000000000000000000000000000000006x of our possible guesses
The only thing that comes close is the number of atoms in the universe, which is between 1078 to 1082. That is 10x-100000x of our possible guesses.
Now, let us go further. Let us add a nonce and a height.
BLOCK HEIGHT
Block height or the number of the particular block in the blockchain. The first block (genesis block) has a height of 0 (early versions of Bitcoin counted it as block 1), block 2 or the first block after the genesis block has a height of 1, block 3 or the second block after the genesis block has a height of 2 and so on.
NONCE
A nonce or a number that the miners must guess to calculate a block hash that meets certain requirements. A nonce is a cryptographic puzzle. What if I change the data from “Chocolate” to “Chocolate.”?
The hash has changed from 000016 and so on to 9c91cf and so on, but the nonce did not. This specific nonce is the number for the data “Chocolate”. But we have changed it by adding a period “Chocolate.” and changed the hash in the end. A nonce is “a number that can only be used once.” It is the only field in the block that can be changed by a miner (anybody can be a miner). If the data has changed, you must find a new nonce.
The reason that we have an invalid block is this, bear with me here. There is another row in the block called Difficulty Target.
DIFFICULTY TARGET
It is a number that sets the difficulty to mine the block. The hash starts with a bunch of zeros because of the Difficulty Target. Fewer zeros = easier to mine, more zeros = harder to mine. What a miner should do is guess a nonce that is smaller than the Difficulty Target. In this case, the Target is 4 zeros at the start of the hash. But we have 9c91, you see where we are getting at? Now, when we re-mine this block, we will get this.
Let us add a new row – Hash of the Previous Block, get back to the data “Chocolate” without a period and create a blockchain.
HASH OF THE PREVIOUS BLOCK
Hash of the Previous Block is just what it sounds like. Each block will have a row of data that has a Hash of the Previous Block. Have a look at Block 1. The Hash of the Previous Block is only 000000 and so on, no letters, no numbers 1-9. Why is that? The Hash full of 0 is the hash of the Genesis Block
Comments