Still confused about SHA-256?

Valarhash
Valarhash
Published in
5 min readMar 17, 2020

March 16, 2020 | A primer on the puzzle all of our ASICs are trying to solve every second.

Bitcoin mining is not easy. Nor is mining for other altcoins. It takes time, effort, and a lot of head banging to figure out how to configure all the tangible and intangible intricacies that are needed. In the early Bitcoin days, there were hardly any tutorials online that could help usher in the introduction of how to mine Bitcoin. Early miners basically had to figure out the convoluted web of Bitcoin’s open source code with their own CPU in determining how to start generating hashes. As GPUs and FPGAs came aboard, things got a lot more confusing and expensive. Considering that most of the early Bitcoiners had, for the most part, some basic computer prowess, they too were even baffled by the complexity of it, let alone trying to have an average person understand it.

Actually when ASICs came along, setting up this new state-of-the-art mining machine was rather simple. Just simply unpack it from the box, plug in a few plugs, and connect your mining pool’s IP address, done. But what was difficult is now setting up these individual miners, but more so how to set up a mining farm consisting of dozens of these machines. That is where things got complicated with having to deal with electricity sources, noise control, HVAC, and so forth.

What exactly is a miner doing??

Most people in the crypto space understand these generalities of mining, but what is sad is that most people in the crypto space don’t really understand SHA-256, which is the crux of what makes Bitcoin secure and decentralized. In this article, we will give you a basic breakdown of this complex number crunching algorithm and hopefully it will give you a better understand of what exactly are mining rigs doing that make them suck up tons of energy and power.

Introduction to Hashing Algorithms

Hashing algorithms are used to secure messages over the internet through an algorithm that essentially shuffles your message around in different numbers and in a different order but with the same fixed size output. Think of it like taking a sentence, rearranging its orders, putting it through a coding sequence such as binary numbers, scrambling it around some more, and spitting out a fixed length of an alphanumeric number.

A quick example of taking a random sentence and putting it through a cryptographic hash function to output a string of letters and numbers that look basically random, but are not.

A good hash function should have the following properties:

  1. Efficiently computable.
  2. Should uniformly distribute the keys

Hashing algorithms are used in all sorts of ways — they are used for storing passwords, in computer vison, digital signatures, in databases, etc. The NSA of the USA came out with SHA-1 which is a more mathematically complex hashing algorithm used for at least a decade when it was exposed to have been compromised. Global SSL/TSL certificates used this standard for years until recently a new SHA, which stands for Secure Hashing Algorithm, was introduced as SHA-256.

Bitcoin’s SHA-256

SHA-256, one could say, is a more advanced and complicated number hashing function. It is not mathematically hard per se, but just more complicated with a longer process of reshuffling data around. Actually, one could perform the SHA-256 algorithm by pencil and paper, but one round of that algorithm takes about 15 minutes as seen here. And if you realize that one round of that algorithm takes 15 minutes, and each hash comprises 130 rounds of that algorithm, and currently right now most advanced ASIC miners are generating about 50,000,000,000,000 to 80,000,000,000,000 hashes/second, you realize the sheer computing power these machines are using every second and why they need to be specially placed in cooled areas to prevent overheating. Just imagine if you were doing these calculations in your head all day, one would probably be brain dead, figuratively speaking, real quick.

To put this into context of what mining ASICs are doing, each machine is literally trying to guess a nonce, that when ran through the SHA-256 algorithm, is equal to or less than the difficulty given for each block. So in a way, they are all racing to guess that certain number in a certain amount of time against each other.

There are four characteristics of Bitcoin’s SHA 256:

  1. Deterministic — for any input into the cryptographic hash function, the resulting output will always be the same.
  2. Fast — Computing the output of the hash function, given any input, is a relatively fast process (doesn’t need heavy computation)
  3. Unique — Every input into the function should result in a completely random and unique output (in other words, no two inputs result in the same output)
  4. Irreversible — Given an output of a hash function, the original input is unable to be obtained

Conclusion

With 2²⁵⁶ possible hash outputs, SHA-256 is one of the world’s most secure hashing functions out there. It is almost impossible to reconstruct the initial data from the hash value. A brute-force attack would need to make 2²⁵⁶ attempts to generate the initial data. That number is so large that it makes numbers in the trillions look minuscule.

This brief overview was a quick and dirty way of describing SHA-256. There are a lot of videos and articles describing it in way more detail than this that you should definitely check out sometime if you want to venture more down into that rabbit hole. But essentially, ASIC miners are just running data through the SHA-256 algorithm as fast as they can to see if they can hit or come close to the target number specified.

Sources

  1. https://www.thesslstore.com/blog/difference-sha-1-sha-2-sha-256-hash-algorithms/
  2. https://www.freecodecamp.org/news/how-bitcoin-mining-really-works-38563ec38c87/

--

--

Valarhash
Valarhash

A Blog Dedicated to Teaching the Community on the Quintessential Importance of Crypto Mining.