What is hash?

A fixed-length string produced by running data through a one-way function, used to identify blocks and transactions.

Not yet verifiedHow we verify

3 min read

In this entry

A fixed-length string produced by running data through a one-way function, used to identify blocks and transactions.

Changing any part of the input produces an entirely different hash, which is what links blocks together and makes tampering detectable. proof of work mining consists of searching for a hash below a target value.

You see hashes constantly without thinking about them: the long hexadecimal string a wallet shows after you send funds, the identifier you paste into a block explorer, the address a contract deploys to. All of them are outputs of the same kind of function. The common confusion is thinking a hash is encryption. Encryption is reversible with a key. A hash is not reversible at all, which is exactly why it is useful.

How it works

A cryptographic hash function takes input of any length and returns a fixed-length output. Bitcoin uses SHA-256, published by the National Institute of Standards and Technology in the Secure Hash Standard, which returns 256 bits shown as 64 hexadecimal characters. Ethereum uses Keccak-256, the same output length with a different construction.

Three properties make the function useful for a blockchain. It is deterministic, so the same input always gives the same output and anyone can recompute it. It is one way, so the output reveals nothing practical about the input. And it is collision resistant, so finding two inputs with the same output is infeasible.

Blocks chain together because each block header contains the hash of the previous header. Change one transaction in an old block and its hash changes, which changes the next block's header, and so on to the tip. That is why rewriting history requires redoing every block after the one you altered. Inside a block, transactions are summarized by a Merkle tree, so a single root hash commits to all of them and a short proof can show that one transaction is included without transmitting the rest.

Mining is a search over this function. A miner varies a nonce in the header and rehashes until the output falls below the current target, which cannot be shortcut and can only be attempted repeatedly.

Example

Illustrative arithmetic. A SHA-256 output is 256 bits, so there are 2 to the power of 256 possible results, a number with 78 digits. Suppose a network's target requires the first 76 bits of the hash to be zero. Roughly one attempt in 2 to the power of 76 succeeds, which is about 75 million billion billion attempts on average. A machine trying 100 trillion hashes per second would need hundreds of years alone. Millions of such machines together find one every ten minutes. That is the whole of proof of work in one calculation.

Why it matters when you buy

Every withdrawal you make from an exchange produces a transaction hash, and that string is your evidence: paste it into a block explorer to see whether the network has the transaction and how many confirmations it has. Support conversations about a missing deposit start with it. The block explorer guide shows what to look for, and the chain pages list how long confirmations typically take on each network.

Questions

Can a hash be reversed to recover the original data?

No. The function discards information by design, and the only general attack is guessing inputs and checking. For an input with enough randomness, that is infeasible.

Why is my transaction hash not found on the explorer?

Usually because the transaction has been created but not yet broadcast or accepted, or because you are searching an explorer for a different network. Check the chain first.

Are two files with the same hash always identical?

For a sound function, finding two different inputs with the same output is infeasible, so in practice a matching hash means matching data. That is why hashes are used to verify downloads.

Guides that use this term

  • How to Use a Block Explorer to Check a Transaction

    A block explorer is a public search engine for a blockchain, and you check a transaction by pasting its hash into the search box and reading three fields: the status, the number of confirmations, and the receiving address.