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 22, 2025
1 parent f4a1fdf commit b1e7c93
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 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,12 @@ use clap::command;

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

Expand Down Expand Up @@ -40,9 +45,21 @@ impl Cmd {
} else {
self.secrets.read_secret()?.into()
};

let print = Print::new(global_args.quiet);
let path = self.config_locator.write_key(&self.name, &key)?;

if let Key::Secret(Secret::SeedPhrase { seed_phrase }) = key {
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."
));
}
}

print.checkln(format!("Key saved with alias {:?} in {path:?}", self.name));

Ok(())
}
}

0 comments on commit b1e7c93

Please sign in to comment.