Implementation of Kangaroo Twelve in Go
I’ve released an implementation of KangarooTwelve in Go
It is heavily based on the official Go’s x/crypto/sha3 library. But because of minor implementation details the relevant files have been copied and modified there so you do not need Go’s SHA-3 implementation to run this package. Hopefully one day Go’s SHA-3 library will be more flexible to allow other keccak construction to rely on it.
I have tested this implementation with different test vectors and it works fine. Note that it has not received proper peer review. If you look at the code and find issues (or not) please let me know!
See here why you should use KangarooTwelve instead of SHA-3. But see here first why you should still not skip SHA-3.
This implementation does not yet make use of SIMD to parallelize the implementation. But we can already see improvements due to the smaller number of rounds:
100 bytes | 1000 bytes | 10,000 bytes | |
K12 | 761 ns/op | 1875 ns/op | 15399 ns/op |
SHA3 | 854 ns/op | 3962 ns/op | 34293 ns/op |
SHAKE128 | 668 ns/op | 2853 ns/op | 29661 ns/op |
This was done with a very simple bench script on my 2 year-old macbook pro.