Skip to content

Commit b85bf99

Browse files
Dori/swap poseidon implementation (#212)
Signed-off-by: Dori Medini <[email protected]>
1 parent 23f361e commit b85bf99

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/hash.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::fmt::{Debug, Display};
66
use std::io::Error;
77

88
use serde::{Deserialize, Serialize};
9-
use starknet_crypto::{poseidon_hash_many, FieldElement};
9+
use starknet_crypto::FieldElement;
1010
use starknet_types_core::felt::Felt;
11-
use starknet_types_core::hash::{Pedersen, StarkHash as StarknetTypesStarkHash};
11+
use starknet_types_core::hash::{Pedersen, Poseidon, StarkHash as StarknetTypesStarkHash};
1212

1313
use crate::serde_utils::{bytes_from_hex_str, hex_str_from_bytes, BytesAsHex, PrefixedBytesAsHex};
1414
use crate::{impl_from_through_intermediate, StarknetApiError};
@@ -53,10 +53,10 @@ impl Display for PoseidonHash {
5353
}
5454

5555
/// Computes Poseidon hash.
56-
pub fn poseidon_hash_array(felts: &[StarkFelt]) -> PoseidonHash {
57-
// TODO(yair): Avoid allocating the vector of FieldElements.
58-
let as_field_elements = felts.iter().map(|felt| FieldElement::from(*felt)).collect::<Vec<_>>();
59-
PoseidonHash(poseidon_hash_many(as_field_elements.as_slice()).into())
56+
pub fn poseidon_hash_array(stark_felts: &[StarkFelt]) -> PoseidonHash {
57+
// TODO(yair): Avoid allocating the vector of Felts.
58+
let as_felts = stark_felts.iter().map(Felt::from).collect::<Vec<_>>();
59+
PoseidonHash(Poseidon::hash_array(as_felts.as_slice()).into())
6060
}
6161

6262
// TODO: Move to a different crate.

0 commit comments

Comments
 (0)