From d665c9ef103219a1990081a47ea735aada3620eb Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 21 Jun 2017 18:57:32 +0200 Subject: [PATCH] Code cleanup from review comments --- cmd/delete.go | 2 +- cmd/get.go | 2 +- cmd/new.go | 2 +- cmd/recover.go | 2 +- cmd/update.go | 2 +- keys/cryptostore/holder.go | 9 +++++++-- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/delete.go b/cmd/delete.go index 6c0185166..033cf2768 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -24,7 +24,7 @@ import ( // deleteCmd represents the delete command var deleteCmd = &cobra.Command{ - Use: "delete ", + Use: "delete [name]", Short: "DANGER: Delete a private key from your system", RunE: runDeleteCmd, } diff --git a/cmd/get.go b/cmd/get.go index 9d30f49b8..dfade2b74 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -22,7 +22,7 @@ import ( // getCmd represents the get command var getCmd = &cobra.Command{ - Use: "get ", + Use: "get [name]", Short: "Get details of one key", Long: `Return public details of one local key.`, RunE: runGetCmd, diff --git a/cmd/new.go b/cmd/new.go index 2969a1042..ce4634074 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -33,7 +33,7 @@ const ( // newCmd represents the new command var newCmd = &cobra.Command{ - Use: "new ", + Use: "new [name]", Short: "Create a new public/private key pair", Long: `Add a public/private key pair to the key store. The password muts be entered in the terminal and not diff --git a/cmd/recover.go b/cmd/recover.go index 3a6953391..f5e4f0527 100644 --- a/cmd/recover.go +++ b/cmd/recover.go @@ -22,7 +22,7 @@ import ( // recoverCmd represents the recover command var recoverCmd = &cobra.Command{ - Use: "recover ", + Use: "recover [name]", Short: "Change the password for a private key", RunE: runRecoverCmd, } diff --git a/cmd/update.go b/cmd/update.go index ec2bd2083..f31af509c 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -24,7 +24,7 @@ import ( // updateCmd represents the update command var updateCmd = &cobra.Command{ - Use: "update ", + Use: "update [name]", Short: "Change the password for a private key", RunE: runUpdateCmd, } diff --git a/keys/cryptostore/holder.go b/keys/cryptostore/holder.go index 6709687d6..0e4fde042 100644 --- a/keys/cryptostore/holder.go +++ b/keys/cryptostore/holder.go @@ -37,8 +37,7 @@ func (s Manager) assertKeyManager() keys.Manager { // Create adds a new key to the storage engine, returning error if // another key already stored under this name // -// algo must be a supported go-crypto algorithm: -// +// algo must be a supported go-crypto algorithm: ed25519, secp256k1 func (s Manager) Create(name, passphrase, algo string) (keys.Info, string, error) { gen, err := getGenerator(algo) if err != nil { @@ -54,6 +53,12 @@ func (s Manager) Create(name, passphrase, algo string) (keys.Info, string, error return info(name, key), phrase, err } +// Recover takes a seed phrase and tries to recover the private key. +// +// If the seed phrase is valid, it will create the private key and store +// it under name, protected by passphrase. +// +// Result similar to New(), except it doesn't return the seed again... func (s Manager) Recover(name, passphrase, seedphrase string) (keys.Info, error) { words := strings.Split(strings.TrimSpace(seedphrase), " ") data, err := s.codec.WordsToBytes(words)