Skip to content

Commit

Permalink
bump outdated starknet related versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Sep 20, 2024
1 parent e573182 commit 42e77cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ thiserror = "1.0" # Error handling
async-trait = "0.1.74" # Async traits
hex = "0.4.3" # Hex encoding
tiny-keccak = "2.0.2" # Keccak hashing
starknet = "0.6.0" # StarkNet pedersen
starknet-crypto = "0.6.0" # StarkNet poseidon
starknet = "0.11.0"
starknet-crypto = "0.7.1"
starknet-types-core = "0.1.5"
uuid = { version = "1.4.1", features = ["v4"] } # UUID
parking_lot = "0.12.1" # Sync mutex
num-bigint = "0.4.4" # Bigints in hashers (TODO: double check if needed)
Expand Down
2 changes: 1 addition & 1 deletion src/hasher/core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use starknet::core::types::FromStrError;
use starknet_types_core::felt::FromStrError;
use std::{fmt::Debug, str::FromStr};
use strum_macros::EnumIter;
use thiserror::Error;
Expand Down
10 changes: 4 additions & 6 deletions src/hasher/hashers/stark_pedersen.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use starknet::core::{crypto::pedersen_hash, types::FieldElement};
use starknet::core::crypto::pedersen_hash;
use starknet_crypto::Felt;

use crate::hasher::{byte_size, HasherError, HashingFunction};

Expand Down Expand Up @@ -69,11 +70,8 @@ impl StarkPedersenHasher {
self.is_element_size_valid(element)?;
}

let result = pedersen_hash(
&FieldElement::from_hex_be(&data[0])?,
&FieldElement::from_hex_be(&data[1])?,
)
.to_bytes_be();
let result =
pedersen_hash(&Felt::from_hex(&data[0])?, &Felt::from_hex(&data[1])?).to_bytes_be();

let padded_hex_str = format!("0x{:0>64}", hex::encode(result));
Ok(padded_hex_str)
Expand Down
5 changes: 2 additions & 3 deletions src/hasher/hashers/stark_poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::hasher::{byte_size, HasherError, HashingFunction};

use super::super::Hasher;
use starknet::core::types::FieldElement;
use starknet_crypto::{poseidon_hash, poseidon_hash_many, poseidon_hash_single};
use starknet_crypto::{poseidon_hash, poseidon_hash_many, poseidon_hash_single, Felt};

/// Hasher for Stark Poseidon
#[derive(Debug, Clone)]
Expand All @@ -26,7 +25,7 @@ impl Hasher for StarkPoseidonHasher {
self.is_element_size_valid(element)?;
}

let field_elements: Vec<FieldElement> =
let field_elements: Vec<Felt> =
data.iter().map(|e| e.parse().unwrap_or_default()).collect();

let hash_core = match field_elements.len() {
Expand Down

0 comments on commit 42e77cd

Please sign in to comment.