forked from TrueCloudLab/frostfs-node
[#562] cmd/neofs-cli: use NEP-6 wallet for keys
Encrypted NEP-2 is still supported. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
3f07313604
commit
fcdef227e4
1 changed files with 2 additions and 15 deletions
|
@ -2,9 +2,7 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"crypto/rand"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/hex"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -18,7 +16,6 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
"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/nspcc-dev/neofs-node/pkg/network"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -138,21 +135,11 @@ const nep2Base58Length = 58
|
||||||
func getKey() (*ecdsa.PrivateKey, error) {
|
func getKey() (*ecdsa.PrivateKey, error) {
|
||||||
privateKey := viper.GetString("key")
|
privateKey := viper.GetString("key")
|
||||||
if privateKey == generateKeyConst {
|
if privateKey == generateKeyConst {
|
||||||
buf := make([]byte, crypto.PrivateKeyCompressedSize)
|
priv, err := keys.NewPrivateKey()
|
||||||
|
|
||||||
_, err := rand.Read(buf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errCantGenerateKey
|
return nil, errCantGenerateKey
|
||||||
}
|
}
|
||||||
|
return &priv.PrivateKey, nil
|
||||||
printVerbose("Generating private key:", hex.EncodeToString(buf))
|
|
||||||
|
|
||||||
return crypto.UnmarshalPrivateKey(buf)
|
|
||||||
}
|
|
||||||
|
|
||||||
key, err := crypto.LoadPrivateKey(privateKey)
|
|
||||||
if err == nil {
|
|
||||||
return key, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w, err := wallet.NewWalletFromFile(privateKey)
|
w, err := wallet.NewWalletFromFile(privateKey)
|
||||||
|
|
Loading…
Reference in a new issue