Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion starknet-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ serde_json = { version = "1.0.96", default-features = false, features = ["alloc"
serde_json_pythonic = { version = "0.1.2", default-features = false, features = ["alloc", "raw_value"] }
serde_with = { version = "3.9.0", default-features = false, features = ["alloc", "macros"] }
sha3 = { version = "0.10.7", default-features = false }
starknet-types-core = { version = "0.1.7", default-features = false, features = ["curve", "serde", "num-traits"] }
starknet-types-core = { version = "0.1.8", default-features = false, features = ["curve", "serde", "num-traits", "zeroize"] }

[dev-dependencies]
bincode = "1.3.3"
Expand Down
4 changes: 2 additions & 2 deletions starknet-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rfc6979 = { version = "0.4.0", default-features = false }
sha2 = { version = "0.10.6", default-features = false }
zeroize = { version = "1.6.0", default-features = false }
hex = { version = "0.4.3", default-features = false, optional = true }
starknet-types-core = { version = "0.1.7", default-features = false, features = ["curve", "hash"] }
starknet-types-core = { version = "0.1.8", default-features = false, features = ["curve", "hash"] }

[features]
default = ["std", "signature-display"]
Expand All @@ -39,7 +39,7 @@ hex = "0.4.3"
hex-literal = "0.4.1"
serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96"
starknet-types-core = { version = "0.1.7", default-features = false, features = ["alloc"] }
starknet-types-core = { version = "0.1.8", default-features = false, features = ["alloc"] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.50"
Expand Down
2 changes: 1 addition & 1 deletion starknet-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Stark curve
keywords = ["ethereum", "starknet", "web3", "no_std"]

[dependencies]
starknet-types-core = { version = "0.1.7", default-features = false, features = ["curve"] }
starknet-types-core = { version = "0.1.8", default-features = false, features = ["curve"] }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest version of starknet-types-core support operations on EC points as well starknet-io/types-rs@e0eff28


[lints]
workspace = true
1 change: 1 addition & 0 deletions starknet-signers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rand = { version = "0.8.5", features = ["std_rng"] }
coins-bip32 = { version = "0.11.1", optional = true }
coins-ledger = { version = "0.12.0", default-features = false, optional = true }
semver = { version = "1.0.23", optional = true }
zeroize = { version = "1.8.1", features = ["derive", "zeroize_derive"] }

[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
eth-keystore = { version = "0.5.0", default-features = false }
Expand Down
9 changes: 5 additions & 4 deletions starknet-signers/src/key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use starknet_core::{
types::Felt,
};
use starknet_crypto::get_public_key;
use zeroize::{Zeroize, ZeroizeOnDrop};

/// A ECDSA signing (private) key on the STARK curve.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Zeroize, ZeroizeOnDrop)]
pub struct SigningKey {
secret_scalar: Felt,
}
Expand Down Expand Up @@ -100,8 +101,8 @@ impl SigningKey {
}

/// Gets the secret scalar in the signing key.
pub const fn secret_scalar(&self) -> Felt {
self.secret_scalar
pub const fn secret_scalar(&self) -> &Felt {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What motivated a change to & when Felt is copiable? Most usage takes a Felt as argument which would lead to a copy while dereferencing.

Copy link
Author

@FilipLaurentiu FilipLaurentiu May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What motivated a change to & when Felt is copiable? Most usage takes a Felt as argument which would lead to a copy while dereferencing.

For this case, the motivation is to avoid creating another copy of a Felt that will not be zeroized on drop and stay in memory. Returning just a reference to the internal value will solve this problem, the value will still be zeroized at the end.

&self.secret_scalar
}

/// Derives the verifying (public) key that corresponds to the signing key.
Expand Down Expand Up @@ -147,7 +148,7 @@ mod tests {

let signing_key = SigningKey::from_secret_scalar(private_key);

assert_eq!(signing_key.secret_scalar(), private_key);
assert_eq!(*signing_key.secret_scalar(), private_key);
}

#[test]
Expand Down