multiformats / multihash

Self describing hashes - for future proofing
https://multiformats.io/multihash/
MIT License
885 stars 113 forks source link

Murmur3-128 output differs between 32-bit and 64-bit implementations by design #85

Open mateon1 opened 7 years ago

mateon1 commented 7 years ago

The current version is MurmurHash3, which yields a 32-bit or 128-bit hash value. When using 128-bits, the x86 and x64 versions do not produce the same values, as the algorithms are optimized for their respective platforms.


Source: Wikipedia

I think this is a major issue for a hashing function for multihash. I believe the idea is for the hash to be reproducible anywhere.

This could be fixed by splitting the Murmur3-128 multihash code into two, whether the 32 bit or 64 bit implementation is to be used.

Alternatively, Murmur could be removed, as it's an unsafe, non-cryptographic hash function, and I am not aware of anything that depends on a multihash library and uses murmur.

Stebalien commented 5 years ago

We use it when building HAMTs (hash maps). Not to build actual multihashes (<type><length><digest>) but just to indicate the hash function.

Stebalien commented 5 years ago

However, you bring up a good point about the architecture dependence. I believe we're using murmur3-128x64.