Skip to content

Commit

Permalink
Remove unneeded permute from Poseidon hashing (#152)
Browse files Browse the repository at this point in the history
* removed unneeded permutes

* tests are consistent

* Apply suggestions from code review

* formatting

---------

Co-authored-by: Eli Margolin <[email protected]>
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Eli Margolin <[email protected]>
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Eli Margolin <[email protected]>
  • Loading branch information
6 people authored Oct 16, 2024
1 parent 8fbf5ef commit e51fc42
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 5 deletions.
1 change: 0 additions & 1 deletion crypto-primitives/src/sponge/poseidon/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ impl<F: PrimeField> CryptographicSpongeVar<F, PoseidonSponge<F>> for PoseidonSpo
DuplexSpongeMode::Squeezing {
next_squeeze_index: _,
} => {
self.permute()?;
self.absorb_internal(0, input.as_slice())?;
}
};
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/sponge/poseidon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ impl<F: PrimeField> CryptographicSponge for PoseidonSponge<F> {
DuplexSpongeMode::Squeezing {
next_squeeze_index: _,
} => {
self.permute();
self.absorb_internal(0, elems.as_slice());
}
};
Expand Down
3 changes: 0 additions & 3 deletions crypto-primitives/src/sponge/poseidon/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ fn run_cross_test<F: PrimeField + Absorb>(cfg: &PoseidonConfig<F>) {
match self.mode() {
SpongeMode::Absorbing => self.absorbing.extend_from_slice(input),
SpongeMode::Squeezing => {
// Wash the state as mode changes
// This is not appied in SAFE sponge
permute(&self.cfg, &mut self.state);
// Append inputs to the absorbing line
self.absorbing.extend_from_slice(input);
// Change mode to absorbing
Expand Down

0 comments on commit e51fc42

Please sign in to comment.