fbpx

Crypto in an Hour: Part 9 – Hash Function

by | Dec 10, 2019

You know that Bitcoin encrypts the data from all the transactions in order to keep the information safe as well as immutable, but how does that encryption work? You might think the answer is too technical for you, but for the most part, it’s fairly simple. There are four parts to the encryption that I’ll go over with you in the next few lessons: the hash function, the Merkel Tree, the difficulty target, and the nonce. Understanding these four parts of the Bitcoin encryption process will allow you to understand how Bitcoin works. Let’s start with the first one on the list, the hash function.

The hash function is an algorithm that converts an input into a different output, like a code. It encrypts information in a way that anybody can trust that it has been encrypted.

For the hashing function to be trusted, it requires several attributes:

  1. The output of the hash function must be able to hide the original information.
  2. The output should look random.
  3. Because no one knows how many transactions are going to take place in any given ten-minute period, the input of the hash function must allow for an arbitrary amount of information while always providing an output of fixed length. For Bitcoin, the hash function is called SHA256, and the output is always 256 characters long.
  4. Running the hash function should be computationally efficient. In other words, running it shouldn’t take a lot of time.
  5. Extrapolating the original information from the hash should be so difficult as to be infeasible.
  6. The output should be deterministic. This means that the same input always produces the same output.
  7. A slight change to the input should produce a completely different output.
  8. The outputs of two different inputs should never be the same.

The Bitcoin hash function ensures that all eight of these requirements are met, so you or anybody else can trust that the information in the block is safe and secure. The result of that encryption is usually referred to as the hash. The important thing to remember is that the hash function is an algorithm that encodes the information of the block. In the next lesson, we’ll go over how all the information gets packaged together into the block.