ensure private key is 64 characters long.

fixes https://github.com/nbd-wtf/go-nostr/issues/111
This commit is contained in:
fiatjaf
2023-11-17 09:27:10 -03:00
parent 307df51b9a
commit 0cfaa0da0a

View File

@@ -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) {