Hash Functions
Danny Diekroeger @dannydiekroeger 路 Jul 09 Hash Functions are a key concept in computer science, cryptography, and yes #bitcoin. |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Hashes are used for all kinds of things, but a simple analogy is to think of them like fingerprints for data. https://t.co/CQywn8n6jf
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 You can think of a Hash Function like a magic fingerprint reader. You can enter any data into the hash function, and it will spit out a fingerprint. https://t.co/AeY1Jop2KB
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Anything can be used as a Hash Function, but a good hash function will ensure that different input data will each have unique fingerprints. |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Check out the link below. Try entering your name and see what the Hash Function spits out |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Here's what happens when I type in my name. Notice that if you type in "Danny" as well, you'll get the exact same result. This is the SHA-256 hash (or "fingerprint") of my name. https://t.co/5ZYt8OWeYI
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 But what is this SHA-256 voodoo anyway? How is it calculating that fingerprint? |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 This fancy math guarantees a couple things: |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 To explain further, here's an example question... |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Any guesses?
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 So go ahead, start guessing! The input data could be anything. Maybe its the letter "A", or maybe its the entire text from the 3rd Harry Potter book.
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 The answer is "Bitcoin is freedom"
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Ok great, so we can play silly games with Hash functions, but what else can we do?
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Imagine if a website just stored your password, in plain text, in their database.
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 When you login, the website takes your password and hashes it, then compares it to the hash that's stored in their database...
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Ever wonder why the "Forgot my password" always makes you create a new password (instead of just telling you what your old one was)? |
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Great so Hashes are neat and useful, but how do they relate to #Bitcoin? ..... https://t.co/QEs0Poy1Zi
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 In Bitcoin, the SHA-256 function plays a key role in addresses, address scripts, and mining.
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Ok here's the game...
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 What's your strategy?
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 We'll brute force it like this:
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Eventually if you keep up this process, you'll come across the number 1918, and check it out!
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 How did I find that out? Well, I just wrote a simple script that does that same brute force process.
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 In fact, what I've done is I "Proved" to you that my computer did some "Work"...
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Just edit our little game and replace the starting word "Bitcoin" with a list of bitcoin transactions thats basically how the bitcoin mining competition works! https://t.co/sU5Bg4IGh0
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Miners are all trying to find a list of valid of transactions that Hash to something with a bunch of leadings 0s
|
|
Danny Diekroeger @dannydiekroeger 路 Jul 09 Anyway, that's the basics, and I'll end the thread on Hash Functions here. |