Crypto ELI8: Hash & Hash Rate
The Crypto ELI8, or Explain Like I’m Eight, series is for anyone who wants to learn about the exciting world of cryptocurrency. Each post is organized around a specific term, concept, question, or other topic related to crypto.
For more on what the series is and a full list of posts check out this series guide.
Sometimes when people talk about cryptocurrencies they use terms like hash and hash rate. Contrary to popular belief, these terms don’t have anything to do with breakfast. In this post, we’ll look at what hash and hash rate mean within the context of crypto and the important role they play in keeping cryptocurrencies secure.
Every last Friday of the month, your school’s art teacher hosts a puzzle competition for all 3rd graders. The winning prize is a pizza party for your class. In order to win, you and/or someone from your class has to win the most rounds. There are four 3rd grade classes and up to five students from each class can participate.
Here’s how the competition works. The teacher hands out a copy of the same puzzle to each class’ team. Depending how many students decide to play, some teams might have five players, some teams might have one, and some might have zero.
Once the teacher says, “Go!”, teams are allowed to open the puzzle box and race to put the pieces together. Once a team puts the last piece in place they shout, “PUZZLE SOLVED!”. Once the teacher verifies the puzzle is solved, they give a point to that team.
Once a puzzle is solved, all students clean up the pieces and exchange that puzzle box for a new puzzle box. Again, the teacher says, “Go!”, and each team races to complete the puzzle.
This process is repeated for five rounds. At the end of all five rounds, whichever class has the most points wins the pizza party!
So, what’s a hash and a hash rate?
A hash is like a completed puzzle. It’s the solution to a problem that’s easy to identify as correct but hard to solve.
Hashing can be thought of as the act of solving the puzzle.
And if hashing is the process of solving, then, hash rate is the time it takes to solve the puzzle. If you have a higher hash rate than someone else that means you solved the puzzle more quickly than they did.
hash = completed puzzle
hashing = process of solving the puzzle
hash rate = the time it takes to solve the puzzle
In the puzzle competition example, teams competed to solve the puzzle faster than the other teams. When they were racing to put the pieces together in the right order, they were hashing. Once completed, the puzzle was the hash that they showed to the teacher to prove they won the round.
Remember how up to five kids from each 3rd grade class could participate? That means the more kids on a team, the more likely that team will solve the puzzle faster.
For example, if there are five kids on a team, they can split up responsibilities. Two kids could be in charge of the edges, one in charge of organizing the pieces by color, and two more putting the actual pieces together. Compare this with a team of one, where the student has to do all those things on their own!
So, the team with more members has a higher hash rate and, in turn, a higher likelihood of winning.
How is hash used in cryptocurrencies?
Cryptocurrency networks are essentially a bunch of computers that are connected to each other and constantly exchanging information. Hashes help the computers verify that the information they receive from other computers is accurate and true, without needing to share all the details of that information. Hashes are essential to ensuring the networks are secure and trustworthy.
Hashes are created using algorithms (a set of steps) that take any amount of inputs and return an output that is always the same size. The output is the hash. The same inputs always produce the same outputs, however, it’s impossible to figure out the inputs based on the output. Even the slightest changes in the input will produce a totally different output.
For example, bitcoin uses a hash algorithm called SHA256. Look at how even a minor change in the input produces a completely different output, or hash:
pizza party >> B1ABDCF830BEF5614D61C91209F3C50878001013E9C2D8BDDEE9E8ADBD19554F
pizza party!>> 06202F05F07D33092A21ED6A2D717C1176784F8A07E30035FD5C127DDC81A591
Pretty cool, right? If you want to try for yourself, here’s a hash generator.
If that sounded a little too technical, don’t worry. Let’s take a look at bitcoin to better understand how hash works.
bitcoin the unit vs. bitcoin the network
When you say “bitcoin”, you could actually be referring to one of two things. There’s bitcoin the unit, or cryptocurrency, which are the actual bitcoins that people buy, sell, and trade. Then there’s bitcoin the network, which are all the computers running the bitcoin software and following a specific set of rules to keep track of information being shared across the network.
Using the same word to refer to two different things can get confusing. To make it easier to keep straight, let’s use “BTC” when referring to bitcoin the unit, or cryptocurrency, and “bitcoin” or “network” when referring to bitcoin the network.
When someone sends you a BTC, that’s called a transaction. On the surface it might seem pretty simple — your friend sends you a BTC and now you see that you have one more BTC. But behind the scenes there’s a lot going on. Computers on the bitcoin network are working hard to make sure your friend has the BTC they say they do and to record the transaction details.
Hashes help these computers to verify, share, and store all of your transaction information, without sharing your personal details. At a basic level, the process looks like this:
Your friend (well, technically your friend’s computer) uses a hash to “sign” the transaction before sending it to you. Your friend tells their computer to tell the other computers on the network: “Hey, I’m going to send 1 BTC to my friend. And here’s a code that you can use to verify I have the BTC I say I do.”
That code is a hash. It points to where the BTC is stored on the network and proves that BTC belongs to your friend. The computers then start solving a puzzle (or hashing) to confirm what your friend’s computer says is true. Once enough computers confirm the transaction, the transaction details are stored in the form of a hash so every computer that’s on the network can see the transaction happened.
This transaction hash is stored in something called a “block”. For now, think of a block as a collection of ~2,000 transactions. A valid block means that all the transactions it contains are legitimate (just like the transaction between you and your friend). The block hash is all those transaction hashes rolled up into a single hash that contains information on all the single transactions.
Block Hashes, Hash Rate & Total Hash Rate
Remember in the puzzle competition, how teams race to complete the puzzle first? Computers on the bitcoin network do the same thing. But instead of solving a puzzle, they race to be the first to complete a valid block. And instead of getting a point for being the first, they get BTCs.
In order to win, the computers race against each other to find the solution, or hash, to a really hard math problem. They do this by trying a bunch of combinations until they find the one that works. It’s kind of like trying a bunch of different puzzle pieces until you find the one that fits.
Hash rate is how many combinations the computer can try in a giving period of time, usually measured in seconds. Some computers can try trillions of combinations per second!
Total hash rate, then, is the sum of all hash rates for each computer on the network. Usually, the higher the total hash rate, the more secure the network because that means there are more computers dedicated to confirming the validity of transactions on the network.
A hash is the solution to a specific type of puzzle, called a hash algorithm. A hash algorithm takes any input and produces an output, called a hash, that is always the same size. The same inputs will always produce the same output, but the inputs can never be determined from the inputs.
In cryptocurrency networks, computers track, validate, and share transaction information using hashes. Validated transactions hashed are stored in blocks that contain the network’s entire transaction history. A block hash is a single hash that contains information about each transaction stored in that block.
Computers in the cryptocurrency network race against one another to validate transactions and solve a math problem in order to create the next valid block, and collect a reward. Hash rate refers to how many solutions the computer can try in a given period of time (usually measured in seconds).
Total hash rate is the sum of all hash rates for each computer in the network. Generally, the higher a network’s total hash rate, the more secure the network because that means there are more computers dedicated to confirming the validity of transactions on the network.