mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
keyer: accept truncated private keys as input and pad them.
This commit is contained in:
parent
7ab94cc3d9
commit
0656357a60
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user