Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added byte shuffle, CRC32c, carryless multiplication, and xor-rotate #13

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is a little tool for automated [integer hash function][wang]
discovery. It generates billions of [integer hash functions][jenkins] at
random from a selection of [nine reversible operations][rev] ([also][]).
random from a selection of 14 [reversible operations][rev] ([also][]).
The generated functions are JIT compiled and their avalanche behavior is
evaluated. The current best function is printed out in C syntax.

Expand Down Expand Up @@ -287,20 +287,37 @@ long.
```c
x = ~x;
x ^= constant;
x *= constant | 1; // e.g. only odd constants
x *= constant | 1; // e.g. only odd constants
x += constant;
x ^= x >> constant;
x ^= x << constant;
x += x << constant;
x -= x << constant;
x <<<= constant; // left rotation
x <<<= constant; // left rotation
x ^= (x <<< constantA) ^ (x <<< constantB); // xor-rotate
bswap(x); // byte swap - the endianess changer
shf(x, constant); // byte shuffle, permutation
crc32(x, constant); // crc32c step, 32-bit only
clmul(x, constant | 1); // carryless multiplication, odd constants
```

Technically `x = ~x` is covered by `x = ^= constant`. However, `~x` is
uniquely special and particularly useful. The generator is very unlikely
to generate the one correct constant for the XOR operator that achieves
the same effect.

`shf` pattern uses the SSSE3 byte shuffle instruction and is available
on corresponding hardware only; `shf:03020100` denotes identity (no change),
`shf:00010203` equals the endianess changing byte swap. 64-bit hashes
optionally take a permutation of `{ 00, ... , 07 }` such as
`shf:0304050607020100`.

`crc` performs a hardware-accelerated CRC32c step – requiring a SSE4.2-
capable CPU. It is defined for 32-bit hashes only, try `-4 -p crc32,mul,crc32`.

`clmul`, the carryless multiplication instruction, is also available on supported
hardware only.

## 16-bit hashes

Because the constraints are different for 16-bit hashes there's a separate
Expand Down
Loading