From 0cfaa0da0a8f6a3fb4740a3fd5e5a579fb6aa19f Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 17 Nov 2023 09:27:10 -0300 Subject: [PATCH] ensure private key is 64 characters long. fixes https://github.com/nbd-wtf/go-nostr/issues/111 --- keys.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/keys.go b/keys.go index b0e8c97..a070246 100644 --- a/keys.go +++ b/keys.go @@ -3,6 +3,7 @@ package nostr import ( "crypto/rand" "encoding/hex" + "fmt" "io" "math/big" "strings" @@ -25,7 +26,7 @@ func GeneratePrivateKey() string { k.Mod(k, n) k.Add(k, one) - return hex.EncodeToString(k.Bytes()) + return fmt.Sprintf("%064x", k.Bytes()) } func GetPublicKey(sk string) (string, error) {