Skip to content

Commit

Permalink
fix: bytearray
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnordelo committed Nov 12, 2024
1 parent 70a2785 commit 3c67aac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/utils/src/bytearray.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ pub fn to_byte_array<T, +Into<T, felt252>, +Copy<T>>(
/// then hashing the span using the Poseidon hash algorithm.
pub fn hash_byte_array(data: @ByteArray) -> felt252 {
let mut serialized = array![];

data.serialize(ref serialized);
let len = serialized.len();

let mut state = PedersenTrait::new(0);
for elem in serialized {
state = state.update_with(elem);
};
state = state.update_with(serialized.len());
state = state.update_with(len);
state.finalize()
}

Expand Down

0 comments on commit 3c67aac

Please sign in to comment.