Homework on Hash Functions - Questions

  1. A hash function is a function that can output a unique output of a fixed length for a given unique input.

  2. Each block in the blockchain has a hash function, which contains all the input of that block and previous blocks. This means that even if a hacker can solve a hash output for a single block, it will be nullified as it can’t access information for future blocks, or previous blocks, and break the blockchain.

  3. Having two different inputs that result in the same hash is known as a collision. So when we say that hash functions are collision resistant, it means the hash functions (i.e SHA-256) will not produce two of the same hash for any given inputs.

  1. Hash Functions are special functions in which each unique input produces a unique output (a unique digital fingerprint). They are also one-way function that as soon as you change something, a new fingerprint is produced.

  2. Hash Functions are utilized in cryptocurrencies like bitcoin to encrypt transactions in a secure manner and where the output will be of a fixed length.

  3. Collision resistant is a property of cryptographic which means it is hard to find two inputs that hash to the same output.

Hash functions don’t encrypt data. They take an input and give you a unique fingerprint of that input. You can’t reverse hash back to the input.

1 Like
  1. Describe hash functions with your own words?
    A hash function is a one way conversion of a string of data (of any size)into a fixed length unique output. And this process cannot be reversed from output to input.

  2. How are hash functions used in cryptocurrencies like bitcoin?
    In bitcoin, the hash function is used to convert any transactional data into a 256-bit output. And this help save space by not having to include all the data, but rather summaries of the data. This is important because the less space transactions take up, the more transactions we can fit into a block.

  3. What does it mean when we say that hash functions need to be collision resistant?
    Collision resistance means, two different inputs cannot have the same output.

Correct. But even if the probability of a random collision is very low we have to keep in mind that a function can still have a flaw. MD5 is an example of a 128-bit hash that you would think is pretty safe (and it still is for a lot of cases) as a chance of a collision is highly unlikely. 2^128 total hashes is a very big number. However there are vulnerabilities that were found in the MD5 function which you can check here if you are interested. I thought this was pretty interesting. Otherwise great answers. Keep it up. :smiley:

1 Like
  1. Hash function are also called one way function. Every each unique input is transformed in a unique output (like a fingerprint). You can go only from input to the output but not the opposite.
  2. Sha256: In Bitcoin, are used private key and public key, which let you to verify.
  3. It means that it is impossible to find two input that have the same output.
  1. Hash functions are one way functions that take input and produce an output. Bitcoin takes input and hashes it with SHA256.

  2. Hash functions are used in cryptocurrencies to mine bitcoin for block rewards.

  3. It means two different inputs getting the same output. It is rare but can happen. We want to avoid collisions because they make brute force attacks easier for hackers to execute cybercrime.

1 Like

1.Describe hash functions in your own words

One way functions that input data and produce a unique output.

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

Bitcoin uses hash functions through the mining process. Miners attempt to combine all the inputs (Utx’s) with their own unique nonce until a hash value is less than the difficulty.

  1. What does it mean when we say that hash functions need to be collision resistant?

The hash function cannot have two different inputs produce the same output.

1 Like
  1. Describe hash functions with your own words
    a hash function is a one way function where an input is converted into a 256bit digital fingerprint, it is repeatable but not reversible.

  2. How are hash functions used in cryptocurrencies like bitcoin? Blocks contain hashes of the previous block on the chain. So if any changes are made to a previous block the hashes of all following blocks will be changed making them invalid

  3. What does it mean when we say that hash functions need to be collision resistant? Means that two different inputs must not result in the same hash, using sha256 It is extremely unlikely to the point it is not worried about, but not theoretically impossible .

  1. Hash functions are security functions, they hash the input and give the 256 bit output which is always the same if the input is the same. You can’t go from output to input for now, thats called one-wayness.
  2. Hash functions are used to encrypt transactions in each block, they are hashed using merkle trees so in the end we have a merkle root with a hash of the entire block which will be used for the next block.
  3. Under the term collision resistant we mean that it should be hard to find 2 different input that gives out the same output in the hash function.
1 Like
  1. Hash functions are one way functions, which means that you cant see the input based on the output.

  2. transactions get hashed, as well as e.g. public keys,…

  3. collision resistant means, that two different inputs cant have the same output. (or chances for that are astronomical low)

  1. A hash function transforms any given input to a specific output with a defined length. With a secure algorithm it is currently not possible to calculate the input with the output. --> one way street

  2. Blocks contain hashes from the previous block. --> If one block is changed this will result in a change of all subsequent blocks.

  3. The hashing function does not create the same output with two different inputs.

  1. A hash function is a function that takes a data input and gives a unique data output for that input, like a digital fingerprint. If you change any data in the input the hashing function will give you a completely different output.
    It is easy to calculate the hashing function in one way but impossible to calculate the other way around. Meaning that with the input of the function you can easily calculate the output, but you can’t calculate the input of the function using the output.

  2. By hashing each block on the blockchain and including that hash in the next block. This way the all the blocks on the blockchain are linked together and it acquires immutability, which means that if you change a single bit of data in any block it will change the hash of that block which will cause a chain reaction and change all the hashes of all other blocks previous of that one.

  3. That it is almost always true that if H = H -> a = b. Being H the hash function output and a, b the input data.

Describe hash functions with your own words

A hash function takes any string of data (input) and converts it into sha-256 (output). This process is impossible to reverse, which means one can’t go (almost impossible) from output back to input.

The same input gives always the same output, but when you change one little thing, the output will be completely different. An entire new “fingerprint”.
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 in bitcoin to accomplish chaining. For every transaction and the output data is stored in a Blockchain. The hash of the previous block is “inside” the current block. Which make it hard (impossible) to hack/attack.
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).

Collision resistant means that not more than one input get the same input. If two different input by probability gets the same output, they collide. Observe, collision resistant does not mean that it is totally impossible to get “collision”, it is just really really seldom. The probability of occurrence are extremely low.

Got It Thanx for your message !

1 Like
  1. Hash functions are algorithms that can take any type of input and put out a unique fixed amount of information.

  2. Hash functions are used in bitcoin in the following ways:

  • Every transaction comes with information and that info hashed together with the pointer address to produce a unique hash value. The chain continues to take the new pointer address and the new transaction info and creates a new hash value.
  • This ensures that every transaction is immutable because if you change just a little bit of information then all information that is connected to the chain has to change - which is of course infeasible.
  1. When we say hash functions are collision resistant we mean that it is very hard to find two different inputs that will produce the same output. f(x) != f(y); x != y
1 Like
  1. Hash functions are used to create unique signature for any given data. This unique signature must be reproducible, quick to compute, and almost impossible to guess the original data.

  2. In Bitcoin, hash functions are used as the puzzle that miners have to solve to verify a block before adding it tot he blockchain.

  3. By being collision resistant, a hash function must make it highly improbable to generate the same signature for two different data input…

Yes, your understanding about this matter is excellent :ok_hand:

Exactly, but because hashes always have a fixed size, it is technically not collision resistant. The larger the size of the output, the less likely you can have a collision. Sha256 with an output of 2^256 bits is a really big number :wink:

1 Like

Here you can play with sha256, a 256bit output (64 digits hexadecimal number)

https://miraclesalad.com/webtools/sha256.php

2 Likes