mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 23:21:12 +02:00
multi: refactor SignDigestCompact into SignMessageCompact
To make it possible to use a remote lnrpc 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 lnrpc.SignMessage RPC to accept a digest instead of only the message which has security implications.
This commit is contained in:
@@ -54,9 +54,15 @@ func (s *SecretKeyRing) SignMessage(_ keychain.KeyDescriptor,
|
||||
return s.RootKey.Sign(digest)
|
||||
}
|
||||
|
||||
// SignDigestCompact signs the passed digest.
|
||||
func (s *SecretKeyRing) SignDigestCompact(_ keychain.KeyDescriptor,
|
||||
digest [32]byte) ([]byte, error) {
|
||||
// SignMessageCompact signs the passed message.
|
||||
func (s *SecretKeyRing) SignMessageCompact(_ keychain.KeyDescriptor,
|
||||
msg []byte, doubleHash bool) ([]byte, error) {
|
||||
|
||||
return btcec.SignCompact(btcec.S256(), s.RootKey, digest[:], true)
|
||||
var digest []byte
|
||||
if doubleHash {
|
||||
digest = chainhash.DoubleHashB(msg)
|
||||
} else {
|
||||
digest = chainhash.HashB(msg)
|
||||
}
|
||||
return btcec.SignCompact(btcec.S256(), s.RootKey, digest, true)
|
||||
}
|
||||
|
Reference in New Issue
Block a user