From 21eef1ae7f7d70bc7f93a30651a8e743e40258c6 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Wed, 12 Oct 2022 14:46:48 +0300 Subject: [PATCH] [#351] Add StringifyPublicKey method for NodeInfo Signed-off-by: Anton Nikiforov --- crypto/util.go | 9 +++++++++ netmap/node_info.go | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 crypto/util.go diff --git a/crypto/util.go b/crypto/util.go new file mode 100644 index 00000000..e6f87a31 --- /dev/null +++ b/crypto/util.go @@ -0,0 +1,9 @@ +package neofscrypto + +import "encoding/hex" + +// StringifyKeyBinary returns string with HEX representation of source. +// Format can be changed and it's unsafe to rely on it beyond human-readable output. +func StringifyKeyBinary(src []byte) string { + return hex.EncodeToString(src) +} diff --git a/netmap/node_info.go b/netmap/node_info.go index 58af58ed..91a3c32b 100644 --- a/netmap/node_info.go +++ b/netmap/node_info.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/hrw" "github.com/nspcc-dev/neofs-api-go/v2/netmap" "github.com/nspcc-dev/neofs-api-go/v2/refs" + neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto" subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id" ) @@ -178,6 +179,11 @@ func (x NodeInfo) PublicKey() []byte { return x.m.GetPublicKey() } +// StringifyPublicKey returns HEX representation of PublicKey. +func StringifyPublicKey(node NodeInfo) string { + return neofscrypto.StringifyKeyBinary(node.PublicKey()) +} + // SetNetworkEndpoints sets list to the announced node's network endpoints. // Node MUSt have at least one announced endpoint. List MUST be unique. // Endpoints are used for communication with the storage node within NeoFS