From 834b42bb3183ab869e323261dba8ceb4dc9247b3 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Sat, 22 Jun 2019 16:35:46 -0700 Subject: [PATCH] get public key from encrypted bls file and passphrase --- cmd/client/wallet/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/client/wallet/main.go b/cmd/client/wallet/main.go index 622bc403a..5fca86aa0 100644 --- a/cmd/client/wallet/main.go +++ b/cmd/client/wallet/main.go @@ -112,6 +112,7 @@ var ( getBlsPublicCommand = flag.NewFlagSet("getBlsPublic", flag.ExitOnError) blsKey2 = getBlsPublicCommand.String("key", "", "The raw private key.") + blsFile2 = getBlsPublicCommand.String("file", "", "The encrypted bls file.") ) var ( @@ -175,6 +176,7 @@ func main() { fmt.Println(" --key - Raw private key.") fmt.Println(" 14. getBlsPublic - Show Bls public key given raw private bls key.") fmt.Println(" --key - Raw private key.") + fmt.Println(" --file - encrypted bls file.") os.Exit(1) } @@ -608,6 +610,19 @@ func getBlsPublic() { os.Exit(101) } fmt.Printf("Your bls public key is: %s\n", privateKey.GetPublicKey().SerializeToHexStr()) + } else if *blsFile2 != "" { + password := utils.AskForPassphrase("Passphrase: ") + password2 := utils.AskForPassphrase("Passphrase again: ") + if password != password2 { + fmt.Printf("Passphrase doesn't match. Please try again!\n") + os.Exit(100) + } + privateKey, err := blsgen.LoadBlsKeyWithPassPhrase(*blsFile2, password) + if err != nil { + fmt.Printf("error when loading bls key, err :%v\n", err) + os.Exit(100) + } + fmt.Printf("Your bls public key is: %s\n", privateKey.GetPublicKey().SerializeToHexStr()) } else { fmt.Println("Please specify the hexadecimal private key string using --key") }