Open
Description
Searching for fast Keccak implementations in Julia, I came across @tecosaur's package KangarooTwelve.jl. I think it should be straightforward to extract SHA-3 implementations from it. For example, changing the hardcoded number of rounds from 12 to 24 in ::Val{nrounds}=Val{12}())
, the function SHA3-256 can be computed as follows:
tecosaur_sha3_256(message) = KangarooTwelve.turboshake(NTuple{32, UInt8}, message, 0b110, Val(512))
On my machine, it performs better for short messages
julia> msg = zeros(UInt8, 10);
julia> @btime SHA.sha3_256(msg);
871.358 ns (5 allocations: 688 bytes)
julia> @btime tecosaur_sha3_256(msg);
437.598 ns (1 allocation: 48 bytes)
and significantly better for long messages:
julia> msg = zeros(UInt8, 100_000_000);
julia> @btime SHA.sha3_256(msg);
614.836 ms (5 allocations: 688 bytes)
julia> @btime tecosaur_sha3_256(msg);
218.257 ms (1 allocation: 48 bytes)
I just wanted to leave this observation as a note. Feel free to close the issue.
Metadata
Assignees
Labels
No labels