Homework on Hash Functions - Questions

Homework on Hash Functions - Questions

  1. Describe hash functions with your own words.

Hash functions are a one way function where each transaction creates a digital fingerprint via a unique input that gives a unique output. You can go from an input to an output, but never from an output to an input.

  1. 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).

Let’s start off by saying that Bitcoin wouldn’t be Bitcoin today without hashing algorithms. BTC uses SHA256 because it is more secure than the old MD5, because people figured out how go from Output to Input on MD5. SHA256 uses hexadecimal Base 16 instead of the MD5 Base 10. One way hashing is essential to BTC as it provides essential security for information in the input. Such usage ensures that it is not possible to generate the input even if the output is known. SHA256 is used because of it’s unique hashing value, high hashing speed and secure hash function that is almost computationally infeasible to reverse the function and make it two-way.

  1. 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).

When hashing from two different inputs A & B to two different outputs H(A) and H(B) you do not want the outputs to ever be the same H(A) and H(B). You want H(A) ≠ H(B). You do not want H(A) = H(B). This would cause a collision. Collisions are more likely to occur with MD5 or SHA1 for example, where there have been identical false hashes produced. It is highly unlikely for a collision to occur with SHA256. Not impossible but highly unlikely as the odds would be astronomical if it were to occur.

2 Likes

No problem. I am glad I could help you out. Keep up the good work. :smiley:

You can’t find the input based on the output, not even in MD5. Try it. Here is my MD5 hash I just created: 00b661d6915dbfa0071f6ae4d011f36c

MD5 is no longer secure due to the collision vulnerability. This means that it is easy to find 2 different inputs that will produce the same output. This is not the same as finding the input based on the output. Hope this makes sense. :slight_smile:

1 Like

No, collision resistance prevents inputs producing the same output.

1 Like
  1. Hash function is inputing an amount of any length and returning it to a fixed output.

  2. Hash functions used in crypto currencies are like bitcoin because you can input an amount of any length and return it to a fixed output.

  3. Each input and output is unique in their own ways.

1 Like

1.a hash-function, imposed on a certain input, calculates a unique output / result, and in the process creates a clear and unique ā€œdigital fingerprintā€
2. 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.
3. for two different inputs, its infeasible that ever a similar output / result is created, meaning of ā€œcollision resistantā€

sorry, I am neither a mathematician, nor an informatic-student… with all the geek-language…

  1. digital signature of a transaction

  2. Sha 256 is used that each block has the previous has and the cureent hash so if anything is changed the block after changes

  3. that you want find the same hash ever the chances are impossible

1 Like

Hashfunction: is a mathematical computation in which a given input transforms into an output.
The same input will always give the same output… a slightest change will change the output of the hash.

HAshfunctions in Bitcoin are used to transfer data and transactions… beacuse the SHA 256 is secure , you can be sure that your data will be transfered safe and secure.

The hash function needs to be collisian resistant , means that the slightest change of breaking by coincident the hash function , must be avoided.

1 Like

thank you for this explanation… about collisiona resistance… I understood that it means that is is infeasable to guess the input by reversing the output…but now I see that it means it is impossible to have the same out put with two different inputs…

1 Like
  1. For each unique input there is an unique output, it is one way from input to output and never from output to input

  2. hash function are used to encrypt any string of characters/text/ number into an encrypted output, the encryption is dependent on the type of encryption algorithm.

  3. Can not determine input from output hash.

  1. Describe hash functions with your own words
    A hash function takes a string as an input and produces for the most part unique output number of constant length that is always the same for the same input (deterministic). For small changes in the input the output changes dramatically. A hash function is only secure if it is pre-image resistant meaning it is infeasible to determine the input from the output.

  2. How are hash functions used in cryptocurrencies like bitcoin?
    Every Block in the bitcoin blockchain contains a hash of the block itself and also a hash for the previous block. The previous hash acts as a pointer or chain. By changing the block content, not only invalidates the block but also every block that follows.

  3. What does it mean when we say that hash functions need to be collision resistant?
    The probability of the hash function to produce the same output for different inputs should be very very low.

2 Likes

Hi there, we all are learner here :slight_smile:
On question 2, In bitcoin protocol, Hash function(it is called SHA256)is used to hash all the transactions, hash of the previous block and nonce(number only used once) then it creates a hash of current block.

1. Describe hash functions with your own words
A hash function is a mini computer that calculates data by using a certain algorithm. A hash function will hash data and this will give a unique number which is the unique fingerprint from the data.

2. 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).
Hash functions are used as pointers and linked lists in the blockchain. Each hash will refer to a location where the data is stored in the data structure. The data structure is called the Merkle tree. Here are all data hashed—>and the combined hashed data will be combined to a new hash value and so on. This will create the block header.

3. 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).
The tiniest change in the input will change the whole output. This make guessing data based on the input impossible.

1 Like

hash functions are a way to create a one way unalterable transmission of information that can be retrieved and reviewed and stored while it can also keep the data private
2 hashing is combining all previous data with new data from each new transaction data input etc… it reduces possibility of breaking encryption by using sha 256 it stop reversing the info because the encryption has no correlation to the original message you would have to spend hundreds of years just inputting info
it reduces the info stored and can be combined with other codes through a merkle tree reducing even further storage needed with a hash it creates a fingerprint that is only related to the one hash any changes can be caught because it changes the hash they then can restore to original hash
3 collision resistant means that no two hashes should be the same this could happen but due to the 10/24 it is unlikely that would happen similar
to throwing a penny in the middle of the ocean trying to hit a gold fish

1 Like
  1. A one way function/computation
  2. An answer that cannot bebanswered without the question (input)
  3. The unlikelyhood of two different inputs results in the same output
1 Like

1- Describe hash functions with your own words?
Hash functions take data of any size and out put this data in a fixed size. This function is a one way function.

2- 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 Bitcoin the block hashing algorithm is used to write new blocks into the block chain via the mining process. Each block contains time stamps, the hashed data, unconfirmed transactions and references to the previous blocks.

3- 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).

The hash functions should very rarely produce the same output from two hashed inputs.

1 Like

Absolutely makes sense now. Thanks for the clarification. There was something about what I said that didn’t sound right but after I did further research I see that you are absolutely right!
Thanks again Mauro.

1 Like

Correct. If you are interested, here is an example of a hash function that has a collision vulnerability: https://en.wikipedia.org/wiki/MD5#Collision_vulnerabilities :smiley:

You haven’t really explained how we use them or what they do. Do you think you could find out? If you need any help feel free to message me back. Hint: Miners

Is a hash function collision resistant if we have 2 different inputs producing the same output?