get public key from encrypted bls file and passphrase

pull/1142/head
Minh Doan 6 years ago committed by Minh Doan
parent da335a65c7
commit 834b42bb31
  1. 15
      cmd/client/wallet/main.go

@ -112,6 +112,7 @@ var (
getBlsPublicCommand = flag.NewFlagSet("getBlsPublic", flag.ExitOnError) getBlsPublicCommand = flag.NewFlagSet("getBlsPublic", flag.ExitOnError)
blsKey2 = getBlsPublicCommand.String("key", "", "The raw private key.") blsKey2 = getBlsPublicCommand.String("key", "", "The raw private key.")
blsFile2 = getBlsPublicCommand.String("file", "", "The encrypted bls file.")
) )
var ( var (
@ -175,6 +176,7 @@ func main() {
fmt.Println(" --key - Raw private key.") fmt.Println(" --key - Raw private key.")
fmt.Println(" 14. getBlsPublic - Show Bls public key given raw private bls key.") fmt.Println(" 14. getBlsPublic - Show Bls public key given raw private bls key.")
fmt.Println(" --key - Raw private key.") fmt.Println(" --key - Raw private key.")
fmt.Println(" --file - encrypted bls file.")
os.Exit(1) os.Exit(1)
} }
@ -608,6 +610,19 @@ func getBlsPublic() {
os.Exit(101) os.Exit(101)
} }
fmt.Printf("Your bls public key is: %s\n", privateKey.GetPublicKey().SerializeToHexStr()) 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 { } else {
fmt.Println("Please specify the hexadecimal private key string using --key") fmt.Println("Please specify the hexadecimal private key string using --key")
} }

Loading…
Cancel
Save