From 780763eaf87dbca7beb0b831278fa141324721b1 Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Thu, 16 Nov 2023 12:44:44 +0200 Subject: [PATCH] Fix Public/PrivateKey configuration type mismatch Signed-off-by: Vasyl Gello --- src/config/config.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/config/config.go b/src/config/config.go index 78fcf123..44ac8a49 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -322,6 +322,15 @@ func ReadConfig(conf []byte) *NodeConfig { } } } + // Ensure PublicKey and PrivateKey are KeyBytes + if privatekey, ok := dat["PrivateKey"]; ok { + if privstr, err := hex.DecodeString(privatekey.(string)); err == nil { + priv := ed25519.PrivateKey(privstr) + pub := priv.Public().(ed25519.PublicKey) + dat["PrivateKey"] = KeyBytes(priv[:]) + dat["PublicKey"] = KeyBytes(pub[:]) + } + } // Sanitise the config confJson, err := json.Marshal(dat) if err != nil {