commonsmachinery / blockhash

blockhash.io
MIT License
86 stars 28 forks source link

Always even? Never odd! #3

Closed jonasob closed 9 years ago

jonasob commented 9 years ago

When I was looking at the statistics of our generated hashes from WMC, it struck me that the hamming distance between two hashes always seem to be an even number. This means we see differences of 2, 4, 6 bits etc but never just 1 or 3 bits. I wonder if this is an implementation fault or a peculiarity of the algorithm: it seems to effectively make it 128 bits.

Something for @petli to consider during his travels :)

petli commented 9 years ago

There's always an equal number of 1s and 0s in the hash, since they are determined by the median value. If you flip a 1 to a 0, you also have to flip a 0 to a 1 somewhere else, effectively doubling the distance.

QED. ;)

But it might be possible to use this behaviour to do something clever in the lookup.