What Is a Second-Preimage Attack and How Does It Differ from a First-Preimage Attack?
A first-preimage attack (or simply a preimage attack) involves finding the input 'x' that maps to a specific, pre-determined hash output 'h'. A second-preimage attack involves being given an input 'x1' and its hash 'h1', and then finding a different input 'x2' such that H(x2) = H(x1).
The key difference is that in a second-preimage attack, the attacker must match the hash of a specific existing message, whereas in a collision attack, any colliding pair is acceptable.