From 0656357a605e244b4d44cab739a56c013051a17b Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 14 Sep 2024 22:47:01 -0300 Subject: [PATCH] keyer: accept truncated private keys as input and pad them. --- keyer/lib.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keyer/lib.go b/keyer/lib.go index ec7eb42..6beb706 100644 --- a/keyer/lib.go +++ b/keyer/lib.go @@ -2,6 +2,7 @@ package keyer import ( "context" + "encoding/hex" "fmt" "strings" "time" @@ -81,7 +82,8 @@ func New(ctx context.Context, pool *nostr.SimplePool, input string, opts *Signer sec := parsed.(string) pk, _ := nostr.GetPublicKey(sec) return KeySigner{sec, pk, make(map[string][32]byte)}, nil - } else if nostr.IsValid32ByteHex(input) { + } else if _, err := hex.DecodeString(input); err == nil && len(input) < 64 { + input = strings.Repeat("0", 64-len(input)) + input // if the key is like '01', fill all the left zeroes pk, _ := nostr.GetPublicKey(input) return KeySigner{input, pk, make(map[string][32]byte)}, nil }