diff --git a/ecdsa_privkey.go b/ecdsa_privkey.go index 88de9b5..d1be53e 100644 --- a/ecdsa_privkey.go +++ b/ecdsa_privkey.go @@ -123,7 +123,7 @@ func (key *ECDSAPrivateKey) Negate() error { return nil } -// Add a tweak to the public key by doing `key + tweak % Group Order`. this adds it in place. +// Add a tweak to the private key by doing `key + tweak % Group Order`. this adds it in place. // This is meant for creating BIP-32(HD) wallets func (key *ECDSAPrivateKey) Add(tweak [32]byte) error { if !key.init { @@ -137,3 +137,13 @@ func (key *ECDSAPrivateKey) Add(tweak [32]byte) error { } return nil } + +// ToSchnorr converts an ECDSA private key to a schnorr keypair +// Note: You shouldn't sign using the same key in both ECDSA and Schnorr signatures. +// this function is for convenience when using BIP-32 +func (key *ECDSAPrivateKey) ToSchnorr() (*SchnorrKeyPair, error) { + if !key.init { + return nil, errors.WithStack(errNonInitializedKey) + } + return DeserializeSchnorrPrivateKey((*SerializedPrivateKey)(&key.privateKey)) +}