- Define a cryptographic hash function and its required properties.
- Demonstrate the avalanche effect with real SHA-256 outputs.
- Identify the hash functions used by Bitcoin and Ethereum.
- List the places where hashing is used inside a blockchain.
What is a Cryptographic Hash Function?
- Think of a hash as a digital fingerprint of data: tiny in size, unique in practice, and it changes completely if the data changes.
- Hashing is not encryption: encryption can be reversed with a key; a hash cannot be “decrypted”.
Properties of a Cryptographic Hash Function
| Property | Meaning |
|---|---|
| Deterministic | The same input always produces the same hash. |
| Fixed-size output | SHA-256 always outputs 256 bits (64 hex characters), whether the input is one letter or a whole book. |
| Fast to compute | Calculating a hash is quick for any input. |
| Pre-image resistance | Given a hash h, it is infeasible to find any input x with hash(x) = h (one-way). |
| Second pre-image resistance | Given an input x, it is infeasible to find a different y with the same hash. |
| Collision resistance | It is infeasible to find any two different inputs with the same hash. |
| Avalanche effect | A tiny change in input (even one bit) changes about half of the output bits. |
| Puzzle friendliness | There is no shortcut to find an input whose hash falls in a target range – only trial and error. This is what makes Proof-of-Work fair. |
Avalanche Effect – Real SHA-256 Examples
| Input | SHA-256 hash |
|---|---|
| Blockchain | 625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1 |
| blockchain | ef7797e13d3a75526946a3bcf00daec9fc9c9c4d51ddc7cc5df888f74dd434d1 |
| Blockchain. | d70efa3d07ce636c2843270e3a67094e60889d5fbd6829a113b14716ee1c0c4f |
Changing one capital letter, or adding a full stop, produces a completely different hash. This is why a single altered transaction changes the Merkle root, the block hash and every link after it.
Hash Functions Used in Blockchains
| Function | Output | Where it is used |
|---|---|---|
| SHA-256 | 256 bits | Bitcoin: block hashes and mining (applied twice – “double SHA-256”), transaction IDs, Merkle trees. |
| RIPEMD-160 | 160 bits | Bitcoin: combined with SHA-256 to shorten public keys into addresses (HASH160). |
| Keccak-256 | 256 bits | Ethereum: addresses, function selectors, storage slots, block and transaction hashes. |
| SHA3-256 (FIPS 202) | 256 bits | NIST standard version of Keccak with different padding – not the same output as Ethereum’s Keccak-256. |
Example: Keccak-256("Blockchain") = fa8871e962875d078135f1c5b27b0f184ab6f4dff8641dd81032226ea0ae9e8c, whereas SHA3-256("Blockchain") = 94074fd5892e84da500a78e4c02ff986c38815ad4063441a1caad310e89cf709.
Where Hashing is Used in a Blockchain
- Chaining blocks – each block header stores the previous block’s hash (Chapter 1).
- Merkle trees – summarise all transactions into one root hash (Chapter 21).
- Proof-of-Work – miners search for a hash below a target (Chapter 15).
- Addresses – derived by hashing public keys (Chapter 10).
- Identifiers – transaction IDs and block IDs are hashes.
- Digital signatures – the message hash, not the whole message, is signed (Chapter 20).
Key Takeaways
- A cryptographic hash is a one-way, fixed-size digital fingerprint of data.
- Key properties: pre-image, second pre-image and collision resistance, plus the avalanche effect.
- Bitcoin relies on SHA-256 (and RIPEMD-160); Ethereum relies on Keccak-256.
Question / Answer (15 questions)
MCQ Test : Check Your Understanding (5 questions)
Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.
Bibliography/References
The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.
- National Institute of Standards and Technology. (2015). Secure Hash Standard (SHS) (FIPS PUB 180-4). https://doi.org/10.6028/NIST.FIPS.180-4
- National Institute of Standards and Technology. (2015). SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions (FIPS PUB 202). https://doi.org/10.6028/NIST.FIPS.202
- Narayanan, A., Bonneau, J., Felten, E., Miller, A., & Goldfeder, S. (2016). Bitcoin and Cryptocurrency Technologies: A Comprehensive Introduction. Princeton University Press. ISBN 978-0-691-17169-2.
- Nakamoto, S. (2008). Bitcoin: A Peer-to-Peer Electronic Cash System. https://bitcoin.org/bitcoin.pdf
- Wood, G. Ethereum: A Secure Decentralised Generalised Transaction Ledger (Ethereum Yellow Paper). https://ethereum.github.io/yellowpaper/paper.pdf
- Antonopoulos, A. M. (2017). Mastering Bitcoin: Programming the Open Blockchain (2nd ed.). O’Reilly Media.
- Yaga, D., Mell, P., Roby, N., & Scarfone, K. (2018). Blockchain Technology Overview (NISTIR 8202). National Institute of Standards and Technology. https://doi.org/10.6028/NIST.IR.8202