Bitcoin Technical Learning Part 1 - Cryptographic Hash Function

Bitcoin Technical Learning Part 1 - Cryptographic Hash Function

By xuanling11 | Crypto Learning | 31 Dec 2020


If you had read of Bitcoin white paper, you will encounter a hash function multiple times.

So what is hash function? Simply it is a algorithm of specific way to calculate large information and turn into bunch of numbers through a function so that someone cannot replicate from the result to get the information.

314cb6e98d3313ed05184774952df7e2021eb014cbb62721e8e525888c47a836.png

Wait what??

c7713ab2ceedba9fa62fbd5f44ef93dbdd5ee78f4ef6e17a83a039f0e47a11a8.png

Photo Reference from: http://www.sra.vjti.info/blog/blog-posts/hash-functions-explained-in-2-minutes

Simply, Hash function can shrink information into small bit size.

Hash function has three properties that make cryptocurrencies work. Before you dive in, if you do not want to read further, you can simply watch this video to understand Hashing.

Property #1: Collision-free

7d36317576c28f6aa7210e3205b719181bb60353efaa0e2cbd5d1f5148f3190e.png

Translating into mathematical interpretation is

Nobody can find x and y such that x != y and H(x) = H(y)

Of course there is possibility that you may find collisions and you can try to find it through 2^130 randomly chosen inputs with 99.8% chance to find two collide. However, since it takes too long to compute, we approximately believe it will never happen!

Thus, hash is message digest that if we know H(x) = H(y), it is safe to assume that x = y.

Collision free provides such function with one way solution that if we know H(x) = H(y), we can find x = y but not the other way around.

In Bitcoin application, where you have public wallet address with string of characters and someone has their wallet address with string of characters, if someone send Bitcoin into your wallet, there must be some information that your and someone's wallet address can validate H(x) = H(y) so that you receive Bitcoin y which is equivalent to someone who sent it to you.

Property #2: Hiding property

b26b22218571c8713e5832158693d487b968d3ff22500d57e382c9d03c15f41c.png

Translating into mathematical interpretation is

Given H(x), it is infeasible to find x

It means some probability of P with given H(P | x), it is infeasible to find x.

Similar to seal a value in an envelope and open the envelop later analogy,  commit to a value and reveal it later.

#Commitment API

com, key) := commit(msg)
match := verify(com, key, msg)

#To seal msg in envelope:
(com, key) := commit(msg) -- then publish com

#To open envelope:
#publish key, msg
#anyone can use verify() to check validity
#Security properties:
#Hiding: Given com, infeasible to find msg
#Biding: infeasible to find msg != msg’ such that 

verify(commit(msg), msg’) == true
commit(msg) := (H(key | msg), key)

#Where key is a random 256-bit value
verify(com, key, msg) := (H(key | msg) == com)

#Security properties:
#Hiding: Given H(key | msg), infeasible to find msg
#Biding: infeasible to find msg != msg’ such that 

H(key | msg) == H(key | msg’)

Or into layman language, the function is hiding information but to translate information into string that only certain people who has a key to open such information. Both of their key must to match.

In Bitcoin, your wallet address must be the same as the address you provide to other for sending their Bitcoin into your wallet.

Property #3: Puzzle-friendly

aa85cffec3c4c52e62dfd03089d062c1d20cfaff83db7c7da3b38335743f377e.png

Translating into mathematical interpretation is

For every possible output value y, if k is chosen from a distribution with equal possibilities then it is infeasible to find x such that H(k | x) = y

Given a “puzzle ID” = id, and a target set Y: Try to find a “solution” x such that H(id | x) ∈ Y

Puzzle-friendly property implies that no solving strategy is much better than trying random value of x

It gives a Bitcoin mining function that miners are constantly searching solutions to verify transaction in the sense of solving puzzles. They will reward with Bitcoin from block the system release.

Thanks for reading and I hope you learn something today!

68589a16f0a34e0e875a5542bc22c08d6b9cc3e76c36f7e68f8fff148cb9c6c8.png

Disclosure: I/we have no positions in any cryptocurrencies mentioned, and no plans to initiate any positions within the next 72 hours. I wrote this article myself, and it expresses my own opinions. I am not receiving compensation for it. I have no business relationship with any company whose cryptocurrencies are mentioned in this article. These information are only for educational purposes.

How do you rate this article?

5


xuanling11
xuanling11

Check out https://www.xuanling11.com/.


Crypto Learning
Crypto Learning

All article was written by a delusional author who is possibly a nut job without any questions whatsoever about expertise in the subject matters.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.