How Hashes Work In Bitcoin

Joaquin Monterrosa
BlockBrain
Published in
3 min readFeb 24, 2020

Most people watching “How Bitcoin Works” videos on YouTube can grasp at least a basic understanding of what’s happening…until the word “hashing” is mentioned, when there is often an abrupt end to all comprehension. This article is intended to bestow knowledge about the specifics of hashing and hashing’s role within the blockchain, so the next time you view that YouTube video you’ll make it over the enormous speed bump that is “hashing”.

What Is The Purpose of Hashing

Simplistically, the purpose of hashing is to render a special nickname to some amount of data. I like to think that a hash is to data what a pen name is to an author. An author may not want to reveal his or her true identity and therefore hides behind the shadow of a pen name. In a similar way, a programmer might not want to see certain data she needs to use. This is very common with sensitive data like passwords and phone numbers. Programmers may need to store and use phone numbers in their database, but they aren’t allowed to see other people’s phone numbers. This is where hashing comes in. The programmer could hash that phone number, get a nickname for the data and then be able to store and use that nickname all they want without knowing the true data that lies behind it.

How Does Hashing Work

A hashing algorithm takes an input, changes it, and creates an output that can’t be reverse-engineered back to its original input.

A simple hashing algorithm could be used on your phone number. Suppose your phone number is 553–7537. A simple hashing algorithm could calculate the sum of those numbers. The hash of that number would be 5+5+3+7+5+3+7 = 35. The input is 553–7537, and the hashed output is 35. It is nearly impossible that another person could reverse-engineer that 35 back to the number 553–7537.

While this example of hashing is conducive for understanding, it is much too simple. In the real world, the standard hashing algorithm is called SHA256. This algorithm was designed by the NSA and is incredibly powerful; unbreakable even by a quantum computer. This algorithm generates an almost-unique, fixed-size 256-bit (32-byte) hash. Some advantages of using SHA256 hashes include:

  • No matter how large or small your data set, the hashed output is always 256-bits.
  • You can’t play the hot and cold game to reverse-engineer the hashed output by getting closer and closer to the input hash you seek.
  • The number of possible combinations of letters and numbers produced by SHA 256 exceeds the number of grains of sand on Earth.
  • It’s a standard that many programs use.

What Is The Role of Hashing in Bitcoin

Hashing plays many roles within bitcoin, but, most importantly, hashing is the mechanism that chains blocks together.

To understand how hashing chains blocks (groups of transactions) together, you must first understand that Each block is characterized by standard information, including the previous block’s hash. All the information (or data) is then hashed by SHA256 to form one, fixed, 256-bit code for each block. This means that block 126’s hash contains information about block 125’s hash. Suppose someone changes data within block 125. This alteration will inevitably change block 125’s hash, and will break the blockchain because the previous block 125 hash value stored within block 126 had will now be different than block 125’s new hash. The resulting broken blockchain will not be considered legitimate by the blockchain network anymore.

--

--