Added Sign method to PrivateKey

This commit is contained in:
2026-02-14 18:12:33 +01:00
parent 7e56dc0eb1
commit 1d56998dd3

View File

@@ -9,6 +9,7 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors" "errors"
"io"
"strconv" "strconv"
"filippo.io/edwards25519" "filippo.io/edwards25519"
@@ -46,6 +47,10 @@ func (priv *PrivateKey) Seed() []byte {
return seed[:] return seed[:]
} }
func (priv *PrivateKey) Sign(_ io.Reader, digest []byte, _ crypto.SignerOpts) (signature []byte, err error) {
return Sign(priv, digest), nil
}
func (priv *PrivateKey) Public() crypto.PublicKey { func (priv *PrivateKey) Public() crypto.PublicKey {
p := &PublicKey{} p := &PublicKey{}
newPublicKey(p, priv.pub[:]) newPublicKey(p, priv.pub[:])
@@ -420,4 +425,7 @@ func verifyWithDom(pub *PublicKey, message, sig []byte, domPrefix, context strin
return nil return nil
} }
var _ crypto.PrivateKey = (*PrivateKey)(nil) var (
_ crypto.PrivateKey = (*PrivateKey)(nil)
_ crypto.Signer = (*PrivateKey)(nil)
)