Skip to content

Commit

Permalink
fix pedersen
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Apr 25, 2024
1 parent 8d83f08 commit 9603f14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 6 additions & 4 deletions starknet-core/src/types/contract/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,19 @@ struct AttributeForHintedHash;
impl From<LegacyEntrypointOffset> for u64 {
fn from(value: LegacyEntrypointOffset) -> Self {
match value {
LegacyEntrypointOffset::U64AsHex(inner) => inner,
LegacyEntrypointOffset::U64AsInt(inner) => inner,
LegacyEntrypointOffset::U64AsHex(inner) | LegacyEntrypointOffset::U64AsInt(inner) => {
inner
}
}
}
}

impl From<LegacyEntrypointOffset> for Felt {
fn from(value: LegacyEntrypointOffset) -> Self {
match value {
LegacyEntrypointOffset::U64AsHex(inner) => inner.into(),
LegacyEntrypointOffset::U64AsInt(inner) => inner.into(),
LegacyEntrypointOffset::U64AsHex(inner) | LegacyEntrypointOffset::U64AsInt(inner) => {
inner.into()
}
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions starknet-crypto/src/pedersen_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ use starknet_types_core::felt::Felt;

use crate::pedersen_points::*;

// const SHIFT_POINT: Result<ProjectivePoint, CurveError> =
// ProjectivePoint::from_affine(curve_params::SHIFT_POINT.x(), curve_params::SHIFT_POINT.y());

/// Computes the Starkware version of the Pedersen hash of x and y. All inputs are little-endian.
///
/// ### Arguments
///
/// * `x`: The x coordinate
/// * `y`: The y coordinate
pub fn pedersen_hash(x: &Felt, y: &Felt) -> Felt {
let x = x.to_bits_be();
let y = y.to_bits_be();
let x = x.to_bits_le();
let y = y.to_bits_le();

// Preprocessed material is lookup-tables for each chunk of bits
let table_size = (1 << CURVE_CONSTS_BITS) - 1;
Expand Down

0 comments on commit 9603f14

Please sign in to comment.