Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split permutation from sponge construction
Work towards #29; this doesn't touch the constraint system implementation yet, in order to be able to get design feedback on the software part. - The `poseidon::PoseidonParameters` struct is renamed to `poseidon::Parameters` but otherwise remains unchanged. - The `poseidon::PoseidonSpongeState` struct is renamed to `poseidon::State` and redefined to hold just the state itself, as well as the parameters needed to run the permutation. It exposes a `permute(&mut self)` method, `rate()` and `capacity()` accessors, as well as `Index`, `IndexMut`, `AsRef`, and `AsMut` impls that allow access to the state. - The `poseidon::PoseidonSponge` struct is renamed to `poseidon::Sponge` and holds a `State` and a `DuplexSpongeMode`. 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 `CryptographicSponge` trait is changed so that `new()` 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, a `CryptographicSponge` implementation could declare the associated `Parameters` type to be some shared type (like an `Arc` wrapper) that avoids the need to copy at all. - The `SpongeExt` trait 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.
- Loading branch information