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

Faster SHA-3 implementations #110

Open
erich-9 opened this issue Apr 25, 2024 · 0 comments
Open

Faster SHA-3 implementations #110

erich-9 opened this issue Apr 25, 2024 · 0 comments

Comments

@erich-9
Copy link

erich-9 commented Apr 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant