- Describe hash functions with your own words
- How are hash functions used in cryptocurrencies like bitcoin? (Try to research this on your own, we will cover this later in the course but challenge yourself and see if you can find information on this already now).
- What does it mean when we say that hash functions need to be collision resistant? (We didnât use the term âcollision resistantâ in the lecture, but you will easily find this on Google, we add this question intentionally to make you research information on your own, thatâs how you learn best).
A.1. In the Blockchain network, Hash function is the process of converting an INPUT data of any length into an OUTPUT of fix size string data of 256-bit using a mathematical function. This means that any text or binary data no matter how long it is, it can be converted into an alphanumeric string of data through an algorithm. Hashing is a one way process enabling security during data transmission to a particular recipient.
It is important to notice that cryptographic Hash function algorithms can only produce unique Hash value to a given INPUT data; the Hash value cannot be reversed to calculate the INPUT data. Hence they are known to be collision-resistant and irreversible. This ensures data integrity.
The OUTPUT data i.e. Hash value is written in hexadecimal numeral system using 16 distinct symbols 0 to 9 and A to F.
This means:
INPUT (data to be hashed) + Hash function = OUTPUT (Hash value)
Example:
INPUT XâHello world!; INPUT YâHelloworld!
Hash function SHA-256
OUTPUT X: c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a
OUTPUT Y: 5c6e9ce66cd85898720fcc906a5ccd2e8447deea99e81ac3c46a6563b29200bf
Please note that the OUTPUT data is known as âHash valueâ or just âHashâ.
A.2. In Bitcoin, Hash functions are part of the block Hashing algorithm used to write new transactions into the Blockchain through the mining process.
For instance, the 1st block in the Blockchain also known as Genesis Block contains transactions that when combined produce a unique Hash. When the 2nd block is created the Hash of the Genesis Block is added to all of the new transactions in the new block. This combination is used to create its respective Hash.
This process is repeated with all the new blocks added to the Blockchain by taking previous Hashes to generate newer ones and therefore creating an unbreakable dependency. This means that each block links back to its previous block through its Hash forming a chain back to the Genesis Block. This makes Blockchain a secure, immutable and transparent network.
A.3. Collision-resistant function simply means that given two different INPUTS X and Y where F(X) and F(Y) are their respective Hashes, it is unlikely for F(X) to be equal to F(Y). What that means is that for the most part, each input will have its own unique Hash. For example:
INPUT XâHello world!; INPUT YâHelloworld!
OUTPUT X: c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a
OUTPUT Y: 5c6e9ce66cd85898720fcc906a5ccd2e8447deea99e81ac3c46a6563b29200bf
Collision-resistant is one of the characteristics of cryptographic Hash functions.
Other examples of cryptographic Hash function characteristics are:
- Deterministic
- Quick Computation
- Pre-Image Resistance
- Small Changes In The Input Changes the Hash.
- Collision Resistant