paritytech / libsecp256k1

Pure Rust Implementation of secp256k1.
Apache License 2.0
172 stars 84 forks source link

Add clean() and is_zero() to SecretKey to clean up the memories #149

Closed chiro-hiro closed 1 year ago

chiro-hiro commented 1 year ago

This pull request aimed to solve #130, example use case:

// Generate raw key pair in bytes array
pub fn generate_raw_keypair() -> RawKeyPair {
    let mut rng = thread_rng();
    let secret = SecretKey::random(&mut rng);
    let secret_key = secret.serialize();
    secret.clear();
    let public_key = PublicKey::from_secret_key(&secret).serialize();
    RawKeyPair {
        public_key,
        secret_key,
    }
}