mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 23:53:41 +02:00
multi: add tag option to SignMessageSchnorr
This commit is contained in:
@@ -458,8 +458,8 @@ func (b *BtcWalletKeyRing) SignMessageCompact(keyLoc KeyLocator,
|
||||
//
|
||||
// NOTE: This is part of the keychain.MessageSignerRing interface.
|
||||
func (b *BtcWalletKeyRing) SignMessageSchnorr(keyLoc KeyLocator,
|
||||
msg []byte, doubleHash bool, taprootTweak []byte) (*schnorr.Signature,
|
||||
error) {
|
||||
msg []byte, doubleHash bool, taprootTweak []byte,
|
||||
tag []byte) (*schnorr.Signature, error) {
|
||||
|
||||
privKey, err := b.DerivePrivKey(KeyDescriptor{
|
||||
KeyLocator: keyLoc,
|
||||
@@ -472,10 +472,15 @@ func (b *BtcWalletKeyRing) SignMessageSchnorr(keyLoc KeyLocator,
|
||||
privKey = txscript.TweakTaprootPrivKey(*privKey, taprootTweak)
|
||||
}
|
||||
|
||||
// If a tag was provided, we need to take the tagged hash of the input.
|
||||
var digest []byte
|
||||
if doubleHash {
|
||||
switch {
|
||||
case len(tag) > 0:
|
||||
taggedHash := chainhash.TaggedHash(tag, msg)
|
||||
digest = taggedHash[:]
|
||||
case doubleHash:
|
||||
digest = chainhash.DoubleHashB(msg)
|
||||
} else {
|
||||
default:
|
||||
digest = chainhash.HashB(msg)
|
||||
}
|
||||
return schnorr.Sign(privKey, digest)
|
||||
|
@@ -239,8 +239,8 @@ type MessageSignerRing interface {
|
||||
// hashing it first, with the private key described in the key locator
|
||||
// and the optional Taproot tweak applied to the private key.
|
||||
SignMessageSchnorr(keyLoc KeyLocator, msg []byte,
|
||||
doubleHash bool, taprootTweak []byte) (*schnorr.Signature,
|
||||
error)
|
||||
doubleHash bool, taprootTweak []byte,
|
||||
tag []byte) (*schnorr.Signature, error)
|
||||
}
|
||||
|
||||
// SingleKeyMessageSigner is an abstraction interface that hides the
|
||||
|
Reference in New Issue
Block a user