multi: use key locator only for signing messages

To simplify the API surface of a remote signer even more, we refactor
the SignMessage and SignMessageCompact calls to only accept a key
locator as we always know what key we're using for signing anyway.
This commit is contained in:
Oliver Gugger
2021-09-23 16:54:29 +02:00
parent 8b7c88537c
commit afa03f22cc
6 changed files with 46 additions and 37 deletions

View File

@@ -392,13 +392,15 @@ func (b *BtcWalletKeyRing) ECDH(keyDesc KeyDescriptor,
}
// SignMessage signs the given message, single or double SHA256 hashing it
// first, with the private key described in the key descriptor.
// first, with the private key described in the key locator.
//
// NOTE: This is part of the keychain.MessageSignerRing interface.
func (b *BtcWalletKeyRing) SignMessage(keyDesc KeyDescriptor,
func (b *BtcWalletKeyRing) SignMessage(keyLoc KeyLocator,
msg []byte, doubleHash bool) (*btcec.Signature, error) {
privKey, err := b.DerivePrivKey(keyDesc)
privKey, err := b.DerivePrivKey(KeyDescriptor{
KeyLocator: keyLoc,
})
if err != nil {
return nil, err
}
@@ -413,14 +415,16 @@ func (b *BtcWalletKeyRing) SignMessage(keyDesc KeyDescriptor,
}
// SignMessageCompact signs the given message, single or double SHA256 hashing
// it first, with the private key described in the key descriptor and returns
// it first, with the private key described in the key locator and returns
// the signature in the compact, public key recoverable format.
//
// NOTE: This is part of the keychain.MessageSignerRing interface.
func (b *BtcWalletKeyRing) SignMessageCompact(keyDesc KeyDescriptor,
func (b *BtcWalletKeyRing) SignMessageCompact(keyLoc KeyLocator,
msg []byte, doubleHash bool) ([]byte, error) {
privKey, err := b.DerivePrivKey(keyDesc)
privKey, err := b.DerivePrivKey(KeyDescriptor{
KeyLocator: keyLoc,
})
if err != nil {
return nil, err
}