mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 18:27:43 +02:00
signrpc: add schnorr sig to sign and validate msg
This commit is contained in:
@@ -3,7 +3,9 @@ package mock
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
||||
@@ -69,3 +71,23 @@ func (s *SecretKeyRing) SignMessageCompact(_ keychain.KeyLocator,
|
||||
}
|
||||
return ecdsa.SignCompact(s.RootKey, digest, true)
|
||||
}
|
||||
|
||||
// SignMessageSchnorr signs the passed message and ignores the KeyDescriptor.
|
||||
func (s *SecretKeyRing) SignMessageSchnorr(_ keychain.KeyLocator,
|
||||
msg []byte, doubleHash bool, taprootTweak []byte) (*schnorr.Signature,
|
||||
error) {
|
||||
|
||||
var digest []byte
|
||||
if doubleHash {
|
||||
digest = chainhash.DoubleHashB(msg)
|
||||
} else {
|
||||
digest = chainhash.HashB(msg)
|
||||
}
|
||||
|
||||
privKey := s.RootKey
|
||||
if len(taprootTweak) > 0 {
|
||||
privKey = txscript.TweakTaprootPrivKey(privKey, taprootTweak)
|
||||
}
|
||||
|
||||
return schnorr.Sign(privKey, digest)
|
||||
}
|
||||
|
Reference in New Issue
Block a user