Bitcoin and BCH Blockchain hashing explained

5 63
Avatar for Bharti
Written by
3 years ago

Hashing means that we take an input string of any length and then give it a fixed length. For bitcoin the transactions are taken as input and then run through the algorithm which gives a fixed output length. For bitcoin, SHA-256 (secure hashing algorithm) is used. The output will be 256 bits length always. Hashing gives security to the message transmission as it is meant for only one intended recipient.

Properties of cryptographic hash function.

1. Deterministic- It means if the input is run several times but the resultant output will always be the same. It is important because if every time we get a different result then it will be impossible to keep track of a particular input.

2. Computation speed- The give efficiency the hash output should be quick.

3. Pre image resistance- Lets take an example. Suppose you roll a dice where the output is the hash of the number that comes. In this case you will not be able to find the original number. So you have to find hash of all the numbers of the dice. As the output hash will be same for each number of the dice (input), therefore you can compare the output and find the original input. But when we are dealing with a large number of data then we have to use the brute force method to find out the target hash. That is we take a random input, put it through the algorithm to hash it and then compare it with the target has we want to find. This process will continue as long as the target hash is found.

4. Changes made in input will change the output- Even if we make a change in one alphabet in the input then the output will completely change. This immutability is one of the critical functions of hashing.

5. Collision resistant- For different inputs the respective output hashes will be infeasible. It is like if you try to match your birthday with one person on the street, the probability of matching is almost nil. But if you ask 50 people then the probability increases to find a match. But with SHA 256 such chances are almost nil.

6. Puzzle friendly – Suppose you are to choose a number between 1-3, it is said a slow min-entropy distribution, but if you have to choose one number between 1 and 1 trillion then it is said to be high min-entropy distribution. The distribution from which the output hash is selected is highly distributed so the chances of having a common output are negligible.

Hashing and Data structure

Two things are important here.

1. pointers

2. linked list

Pointers

They are variable in programs that store the address of another variable. Ex- integer g =5, it means there is a variable g which is storing the integer value which is 5. Pointers are however used not to store the value but will store addresses of other values. They point towards the location of other variables that why they are called pointers.

Linked list

This is a very important function of data structure. Suppose there are many blocks and each block has a pointer which directs it to the next block, and thus a connection is made. The last node has no pointers. The pointers hold the address to the next block only. A block chain is just a linked list. A hash pointer is just like the pointer but it holds the address to the previous block but also the hash of that data of the previous block.

Suppose a hacker changes the data in block 4, this will change the hash in block 4. This will change the hash and the data in block 3 and continue this way in block 2 and 1. The chain will be changed completely which is impossible.

In the next part I will cover

• what a block header look like

• Merkle tree and its importance

• The mining process

• what is hash rate

3
$ 0.09
$ 0.09 from @TheRandomRewarder
Sponsors of Bharti
empty
empty
empty
Avatar for Bharti
Written by
3 years ago

Comments

Save your all posts on Blockchain. It will be usefull for developing good crypto website. I want your help for creating good crypto website. This time, no one is taking interest in my project, but I beleive it will work, so I will be active after my exams. Exams are postponed till 6th Dec.

$ 0.00
3 years ago

Seeing you active after a long time.

$ 0.00
3 years ago

Ya, I was not active, as you know I am trying to qualify for CA, exams are scheduled from 01/Nov to 19/Nov but due to Bihar elections and COVID-19 guidelines exams are postponed to 21/Nov to 06/Dec. CA ab meri zid bn chuke hi.

$ 0.00
3 years ago

After qualifying CA you won't have to think about passive income like this site.

$ 0.00
3 years ago

For me CA is social respect. I will use my knowledge in Capital as well as Crypto Market.

$ 0.00
3 years ago