Add optional zeroize support
This commit is contained in:
parent
520e15a6e5
commit
a298344178
|
@ -46,6 +46,7 @@ rand_core = "0.4.0"
|
|||
unicode-normalization = { version = "=0.1.9", optional = true }
|
||||
rand = { version = "0.6.0", optional = true }
|
||||
serde = { version = "1.0", default-features = false, optional = true }
|
||||
zeroize = {version = "1.2", optional = true}
|
||||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.6.0", optional = false }
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -53,6 +53,11 @@ use bitcoin_hashes::{sha256, Hash};
|
|||
#[cfg(feature = "std")]
|
||||
use unicode_normalization::UnicodeNormalization;
|
||||
|
||||
#[cfg(feature = "zeroize")]
|
||||
extern crate zeroize;
|
||||
#[cfg(feature = "zeroize")]
|
||||
use zeroize::Zeroize;
|
||||
|
||||
#[macro_use]
|
||||
mod internal_macros;
|
||||
mod language;
|
||||
|
@ -160,6 +165,13 @@ pub struct Mnemonic {
|
|||
words: [u16; MAX_NB_WORDS],
|
||||
}
|
||||
|
||||
#[cfg(feature = "zeroize")]
|
||||
impl Zeroize for Mnemonic {
|
||||
fn zeroize(&mut self) {
|
||||
self.words.zeroize()
|
||||
}
|
||||
}
|
||||
|
||||
serde_string_impl!(Mnemonic, "a BIP-39 Mnemonic Code");
|
||||
|
||||
impl Mnemonic {
|
||||
|
|
Loading…
Reference in New Issue