[#8] Use proper creds contructor to avoid unnatural convertions

Signed-off-by: Pavel Korotkov <pkorotkov@gmail.com>
This commit is contained in:
Pavel Korotkov 2020-08-06 20:55:07 +03:00
parent c5489da3cc
commit 8d4017f1d3
2 changed files with 6 additions and 6 deletions

View file

@ -18,7 +18,6 @@ import (
"github.com/nspcc-dev/neofs-authmate/credentials"
"github.com/nspcc-dev/neofs-authmate/gates"
manager "github.com/nspcc-dev/neofs-authmate/neofsmanager"
crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/pkg/errors"
"go.uber.org/zap"
)
@ -50,9 +49,10 @@ func NewCenter(log *zap.Logger, neofsNodeAddress string) (*Center, error) {
}
func (center *Center) SetNeoFSKeys(key *ecdsa.PrivateKey) error {
// TODO: Change when credentials will start taking not just a string.
wif, _ := crypto.WIFEncode(key)
creds, _ := credentials.NewCredentials(wif)
creds, err := credentials.NewFromKey(key)
if err != nil {
return err
}
center.neofsCredentials = creds
return nil
}
@ -65,7 +65,7 @@ func (center *Center) GetOwnerID() refs.OwnerID {
return center.neofsCredentials.OwnerID()
}
func (center *Center) SetUserAuthKeys(key hcs.X25519PrivateKey) error {
func (center *Center) SetAuthKeys(key hcs.X25519PrivateKey) error {
keys, err := hcs.NewKeys(key)
if err != nil {
return err

View file

@ -118,7 +118,7 @@ func fetchAuthCenter(l *zap.Logger, v *viper.Viper, peers []pool.Peer) (*auth.Ce
if err != nil {
return nil, errors.Wrap(err, "failed to create auth center")
}
if err = center.SetUserAuthKeys(gateAuthPrivateKey); err != nil {
if err = center.SetAuthKeys(gateAuthPrivateKey); err != nil {
return nil, errors.Wrap(err, "failed to set gate auth keys")
}
if err = center.SetNeoFSKeys(neofsPrivateKey); err != nil {