Skip to content

Commit

Permalink
zeroize and OsRng
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev3rlasting committed Jan 26, 2025
1 parent 28b2cbc commit f4201d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bip39 = { version = "2.1.0", features = ["chinese-simplified", "chinese-traditio
rand = "0.7.3"
shamir_secret_sharing = "0.1.1"
num-bigint = "0.2.6"
zeroize = "1.8.1"
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use bip39::Mnemonic;
use num_bigint::BigInt;
use rand::{thread_rng, RngCore};
use rand::RngCore;
use shamir_secret_sharing::ShamirSecretSharing as SSS;
use std::{
fmt::Display,
io::{self, Write},
};
use rand::rngs::OsRng;
use zeroize::Zeroizing;

const PRIME_HEX: &str = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f";
#[derive(Clone)]
Expand All @@ -32,9 +34,9 @@ impl Display for Shamir39Share {
}
}

fn generate_secure_entropy(byte_length: usize) -> Vec<u8> {
let mut entropy = vec![0u8; byte_length];
thread_rng().fill_bytes(&mut entropy);
fn generate_secure_entropy(byte_length: usize) -> Zeroizing<Vec<u8>> {
let mut entropy = Zeroizing::new(vec![0u8; byte_length]);
OsRng.fill_bytes(&mut entropy);
entropy
}
fn bytes_to_mnemonic(bytes: &[u8], language: bip39::Language) -> Mnemonic {
Expand Down

0 comments on commit f4201d8

Please sign in to comment.