Skip to content

Commit

Permalink
Zeroize bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
hmzakhalid committed Dec 19, 2024
1 parent cd4a824 commit 5d5fa3e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ciphernode/enclave/src/commands/net/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ use config::AppConfig;
use enclave_core::{EventBus, GetErrors};
use enclave_node::get_repositories;
use libp2p::identity::Keypair;
use zeroize::Zeroize;

pub async fn execute(config: &AppConfig) -> Result<()> {
let kp = Keypair::generate_ed25519();
println!(
"Generated new keypair with peer ID: {}",
kp.public().to_peer_id()
);
let bytes = kp.try_into_ed25519()?.to_bytes().to_vec();
let mut bytes = kp.try_into_ed25519()?.to_bytes().to_vec();
let cipher = Cipher::from_config(config).await?;
let encrypted = cipher.encrypt_data(&mut bytes.clone())?;
let bus = EventBus::new(true).start();
let repositories = get_repositories(&config, &bus)?;
bytes.zeroize();

// NOTE: We are writing an encrypted string here
repositories.libp2p_keypair().write(&encrypted);
Expand Down

0 comments on commit 5d5fa3e

Please sign in to comment.