-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/os keychain followup #1770
base: main
Are you sure you want to change the base?
Conversation
244508d
to
a97ccbb
Compare
072a3af
to
e120595
Compare
df3543a
to
3311a50
Compare
6a4b0ff
to
f263d8d
Compare
c39bf60
to
fe02078
Compare
f4e2913
to
3acc3d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to try this out locally, but correct me if I'm wrong, but it's possible to have the name used in keys add
differ from what is used in entry-name
?
Good call! Yeah, at the moment, this is possible. It still ends up working because we are saving the value of Though, this may be confusing. 🤔 Instead, we could remove the But, now I'm starting to wonder if we shouldn't allow users to add keys from the keychain at all. If we do, we'd need to make sure that users add the keys to their secure store with:
And we could probably do that, but I'm not sure how necessary this feature is. 🤔 |
Since we are now planning to store the seed phrase instead of the signing key in the OS secure storage, I think that a more useful feature would be to allow a user to add a new key with their seed phrase, which is saved in secure storage instead of in the local file. So the command could look like this:
which would then prompt the user to enter their seed phrase:
|
- this is the only place it is being used - also, this help with a cyclic dependency i was noticing when trying to use secure_store in secret and generate
7b8d00c
to
8e234bc
Compare
let path = self.config_locator.write_identity(&self.name, &secret)?; | ||
print.checkln(format!("Key saved with alias {:?} in {path:?}", self.name)); | ||
Ok(()) | ||
} | ||
|
||
fn read_secret(&self, print: &Print) -> Result<Secret, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved this here from config/secret.rs
- i was seeing an interesting cyclical dependency, and moving this here helped that be a bit less confusing.
let prompt = "Type a 12 or 24 word seed phrase:"; | ||
let secret_key = read_password(print, prompt)?; | ||
|
||
let seed_phrase: SeedPhrase = secret_key.parse()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment I only added support for a user to add a new seed phrase to secure storage. I'm happy to make a change so that this supports adding a private key directly as well, but wanted to get some more eyes on this to see if folks thought it was worth the effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's always a mistake to use a private key directly when storing keys. It has no recovery method and almost all wallets to my knowledge use a seed phrase so if users would be importing it wouldn't be a Secret Key.
@@ -0,0 +1,59 @@ | |||
use sep5::SeedPhrase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure if this needs its own mod, or exactly where to put this, but I wanted to pull the code out where both add
and generate
could use it
} | ||
|
||
fn write_to_secure_store( | ||
entry_name: &String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entry_name: &String, | |
entry_name: &str, |
if let Secret::SecureStore { entry_name } = identity { | ||
let entry = StellarEntry::new(&entry_name)?; | ||
match entry.delete_seed_phrase() { | ||
Ok(()) => {} | ||
Err(e) => match e { | ||
signer::keyring::Error::Keyring(keyring::Error::NoEntry) => { | ||
print.infoln("This key was already removed from the secure store. Removing the cli config file."); | ||
} | ||
_ => { | ||
return Err(Error::Keyring(e)); | ||
} | ||
}, | ||
} | ||
} | ||
KeyType::Identity.remove(name, &self.config_dir()?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this will be an issue, but it seems like it could be possible for the keyring to successfully delete the key but not the Identity file? I think we can assume this isn't the case since we read the id first.
🎉 |
What
This PR is based on #1703 and adds some additional compatibility with the secure store like
keys rm
andkeys add
.keys rm
keys add
cargo run keys add --secure-store alice
(will be prompted for a seed phrase)cargo run keys address alice
stello keys rm alice
Why
I wanted to keep #1703 from getting too big so it was easier to review.
Known limitations
[TODO or N/A]