Skip to content

Commit

Permalink
tests are consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Margolin committed Oct 15, 2024
1 parent b4bbe32 commit 71053a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion crypto-primitives/src/sponge/poseidon/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl<F: PrimeField> CryptographicSpongeVar<F, PoseidonSponge<F>> for PoseidonSpo
) -> Result<Vec<FpVar<F>>, SynthesisError> {
let zero = FpVar::zero();
let mut squeezed_elems = vec![zero; num_elements];
// self.permute()?;
match self.mode {
DuplexSpongeMode::Absorbing {
next_absorb_index: _,
Expand All @@ -279,8 +280,8 @@ impl<F: PrimeField> CryptographicSpongeVar<F, PoseidonSponge<F>> for PoseidonSpo
}
DuplexSpongeMode::Squeezing { next_squeeze_index } => {
let mut squeeze_index = next_squeeze_index;
self.permute()?;
if squeeze_index == self.parameters.rate {
self.permute()?;
squeeze_index = 0;
}
self.squeeze_internal(squeeze_index, &mut squeezed_elems)?;
Expand Down
3 changes: 1 addition & 2 deletions crypto-primitives/src/sponge/poseidon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<F: PrimeField> CryptographicSponge for PoseidonSponge<F> {
if elems.is_empty() {
return;
}

match self.mode {
DuplexSpongeMode::Absorbing { next_absorb_index } => {
let mut absorb_index = next_absorb_index;
Expand All @@ -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
5 changes: 1 addition & 4 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 Expand Up @@ -1050,4 +1047,4 @@ pub(crate) fn poseidon_parameters_for_test<F: PrimeField>() -> PoseidonConfig<F>
rate,
capacity,
}
}
}

0 comments on commit 71053a1

Please sign in to comment.