Homework on Hash Functions - Questions

  1. A hash function takes input, such as any line of text, runs that through a function or a mathematical equation which produces an output. This output changes depending on what the input was.

  2. Hash function in BTC are used to mine new BTC and to write transaction on the blockchain.

  3. Collision resistant means that 2 inputs will not create the same output.

1 Like
  1. A hash function is a mathematical computation where one input gives one unique output. No matter the size of the input, you always get a fixed-length output when hashing. It is like a fingerprint of the input.

  2. Cryptographic hash functions are essential to cryptocurrencies since it guarantees one of the blockchain’s most important features:– immutability.
    Since cryptocurrency blockchains deal with large numbers of transactions, they use hashing. This is a far more practical and secure approach than to keep every record of every single transaction in the ledger. In Bitcoin’s case, the miners run a series of SHA-256 functions to create the hash of a block. Then the latter receives a timestamp. Once the nodes reach consensus, the block is added to the blockchain. Not only does the block have its own hash, but it also contains the hash of the previous one, thus chaining all of them together.

  3. It means that it has to be hard to find two inputs that hash to the same output

1 Like
  1. Describe hash functions with your own words
    Has functions are the those which gives a unique output given the content of a file or variable. If any value/bit of this file or variable changes, hash generated will be completely different.

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

Has functions take the values of a transactions (receipt, sender, previous block, timestamp, etc.) and generate a randomly unique (hash) value to validate and be written in the ledger.

  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 resistant means that an output is unique and difficult (imposible?) to find any other input which replies the same output.

1 Like

Describe hash functions with your own words
A hash function is a function that have a set amount of instructions to change an input to an output. Why it is different from just a normal function and consists of the definition of a hash function is because of its unique characteristics. It should be easy to generate an output from a specific input, but it should be extremely hard (practically impossible) to reverse the process to get the input of a specific output. It should consist of large enough different hash values (outputs) so that every single possible input gets a unique output a fingerprint of a set number of bits.

So to my understanding the main thing of hash functions is the one way aspect of it together with the “fingerprint” that each input gets a unique output that is different from every other input. This is not really the case in theory when we have more inputs than the 256bit output value but practically speaking it is extremely unlikely that two of the same input value gets the same hash output.

How are hash functions used in cryptocurrencies like bitcoin?
Hash functions is used mainly in the mining process of it, in the proof of work of the blockchain. To proof that a miner has put in the work to solve the mathematical problem that the protocol consists of, one needs to hash the new block with all its new valid transactions and then randomly choose different input to connect with the hash from the block and hash these to search for a output with a set number of 0’s depending on the current difficult levels. This is where the one way aspect of a hash function come in handy when it is practically impossible to reverse engineer a hash function so a miner needs to only randomly guess on inputs to get the desired output of a number of 0’s in the output hash value.

The raise in difficulty to my understanding is that when more 0’s are added to the requirements is that fewer actual different bits combinations is existing when you restricts the number of 0’s in the bit number. If for example only one 0’s are needed that is not restricting it a lot and a HUGE number of bits combination still exist.

Hashing is also used through “hash pointers” where every new block needs to include the previous blocks hash. That will secure that the chain from the beginning up until that exact block its unchanged. Here the property of a hash function like that it is deterministic is of great importance.

I doesn’t have enough knowledge about how hashing is used in the actual transactions with the public and private key to prove that the sender has enough coins with a digital signature. I have very briefly read about it where some transaction message together with the private key is hashing a digital signature so that others can verify that I have enough “unspent” input transactions to spend.

What does it mean when we say that hash functions need to be collision resistant?
To be collision resistant is not possible for a hash function in theory for the fact that we have more more different combination of input values than possible output values in a 256bit output hash. When a hash function is collision resistant is when we can for sure say that it is practically impossible or at least to a degree where it doesn’t matter anymore. The astronomical unlikely event of a collision is leading us to say that collision will not happen. My understanding when reading about hashing is that we need hash functions in the present so that the computing power that we have today can’t in any reasonable amount of time break the hash function in the only way we humans know in these newer hashing algorithms through that of brute-force. My guess is the SHA-256 will eventually come to a time where it needs to change, when that will happen I have no clue of with the very small amount of knowledge I possesses.

1 Like

1.) Hash functions are a one way street, in the sense that if you turn information into a hash, you can’t turn it back into information.

2.) Crypto transactions are run through a hashing algorithm (SHA-256), which turn the transactions into hashes.

3.) Collision resistance simply means that it is very hard to find two inputs with the same output.

1 Like

Thanks for pointing it out. Now that I think about it, it doesn’t make sense at all.
People have the option to share their private keys to other people and it doesn’t have anything to do with collision resistance. I delete that sharing part from my answer.

Q: Describe hash functions with your own words

Answer: A hash function is generating a value or values from a string of text using a computation that has both an input and an output to create an output that is not feasible to to undue.

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

Answer: In crypto, hash functions are used to convert an input of any length to return an output of a fixed length. In Bitcoin, that length is set to 256 bits. The purpose of hash function in BTC is to provide a secure way of validating new transactions that will be added to the network, and encrypting those transactions so that the recipient is the only one who can decrypt it…

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

Answer: Collision resistant hash functions means two different inputs should not equal the same output. If they do equal the same output, the inputs should be the same. We use the term “resistant” because there is mathematical small probability of two different inputs creating the same output (example of two people randomly meeting and having the exact same birthday).

1 Like
  1. Describe hash functions with your own words
    These are one way injective functions with a cryptographic purpose, in this case providing an unique fingerprient to Tx, giving place to the immutability property of blockchain.

  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 identify Txs and then building a merkle tree, and also are used to identify the previous block in the chain. So if somebody wants to change a Tx, this will change the hash in the block, and that will change the hash in the previous block, and so on. But this cannot happen unless a 51% attack takes place.

  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).
    It means that it has to minimise the possibility of providing 2 different Tx with the same fingerprint

1 Like
  1. Hash function is a function that converts input to output but makes it impossible to find input using output only. The output is of a same length and is completely changed even if the smallest thing is changed in input.

  2. It is used in mining as proof of work. You use your computing power and spend money on electricity to break/guess the hash function input.

  3. Collision resistant means that even if different inputs produce same output, it is very difficult to find those inputs. Guessing is the only way of finding it.

1 Like
  1. A hash function is a special type of function that gives the input a unique output, almost like a fingerprint. A one way function meaning the it can only go from “input -> output” and not “output -> input”.

  2. In cryptocurrencies like bitcoin, transactions are entered as an input into the hashing algorithm SHA-256 which then gives an output of fixed length.

  3. Hash functions need to be collision resistant, meaning the inputs that hash out to the same output are hard to find.

1 Like
  1. Hash functions are taking an input in any length to give a fix length of an output, and it’s infeasible.
  2. Hash functions in bitcoin are keeping bitcoin secure the blocked that it is impossible to copy and change. The hash is running by miners in order to confirm transaction validity and add new block to the chain.
  3. Collision resistant is high unlikely that two different inputs generate the same output, but mathematically speaking it can.
1 Like

It is an option, but sharing private keys is not a good option :slight_smile:

1 Like
  1. inputting information and getting an output that is encrypted
  2. hashes are re-hashed to a new hash. miners attempt to solve the equation and get rewarded in new coins if they solve the ‘puzzle.’
  3. Low probability so that hash results do not get duplicated
1 Like
  1. Describe hash functions with your own words
    Hashes fx basicly turn primary input given into an output through mathematics logic application (algorythm)
  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).
    The specific hash used in bitcoin is SHA256. Hash functions works like this: a private key is generated in a random way with a fix length and a fix format. Once given private key a public key is also created and mathematically related on it
  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).
    Collision resistance is a property of cryptographic hash functions:
    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).
    Every hash function with more inputs than outputs will necessarily have collisions.
    Consider a hash function such as SHA-256 that produces 256 bits of output from an arbitrarily large input.
1 Like
  1. Hash functions are equations that use an input to create a specific output, and when an input is entered, the function creates an output in the form of a hash, which is also defined with a nonce, which is a concatenation with the hash function, which together display the output as a long string of bits.
  2. Cryptocurrencies today use the hash function called SHA-256 which allows cryptocurrency exchanges to create a secure financial environment where every transaction (input) can be tracked by its output. Hash functions will continue to be used for cryptocurrencies to create a more secure environment for Bitcoin and the entire decentralized financial structure that is growing by the day.
    3.Stronger hash functions like SHA-256 are collision resistant because it is far less likely for multiple inputs to have the same output. Hash functions must be collision resistance, otherwise blocks in the blockchain would be less likely to become permanent; and since there is a finite amount of hashes that are possible to be mined, cryptocurrencies cannot be mined too fast, because this would cause an environment where collision would be more likely to occur.
1 Like

Hash functions are not used to derive public key from the private key, For that the elliptic curve is used :slight_smile: There is another use case. Can you figure it out? :wink:

1 Like
  1. Hash function is a mathematical process. They take input data of any size, performs some operation and give output data. They are one way functions with input that produce unique output. Each output is like digital fingerprint and it can not be reversed or deducted ever without changing the bit code.
  2. In Bitcoin protocol the Hash functions are part of algorithm which is used to transact data to blockchain through mining.
  3. Collision resistance does not means that there are no collision but that they are hard to find. No hash function is collision free, but it usually takes so long to find a collision. Hash function is collision resistant if it is hard to find two inputs that hash to the same output.
1 Like
  1. With hash function you can convert any input data to a “hashed” (cryptographically secured) output data in a way that is almost impossible (infeasible) to recover from output. The hash function is using complex math to perform this task.

  2. In bitcoin all the transaction data in the blocks are stored in hashed form. Also, for collecting block reward (i.e. bitcoins) the miners competing to solve the cryptographic puzzle with tyring different nonces (arbitrary string) with hashed block data. The nonce is concatenated to the hashed block data and after another hashing, if it is resolving the cryptographic puzzle, then the actual miner receives the block reward.

  3. Collision resistant means if I hash A input and B input, it is not likely that A output and B output is equal, unless if A input = B input. A collision can be found only with brute-force computing (meaning that after performing 2^128 computes, then there is around 50% chance to have a collision between two outputs).

1 Like

I didn’t have private key creation in mind. I was thinking of signing transactions. How are transactions signed using the private key?

  1. Hash functions are functions that take an input value of any size and generate a random, unique output value of consistent size. Ideally, you cannot feasibly take an hash function output and determine its input.
  2. Cryptocurrencies like bitcoin use hash functions to codify transactions into a hashes of consistent size. The consistency of size allows for some predictability regarding the amount of processing power it would take to generate the hash. Mining is the process of generating these hashes.
    The hash of each block is stored in the header of the next block in the chain. This is how bitcoin uses the hash function to make the blockchain immutable.
  3. Collision resistant means that it is infeasible for 2 given inputs to have the same output. There will always be a small chance that a collision will occur, but the practical goal is for the likelihood of this occurrence to be so small that it is negligible.
1 Like