Conversation
| let mut buf = Array::<u8, Rate>::default(); | ||
| let mut chunks = buf.chunks_exact_mut(size_of::<u64>()); | ||
| for (src, dst) in state.iter().zip(&mut chunks) { | ||
| dst.copy_from_slice(&src.to_le_bytes()); |
There was a problem hiding this comment.
Implementation of xor_in and read_into for big-endian targets is quite sub-optimal, but I prioritized simplicity of implementation. Considering that big-endian targets are practically extinct, I think it's a fine trade-off. We could easily improve it in future if someone interested in it.
| /// `Rate` MUST be smaller than `U256`, trying to initialize cursor with an invalid rate will | ||
| /// result in a compilation error. | ||
| #[derive(Debug, Clone)] | ||
| pub struct SpongeCursor<Rate: ArraySize> { |
There was a problem hiding this comment.
It's possible to implement the crate using const generics (i.e. const RATE: usize instead of Rate: ArraySize>), but it would not work with generic rates (e.g. in cshake) since we can not currently use SpongeCursor<{ Rate::USIZE }>.
We could drop the BlockSizeUser impl and use const generic rates in implementation crates (since they are unlikely to be used with HMAC), but I am not sure whether we should do it.
sponge-cursoris a helper crate which allows to remove unnecessary buffering from sponge-based constructions.TODO: add tests, examples, and CI config