Section II: Cryptographic Primitives
April 9, 2026
Define a cryptographic hash function
Explain key properties: preimage, second‑preimage, collision resistance, and avalanche.
Build and verify Merkle tree commitments and inclusion proofs; discuss variants and pitfalls.
Understand the relevance of hashing to commit information within blockchain technology.
| Property | Meaning | Importance |
|---|---|---|
| Pre-image resistance | Hard to find input for given hash. | Protects passwords and commitments. |
| Second pre-image resistance | Hard to find another input with same hash. | Prevents forgery. |
| Collision resistance | Hard to find any two inputs with same hash. | Ensures uniqueness and integrity. |
| Avalanche effect | Tiny input change → major output change. | Detects even 1-bit alteration. |
| Uniform Distribution | Outputs should be uniformly distributed | no structural shortcuts should exist. |
ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94fcbe6beb26479b568e5f15b50217c6c83c0ee051dc4e522b9840d8e291d6aaf463615f80c9d293ed7...c6f4b0a7af12e91b...Choose digest lengths ensuring \(2^{n/2}\) work is infeasible — e.g., SHA-256 or SHA-3.
Use the following microlab to demonstrate the principles of hashing using real algorithms
| Algorithm | Output (bits) | Status | Notes |
|---|---|---|---|
| SHA-1 | 160 | Deprecated | Collisions found |
| SHA-2 | 224–512 | Secure | Bitcoin uses SHA-256 |
| SHA-3 | 224–512 | Secure | sponge construction |
Core idea: compress each message block one at a time, chaining the output into the next round.
Root cause: in Merkle–Damgård, the digest is the final internal state — so it can be used as a starting point to keep hashing.
token and "amount=100", where token = SHA256(secret ∥ "amount=100") — they don’t know secret.token directly into SHA-256’s internal state (it’s just 8 words of 32 bits each).pad ∥ "amount=1000000" — continuing the hash as if they were the original signer.token2′ = SHA256(secret ∥ "amount=100" ∥ pad ∥ "amount=1000000").SHA256(secret ∥ forged_body) — and it matches token2′.Any scheme of the form H(secret ∥ data) used as a MAC is broken against length extension. This affected Flickr’s API (2009), several Amazon S3 auth schemes, and many custom-rolled API signatures.
Mitigation: Hash-based Message Authentication Code (HMAC)
\[\text{HMAC}(k, m) = H\bigl(k \oplus \text{opad} \;\|\; H(k \oplus \text{ipad} \;\|\; m)\bigr)\]
The outer hash takes the result of the inner hash as input — an attacker extending the inner computation gets a value that is immediately re-hashed with the key, producing garbage.
Core idea: absorb message blocks into a large state, then squeeze output out — the hidden interior is never exposed.
| Merkle–Damgård (SHA-256) | Sponge (SHA-3) | |
|---|---|---|
| Structure | Iterated compression | Absorb → permute → squeeze |
| Digest = internal state? | Yes | No — capacity is hidden |
| Length-extension vulnerable? | Yes | No |
| Used in Bitcoin / Ethereum | SHA-256 / Keccak-256 | Keccak-256 |
The sponge’s hidden capacity makes length-extension impossible by design — you can’t reconstruct the full internal state from the digest alone.
LeafTag vs NodeTag to avoid ambiguity.0x00 for leaves, 0x01 for nodes).Review the following interactive labs:
First: Merkle-trees Lab
Second: Hashing Merkle Lab

Hashing and Merkle Trees — Army Cyber Institute — April 9, 2026