Skip to content

Commit

Permalink
Check seed phrase entropy and warn user when using a 12-word seed.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Jan 21, 2025
1 parent 1160470 commit 8b51eba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/soroban-cli/src/commands/keys/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use clap::command;

use crate::{
commands::global,
config::{address::KeyName, locator, secret},
config::{
address::KeyName,
locator,
secret::{self, Secret},
},
print::Print,
};

Expand Down Expand Up @@ -32,6 +36,16 @@ impl Cmd {
pub fn run(&self, global_args: &global::Args) -> Result<(), Error> {
let print = Print::new(global_args.quiet);
let secret = self.secrets.read_secret()?;

if let Secret::SeedPhrase { seed_phrase } = &secret {
if seed_phrase.split_whitespace().count() < 24 {
print.warnln(format!("The provided seed phrase lacks sufficient entropy and should be avoided. Using a 24-word seed phrase is a safer option."));
print.warnln(format!(
"To generate a new key, use the `stellar keys generate` command."
));
}
}

let path = self.config_locator.write_identity(&self.name, &secret)?;
print.checkln(format!("Key saved with alias {:?} in {path:?}", self.name));
Ok(())
Expand Down

0 comments on commit 8b51eba

Please sign in to comment.