@@ -6,9 +6,9 @@ use std::fmt::{Debug, Display};
6
6
use std:: io:: Error ;
7
7
8
8
use serde:: { Deserialize , Serialize } ;
9
- use starknet_crypto:: { poseidon_hash_many , FieldElement } ;
9
+ use starknet_crypto:: FieldElement ;
10
10
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 } ;
12
12
13
13
use crate :: serde_utils:: { bytes_from_hex_str, hex_str_from_bytes, BytesAsHex , PrefixedBytesAsHex } ;
14
14
use crate :: { impl_from_through_intermediate, StarknetApiError } ;
@@ -53,10 +53,10 @@ impl Display for PoseidonHash {
53
53
}
54
54
55
55
/// 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 ( ) )
60
60
}
61
61
62
62
// TODO: Move to a different crate.
0 commit comments