Why Nostr? What is Njump?
fishcake / The Fishcake🐶🐾
npub137c…k37w
2024-07-05 09:06:46
in reply to nevent1q…p2qq

fishcake on Nostr: // Sign signs an event with a given privateKey. func (evt *Event) Sign(privateKey ...

// Sign signs an event with a given privateKey.
func (evt *Event) Sign(privateKey string, signOpts ...schnorr.SignOption) error {
s, err := hex.DecodeString(privateKey)
if err != nil {
return fmt.Errorf("Sign called with invalid private key '%s': %w", privateKey, err)
}

if evt.Tags == nil {
evt.Tags = make(Tags, 0)
}

sk, pk := btcec.PrivKeyFromBytes(s)
pkBytes := pk.SerializeCompressed()
evt.PubKey = hex.EncodeToString(pkBytes[1:])

h := sha256.Sum256(evt.Serialize())
sig, err := schnorr.Sign(sk, h[:], signOpts...)
if err != nil {
return err
}

evt.ID = hex.EncodeToString(h[:])
evt.Sig = hex.EncodeToString(sig.Serialize())

return nil
}

🐶🐾🫡
Author Public Key
npub137c5pd8gmhhe0njtsgwjgunc5xjr2vmzvglkgqs5sjeh972gqqxqjak37w