Homework on Hash Functions - Questions

They hash. Encryption is something different. :smiley:

1 Like

Of course. It was just a friendly smiley face. Keep up the good work. :muscle:

Very nice way of saying it. Great job. :smiley:

We have to keep the input data and the hash. Since we can’t go from the hash back to the input we need to remember it. If anyone tampers with the data the hash will change and we will know the data has been tampered with. :slight_smile:

Not true. While we do use digital signatures to authorize transactions on the blockchain, they are not based on hash functions. They are the part of the public and private key cryptography. Public and private key cryptography enables us to have a 2 way function. Which means I can sign something with my private key and you can check that I signed it using my public key. Hash functions are one way fucntion, which means there is no way for anyone verify an output.

Hash functions are used to secure blocks in the bitcoin network. Miners create hashes for the blocks. We keep the block input data and the hash together, so if anyone tampers with the data we will know it. And this is all secured by electricity work miners do.

Everything you said in the second answer makes perfect sense, just replace it with the public and private key cryptography.

  1. A hash function is a unique output that secures a certain input
  2. bitcoin uses hash functions to secure the data so that the integrity of the chain is in place. Therefore, if someone were to attempt to change the block, they would not be able to as it would not only require that all previous linked blocks be changed, but also since the SHA256 hashing method is not yet vulnerable, that is you cannot go from an output to an input, you could not achieve this anyways
  3. Collision resistance refers to the low probability that two inputs will hash into the same output. So if I hashed the input a, it is very unlikely that a would be discovered to be the input by another person, such that a equals a SHA256 string of values
1 Like
  1. Hash functions are mathematical functions used in cryptography to verify the integrity of data. By converting identical data/input (of any size) into a unique output, giving it a unique fingerprint (a fixed size code).

  2. Hash functions are used, in the case of cryptocurrencies like bitcoin, to establish that the broadcasted data was not corrupted during transmission, to verify block integrity and to establish the chronological order of the blockchain. They are part of the proof of work (PoW) algorithm, used to mine some types of cryptocurrencies, like Bitcoin.

  3. Collision resistance is a property of cryptographic hash functions. It means that different inputs should never generate the same output/hash. However, it doesn’t mean that no collisions exist, it just means that it is difficult to find them. Hashes are very difficult to reverse engineer, to find its input value.

1 Like
  1. Describe hash functions with your own words:

Hash functions are unique inputs big or small that it will get back a unique and tailored output directly reflecting the input.

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

From what I’ve gathered, Hash functions are used to encrypt each block that’s connected to the blockchain. Every following block generated and added to the chain is also encrypted. using SHA256 no matter the size of the input, a fixed output will be the final product. the last block generated has a timestamp along with all the same information from the previous block and ready for new input.

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

From what I’ve gathered, the need to make sure the hash needs to be collision resistant means that no matter how many unique inputs are put in the hash function, that the output of them are rarely if ever equal. if more than one unique input has the same/shared output, there could be a serious flaw in the hash and that there are more options to break the algorithm besides brute force.

i hope i’m write, open to corrections!

1 Like

tks a lot, I’m studying like a Mad hahahah All this coding world is new for me, it helped me a lot! :=)

2 Likes
  1. Hash function is a function where every unique input has a unique output, and the formula of the function from output to input cannot easily be determined.
  2. In cryptocurrency, it is used in mining: when a computer solves for a specific target hash, the miner gets currency and the block is added to the blockchain.
  3. Collision resistant means it’s hard to find two inputs that get to the same output; critical as if two inputs had the same output two different transactions could be seen as one.
1 Like
  1. Hash function is a mathematical process that creates a fixed-size unique ID for each unique data set of any size. Hash functions cannot be reversed engineered.

  2. Hash functions are used in bitcoin as follows: the input data is comprised of the new not-yet-confirmed (meaning: not yet added to the blockchain) data-set plus a timestamp plus a reference to the previous block plus an additional arbitrary input data added by the miner in order to result in an output data (Unique ID) that conforms to the bitcoin protocol (proscribed number of leading zeroes in the resulting Unique ID).

  3. Hash functions need to be collision resistant (meaning, two or more set of unique datasets resulting in the same Unique ID) in order to preserve the integrity of any particular block.

1 Like

Haha no problem. I’m the same way. Been at it a few months, and there’s always something new to learn. Happy to answer any other questions you may have if I can.

1 Like
  1. A hash function gives a unique output specific to an input. They only operate in one direction, you cannot take the output and perform any operations that would reveal the input.

  2. Hash functions are used to ensure that a hacker cannot attempt to find an input value through running a string of random values through the hash in order to duplicate a specific output. Another useful feature of hash functions is ensuring the smallest change in the input produces a significant difference in the output. Pointers also add to the immutability of hash functions, they are variables that point to addresses of other variables instead of pointing to addresses of data.

  3. Collision resistance means that each input must have its own unique output, and measures need to be taken to make sure that two different inputs do not result in an identical output.

1 Like

Hi there! Maybe you meant that the hash of the block must start with a certain number of zeros. You can verify this in a block explorer!

1 Like

1.) A hash function gives a unique code to your entered data that is nearly impossible to reverse engineer.

2.) The hashes are encapsulated with the next within the block and linked in the chain to the next hash so that a new hash is generated, and all the previous hashes are attached so that if one hash is changed it will change all of the others which would then make them invalid to the nodes whose hashes would not agree.

3.) The more hashes on the block the more susceptible to the “birthday paradox” where a hash may be so close to the same that one concludes, or necessarily follows the next hash. At the halfway point of the 128bit protocol is when a collision would occur if the inscription of hash 2^128 and 2^64 collide in a chain.

  1. Hash function is one way function where each input produces one output or digital fingerprint.
  2. For bitcoin the transactions are taken as an input and run through a hashing function which gives an output of a fixed lenght.
  3. Each input is transformed to unique output and probability of two different inputs transporting to same output is impossible.
1 Like

Hash Function

  1. Hash function generates a value of fixed length from a string of text. It’s a one way function where every unique input produces a unique output.

  2. Bitcoin uses SHA-256 hashing algorithm, the transactions are the input and run through the hashing algorithm producing an output of fixed length i.e. the hash value at 256 bits in size.

  3. It should be improbable to find a pair of different inputs that will hash to the same output.

1 Like
  1. Describe hash functions with your own words
    A. Hash function are essentially a digital fingerprint, you can got from input to output, but can never go from output to input.

  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 to encrypt data on the block-chain.

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

Collision resistance means that you will have extremely low probability in two things meeting, (i.e.you do not create the same private key as someone else)

1 Like
  1. Describe the hash function?
    It is very secure, extremely difficult and impossible to determine the input hash value while the input slightess change to an input will generate different hash. Each unique input gives unique output with unique digital finger print.
  2. How are hash function used in cryptocurrencies like bitcoin?
    Hash function used to write new transactions into the blockchain through the mining process.
    The transaction are taken as input and run through a hashing algorithm uses SHA 256 which gives an input of a fixed length. Instead of remembering the input data which could be huge, we just remember the hash and keep track.
  1. A hash function takes an input of any size and converts it into an output of fixed size. This is done with a mathematical algorithm. There are many algorithms that can hash an input but cryptography requires a certain number of qualities. These qualities are:
    a) Deterministic. This means the same input will always produce the same output.
    b) Speed. A hash function should be quick to produce a hash value.
    c) Pre-Image Resistant. The input should be extremely difficult, ideally impossible, to deduce from the output to prevent or dissuade brute force attack.
    d) Any change to the input should produce a significant change to the output.
    e) Collision resistant. It should be extremely unlikely, ideally impossible, to get matching outputs from different inputs.
    f) Puzzle friendly. The algorithm should allow the concatenation of hash values.

  2. The hash function in bitcoin uses the data from the previous block as the input and records the hash output in the new block. As each blocks data is dependant on the preceding block all the way back to the genesis block, it is nearly impossible to change an entry within a block without producing a disparity with the following blocks recorded hash output. This enables the network to easily detect attempts to change confirmed blocks.

  3. Collision resistance is a term used to describe the statistical probability of producing 2 outputs of the same value. The lower the probability of a “collision” of outputs the more secure the algorithm is against brute force attacks. It is speculated that in time all algorithms will be “cracked”, either by discovery of mathematical flaws in the algorithm - as was the case with SHA-1 which was hacked with just 2^51 operations despite an output of 160 bits, or by improved technology allowing brute force attack.