wyhash
Wang Yi's compact, very fast hash based on 64x64-to-128-bit multiplication
Overview
wyhash is a non-cryptographic hash function by Wang Yi, notable for its small code size and high speed. It is used in several language runtimes and libraries, including Zig's standard library. It provides no security against a deliberate attacker.
wyhash's core operation, called mum, multiplies two 64-bit values to a 128-bit product and XORs the high and low halves. Input is consumed 48 bytes at a time across three lanes, each mixing input words XORed with secret constants through mum, and the lanes are combined at the end. Short inputs use direct loads with no loop.
NextSSL includes wyhash final version 3 wired from source and not yet verified. wyhash has gone through several revisions with different outputs, so the version must be fixed. None of this provides security: the function has no secret key, and anyone can compute or deliberately collide its outputs. Seed it randomly.
History
2019–2019wyhash published by Wang Yi
Security notes
wyhash is not cryptographic. With a random secret seed it resists casual hash flooding better than unseeded hashes, but it makes no formal security claims and should not be used where an attacker can adaptively choose inputs against a known seed.
Typical uses
Variants in NextSSL
1| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| Wyhash wyhash |
unverified | out 8 | wyhash final3 (Wang Yi), NON-cryptographic | root |
Frequently asked questions
Which wyhash variants does NextSSL include?
NextSSL registers 1 wyhash variant: wyhash.