- Describe hash functions with your own words
Hash function is an algorithm that map data with variable length for data with fix length. The values returned for one hash function is called hash values/code hash/hash sums. The input data for an hash function can be anything, texts, files, images, videos, etc. Must be impossible generate the input data through the hash code done with the hash function. The hash code is represented in hexadecimal base. This code serves to ensure data integrity.
- 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).
In the bitcoin protocol, hash functions are part of the block hashing algorithm which is used to write new transactions into the blockchain through the mining process.
In bitcoin mining, the inputs for the function are all of the most recent, not-yet-confirmed transactions (along with some additional inputs relating to the timestamp and a reference to the previous block).
Changing a small part of the input for a hash function results in a completely different output. This property is crucial to the âproof of workâ algorithm involved in mining: to successfully âsolveâ a block, miners try to combine all of the inputs with their own arbitrary piece of input data in such a way that the resulting hash starts with a certain number of zeroes.
Hash functions is used to for the wallet addresses, public keys and private keys.
- 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).
Every time you put in a certain input on a hash function, it has to produce the same output and to be preimage resistant which means it cannot reveal any information about the input in the output.
A hash function has to be collision-resistant which ensures that it has to be impossible for two different inputs to produce the same output. It is the deterministic feature, pre-image resistance and collision-resistance that constitute the three most important properties of hash functions in the Bitcoin mining process.