diff --git a/starknet-core/src/crypto.rs b/starknet-core/src/crypto.rs index e703fc24..41af08e8 100644 --- a/starknet-core/src/crypto.rs +++ b/starknet-core/src/crypto.rs @@ -46,14 +46,19 @@ mod errors { } pub use errors::{EcdsaSignError, EcdsaVerifyError}; -pub fn compute_hash_on_elements(data: &[FieldElement]) -> FieldElement { +pub fn compute_hash_on_elements<'a, ESI, II>(data: II) -> FieldElement +where + ESI: ExactSizeIterator, + II: IntoIterator, +{ let mut current_hash = FieldElement::ZERO; + let iter = data.into_iter(); + let data_len = FieldElement::from(iter.len()); - for item in data.iter() { + for item in iter { current_hash = pedersen_hash(¤t_hash, item); } - let data_len = FieldElement::from(data.len()); pedersen_hash(¤t_hash, &data_len) }