feat: add hash_iter to algebraic sponge hash functions#823
Open
Farukest wants to merge 2 commits into0xMiden:nextfrom
Open
feat: add hash_iter to algebraic sponge hash functions#823Farukest wants to merge 2 commits into0xMiden:nextfrom
Farukest wants to merge 2 commits into0xMiden:nextfrom
Conversation
Add `AlgebraicSponge::hash_iter()` which accepts an iterator of field elements instead of a slice, avoiding intermediate allocations when elements are produced lazily or come from multiple sources. The method is exposed on Rpo256, Rpx256, and Poseidon2 and produces identical output to `hash_elements` for the same input sequence. Closes 0xMiden#571
c6c568b to
f88eaa8
Compare
Contributor
|
Let's hold off on this for now. This is not a priority, and our review bandwidth is limited at the moment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AlgebraicSponge::hash_iter()acceptingimpl IntoIterator<Item = Felt>withExactSizeIteratorboundRpo256,Rpx256, andPoseidon2hash_elements— avoids intermediateVecallocations when elements come from iteratorsCloses #571
Test plan
hash_iter_vs_hash_elementstest: empty, single, partial rate, exact rate, multi-rate, and all 19 known test vectorscargo +nightly fmt --checkcargo clippy -p miden-cryptocargo doc -p miden-crypto --no-deps