Homework on Hash Functions - Questions
- Describe hash functions with your own words
Each unique input gives a unique output.
This is always a one way function which means that you can never get to the unique input based on the unique output.
- 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).
Merkle tree
The bottom layer of a Merkle tree consists of the Bitcoin transactions. These are also called “leaves”. Each transaction is gehasht. So Tx0 gets Hash0, Tx1 gets Hash1, Tx2 gets Hash2 and Tx3 gets Hash3. The hashes are put together in pairs, and are then gehashed again. Hash0 and Hash1 are placed together to take a hash of them, Hash(0,1). The same is done with the hash pairs Hash2 and Hash3, resulting in Hash(2,3). Next, the resulting hashes, Hash(0,1) and Hash(2,3) are merged and hashed again, leaving only a single hash. This final hash is the Merkle tree root hash. This root hash is included in the block header hash.
- 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 hash function is collision resistant if it is hard to find two inputs that hash to the same output; that is, two inputs a and b such that H(a) = H(b), and a ≠ b.