Probability in Bitcoin Mining: The Hashing Function

The only way to send money electronically
has always been to rely on a centralized intermediary. Say, someone like PayPal. How do we randomly select a miner amongst
all the miners on the network to play this role, to be kind of like PayPal for a short, ten-minute period? Well, it’s actually through hash functions. A hash function is a mathematical function. It’s rather like what you would have learned
in grade school, just more complicated. You take your input data, and that could be
anything. Anything that can be represented in ones and
zeroes. So, it could be just the letter A. You take
the letter A and you cut and paste it into the hash function. What’s going to come out the other side? What is Y if that’s X? What’s going to come out is actually a 64-character string. It’ll look like a bunch of random letters
and numbers, but it will be unique and perfectly correlate to the letter A. So if someone across
the world takes the character A, cuts and pastes it into the same hash function, they’ll
get the same answer. It’s just math. If you cut and paste the complete works of
William Shakespeare into the same hash function, you’ll still get a 64-character string. It won’t be longer because your input data
was longer. It’ll be very similar to the hash of the letter
A. The particular letters and numbers and seemingly random text will be different than
the one before, but it’ll just be 64 characters long. And, again, if somebody did that same function
with that same input, the William Shakespeare through the same hash function, they’ll get
the same result you got when you ran that equation. So, what is a bitcoin miner actually hashing? They’re not hashing the letter A, they’re
not hashing the complete works of Sh- … William Shakespeare. They’re hashing all of the validly signed
transaction data that they just accumulated by listening to the peer-to-peer network over
the last ten minutes. And they’re also hashing a reference to the
previous block in the block chain. And this is how they’re actually chained together. This block references the previous block. And they’re also hashing one third thing. And that’s a random number. And each time they run all this data through
the hash function, they’re going to change the random number slightly to get a different
output. They’re trying to get an output that’s kind
of like flipping a coin heads up 20 times in a row. In Bitcoin, we use that kind of entropy to
randomly select winners in this open competition to be PayPal for ten minutes, and we do it using
a hash function.

Leave a Reply

Your email address will not be published. Required fields are marked *