28th Jan 2022

A Billion-Dollar Math Problem: Reversal of SHA-256

Blockchain, Mean

Written By, Shrey Banugaria

Have you heard of a mathematical problem that will result in billions of dollars to solve? A computer algorithm that is one of the strongest hash functions, having implications in cryptocurrency and bitcoin mining. It would require so much computing power and brilliant brains that billions of dollars are in play. 

About the hash

A Hash function takes a bunch of characters and maps it into another string which we say “Hash value”. They are used in the encryption of digital signatures, retrieving items from the database quickly and more. SHA-256 is a cryptographic hash that generates a unique 256 bits output, resembling its name. Developed by NSA (National Security Agency — USA), SHA-256 is a part of the SHA-2 Cryptographic hash function. Its predecessor, SHA-1 was a widely acclaimed encryption algorithm but became deprecated against brute-force attacks. SSL certificate industry transitioned to SHA-256 and thus how it became the standard. But what makes it complex?

Working of Hash, SHA-256

SHA-256 is a one-way hash factor. A hash generated from data, cannot be reversed to get the data back. It is so secure that a slight change in the input value results in a completely different output. It is a deterministic one-way algorithm, as the same input generates the same output. SHA-256 returns a hexadecimal expression, 64 hexadecimal output is generated for any length of the input string. One-way hash functions are hard to do backwards (that’s what one-way means) so, let’s take an input of 50 and add 50 to it. You can reverse 100(output) to 50 again, easy? Well, not exactly. SHA-256 returns 256 1s and 0s.

Here is an example:

Input: This is an example
Output: 47FB563CC8F86DC37C86D08BC542968F7986ACD81C97BF76DB7AD744407FE117

Input: this is an example
Output: D44C035835F1C5E0668B7D186A2FF5B0DC2E3137EC3C50B12A34C47B7AF51E44As you can see, a slight change in the case changes the whole output. But no matter the size it will return 64 characters.

Input: This is a hash demo
Output: C7B9D2001E2AA2FE2100F6C2DC5CFAF8006C027DFD58655FA9FAD9C0D1A03296

Input: I hope this is interesting for you to read and explore
Output: C7B9D2001E2AA2FE2100F6C2DC5CFAF8006C027DFD58655FA9FAD9C0D1A03296

The fun part is, the input can be of any form/type. Images, Videos, Text, Numbers, etc of any length. 

Step-by-step hashing

  1. Pre-Processing
  2. Hash Values
    –  Create 8 hash values
  3. Initialize constants
    – 64 constants each of value (0–63), they are the first 32 bits of the fractional part.
  4. Loop in chunks
    –  For larger data, the loop will be iterating in chunks, mutating hash values.
  5. Divide
    – Copy in an array
    – Add 48 more words initialized with 0s
    – Modify 0ed indexes ( through predefined formulas)
  6. Compress
  7. Modify the result
    – Adding to modulo 2³²
  8. Concatenate

To keep it understandable I have skipped several substeps. Phew! It’s a lengthy and complex process. With all that is mentioned above, what is generated is a digital fingerprint of the input file. But all of these for what? Let’s check.

Is the hash Secure enough?

For any output, there are 2²⁵⁶ possible combinations that match your input string. That’s something 115 quattuorvigintillion and some Tresvigintillion…. and terms we never heard of, putting billions and trillions to shame. That’s a lot of calculations and a ton of computing power. So breaking into a password that is hashed with SHA-265 would require a computational power more than what we have currently, worldwide. For an input key, a  number generated has a possibility that it has never appeared to a human eye. 

Why are the billions of dollars into play?

No one has found a solution to revert the output, yet. But if you can, you can mine bitcoins faster than anyone. You need to reverse the SHA-256 output containing 10s of zeros at the beginning to mine bitcoins. As of now, we don’t have any formula or method to crack it down. We rely on the Brut-force attacks. Trying different inputs until you get something that works. For bitcoins only a smaller part of the string is to be matched so, it works. If so is the case with you it can make you a billionaire in no time, and if your algorithm works, you will be earning billions every 10 minutes.

It takes 2.7 Quadrillion hashes to generate a BTC and every second bitcoin miners are running 60 quintillion hashes. Reversal of SHA-256 is just one brilliant solution and a few high processing GPUs away. Wanna try your luck?

Let’s discuss more here: Shrey Banugaria or mail @Shrey Banugariya 

Written By,

MEAN Developer at Yudiz Solutions Pvt. Ltd