How Does Bitcoin Hash Works?

How Does Bitcoin Hash Works?

in Bitcoin, Cryptocurrency, Blockchain, Know-it-all
If you have used cryptocurrencies and wallets for a while, you have certainly noticed that a thing called hashing is a part of the process. Why should you know about hashing? Firstly, to protect your own funds. But also, a brief discussion of the work of generating and testing hashes is a good counter-argument to being told that "cryptocurrencies are money out of thin air." You can make the argument that cryptocurrencies are backed by mathematics. Calculating a new block on the blockchain involves hashing. Producing a wallet private key also uses a form of hashing. But what exactly is this process? In the abstract, a hash function is a mathematical process that takes input data of any size, performs an operation on it, and returns output data of a fixed size. In a more concrete example, this can be used to take a sequence of letters of any length as input – what we call a string – and return a sequence of letters of a fixed length. Whether the input string is a single letter, a word, a sentence, or an entire novel, the output – called the digest – will always be the same length. A common use of this kind of hash function is to store passwords. When you create a user account with a web service which requires a password, the password is run through a hash function, and the hash digest of the message is stored. When you type in your password to log in, the same hash function is run on the word you've entered, and the server checks whether the result matches the stored digest. This means that if a hacker is able to access the database containing the stored hashes, they will not be able to immediately compromise all user accounts because there is no easy way to find the password which produced any given hash. In other words, a hash is the cryptographic byproduct of a hash algorithm. The hash algorithm has certain unique properties:
  • It produces a unique output (or hash).
  • It is a one-way function.
The mathematics behind the hash algorithm ensures that there is no way to generate the original data from its generated hash. This means the hash only functions in a linear progression. A simple analogy would be that you can’t produce a real human thumb from a thumbprint. This is why a hash can be treated as a “digital fingerprint” of the data processed through the hash function. To logically conclude, the same hash will only be generated from the same input data. But if you modify the data with something minuscule, like a single space or a comma, it will completely change the hash output. Here is how a string looks when hashed under the SHA-256 algorithm, used in Bitcoin and others. As you can see, a small difference in input leads to a large difference in the digest or hash:   TestString 6dd79f2770a0bb38073b814a5ff000647b37be5abbde71ec9176c6ce0cb32a27 TestString1 230b94a79b35a026063a4b87469b4c42836e1c30ca13d5dc4ab42563a4d13b72   The biggest challenge for hash functions is to avoid the case of collision, where two information inputs have the same digests. This is an astronomically rare event, especially with a well-designed and time-tested hash function. So what is the input that produces the number (or hash) for the next block in a blockchain? The input takes a bit of information from every transaction and adds another number coming from the miner- the nonce. But just hashing the information is not enough- the number must satisfy a certain condition. So all of the information is hashed again and again, with a different nonce and tested against a target number. This is yet another definition of mining- the generation of potential hashes with a different nonce.
cryptocurrency
You can see that the hash begins with many zero characters- this is to comply with the target. The greater the difficulty, the more zero characters. The hash displayed has the right number of zeros and is smaller than the target number, so it is accepted as a block header. And the miner who discovered it got the block reward of 25 Bitcoin. Hash functions create what is called "an avalanche effect," so a small change in the input information leads to a very different digest or hash. When calculating the next block for any of the existing blockchains, what happens is that up to a trillion hashes are generated every second and checked for fulfilling a certain condition. In a way, this works like a lottery, since every hash is wildly different from the previous one, and may become "the winning number".  

What Is Hash Rate Or Hash Power?

Hash Rate, also Hash Power, is the measuring unit that measures how much power Bitcoin network is consuming to be continuously functional. By continuously functional is how much hash power is it consuming to generate/find blocks at the normal mean time of 10 minutes. Bitcoin network consumes a lot of energy because it has to solve mathematical intensive computations regularly to find the blocks. These computations for finding the blocks are basically mathematical puzzles that a miner cannot just guess without a lot of computation. To successfully mine a block, a miner needs to hash the block’s header in such a way that it is less than or equal to the “target.” The target, at the time of writing this article, is that the SHA-256 hash of a block’s header must be a 256-bit alphanumeric string, and must start with 18 zeros. The target changes as the difficulty change every 2016 blocks. And the miners arrive at this particular hash (or target) by varying a small portion of the block’s headers, which is called a “nonce.” A nonce always starts with “0” and is incremented every time for obtaining the required hash (or target). Since the varying of the nonce is hit and miss, the chances of getting this particular hash (or target), which starts with these many zeros, is very low. Therefore, many attempts must be made by a miner by varying the nonce. And this number of attempts made per second is called hash rate or hash power. And this requires an enormous amount of computational power and hardware resources which proves that a large amount of work is carried out before mining any individual block. That’s why this is called “proof-of-work“. So, this hash power or guessing attempts are made by miners who mine the Bitcoin blocks by a process called Bitcoin mining. And in this way, whichever miner first obtains the correct Bitcoin Hash will win the lottery and get the block reward of 12.5 BTC.  

How Is The Hash Rate Measured & its Unit?

Hash rate is a unit measured in hashes per second or [h/s] and here are some usual denominations used to refer it.

Hash rate denominations

1 kH/s is 1,000 (one thousand) hashes per second 1 MH/s is 1,000,000 (one million) hashes per second. 1 GH/s is 1,000,000,000 (one billion) hashes per second. 1 TH/s is 1,000,000,000,000 (one trillion) hashes per second. 1 PH/s is 1,000,000,000,000,000 (one quadrillion) hashes per second. 1 EH/s is 1,000,000,000,000,000,000 (one quintillion) hashes per second.

Common Hash rate Conversions

1 MH/s = 1,000 kH/s 1 GH/s = 1,000 MH/s = 1,000,000 kH/s 1 TH/s = 1,000 GH/s = 1,000,000 MH/s = 1,000,000,000 kH/s and so forth  

Follow us on Facebook


Facebook Comment
How To Read Trading Charts For Beginners

January 17, 2018

How To Read Trading Charts For Beginners Read more