What’s the world’s most popular computer algorithm? Maybe the SHA 256 hash function. I want to show you what it does, and tell you about a problem that no one on Earth knows how to solve, and explain why billions of dollars are at stake. [Intro Music] The SHA 256 algorithm is a deterministic one-way hash function. Now, what it the world do those words even mean? An algorithm is just a process, or list of steps for doing something. A hash function is a mathematical function that takes any size of input but has an output of a fixed size. You can think of it as a digital fingerprint for the file. It’s deterministic which means whenever you start with the same input, you always get the same output. And SHA 256 stands for “Secure Hash Algorithm” and it outputs 256 bits. What does “one-way” mean? Well, that’s just a function that’s hard to do backwards. Some functions are easy to do backwards, like for example the function of adding 30. You just subtract 30 to do the reverse. But the function of multiplying two large primes together is really hard to do backwards. Take a look at my follow-up video for more details. Okay, back to SHA 256. It’s an algorithm for a one-way hash function that takes any kind of digital input and any length of input and always outputs exactly 256 bits, or 256 ones and zeros, which is basically a big long number, usually written as 64 hex digits, like this. Let me tell you about two things that make this function really interesting and useful. First of all, the only time you ever end up with the same hash, or the same fingerprint, is if you started with the exactly identical input. There are so many different possible fingerprints that no two inputs have ever ended up with the same fingerprint, and I mean never, in the history of the world. How many different hashes are there? Two to the 256th, which means two multiplied by itself 256 times, or to be specific, 115 quattourvigintillion, 792 tresvigintillion, 89 duovigintillion, 230, you get the idea. Another interesting property of this funciton is that it’s designed to have the butterfly effect built in such that changing the input just a little bit completely changes the output. Let me show you an example. Here’s a picture I took. It’s 1000 by 1000 pixels, and the file is 24 million bits long. When I run this through the SHA 256 algorithm, it outputs this hash. Now watch what happens when I change one single bit in the input. I’m going to zoom in to this pixel on the telephone pole and change the green value by changing this zero to a one. Now I re-run the algorithm, and I get a completely different output. And that’s from changing just one single bit out of more than 24 million bits. So these properties make SHA 256 useful for all kinds of applications: cryptography, digital signatures, authentication. Oh, and there’s bitcoin. More in a minute. Beyond the usefulness of this algorithm, I think some of the philosophical consequences are amazing to think about. First of all it’s possible for you to see a number that literally no one else in human history has ever seen before. All you have to do is take a picture with some randomness in it, and calculate the SHA 256 hash. So ladies and gentlemen, here’s the world premiere of this number that I just made from that picture. It’s never been seen before. Also, I think it’s cool that here’s a mathematical function that anyone can do on their computer but no one has any idea how to do the reverse of this function. How do we know? Because there are billions of dollars at stake. You see, SHA 256 is a key part of the bitcoin protocol. If you could reverse the algorithm, you could mine bitcoin faster than anyone else and make a lot of money. In order to mine bitcoin, all you have to do is find an input that produces a SHA 256 output with 70-something zeros at the beginning. But, since there’s no known formula, the best anyone can do, is to do it by brute force, which means just trying a bunch of different inputs until they find something that works. Now I said before it’s impossible to find an input that matches a specific hash fingerprint. And that’s true. But bitcoin mining only requires that you find a hash that’s close, not an exact match. In fact, the difficulty can be adjusted up or down, to make it such that about every ten minutes, someone, somewhere finds a match, earning themselves 12.5 bitcoins, which is worth somewhere between
12 dollars and 12 million dollars. Also, that’s why I think it’s the most popular algorithm on Earth, or maybe I should say the most “commonly computed” algorithm on Earth. In this race to mine bitcoin, special computers have been built just for running SHA 256 as fast as possible. How fast? Well, if you add up all of the bitcoin miners in all of the world, they’re currently doing 60 trillion hashes, no wait, 60 quadrillion, no 60 quintillion hashes per day mining bitcoin. Oh, wait, I’m wrong again, not 60 quintillion per day, not per hour, not per minute, but per second. That’s right, SHA 256 is run 60 quintillion times per second,
all day, every day. So yes, I think it’s fair to say that SHA 256 is the most popular algorithm. I mean, unless you count adding and multiplying, which are parts of SHA 256. Maybe it’s the most popular “big” algorithm? Actually, I suppose there might be some digital signal processing algorithms like Fourier transforms that beat it? But more than 60 quintillion times per second? I don’t know. Anyway, all of this is good evidence that no one has figured out a shortcut, because there’s a huge financial incentive to do so. Or maybe they have, but they know not to kill the goose laying the golden eggs, and they’re just slowly collecting bitcoins. Or maybe there’s some kind a secretive government organization, hiding the truth from the populace. Let’s see, who invented bitcoin? Nobody knows, what? And who designed SHA 256? Let’s see, the NSA? Who are they? United States National Security Agency! Uh-Oh. I think I better go now. Thanks for watching.