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:
Oliver Gugger committed 2021-10-08 12:06:52 +02:00
1 parent 02757f6735
commit 8b7c88537c
17 files changed
+2407 -2373

No files matched your search

+15 -13
View File
@@ -178,7 +178,7 @@ type SecretKeyRing interface {
ECDHRing
DigestSignerRing
MessageSignerRing
// DerivePrivKey attempts to derive the private key that corresponds to
// the passed key descriptor. If the public key is set, then this
@@ -188,24 +188,26 @@ type SecretKeyRing interface {
DerivePrivKey(keyDesc KeyDescriptor) (*btcec.PrivateKey, error)
}
// DigestSignerRing is an interface that abstracts away basic low-level ECDSA
// MessageSignerRing is an interface that abstracts away basic low-level ECDSA
// signing on keys within a key ring.
type DigestSignerRing interface {
type MessageSignerRing interface {
// SignMessage signs the given message, single or double SHA256 hashing
// it first, with the private key described in the key descriptor.
SignMessage(keyDesc KeyDescriptor, message []byte,
doubleHash bool) (*btcec.Signature, error)
// SignDigestCompact signs the given SHA256 message digest with the
// private key described in the key descriptor and returns the signature
// in the compact, public key recoverable format.
SignDigestCompact(keyDesc KeyDescriptor, digest [32]byte) ([]byte, error)
// SignMessageCompact signs the given message, single or double SHA256
// hashing it first, with the private key described in the key
// descriptor and returns the signature in the compact, public key
// recoverable format.
SignMessageCompact(keyDesc KeyDescriptor, message []byte,
doubleHash bool) ([]byte, error)
}
// SingleKeyDigestSigner is an abstraction interface that hides the
// SingleKeyMessageSigner is an abstraction interface that hides the
// implementation of the low-level ECDSA signing operations by wrapping a
// single, specific private key.
type SingleKeyDigestSigner interface {
type SingleKeyMessageSigner interface {
// PubKey returns the public key of the wrapped private key.
PubKey() *btcec.PublicKey
@@ -213,10 +215,10 @@ type SingleKeyDigestSigner interface {
// it first, with the wrapped private key.
SignMessage(message []byte, doubleHash bool) (*btcec.Signature, error)
// SignDigestCompact signs the given SHA256 message digest with the
// wrapped private key and returns the signature in the compact, public
// key recoverable format.
SignDigestCompact(digest [32]byte) ([]byte, error)
// SignMessageCompact signs the given message, single or double SHA256
// hashing it first, with the wrapped private key and returns the
// signature in the compact, public key recoverable format.
SignMessageCompact(message []byte, doubleHash bool) ([]byte, error)
}
// ECDHRing is an interface that abstracts away basic low-level ECDH shared key