hashes
hashes copied to clipboard
Refactor k12
The k12 crate had its own keccak-p permutation implementation. With https://github.com/RustCrypto/sponges/pull/7 a generic keccak-p implementation would be available, which could be used within the k12 crate.
Depends on
- [ ] https://github.com/RustCrypto/sponges/pull/7
- [ ] and a new release of the keccak crate ;)
For K12, it would be interesting to also have SIMD implementations of parallel Keccak-p permutations.
Sorry, I cannot help directly because I am not fluent in Rust, but I can at least point out such implementations in XKCP/K12 for inspiration.
For K12, it would be interesting to also have SIMD implementations of parallel Keccak-p permutations.
Sorry, I cannot help directly because I am not fluent in Rust, but I can at least point out such implementations in XKCP/K12 for inspiration.
Yes, that definitely would get some nice improvements. Currently I have made a draft PR for SIMD backed Keccak-f permutations in https://github.com/RustCrypto/sponges/pull/8. As soon as this is available, the k12 implementation could be updated to incorporate it.
EDIT: https://github.com/RustCrypto/sponges/pull/8 would need an generic SIMD backed keccak-p permutation for use within k12. I'll extend the draft PR.
I was not aware of that PR. Nice!
@aewag this is great work. Anything I can do to help move it along?
@aewag this is great work. Anything I can do to help move it along?
If you have time to review https://github.com/RustCrypto/sponges/pull/7, that would be great. Other than that, this propably needs a rebase and should more or less work.
(I planned to further update the implementation to be alloc-free and maybe also in the future with SIMD support, but I will not able to work on this in the near future.)
EDIT: I just rebased this on top of the current master.
@aewag went ahead and merged https://github.com/RustCrypto/sponges/pull/7. We can probably cut another release of the keccak crate.
I wanted to point out this is probably the biggest problem with the k12 crate in its current form:
https://github.com/RustCrypto/hashes/blob/1cdbd5363f8e20cc378e19bce4d6470143f08ff7/k12/src/lib.rs#L37-L39
It buffers all of the input in a Vec<u8> and doesn't actually hash it until XofReader::read:
https://github.com/RustCrypto/hashes/blob/1cdbd5363f8e20cc378e19bce4d6470143f08ff7/k12/src/lib.rs#L128-L177
That makes the implementation unusable for large inputs, and it doesn't properly implement the XofReader contract in that it will panic if XofReader::read is called repeatedly.
@aewag went ahead and merged RustCrypto/sponges#7. We can probably cut another release of the
keccakcrate.I wanted to point out this is probably the biggest problem with the
k12crate in its current form. That makes the implementation unusable for large inputs, and it doesn't properly implement theXofReadercontract in that it will panic ifXofReader::readis called repeatedly.
Yep, agreed. I started to work on these (two) issue(s), but I don't have yet a working implementation.
@tarcieri I finished the refactoring. The PR is ready for review.
Thank you! :+1:
I can cut a release if you'd like
Yeah, that would be nice. Thanks!