Skip to content
Tech Interview Prep
Technical interview guide

Cryptographic Primitives for Blockchain

The hashing, digital signature, and Merkle tree building blocks every blockchain is constructed from.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v4
Editorial status
Reviewed

Scope: NIST FIPS 180-4 (revision planned), FIPS 186-5 with published errata status reviewed 2026-09-04, SP 800-57 Part 1 Rev. 5, SP 800-186, RFC 6979, Bitcoin and Ethereum protocol documentation reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

Cryptographic Primitives for Blockchain

In one line

A hash binds exact bytes, a signature binds those bytes to a key, and a Merkle root binds leaves to a block. Reach for this set whenever you must say what a block, transaction or state root proves, and what it leaves unproven.

Key definitions

  • Preimage resistance: given a digest, no input is found that produces it.
  • Second-preimage resistance: given one message, no different message shares its digest.
  • Collision resistance: no two distinct messages share a digest. For an ideal n-bit hash, the work is about 2^(n/2).
  • Domain separation: a prefix or structure that stops a valid value in one context being accepted in another.
  • Low-S: the rule s <= n/2. It removes one of the two valid ECDSA forms, (r, s) and (r, n-s).
  • Merkle membership proof: sibling hashes and their left/right orientation that recompute a root you already trust.

Formulas and complexity

collision work≈2n/2,preimage work≈2n\text{collision work} \approx 2^{n/2}, \qquad \text{preimage work} \approx 2^{n} k=(z1−z2)(s1−s2)−1 mod n,d=(s1k−z1) r−1 mod nk = (z_1 - z_2)(s_1 - s_2)^{-1} \bmod n, \qquad d = (s_1 k - z_1)\, r^{-1} \bmod n membership proof=⌈log⁡2N⌉ hashes for N leaves\text{membership proof} = \lceil \log_2 N \rceil \text{ hashes for } N \text{ leaves}

For a 256-bit ideal digest, collision work is about 2^128 hashes, so a root committed under that digest inherits 128-bit collision security. Preimage stays near 2^256. A tree with 2^20 leaves needs 20 sibling hashes.

How it works

  1. Canonicalise the fields: fixed order, length prefixes, fixed integer width and endianness, NFC text.
  2. Prefix a domain tag (network, message type, version), then hash the bytes with the chain's exact algorithm.
  3. Sign the digest. The verifier rebuilds the digest from its own encoding before checking the signature.
  4. Leaf hashes fold into a Merkle root. The block header commits to that root and to its parent's header hash.
Canonical bytes plus domain tag Digest: SHA-256 or Keccak-256 Signature over digest Leaf hashes Merkle root Block header Child header stores this header hash as parent

When to use and when not to

NeedUseWatch for
Bind a block to its contentsRoot in header, parent-hash linkA root does not prove the leaves are available
Prove membershipMerkle membership pathAbsence needs a sorted or sparse tree with explicit absence semantics
Authenticate a requestEd25519, or secp256k1 where the chain requires itSignatures do not encrypt and do not prove a human intended the action
Verify many signaturesSchnorr or Ed25519 batch verificationECDSA batches gain nothing
Long-lived keysAlgorithm IDs and a migration planDiscrete-log signatures fall to a quantum computer

Traps interviewers probe

  1. Claiming 256-bit collision security. The fix: state 128-bit collision and 256-bit preimage, and say which one a root inherits.
  2. Hashing concatenated fields with no length prefix. Different messages then share bytes. The fix: length-prefix every variable field and check test vectors across every implementation.
  3. Treating a valid proof as proof of inclusion. A proof against an attacker-supplied root proves only internal consistency. The fix: anchor the root to consensus, a trusted checkpoint, a block, a network and a finality state.
  4. Re-signing a block and assuming it stands. The fix: check the child's parent hash. A changed header breaks that link, whatever the signature says.
  5. Reusing or biasing ECDSA nonces. Two signatures with the same k reveal the key by the algebra above. The fix: RFC 6979 or a CSPRNG with a unique k per message.

Interview tips

Open with the chain of evidence: "The hash binds these exact bytes, the signature binds them to this key, and the root binds them to this block. None of that shows the data is available or that the key belongs to a person."

Expect these follow-ups:

  • How you rotate a compromised key on an immutable ledger. Old signatures stay verifiable; future authority moves by policy.
  • How a light client gets a trusted root. It needs consensus, a checkpoint or another explicit anchor.
  • Why a valid proof against an attacker's root proves nothing.
  • What changes at billions of leaves. Proof size grows only logarithmically (40 hashes for 2^40 leaves), but storage grows linearly.

30-second outline:

  • Claim: what the artifact proves, in terms of bytes, key and root.
  • Mechanism: canonical encoding, domain-tagged digest, signature, then a path to a trusted root.
  • Limits: no availability, no identity or intent, no non-membership without absence semantics.
  • Failure: name the specific break, such as nonce reuse, a collision at 2^128 work, or a missing domain tag.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.