Homework on Hash Functions - Questions

  • Describe hash functions with your own words
    – a function that encrypts any type of input data and outputs a set of alphanumerical characters with a predetermined length

  • 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 function is used to encrypt the transaction data (timestamp/nonce/transaction details/previous hash) which then goes into the mempool of a block.

  • 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 the chance of two different input messages having the same resulting hash is minimal

1 Like

Public key cryptography does not use hash functions but another function called the elliptic curve, it has a different function, you can check the beginning of the privacy course on the academy that explains it quite well :slight_smile:
But basically it has a formula like this (k + j)H = kH + jH
where
kH = public key
k = private key
j = “shared secret”
kH + jH is publicly known
With these parameters you can prove that you know k (i.e. are the owner of the private key) by providing the solution to k + j

2 Likes

I think you are mixing blocks and transactions here a bit :slight_smile: the first part of your answer refers to a block hash and the second part is the hash of a transaction (both are actually correct) :slight_smile:

1 Like

hash function is a way to secure the data .once you have the input the output is generated buts its very difficult to go from output to input

hash function are used in cryptocurrency by using transactions as inputs and generating output of a fixed length of letters and numbers

collision resistant means that sometimes the same hash is generated for two different outputs

1 Like

you mean inputs? :slight_smile:

1 Like

Hash fx, basicly, are used to obtain an output from everery given input using computational power of the blockchain nodes, applying algorythm, isn´t it?

  1. a hash function maps an input of any length to a unique number of a fixed length, (256 bits in the case of SHA 256), in a way that
    a-makes it near impossible to find the input number
    b- gives completely different outputs for 2 inputs that may differ only by a single bit

2.hash functions in bitcoin are used at multiple steps
a- Miners have to solve a computational problem based on a hash function to mine the next block
b- the entire blockchain is represented by its hash instead of the whole actual file, and blocks are tied together by including in each new block the hash of the blockchain up until that point

1 Like

oh and 3- hash functions need to make it extremely unlikely that 2 different inputs could have the same hash. Since Hash functions are by nature non injective (the set of results if finite, albeit very large, but still finite while the set of inputs is infinite), 2 separate inputs can produce the same hash in theory. In practice it is extremely improbable to find 2 inputs which have the same hash thanks to the property of the hash function which creates wildly different hash for very similar but not identical inputs.
Someone trying to tamper with the blockchain will likely try and make minor modifications which can immediately be identified with the hash

1 Like

1: A hash function takes an input string of any length and converts it to a fixed string of a set length creating what should be a 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: A hashing algorithm that has a low collision resistance is more likely to provide the same answer for two separate inputs meaning the digital fingerprint is less likely to be unique. If the collision resistance is high this should be almost impossible.

1 Like

Kind of :slight_smile: the inputs to the function is actually the hash of the previous block, merkle root hash of transactions and a nonce that miners use to solve the PoW puzzle :slight_smile:

1 Like
  1. a hash function it has the purpose of transformed the input in a random text that can’t be reversed back.
  2. In bitcoin the block of transaction are being hashed and are pushed to the blockchain.Together with the block is included also the previous hash value.
    3)It means that for different inputs would be impossible to get the same outputs
1 Like
  1. hash functions are mathematical functions that take an input and give a fixed-length, input-dependent output

  2. they are used in the blockchain technology for the mining process (an hash is created for the difficulty target of the block and compared to the hash of the previous block data concatenated with the nonce); they’re used in the Merkle Tree, which is way of streamlining the data of the blockchain in a cost/time efficient way; they’re used for security purposes - the blockchain is essentially a linked list (hash pointers), with each block pointing to the hash of the previous block, basically rendering an hacker’s attack cumbersome due to the combined properties of both the linked list data structure and the hash function’s.

  3. It means that one their most desirable properties has to be making sure that the probability of two hash outputs yielding the same result is almost negligible.

1 Like
  1. A hash function takes an input of any length and generates an output of fixed length. There’s a unique hash value for each unique input. If this input is changed but slightly will also generate a different hash value. A hash function is a one-way function that generates hash values that cant be used to find the input.

  2. A hash function is used in numbers of ways in bitcoin;

Transaction hash(TXID) enables the identification, tracking and verifying of any individual transaction.

Merkle root hash & Merkel tree Maintain data integrity and make searching and verifying TXID possible and quickly.

Block Hash(block header hash) Linking to previous block by a hash pointer.

Create new blocks by finding targeting difficulty by repeatedly hashing a block header each time changing the Nonce until the block hash is less or equal to the target. The new block hash becomes a reference point for the next new block.

  1. A hash function needs to be collision-resistant so that the possibility of finding more than one unique input share the same hash value is small enough so that it doesn’t happen in real life.
1 Like
  1. Hash functions convert data in to a hexadecimal value that is like a “fingerprint” of that initial data. To be secure the function needs to convert only one way so that it is not easy to find the original data from the hash output.
  2. Hash functions are used in Bitcoin mining for the not-yet confirmed transactions. Those transactions are then combined with arbitrary data and hashed. Blocks are created when the hash starts with a specific number of 0s. The block will then contain the new transactions on the Bitcoin blockchain and the miners will be rewarded with Bitcoin.
  3. It needs to be very difficult for hashing two different values to generate the same output.
1 Like

Homework on Hash Functions - Questions

  1. Hash functions are the mathematical process of changing specific data inputs of any size into a unique alphanumeric string output of a fixed length based on the hashing algorithm used like SHA256

  2. Hashing functions are used in cryptocurrencies like Bitcoin, to write new transactions into the blockchain through the mining process.

  3. Hash functions need to be collision resistant means that there needs to be a very high improbability of two hashing signatures being the same. If the hashing function isn’t collision resistant that means that someone can substitute the original data with substitute data that produces the same hashing signature and no one will know the difference. The hashing function needs to be very difficult for someone to hack, crack or manipulate resulting in collision resistance.

1 Like
  1. Hash functions take an input of any length and return an output of a fixed length. This makes them useful for quickly and efficiently handling large amounts of data and transactions.

  2. Cryptographic hash functions are used in combination with linked list data structure to create blockchains. Transaction data is hashed and stored in blocks. Hash functions provide blockchains immutable quality, as each block contains a hash of the previous block’s header. Since it is currently infeasible to find the input from the hashed output, attempting to make any changes to a block in the blockchain will chain all previous blocks in the chain, which means that miners will invalidate and discard the altered block, which maintains the security of the blockchain. Hash functions are in turn, essential to the miners who maintain the network, because hash functions are used to mine new blocks for the financial rewards they receive by doing so.

  3. Hash functions need to be collision resistant to provide security and authenticity to the blockchain. Collision resistant means that there should be sufficiently numerous potential outputs of the hash function, that it is extremely difficult for any two inputs to hash the same output. This is important because hash collisions can create opportunities for bad actors to cheat the system, such as providing multiple public key signatures on the hash of a document or providing the collision hash as PoW to collect block rewards.

1 Like

1. Describe hash functions with your own words
A hash function converts any input (any length) into a series of alphanumeric combination of words and numbers (fixed length).
For example,
Input: I am Victoria Chua
Output: 0F6FC0AACAB95CBFCA5E54680BA1F0457A1E811056887C2DA0824D0D48011754

No matter what I write or how long my sentence is, the output will always be fixed length.

2. How are hash functions used in cryptocurrencies like bitcoin?
(1) To create bitcoin
It takes 2.7 Quadrillion hashes calculated to generate a BTC.
(2) To organize data and retrieve data
As the output is always of a fixed length, it is easier to organize information of fixed lengths into a systematic order. It is also easier to find and search the information.
3. What does it mean when we say that hash functions need to be collision resistant?
It means every input must give rise to a unique output hash function.
We cannot have a situation that two different inputs give rise to the same hash function output. Every hash function with more inputs than outputs will necessarily have collisions. Therefore, hash functions need to be collision resistant.

1 Like

Describe hash functions with your own words

A hash is a unique fingerprint of collected data. If the data changes in any way, the entire fingerprint changes as well.

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

They take a fingerprint of the entire blockchain and put it into a small string of numbers, so that everyone can now the collection of blockchain data is correct.

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 two different sets of data is unlikely to product the same fingerprint (hash).

1 Like

Awesome, I just learned create a Hash in Linux now and yours checks out!
echo -n “I am Victoria Chua” |sha256sum
0f6fc0aacab95cbfca5e54680ba1f0457a1e811056887c2da0824d0d48011754 -

That is pretty cool stuff… I always see you can check the Hash of a file to make sure it is legit (crypto wallets). Going to start using this! This is awesome.

2 Likes
  1. They are functions that map every input to a single, fixed-size output.

  2. Hash functions enhance blockchain security through connection the blocks with each other (every block contains the hash of a previous block), help efficiently store transaction data being an essential part of a merkle tree data structure and are the base of computations used for providing the proof of work.

  3. It means that ideally no 2 inputs will give the same output.

1 Like