diff --git a/packages/networking/hyprspace/cli/init.go b/packages/networking/hyprspace/cli/init.go index 31c244d..47abbdb 100644 --- a/packages/networking/hyprspace/cli/init.go +++ b/packages/networking/hyprspace/cli/init.go @@ -10,6 +10,7 @@ import ( "github.com/hyprspace/hyprspace/config" "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p-core/crypto" + "github.com/multiformats/go-multibase" "gopkg.in/yaml.v2" ) @@ -53,7 +54,7 @@ func InitRun(r *cmd.Root, c *cmd.Sub) { ListenPort: 8001, Address: "10.1.1.1/24", ID: host.ID().Pretty(), - PrivateKey: string(keyBytes), + PrivateKey: multibase.MustNewEncoder(multibase.Base58BTC).Encode(keyBytes), }, } diff --git a/packages/networking/hyprspace/cli/up.go b/packages/networking/hyprspace/cli/up.go index cb23822..dd671d1 100644 --- a/packages/networking/hyprspace/cli/up.go +++ b/packages/networking/hyprspace/cli/up.go @@ -23,6 +23,7 @@ import ( "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + "github.com/multiformats/go-multibase" "github.com/nxadm/tail" ) @@ -132,10 +133,11 @@ func UpRun(r *cmd.Root, c *cmd.Sub) { port, err := verifyPort(cfg.Interface.ListenPort) checkErr(err) + _, privateKey, err := multibase.Decode(cfg.Interface.PrivateKey) // Create P2P Node host, dht, err := p2p.CreateNode( ctx, - cfg.Interface.PrivateKey, + privateKey, port, streamHandler, ) diff --git a/packages/networking/hyprspace/go.mod b/packages/networking/hyprspace/go.mod index 1092553..95e6aac 100644 --- a/packages/networking/hyprspace/go.mod +++ b/packages/networking/hyprspace/go.mod @@ -13,6 +13,7 @@ require ( github.com/libp2p/go-libp2p-kad-dht v0.15.0 github.com/libp2p/go-tcp-transport v0.4.0 github.com/multiformats/go-multiaddr v0.4.1 + github.com/multiformats/go-multibase v0.0.3 github.com/nxadm/tail v1.4.8 github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e diff --git a/packages/networking/hyprspace/p2p/node.go b/packages/networking/hyprspace/p2p/node.go index 8c2da2b..f5b89e4 100644 --- a/packages/networking/hyprspace/p2p/node.go +++ b/packages/networking/hyprspace/p2p/node.go @@ -56,9 +56,9 @@ func getExtraBootstrapNodes(addr ma.Multiaddr) (nodesList []string) { } // CreateNode creates an internal Libp2p nodes and returns it and it's DHT Discovery service. -func CreateNode(ctx context.Context, inputKey string, port int, handler network.StreamHandler) (node host.Host, dhtOut *dht.IpfsDHT, err error) { +func CreateNode(ctx context.Context, inputKey []byte, port int, handler network.StreamHandler) (node host.Host, dhtOut *dht.IpfsDHT, err error) { // Unmarshal Private Key - privateKey, err := crypto.UnmarshalPrivateKey([]byte(inputKey)) + privateKey, err := crypto.UnmarshalPrivateKey(inputKey) if err != nil { return }