sponge
sponge copied to clipboard
Split permutation from sponge construction
Work towards arkworks-rs/crypto-primitives#93; this doesn't touch the constraint system implementation yet, in order to be able to get design feedback on the software part.
-
The
poseidon::PoseidonParametersstruct is renamed toposeidon::Parametersbut otherwise remains unchanged. -
The
poseidon::PoseidonSpongeStatestruct is renamed toposeidon::Stateand redefined to hold just the state itself, as well as the parameters needed to run the permutation. It exposes apermute(&mut self)method,rate()andcapacity()accessors, as well asIndex,IndexMut,AsRef, andAsMutimpls that allow access to the state. -
The
poseidon::PoseidonSpongestruct is renamed toposeidon::Spongeand holds aStateand aDuplexSpongeMode. In other words, it consists of the state, together with the extra data tracking how that state is being used to implement a higher-level duplex construction. -
The
CryptographicSpongetrait is changed so thatnew()takes an owned,Self::Parameters, not a borrowed one. This allows the caller to decide where to copy data, instead of forcing the sponge implementation to clone internally. Or, aCryptographicSpongeimplementation could declare the associatedParameterstype to be some shared type (like anArcwrapper) that avoids the need to copy at all. -
The
SpongeExttrait that allows converting back and forth between a state and a sponge is deleted; it's not safe to pass between abstraction layers that way.
Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why.
- [x] Targeted PR against correct branch (master)
- [x] Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
- ~~[ ] Wrote unit tests~~
- [x] Updated relevant documentation in the code
- [ ] Added a relevant changelog entry to the
Pendingsection inCHANGELOG.md - [ ] Re-reviewed
Files changedin the Github PR explorer
(A rendered copy of the docs is available here: https://rustdoc.penumbra.zone/main/ark_sponge/poseidon/index.html)
The changes look great so far, though I'm not the most qualified to review this stuff; @ValarDragon and @weikengchen are more familiar with this code. Also, is there something specific that you'd like to get feedback on?
Also, is there something specific that you'd like to get feedback on?
Yeah, the main thing is whether this general approach seems good, before doing the work of also updating the constraint implementations.
Hey, just bumping this -- if this approach seems good I can also apply it to the constraint implementations.
Feel free to apply to the constraints implementations.