rpc: modify SignMessage+VerifyMessage to bind msg to LN context

In this commit, we modify the SignMessage+VerifyMessage slightly in
order to bind the message we're signing to our specific context. We do
this by pre-pending the ascii text "Lightning Signed Message:" to the
msg before we run it through dsha256. Adding this prefix binds the
message to our context in order to avoid accidentally signing a sighash
or the like.
This commit is contained in:
Olaoluwa Osuntokun
2018-04-25 19:45:26 -07:00
parent 86fd9e361e
commit c54a91f44d
2 changed files with 20 additions and 8 deletions

View File

@@ -67,8 +67,9 @@ func (n *nodeSigner) SignDigestCompact(hash []byte) ([]byte, error) {
isCompressedKey := true
// btcec.SignCompact returns a pubkey-recoverable signature
sig, err := btcec.SignCompact(btcec.S256(), n.privKey, hash,
isCompressedKey)
sig, err := btcec.SignCompact(
btcec.S256(), n.privKey, hash, isCompressedKey,
)
if err != nil {
return nil, fmt.Errorf("can't sign the hash: %v", err)
}