Hashing is one of the most crucial pieces of technology that keeps the Bitcoin network secure. But how does it work?
A hash function takes a piece of data and turns it into a string of numbers and letters. The key points are:
A piece of data will always produce the same output. It is near impossible to reverse the transaction and find the original piece of data.
This means hash functions can be used to determine that someone owns a piece of data without them revealing what it is. In a way, like a digital key.
A hash function takes a piece of data and scrambles it in such a complicated way that it becomes practically difficult to reverse.
Hashing turns the piece of data into binary code, just numbers and zeros. Then it breaks up the numbers into sections and repeatedly applies a computation function. The end result is typically a 64-digit string of numbers and letters.
When trying to reverse it, it creates an exponentially increasing number of options. It’s a bit like trying to navigate a path through a kaleidoscope. This means that, for a computer to hack it, it would need to be able to compute many more calculations than required to create the hash in the first place.
Did you know?
A computer capable of running 15 trillion calculations per second would take almost 0.65 billion billion years to crack the hash of a single Bitcoin address.
It has a couple of main uses:
For Bitcoin transactions to work, a transaction needs to be signed in a way that is publicly accessible without revealing the signature–otherwise it could be duplicated.
Public/private key cryptography achieves this by using the private key to generate a public key which signs the transaction. This means somebody who doesn’t have the private can’t generate the public key to sign it.
A private key is used to generate a public key. The private key is multiplied using an elliptic curve to produce a public key which is then goes through two hash functions.
So, someone can’t make a Bitcoin transaction without breaking two hash functions and elliptic curve cryptography. This is why Bitcoin itself can’t be hacked.
Read more about hacking blockchain.
“I want to mine the next Bitcoin block.” Wait in line, kid.
In order to keep the network running fairly, Bitcoin has a fair playing ground for participants to earn themselves the right to create the next block. It uses a computational race that starts again every time a block is published.
To win the race, each miner collects a set of transactions, includes a reference to the previous block and uses this as a piece of data to put into a hash function. To win the race, the hash function that results must start with a certain number of zeros depending on the current difficulty of the network. The higher the zeros, the harder it is.
Did you know?
In October, 2018, the Bitcoin hashrate was 50 Exa hashes per second. This makes the network 15 million times more powerful than the world’s fastest supercomputer, the tianhe-2.
If blocks in a blockchain weren’t linked, it would be easy to insert a fake one. Bitcoin avoids this by linking each block to the previous block. It does so by using a hash pointer.
A hash pointer is the result worked out from hashing the previous block in the chain. This means that anyone can check that the transactions in the block follow on from the previous one. This actually allows miners to ensure the whole chain is legitimate and that not a single block has been added by a malicious miner.
This also means that every coin’s history can be traced back to when it was mined.
Did you know?
In 2013, the Bitcoin blockchain accidentally split in two because some miners hadn’t upgraded their software. During this time, double spends were possible.
Nothing is computing is unhackable but hashing comes pretty close. Right now, it would take millions or billions of years to hack a hash function. The worry for the future is quantum computing. In theory this could break the hash functions used by Bitcoin, exposing it. Will developers manage to secure the network to prevent this? We can only hope.