diff --git a/crypto-primitives/src/sponge/poseidon/mod.rs b/crypto-primitives/src/sponge/poseidon/mod.rs index ff05b9f3..b12cfaee 100644 --- a/crypto-primitives/src/sponge/poseidon/mod.rs +++ b/crypto-primitives/src/sponge/poseidon/mod.rs @@ -292,7 +292,9 @@ impl CryptographicSponge for PoseidonSponge { &mut self, sizes: &[FieldElementSize], ) -> Vec { - if F::characteristic() == F2::characteristic() { + // Use exact type match for native case to avoid incorrect casts across distinct fields + // that share the same field characteristic. + if TypeId::of::() == TypeId::of::() { // native case let mut buf = Vec::with_capacity(sizes.len()); field_cast(