A cryptocurrency exchange is developing a new system to generate transaction IDs. They need a cryptographic primitive that produces a fixed-size output, is computationally infeasible to reverse, and ensures that even a tiny change in the input results in a drastically different output. Which primitive should they use?
- AAsymmetric encryption algorithm
- BCryptographic hash function
- CSymmetric encryption algorithm
- DDigital signature algorithm
Show answer & explanationAnswer & explanation
Correct answer: B. Cryptographic hash function
A cryptographic hash function meets all the described requirements: it produces a fixed-size output (e.g., a transaction ID), is computationally infeasible to reverse (one-way property), and exhibits the avalanche effect, where a small input change leads to a large, unpredictable change in the output. This makes them ideal for integrity checks and unique identifiers like transaction IDs.
Why the other options are wrong
- A. Asymmetric encryption is for confidentiality, key exchange, and digital signatures, not for generating irreversible, fixed-size identifiers.
- C. Symmetric encryption is for confidentiality, not for producing fixed-size, irreversible identifiers.
- D. Digital signatures provide authenticity and non-repudiation, but they use hash functions internally; the primitive itself is the hash function for this specific need.
Cryptographic Hash Function
A cryptographic hash function is a mathematical algorithm that maps data of arbitrary size to a bit array of a fixed size (the 'hash value'). It's designed to be a one-way function, resistant to various attacks, and produces drastically different outputs for even minor input changes.
- One-way (computationally irreversible).
- Fixed-size output.
- Avalanche effect (small input change = large output change).
- Collision resistant.
Memory trick: Hash for integrity, Encrypt for secret, Sign for proof.