Bitcoin Forum

Other => Beginners & Help => Topic started by: Insufficient on July 20, 2018, 06:07:59 AM



Title: Understanding about Hash functions
Post by: Insufficient on July 20, 2018, 06:07:59 AM
Introduction
    Hash functions (https://en.m.wikipedia.org/wiki/Hash_function) are the fundamental and vital part of the Blockchain  (https://en.m.wikipedia.org/wiki/Blockchain). In summarize if you understand how the Hash functions work,  you'll understand too the Blockchain.

Hash Function What is it? ???
  In the abstract, a Hash function (https://en.m.wikipedia.org/wiki/Hash_function) is a mathematical process that takes input data of any size, performs an operation on it, and returns output data of a fixed size. In summarize , a hash function takes an input of any length and creates an output of fixed length.

  Hash function have a three basic characteristics :
  • Secure - Non-reversible function
  • Fixed size - short or long data will produce fixed-size digest
  • Unique - two different data sets cannot produce the same digest

How this relate to the blockchain? ???
   Blockchain use hash functions everywhere : i.e In Bitcoin private key ; every public key linked to a private key , private key can generate an essentially unlimited supply of public addresses but you can not reverse it to show the secret key behind it.



Title: Re: Understanding about Hash functions
Post by: r1s2g3 on July 21, 2018, 07:32:51 AM
How this relate to the blockchain? ???
   Blockchain use hash functions everywhere : i.e In Bitcoin private key ; every public key linked to a private key , private key can generate an essentially unlimited supply of public addresses but you can not reverse it to show the secret key behind it.



I guess, this part is wrong, Private key is used to generate public key by  using elliptic curve multiplication. Bitcoin Address are generated by using Hash function on Public key.


https://i.imgur.com/5pZkcKZ.png


source : https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc



  Hash function have a three basic characteristics :
  • Unique - two different data sets cannot produce the same digest


I do not have source but I remember to read that it is very rare scenarios but it is possible that 2 different input can have same hash.


Title: Re: Understanding about Hash functions
Post by: HCP on July 21, 2018, 09:46:48 AM
I do not have source but I remember to read that it is very rare scenarios but it is possible that 2 different input can have same hash.
You are indeed correct... this is known as a "collision". Refer: https://en.wikipedia.org/wiki/Collision_(computer_science)

Basically, it depends on the size of the output space for your hash function. The larger the space, the smaller the chance of a collision.

For example, if you have a 2 bit hash function (as opposed to bitcoins 256 bit hash functions)... then the only possible outputs of your hash function are:
Quote
00
01
10
11

Given any two different inputs... there is a 1/4 chance that they'll both generate the same output. A 256 bit hash function on the other hand has 2256 possible outputs... the odds of finding a collision are so small it is generally regarded as zero.


Title: Re: Understanding about Hash functions
Post by: vphasitha01 on July 21, 2018, 09:52:18 AM
I do not have source but I remember to read that it is very rare scenarios but it is possible that 2 different input can have same hash.
When we compare to the SHA-2 series of hash functions(SHA-256, SHA-384, SHA 512) has strong collision resistance (https://en.wikipedia.org/wiki/Collision_resistance). so it is hard to find two inputs having the same hash. I think you're talking about MD5 (http://www.iusmentis.com/technology/hashfunctions/md5/) hash function which is vulnerable for collision attacks and also a hacker can produce two colliding hashes in no time with higher CPU power, but not with the SHA-2 series.

With SHA-256 function, almost all the time we cannot get Hash(A)=Hash(B) if A≠B


<...snip...>

I have created a thread (https://bitcointalk.org/index.php?topic=4613193.0) regarding Hash function which I believed helpful for you :). This Hash calculator (https://www.fileformat.info/tool/hash.htm) is a very good one for reference with different hash functions.