Difficulty and Hashing on the Blockchain

What is Bitcoin Mining Difficulty?

Difficulty is an inherent property of a blockchain network. It is used to measure how hard it is to find a hash that will meet the current target. The network will adjust the difficulty so that a hash is found every 10 minutes. The difficulty of the network can be measured in hashes per second.

If the hash is not found, it will be decreased by the network and the process will continue. The difficulty of the network is adjusted every 2016 blocks.

The difficulty is an important aspect of the network because it determines how much power is required to mine a block. If the difficulty is high, it takes longer to find a hash that meets the target (in order to be accepted). If the difficulty is is low, then it’s easier to find the hash that will win the block.

Some people argue that all this hashing is simply using burning up electricity, and generating heat, in an already warming climate. I can understand that the concern is about “real physical harm” being caused for “imaginary money benefit”, but this argument also applies to paper money, which is also imaginary, in a sense. Billions of dollars are printed onto fabric, and swimming pools full of special expensive inks are sloshed onto bills. All of that shipping and printing machinery and lighting also requires electricity. However, because absolutely everyone has (at least a few times in their life) used cash, and so as a result, to most people, it seems like a “necessary” cost, compared to the relatively smaller environmental cost of mining bitcoin. Further to this, miners actually greatly prefer renewable sources of electricity such as solar or geothermal, because they don’t have to pay for it: It makes business sense as well as environmental sense.

The benefits to society already are substantial. It takes a lot of power to run the entire financial system. Mining is a way to “outsource” that to a decentralized system, distributing the load, rather than having it all in a few locations.

What is a Hash?

There are a few different ways to compute a hash. The most common is to use the SHA256 hash function. This is a cryptographic hash function that produces a 256-bit hash. SHA256 is designed to be feasibly impossible to reverse. That means it is very hard to find two inputs that hash to the same output.

In this case, the input is the block data, and the output is the hash. A hash will always be the same length, which is usually smaller than the data it is hashing. If the block data was several megabytes, then the hash will be smaller, simply the same length every time. The block hash is a representation of the data in the block.

The block hash is not the same as the transaction hash. A block can contain multiple transactions, but a transaction will only have one hash.

If you are wondering why the hash must be smaller than the data, think about how a hash is made. A hash function is a one-way function that takes an input and returns an output. Data is not returned as part of the output, so information must be lost. In essence, the hash function is like a super-secure checksum. It can be used to detect errors in data. If you start with a certain amount of data, and change it to other data, the hash will change. Blockchain relies on this fact to keep everything secure.

If we are given the block data and want to determine the hash, we would feed the data into the hash function and get back a unique string of 256 bits. This is called hashing the data. We then compare this hash to the target. If the hash is less than the target, we have found a valid block hash.

The target is just a random number that is stored on the network. It is set when the network starts. Every time a new block is mined, the target is increased to ensure that a block is found every 10 minutes. The network can adjust the difficulty of the hash via the target.

In Bitcoin’s case, the target is a 256-bit number. It is an extremely large number that requires a lot of power to calculate. The more power you have, the higher the chance you have of finding the hash.

Bitcoin Mining Hardware

The main hardware used in mining is the application-specific integrated circuit (ASIC) which is a piece of hardware designed for Bitcoin mining. The ASIC is designed specifically to do the hashing required for Bitcoin mining. A normal computer is not powerful enough (in this narrow domain) to compete with an ASIC. However, an ASIC cannot perform even the most basic functions that a normal computer can perform.

ASICs are extremely powerful and efficient at the task they are designed for, only. They are very expensive, and can cost thousands of dollars. A normal computer system is not able to compete with ASICs because it will take a very long time to find the hash, even with free electricity. In the early days of bitcoin mining, moving from a normal computer to an ASIC was like putting on a weight lifting belt. You just feel so much more powerful.

ASICs have a lot of hash power. Currently, the best ASIC miners are able to mine about 5 TH/s. That is 5 trillion hashes per second. The Bitcoin network is designed to generate 1 block every 10 minutes, so that means the network is over 500 trillion hashes per second.

The advantage to having so much power is that you are very likely to find the hash first. Then you will be able to add the block to the block chain before anyone else does. You will get the reward for finding the block.

What is the Block Reward?

When a block is found, a fixed amount of bitcoin is created. The reward for mining is the bitcoin. The reward is given to the block’s miner. The amount of bitcoin the miner is rewarded is the block reward. The block reward was huge in the early days, but decreases over time.

The block reward was 50 bitcoin when Bitcoin was first released, which seems like a huge amount of money now, but back then, it was worth nothing. The block reward is halved every 210,000 blocks. This is called “halving the block reward”. This will continue until 21 million bitcoin have been mined.

Why Do We Use Proof of Work?

Proof of work is the main way that Bitcoin secures the block chain. Proof of work is the cryptographic hash function that miners use to find the hash. Proof of work ensures that a miner must do some work to find the hash. This is what secures the network.

Proof of work is very hard to calculate, but easy to verify. That means that it is easy to check if someone has done the work, but very hard to come up with the answer without actually doing the work.┬áThis is one of the few important properties pf the mathematics that make Bitcoin’s proof of work so useful.

Alright, that is enough theory on the inner workings of blockchain for this article, thank you for reading!