Skip to content

gxhash64() on x86 ignores half of its input bytes #320

Description

@sesse

Hi,

It seems gxhash64() does this to reduce 256 to 64 bits:

    return *(uint64_t*)&full_hash;

However, all the mixing operations in GxHash (when using AVX2; not so much on NEON) are two parallel 128-bit lanes that never get combined together (all the operations are _si128, so 128-bit AES). Thus, when dealing with e.g. 32-byte strings, this means that the returned answer is entirely unaffected by the contents of bytes 16…31. gxhash32() has the same problem.

I found this out when trying to use the code for a real-world system and then ended up with tons of collisions on almost-equal strings :-) I'm a bit surprised that no SMHasher tests triggered on this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions