f2568() - A variable Length Tabulation Hash Function
 
 

f2568() - A variable Length Tabulation Hash Function

June 1, 2025
development
algorithms, Tabulation Hashing, C

f2568() #

f2568() is a variable length tabulation hashing function which returns a 64 bit hash result of input data up to a size of 256 bytes. It’s quite fast (basically requiring as many XOR operations as the data length in bytes), easy to understand and very strong at the same time.

f2568() is publicly available under the BSD-3-Clause License.

Being a tabulation hash function, it’s not 4-independent, which can safely be ignored for the intended purposes.

The Implementation #

The Random Material #

The random material is “true random” as it has been retrieved from the Quantis QRNG device, a physical random number generator exploiting an elementary quantum optics process.

To cover the possible input space of 256 bytes the required ramdom material size becomes 256 * 256 * sizeof(uint64_t) bytes (256KB). This size leads to increased latency due to memory cache misses, detailed performance benchmarks and comparisons are not yet ready.

f2568() #

The implementation is straightforward, note the fixed random initialisation value result = 0xdc6cd513e996ae54; which is the f2568() result of data with length zero.

f2568resume() #

f2568resume() allows to resume computation with additional data which is non consecutively located at another place.

Also, it allows to chain multiple f2568resume() calls to obtain a strong 64 bit hash of larger data (dividing it into 256 byte blocks and setting the offset to 0 on consecutive calls).

f2568.c #

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
static uint64_t material[256 * 256];

uint64_t f2568(uint8_t* data, uint16_t len) {
  int i;
  uint64_t result;

  result = 0xdc6cd513e996ae54;
  for (i = 0; (i < 256) && (i < len); i++) {
    result ^= *(material + i * 256 + data[i]);
  }
  return (result);
}

uint64_t f2568resume(uint8_t* data, uint16_t len, uint16_t offset, uint64_t previous) {
  int i;
  uint64_t result;

  result = previous;
  for (i = 0; (i + offset < 256) && (i < len); i++) {
    result ^= *(material + (i + offset) * 256 + data[i]);
  }
  return (result);
}

static uint64_t material[256 * 256] = { 
  0xa9a5be624fabaa36, 0x4244b57f4c97d512, 0x0b2ce509c4827510, 0x8eb519ed8e23e207,
  0x9e8ff36bd45a7fb2, 0xcb1036c7ad451936, 0x10d22673f56a3925, 0x69f1e6968a65fb61,
  // true random data omitted
  0x042455208e226dce, 0x5ba3a465aa881c02, 0xf9f052d441284117, 0xa557c4212ec4c08a,
  0xa76d05d9e84c144c, 0x491e43cd77134161, 0xe13f55a5ac39d0ec, 0x5d6d37d6c2d333f5
};

Test Vectors #

f2568("", 0)                                   0xdc6cd513e996ae54
f2568("a", 1)                                  0x733057f5184fd8e8
f2568("ab", 2)                                 0x7e7a27a682632a2c
f2568("abc", 3)                                0x033ba573649a3044
f2568("abcd", 4)                               0xb3f66d62bcf674a4
f2568resume("cd", 2, 2, 0x7e7a27a682632a2c)    0xb3f66d62bcf674a4
f2568("abcde", 5)                              0xa6141edba1c60acd
f2568("abcdef", 6)                             0x430e40daa722a64b
f2568("abcdefg", 7)                            0x3111e6b33be5be6c
f2568("abcdefgh", 8)                           0x302ce90427347152
f2568resume("efgh", 4, 4, 0xb3f66d62bcf674a4)  0x302ce90427347152

Resources #