highwayhash(3)
β¨ highwayhash β the manual page, but make it cute β¨
okay so bestie, you're reading the highwayhash(3) page from the Library Functions Manual and honestly? it's giving "fast strong 64-bit hash functions" energy and I am obsessed. let's get into it π
πΈ NAME πΈ
highwayhash β fast strong 64-bit hash functions. yes that's it, that's the whole name, slay.
π SYNOPSIS π
first up, the C girlies:
#include <highwayhash/c_bindings.h> /* C */
uint64_t SipHashC(const uint64_t* key, const char* bytes, const
uint64_t size);
uint64_t SipHash13C(const uint64_t* key, const char* bytes, const
uint64_t size);
uint64_t HighwayHash64(const HHKey key, const char* bytes, const
uint64_t size);
and now the C++ besties:
#include <highwayhash/highwayhash.h> /* C++ */
using namespace highwayhash;
void HighwayHashT(State* HH_RESTRICT state,
const char* HH_RESTRICT bytes, const size_t size,
Result* HH_RESTRICT hash);
#include <highwayhash/sip_hash.h> /* C++ */
using namespace highwayhash;
HH_U64 SipHash(const SipHashState::Key& key, const char* bytes,const
HH_U64 size);
and when you link, you link with -lhighwayhash π«Ά don't forget her, she's the whole reason it works.
π DESCRIPTION π
so hash functions are used everywhere, right? which means obviously we want them faster and safer. this package serves you two 'strong' hash functions β and by strong we mean well-distributed and unpredictable, not just "vibes are good":
- a faster version of SipHash
- and an even faster algorithm that they literally named HighwayHash π£οΈβ¨
SipHash is a fast but 'cryptographically strong' pseudo-random function, and it was made by Aumasson and Bernstein β the paper lives at https://www.131002.net/siphash/siphash.pdf if you want the lore.
HighwayHash is a new way of mixing inputs which may inspire new cryptographically strong hashes π and the numbers?? iconic:
- Large inputs are processed at a rate of 0.24 cycles per byte β‘
- latency stays low even for small inputs
- HighwayHash is faster than SipHash for all input sizes
- with 5 times higher throughput at 1 KiB
they discuss design choices and give you statistical analysis plus preliminary cryptanalysis over at https://arxiv.org/abs/1612.06257 β go read it, iykyk π
β οΈ also important bestie: note that SipHash wants anuint64_t[2]key while HighwayHash wantsuint64_t[4]. do not mix those up, that's a whole different vibe and not the good kind π
π EXAMPLES π
64-bit SipHash for any CPU:
#include "highwayhash/sip_hash.h"
using namespace highwayhash;
const HH_U64 key2[2] HH_ALIGNAS(16) = {1234, 5678};
char in[8] = {1};
return SipHash(key2, in, 8);
64, 128 or 256 bit HighwayHash for the CPU determined by compiler flags:
#include "highwayhash/highwayhash.h"
using namespace highwayhash;
const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
char in[8] = {1};
HHResult64 result; // or HHResult128 or HHResult256
HHStateT<HH_TARGET> state(key);
HighwayHashT(&state, in, 8, &result);
64, 128 or 256 bit HighwayHash for the CPU on which we're currently running:
#include "highwayhash/highwayhash_target.h"
#include "highwayhash/instruction_sets.h"
using namespace highwayhash;
const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
char in[8] = {1};
HHResult64 result; // or HHResult128 or HHResult256
InstructionSets::Run<HighwayHash>(key, in, 8, &result);
C-callable 64-bit HighwayHash for the CPU on which we're currently running:
#include "highwayhash/c_bindings.h"
const uint64_t key[4] = {1, 2, 3, 4};
char in[8] = {1};
return HighwayHash64(key, in, 8);
like... four whole flavours of the same gorgeous algorithm?? we ate π
π SEE ALSO π
/usr/include/highwayhash/c_bindings.h(C)/usr/include/highwayhash/highwayhash.h(C++)
go read the headers, they're right there, they're free π
π BUGS π
found something cursed? take it straight to the source, bestie:
π AUTHOR π
the upstream authors are Jan Wassenberg <jan.wassenberg@gmail.com> and Jyrki Alakuijala <jyrki.alakuijala@gmail.com>, updated 2017-02-07 β legends, no cap.
this manpage was created by Adam Borowski <kilobyte@angband.pl>, and completed by Zhou Mo <cdluminate@gmail.com> according to upstream readme and header files. π«Ά
and that's the whole page!! this highwayhash(3) manual was brought to you by Library Functions Manual energy, dated April 25, 2017 β go hash something beautiful, mwah π
β¨
π¦ where this page comes from
- debian bookworm: libhighwayhash-dev 0~git20200803.9490b14-3+b1 Β· Apache-2.0
- debian trixie: libhighwayhash-dev 0~git20200803.9490b14-4.1+b1 Β· Apache-2.0
- ubuntu jammy: libhighwayhash-dev 0~git20200803.9490b14-3 Β· Apache-2.0
- ubuntu noble: libhighwayhash-dev 0~git20200803.9490b14-4.1build1 Β· Apache-2.0
- ubuntu questing: libhighwayhash-dev 0~git20200803.9490b14-4.1build1
- ubuntu resolute: libhighwayhash-dev 0~git20200803.9490b14-4.1build2 Β· Apache-2.0
- ubuntu stonking: libhighwayhash-dev 0~git20200803.9490b14-5 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms