KangarooTwelveNIST created a competition for SHA-3, and it was Keccak that was crowned the champion. Since then, SHA-3 has received good adoption levels, but you’ll also see BLAKE2 — one of the finalists — being used in many applications. Keccak won because it was fast, and where BLAKE2 was submitted too late to compete against it. Since many have seen BLAKE2 as the better alternative [article]. So, in 2016, the Keccak research team came up with a new method: KangarooTwelve. For this they managed to get significant speed improvements and managed to reduce the number of rounds from 24 to 12 (and with a security level of around 128 bits). A new method of tree hashing has also been added, and which supports the parallel hashing of large files [article]. |
Coding
The following is some sample Go code:
package main import( "fmt" "github.com/mimoo/GoKangarooTwelve/K12" "encoding/hex" "os" ) func main(){ str1:="" message:="" argCount := len(os.Args[1:]) if (argCount>0) {str1 = string(os.Args[1])} if (argCount>1) {message = string(os.Args[2])} customString := []byte(str1) payload := []byte(message) out := make([]byte, 32) K12.K12Sum(customString, payload, out) fmt.Printf("Custom string:\t%s\nMessage:\t%s\n\n",str1,message) fmt.Printf("Hash:\t%s",hex.EncodeToString(out)) }
A sample run is:
Custom string: Hello Message: qwerty Hash: d7aa928c520c8d48a0734ad96c2b43d237197f7bedab6ef014c7ed5f60fc160b