mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
multi: refactor SignDigest into SignMessage
To make it possible to use a remote signrpc server as a signer for our wallet, we need to change our main interface to sign the message instead of the message's digest. Otherwise we'd need to alter the signrpc.SignMessage RPC to accept a digest instead of only the message which has security implications.
This commit is contained in:
@@ -2,7 +2,7 @@ package mock
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
||||
@@ -41,11 +41,17 @@ func (s *SecretKeyRing) ECDH(_ keychain.KeyDescriptor, pubKey *btcec.PublicKey)
|
||||
return [32]byte{}, nil
|
||||
}
|
||||
|
||||
// SignDigest signs the passed digest and ignores the KeyDescriptor.
|
||||
func (s *SecretKeyRing) SignDigest(_ keychain.KeyDescriptor,
|
||||
digest [32]byte) (*btcec.Signature, error) {
|
||||
// SignMessage signs the passed message and ignores the KeyDescriptor.
|
||||
func (s *SecretKeyRing) SignMessage(_ keychain.KeyDescriptor,
|
||||
msg []byte, doubleHash bool) (*btcec.Signature, error) {
|
||||
|
||||
return s.RootKey.Sign(digest[:])
|
||||
var digest []byte
|
||||
if doubleHash {
|
||||
digest = chainhash.DoubleHashB(msg)
|
||||
} else {
|
||||
digest = chainhash.HashB(msg)
|
||||
}
|
||||
return s.RootKey.Sign(digest)
|
||||
}
|
||||
|
||||
// SignDigestCompact signs the passed digest.
|
||||
|
Reference in New Issue
Block a user