-
Notifications
You must be signed in to change notification settings - Fork 133
Use zeroize
crate for SigningKey.
#735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
292b077
61105cb
6aa4be9
2b3d7ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
} | ||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What motivated a change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For this case, the motivation is to avoid creating another copy of a |
||
&self.secret_scalar | ||
} | ||
|
||
/// Derives the verifying (public) key that corresponds to the signing key. | ||
|
@@ -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] | ||
|
There was a problem hiding this comment.
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