mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-26 14:08:41 +01:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user