Photo by Mathew Schwartz on Unsplash

For Hashing, The Fastest of the Fastest? … Meet t1ha

--

You might know those slow old hashing methods, such as MD5, SHA-1, and SHA-256. Well, they were designed to be fast, but also highly secure. But, if we just need a hashing method, such as for a hashtable or Bloom filter, we often don’t need all the security that comes with the main cryptography hashing methods. And so we have the non-cryptography hashing methods, and which are often ultra-fast and highly efficient. To show the difference, in a test, SHA-1 — one of the fastest cryptography hashing methods — managed a processing rate of 364.95 MiB/s, while t1ha was nearly a 100 times faster, at 34,636 MiB/s.

The results from smhasher show that t1ha, MeowHash, xxHash, and MetroHash are three of the fastest non-cryptography methods:

The fast non-cryptography methods often do not try to be compatiable with the slow 32-bit CPUs, and often use AES-based extensions within the processor. This allows them to process data faster and — often — in the hardware of the processor.

The fastest ‘useful’ hash is probably t1h. It was derived from the 1Hippeus project (t1h) was created by Leonid Yuriev. The three main versions are:

  • t1ha0. This produces a 64-bit hash. It is ultrafast and focused on 64-bit CPUs. At the present time, it beats all the other non-cryptography methods for speed. There are some trade-offs for security, in order to boost the speed of operation. The AES-NI version provides the best results and it uses the embedded AES instructions within the CPU.
  • t1ha1. This version is designed to be as secure as possible and is also portable on a range of systems — not just for 64-bit CPUs. Unfortunately, Yves Orton discovered this family of hashes failed some of the avalanche tests. The avalanche test involves changing one or more bits in the input, then — on average —it should result in half of the bits changing on the output hash. t1ha1 is mainly focused on little-endian processors— such as for Intel x86/x64 — and will run slower on big-endian processors.
  • t1ha2. This is the recommended version, and overcomes the problems of t1ha1, but is still faster than other non-cryptography hashing methods. It can also produce a 128-bit hash output (t1ha3). Again it focuses on little-endian processors.

Overall a good hash should be free from being reversible, and where it is not possible to mathematically reverse the hash back to its original input, or where it is not possible to discover parts of the input data. Along with this, it should be difficult to find collisions, and where two different inputs lead to the same output hash. t1ha passes each of these criteria.

In most cases, such as for hashtables, a 64-bit hash output is acceptable, and this is optimized within 64-bit processors. Overall, a 128-bit will be much freer of collisions, but there will be a performance hit.

Anyway, here it is:

https://asecuritysite.com/encryption/smh_t1ha

and the code is here:

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.