signrpc: add schnorr sig to sign and validate msg
This commit is contained in:
1 parent
9d568cc119
commit
b5af0ce327
8 files changed
+449
-213
No files matched your search
@@ -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