4 ms·
There's always a huge focus on speed in these type of articles, and rightfully so for most applications. However, I often find myself in situations where I car
by ur-whale 5y ago
There's always a huge focus on speed in these type of articles, and rightfully so for most applications.
However, I often find myself in situations where I care neither about speed nor any other of the traditional performance metrics (memory consumption, latency, bandwidth, parallelizability, etc ...).
In these situations, what I actually care about is:
a) code size (as in: fits compiled in 512 bytes)
b) code simplicity (as in: fits in head, takes up around 20 C++ LOC)
Very unfortunately, there are very, very few algorithms that are designed to optimize along these lines.
Exceptions:
TEA : https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
Speck: https://en.wikipedia.org/wiki/Speck_(cipher) https://en.wikipedia.org/wiki/Speck_(cipher)
Both of these are ciphers, and both can be perverted into becoming hashes for various scenarios.
But, there aren't any compression or native crypto-hard hashing algorithms that I know of that are specifically designed to optimize along that particular dimension.
Blake3 or zstd are large pieces of code.
- oconnor663 5y agoMost of the BLAKE3 code size is optimized implementations for four different flavors of SIMD. But if you only compile the portable implementation, I don't think it's substantially more code than e.g. BLAKE2 or ChaCha. (Though tbh I haven't measured.) In particular, the tree mode adds very little extra code.