KangarooTwelve
Background
A pure-Julia implementation of the KangarooTwelve hashing scheme, so named because it consists of 12 rounds of Keccak (TurboSHAKE128) with kangaroo hopping, allowing for parallel tree-ish hashing termed "leaves stapled to a pole".
This scheme presents a particularly good balance of:
- Simplicity (Keccak + sponge + hopping)
- Security (128-bit)
- Speed (up to ~2bytes/cycle)
It is currently an IETF draft.
Usage
KangarooTwelve.k12
— Functionk12(data::Union{IO, String, AbstractVector{<:Unsigned}},
customisation::Union{String, AbstractVector{<:Unsigned}};
thread::Bool=true) -> UInt128
Hash data
with the KangarooTwelve scheme and a customisation
value, using multithreading when thread
is true
.
This scheme presents a good balance of Simplicity, Security, and Speed.
Extended help
The KangarooTwelve hashing scheme works by splitting the input data into $n$ 8192-byte blocks ($S₀$, $S₁$, …, $Sₙ₋₁$) which are individually hashed with TurboSHAKE128
to produce 32-byte "chaining values" (CVs), which are put together and absorbed to produce the final state.
╭────╮ ╭────╮ ╭────╮ ╭────╮
│ S₁ │ │ S₂ │ │Sₙ₋₂│ │Sₙ₋₁│
╰─┬──╯ ╰─┬──╯ ╰─┬──╯ ╰─┬──╯
│110 │110 │110 │110
▼ ▼ ▼ ▼
╭────────╮110⁶²╭─┴──╮ ╭─┴──╮ ╭─┴──╮ ╭─┴──╮
│ S₀ ├─────┤ CV ├─┤ CV ├╴╍╶┤ CV ├─┤ CV ├─(n-1)(FFFF)(01)──▶─┤HASH│
╰────────╯ ╰────╯ ╰────╯ ╰────╯ ╰────╯
This scheme has been described as "leaves on a vine". The hashing of blocks $S₁$ to $Sₙ₋₁$ is embarassingly parallel, and can be accelerated with both SIMD and multithreading.