diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/storage/map.nr b/noir-projects/noir-protocol-circuits/crates/types/src/storage/map.nr index 13a82bc58b58..585c3ead13fb 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/storage/map.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/storage/map.nr @@ -1,7 +1,7 @@ -use crate::{hash::pedersen_hash, traits::ToField}; +use crate::{hash::poseidon2_hash_with_separator, traits::ToField}; pub fn derive_storage_slot_in_map(storage_slot: Field, key: K) -> Field where K: ToField { - pedersen_hash([storage_slot, key.to_field()], 0) + poseidon2_hash_with_separator([storage_slot, key.to_field()], 0) } mod test { diff --git a/noir/noir-repo/noir_stdlib/src/hash/mod.nr b/noir/noir-repo/noir_stdlib/src/hash/mod.nr index c69c3f9c49ef..f555e63d385a 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/mod.nr @@ -33,16 +33,11 @@ pub fn pedersen_commitment(input: [Field; N]) -> EmbeddedCurvePoint } pub fn pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field { - __pedersen_hash_with_separator(input, separator) + pedersen_hash_with_separator_noir(input, separator) } pub fn pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> EmbeddedCurvePoint { - let value = __pedersen_commitment_with_separator(input, separator); - if (value[0] == 0) & (value[1] == 0) { - EmbeddedCurvePoint { x: 0, y: 0, is_infinite: true } - } else { - EmbeddedCurvePoint { x: value[0], y: value[1], is_infinite: false } - } + pedersen_commitment_with_separator_noir(input, separator) } #[no_predicates] @@ -78,7 +73,7 @@ fn pedersen_hash_with_separator_noir(input: [Field; N], separator: u pub fn pedersen_hash(input: [Field; N]) -> Field // docs:end:pedersen_hash { - __pedersen_hash_with_separator(input, 0) + pedersen_hash_with_separator_noir(input, 0) } #[foreign(pedersen_hash)] diff --git a/yarn-project/circuits.js/src/hash/map_slot.ts b/yarn-project/circuits.js/src/hash/map_slot.ts index d14b85b0ea9f..8ffed794039d 100644 --- a/yarn-project/circuits.js/src/hash/map_slot.ts +++ b/yarn-project/circuits.js/src/hash/map_slot.ts @@ -1,4 +1,4 @@ -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2Hash } from '@aztec/foundation/crypto'; import { type Fr } from '@aztec/foundation/fields'; /** @@ -14,5 +14,5 @@ export function deriveStorageSlotInMap( toField: () => Fr; }, ): Fr { - return pedersenHash([mapSlot, key.toField()]); + return poseidon2Hash([mapSlot, key.toField()]); }