From fcdef227e4b5bb66e98005643f7d62459cc3f4fa Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 31 May 2021 11:55:38 +0300 Subject: [PATCH] [#562] cmd/neofs-cli: use NEP-6 wallet for keys Encrypted NEP-2 is still supported. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-cli/modules/root.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index 08be163c3..446828824 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -2,9 +2,7 @@ package cmd import ( "crypto/ecdsa" - "crypto/rand" "crypto/tls" - "encoding/hex" "errors" "fmt" "os" @@ -18,7 +16,6 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/owner" - crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-node/pkg/network" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -138,21 +135,11 @@ const nep2Base58Length = 58 func getKey() (*ecdsa.PrivateKey, error) { privateKey := viper.GetString("key") if privateKey == generateKeyConst { - buf := make([]byte, crypto.PrivateKeyCompressedSize) - - _, err := rand.Read(buf) + priv, err := keys.NewPrivateKey() if err != nil { return nil, errCantGenerateKey } - - printVerbose("Generating private key:", hex.EncodeToString(buf)) - - return crypto.UnmarshalPrivateKey(buf) - } - - key, err := crypto.LoadPrivateKey(privateKey) - if err == nil { - return key, nil + return &priv.PrivateKey, nil } w, err := wallet.NewWalletFromFile(privateKey)