4 ms·
Hashes aren't strictly reversible, so "reversing" a hash usually means finding data that hashes to a given value. E.g. in the case of PhotoDNA there are 256^144
by yakubin 5y ago
Hashes aren't strictly reversible, so "reversing" a hash usually means finding data that hashes to a given value. E.g. in the case of PhotoDNA there are 256^144 possible hash values (the hash is 144 bytes long). So you can't avoid collisions in a set with more than 256^144 elements. So recersing PhotoDNA means finding an element that hashes to a given value, but it doesn't mean that that's the image that was hashed to this value that is the real-world source of this hash.
Now as for completely theoretical possibility you can reverse any hash by brute-force. But that may not be computationally feasible. Now let's think what is easier: reversing a hash with few or many collisions? Let's take an edge case: a hash function hashes everything to just one value (not a very good hash function, but bear with me). That will be the easiest hash function to reverse, since any input is a right answer. Now as you reduce the number of collisions, the task becomes harder: you can divide images into disjoint sets such that each of them is defined by the hash value images in this set hash to, so if you have two images, each from distinct set, they hash to distinct values, and if they are in the same set, they hash to the same value. When you reduce the number of collisions the sets get smaller in size, but their amount grows. So for any given hash value which you want to reverse you need to check a bigger number of candidates to figure out which of the sets is the one for the given hash value (one candidate to check from each set). And that's assuming it would be feasible to just keep a list of those sets and their members, which it isn't, but illustrates the correlation. So actually it's easier to reverse when you have more collisions. It's counter-intuitive, because it's a different kind of reversing than what is usually meant by "reversing a function", which requires a function to be injective.
But: with fewer collisions you have higher likelihood that what you got as the result of reversing is what someone else used as input to the hash function (each of the sets is smaller, so with uniform distribution we get 1/n probability, where n is the number of elements in a given set of elements hashing to the same value).
Anyway, the sets I wrote about here are elements of a quotient set defined by the equivalence relation of hashing to the same value. You can read more on Wikipedia, if my description was a bit confusing: <https://en.wikipedia.org/wiki/Equivalence_class#quotient_set https://en.wikipedia.org/wiki/Equivalence_class#quotient_set>