Cryptographic Hash
- Category
- Blockchain
- Level
- Professional
Simple definition
A function that turns any data into a fixed-length fingerprint. The same input always gives the same fingerprint, and the fingerprint cannot be turned back into the data.
Professional definition
A deterministic one-way function mapping input of any length to a fixed-length digest, built so that finding an input for a given digest, a second input matching a known one, or any colliding pair, is computationally infeasible. It has no key and is not encryption: there is nothing to decrypt.
Technical definition
Three properties are distinct and must be stated separately. Preimage resistance: given a digest, finding any input producing it is infeasible. Second-preimage resistance: given one input, finding a different input with the same digest is infeasible. Collision resistance: finding any two distinct inputs sharing a digest is infeasible, and it is the weakest of the three, because the birthday bound halves effective security. SHA-256, standardised in FIPS 180-4, emits 256 bits regardless of input size.
Academic definition
A deterministic map from arbitrary-length strings to fixed-length digests for which preimage, second-preimage and collision finding are computationally infeasible, and which, being keyless, is not a cipher.
Mechanism
The useful behaviour is avalanche: one flipped input bit rewrites the entire digest unpredictably, so a digest both names data and detects any change to it. Chains lean on this twice — to link blocks, where a rewritten past breaks every later header, and to price mining, where an unpredictable digest leaves brute-force search as the only strategy.
In practice
- Who uses it
- Protocol implementers, wallet and signing-library authors, auditors checking file or state integrity, and analysts matching transaction identifiers.
- Why it matters
- It compresses data of any size into a short, comparable commitment, which is what makes block linking, Merkle proofs and proof-of-work scoring possible at all.
- Limitations
- A digest shows data is unchanged, not that it is authentic or authorised. Anyone can hash anything, and low-entropy inputs such as short passwords can simply be guessed.
Common mistakes
- Calling hashing encryption, or expecting to recover the input from a digest.
- Trusting a digest alone as proof of who produced a file.
- Reading collision resistance as a guarantee rather than a computational assumption.
Examples
A publisher prints the digest of a software release. Anyone who downloads the file can hash it and compare. A match proves the bytes are unchanged; it proves nothing about who built them.
For a 256-bit digest, a generic preimage search costs about 2^256 attempts, while a birthday collision search costs about 2^128. Collision resistance is therefore the binding constraint when a protocol chooses a digest length.
- digest length n = 256 bits
- no structural weakness, generic attacks only
- preimage work ~ 2^n = 2^256
- collision work ~ 2^(n/2) = 2^128
These are generic bounds against an idealised function. A break in the specific function can lower them, which is why standards are retired before they fail.
Mathematical foundation
Variables
| n | Digest length in bits | bits |
| W_{pre} | Expected work for a generic preimage search | hash operations |
| W_{coll} | Expected work for a generic birthday collision search | hash operations |
Procedure
Read the digest length in bits. Generic preimage search scales with two to that power; generic collision search scales with two to half that power, because random digests begin to repeat after roughly the square root of the output space.
Worked example
- n = 256 (SHA-256)
- W_pre ~ 2^256
- W_coll ~ 2^(256/2) = 2^128
Interpretation
The halving is why a 256-bit digest is described as offering 128-bit collision security. It sets the design margin; it does not promise any specific function will hold.
Assumptions
- Generic attacks only: the function is modelled as an ideal random function with no exploitable structure.
- Work is counted in hash evaluations and ignores memory and parallelism costs, which matter in practice for collision search.
- These are not proofs of security. They are the best generic attacks known; a structural break lowers the real cost, as the history of earlier hash standards shows.
- The bounds say nothing about resistance to brute-forcing low-entropy inputs, which no digest length can fix.
Related terminology
Public-Key Cryptography
Hashing is keyless and one-way: nothing is hidden for later recovery. Public-key cryptography uses keys and is reversible in the specific sense that a signature can be verified or a ciphertext decrypted.
Sources
NIST · SHA-256 specification and digest lengths
https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf URL verified
bitcoin.org · 2008-10-31 · section 4: hashing in proof-of-work
https://bitcoin.org/bitcoin.pdf URL verified
O'Reilly · 2017 · chapters on keys, addresses and mining, on hash function properties
Print source
Editorial status
Flagged by the editor as uncertain on a linguistic, mathematical or regulatory point.
