mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-15 16:50:16 +01:00
accept custom sign options for schnorr library.
This commit is contained in:
4
event.go
4
event.go
@@ -129,7 +129,7 @@ func (evt Event) CheckSignature() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sign signs an event with a given privateKey.
|
// Sign signs an event with a given privateKey.
|
||||||
func (evt *Event) Sign(privateKey string) error {
|
func (evt *Event) Sign(privateKey string, signOpts ...schnorr.SignOption) error {
|
||||||
s, err := hex.DecodeString(privateKey)
|
s, err := hex.DecodeString(privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Sign called with invalid private key '%s': %w", privateKey, err)
|
return fmt.Errorf("Sign called with invalid private key '%s': %w", privateKey, err)
|
||||||
@@ -144,7 +144,7 @@ func (evt *Event) Sign(privateKey string) error {
|
|||||||
evt.PubKey = hex.EncodeToString(pkBytes[1:])
|
evt.PubKey = hex.EncodeToString(pkBytes[1:])
|
||||||
|
|
||||||
h := sha256.Sum256(evt.Serialize())
|
h := sha256.Sum256(evt.Serialize())
|
||||||
sig, err := schnorr.Sign(sk, h[:])
|
sig, err := schnorr.Sign(sk, h[:], signOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user