mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-06 04:59:12 +02: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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -81,7 +82,8 @@ func New(ctx context.Context, pool *nostr.SimplePool, input string, opts *Signer
|
|||||||
sec := parsed.(string)
|
sec := parsed.(string)
|
||||||
pk, _ := nostr.GetPublicKey(sec)
|
pk, _ := nostr.GetPublicKey(sec)
|
||||||
return KeySigner{sec, pk, make(map[string][32]byte)}, nil
|
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)
|
pk, _ := nostr.GetPublicKey(input)
|
||||||
return KeySigner{input, pk, make(map[string][32]byte)}, nil
|
return KeySigner{input, pk, make(map[string][32]byte)}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user