Skip to content

feat: add hash_iter to algebraic sponge hash functions#823

Open
Farukest wants to merge 2 commits into0xMiden:nextfrom
Farukest:feat/hash-iter-571
Open

feat: add hash_iter to algebraic sponge hash functions#823
Farukest wants to merge 2 commits into0xMiden:nextfrom
Farukest:feat/hash-iter-571

Conversation

@Farukest
Copy link
Contributor

Summary

  • Add AlgebraicSponge::hash_iter() accepting impl IntoIterator<Item = Felt> with ExactSizeIterator bound
  • Exposed as public methods on Rpo256, Rpx256, and Poseidon2
  • Produces identical output to hash_elements — avoids intermediate Vec allocations when elements come from iterators

Closes #571

Test plan

  • hash_iter_vs_hash_elements test: empty, single, partial rate, exact rate, multi-rate, and all 19 known test vectors
  • cargo +nightly fmt --check
  • cargo clippy -p miden-crypto
  • cargo doc -p miden-crypto --no-deps

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
@bobbinth
Copy link
Contributor

Let's hold off on this for now. This is not a priority, and our review bandwidth is limited at the moment.

@bobbinth bobbinth added the on hold Currently not a priority label Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold Currently not a priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AlgebraicSponge should support hashing from iterators

2 participants