What is a Hash?
(And I'm not talking about potatoes)
I'm talking about a cryptographic hash that is Bitcoin's bread and butter.
What’s a Bitcoin hash?
Read on to clear up any uncertainty and see why hashing is like baking➡️
If you mine Bitcoin, the term “hash’ is everywhere.
Hashrate, hashprice, TH/s, etc.
There was even Hashcash, which inspired the creation of Bitcoin.
Hash is important because it describes machine efficiency, profitability, and network security.
You have likely heard the surface-level explanation of a hash as a "complex computer guess at a particular combination."
That is a rudimentary truth, but there is more to it than that.
Bitcoin uses hashing to generate addresses, provide proof-of-work, and sign transactions.
If you believe Bitcoin will change money as we know it, understanding how these work will increase your confidence as a network participant.
The Brass-Tacks:
Satoshi was a hash and cryptography fanatic.
A "hash" is the output of a "hash function".
It is a mathematical function like y=mx+b in 8th grade, except far more useful and interesting.
Baking a cake is a basic analogy:
The input is flour, sugar, eggs, etc.
The function is the physical transformation of the ingredients (mixing, baking, etc.)
The output is the finished cake.
The big idea here is an input that passes through the hash function and produces an output.
The input could be any message; the output is the hash of the message:
What makes a hash function "cryptographic"?
1) Has to be computationally capable of converting input to a hash output
2) Has to be computationally infeasible to guess the message from output hash.
3) Input must determine hash output. "hello" will always return the same output hash.
4) Each hash is unique. "helloo" will be an entirely different hash output.
5) Should be computationally infeasible to find 2 message inputs that produce the same hash output.
For context:
Bitcoin hashing uses SHA-256 (secure hash algorithm - 256 bits):
SHA-256 is not just used in Bitcoin; it is a global cybersecurity standard.
Proof-of-work is one example of how a miner uses hashing.
It is the proof a miner provides to show they successfully completed the work to find a block.
This is done by taking a hash of the block header, which contains information about the software version, a time stamp, and the previous block’s winning hash.
This is also what makes Bitcoin transactions a "chain”; each block of transactions is connected to the previous. This prevents the transaction history from changing (double spending). If a previous block is altered, so is the hash and the hash of all the blocks coming after.
Side note, when you see a mining machine has 200 TH/s, this is 1 trillion hashes/second, or 1 trillion input attempts.
The longest chain is always the truth because it contains the most proof-of-work.
Remember, for a hash to be cryptographic, it should be impossible to determine the input based on the hash output.
The most efficient way would be to guess and check.
Which would be insane because it would be a needle hash in a stack of 2^256 hashes.
Now you know what the nitty-gritty of a hash.
Hashing is one of the many brilliant technical features helping Bitcoin secure over $1T of value today.
Hashrate is considered a network security metric because it shows how many hashes are being expended to keep Bitcoin running.