-
Describe hash functions with your own words
Hash functions are a special type of function where each unique input has a unique output. The output is like a digital fingerprint of the input data. Hash functions are also one-way, in that it is infeasible to extract the input from the output. -
How are hash functions used in cryptocurrencies like bitcoin?
Hash functions have special properties that are crucial to the functioning of cryptocurrencies.
- Because hash functions are deterministic, the input data generates a unique output hash.
- Pre-image resistance in hash functions ensures even the smallest change in input data drastically changes the hash output.
- In a blockchain, the hash pointer of each block points to the previous block in the chain AND also contains the data of the previous block
- When an attempt is made to change the data in (say) block #6, it drastically changes the hash for that block. But because the block ALSO contains the hash pointer (data plus address) of the previous block, this will be different from the hash stored in block #5⌠and block#4 and so on. Thus even the smallest change in any block is immediately noticed and nullified by the preceding blocks. This is how a blockchain achieves immutability.