Skip to content

Commit

Permalink
Implement Drop for Scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas committed Oct 3, 2019
1 parent 11ba23a commit c05c4e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libsecp256k1"
description = "Pure Rust secp256k1 implementation."
license = "Apache-2.0"
version = "0.4.0"
version = "0.3.1"
authors = ["Wei Tang <hi@that.world>"]
repository = "https://github.com/sorpaas/libsecp256k1-rs"
keywords = [ "crypto", "ECDSA", "secp256k1", "bitcoin", "no_std" ]
Expand Down
6 changes: 6 additions & 0 deletions src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const SECP256K1_N_H_7: u32 = 0x7FFFFFFF;
/// A 256-bit scalar value.
pub struct Scalar(pub [u32; 8]);

impl Drop for Scalar {
fn drop(&mut self) {
self.clear();
}
}

impl Scalar {
/// Clear a scalar to prevent the leak of sensitive data.
pub fn clear(&mut self) {
Expand Down

0 comments on commit c05c4e0

Please sign in to comment.