mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 00:59:07 -04:00
left pad keys on nak key
too so nak key public 02
works, for example.
This commit is contained in:
parent
79cb63a1b4
commit
27f925c05e
|
@ -210,7 +210,7 @@ func gatherSecretKeyOrBunkerFromArguments(ctx context.Context, c *cli.Command) (
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, fmt.Errorf("failed to decrypt: %w", err)
|
return "", nil, fmt.Errorf("failed to decrypt: %w", err)
|
||||||
}
|
}
|
||||||
} else if bsec, err := hex.DecodeString(strings.Repeat("0", 64-len(sec)) + sec); err == nil {
|
} else if bsec, err := hex.DecodeString(leftPadKey(sec)); err == nil {
|
||||||
sec = hex.EncodeToString(bsec)
|
sec = hex.EncodeToString(bsec)
|
||||||
} else if prefix, hexvalue, err := nip19.Decode(sec); err != nil {
|
} else if prefix, hexvalue, err := nip19.Decode(sec); err != nil {
|
||||||
return "", nil, fmt.Errorf("invalid nsec: %w", err)
|
return "", nil, fmt.Errorf("invalid nsec: %w", err)
|
||||||
|
@ -284,3 +284,7 @@ func randString(n int) string {
|
||||||
}
|
}
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func leftPadKey(k string) string {
|
||||||
|
return strings.Repeat("0", 64-len(k)) + k
|
||||||
|
}
|
||||||
|
|
1
key.go
1
key.go
|
@ -269,6 +269,7 @@ func getSecretKeysFromStdinLinesOrSlice(ctx context.Context, c *cli.Command, key
|
||||||
}
|
}
|
||||||
sec = data.(string)
|
sec = data.(string)
|
||||||
}
|
}
|
||||||
|
sec = leftPadKey(sec)
|
||||||
if !nostr.IsValid32ByteHex(sec) {
|
if !nostr.IsValid32ByteHex(sec) {
|
||||||
ctx = lineProcessingError(ctx, "invalid hex key")
|
ctx = lineProcessingError(ctx, "invalid hex key")
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user