Questions about signMessage, signing arbitrary messages with Leather
Quoted from Discord to make sure the questions don't get lost and the answers are saved here.
Hey people, I'm trying to use the Leather wallet signmessage functionality (https://leather.gitbook.io/developers/bitcoin/sign-messages) for signing arbitrary data with my Bitcoin wallet. I have a couple of questions:
It says that Leather supports BIP-322 message signing, but the unincluded PR mentioned on Bitcoin Core seems to have been closed: https://github.com/bitcoin/bitcoin/pull/24058
The btckit docs do not contain anything about the signMessage method (https://btckit.org/docs/category/btc). However, looking at the code, I see that there's a method for signing messages (https://github.com/btckit-org/btckit/blob/main/packages/types/src/methods/sign-message.ts) that allows for specifying for the type of the signature according to the BIP-322 docs. However, changing the type does not produce a different signature at all. I looked into the implementation of Leather recently, and potentially found that in all cases the Simple message type is used. Not sure about this though as I'm not familiar with the repo.
Overall, my goal is to create BIP-340 Schnorr signatures from Leather for an application I'm building. Is this possible with the Leather wallet? If not, is it at least possible to perform some custom operation with the Bitcoin private key of the user?
Have our docs been referenced? https://leather.gitbook.io/developers/bitcoin/sign-messages
I did not work on this feature, so I'd have to dig into it but @kyranjamie will be the best person to respond here next week.
BIP-322 was, and I think still is, the best solution to creates signatures to prove ownership of an address. Sadly, it hasn't gained much traction and the dev maintaining the PR closed it.
Understandably, having to host a custom bitcoin node of a now-closed PR isn't ideal.
There is now a JS library to verify BIP-322 packages. You can see a test implementation of this here. ⚠️ I don't know the author of this package. Use it at your own risk.
Right now, we don't support direct signing with Schrorr signatures. @314159265359879 can you ask the user to share more about their use case?
Thanks for the response. I have managed to verify the validity of BIP-322 signatures since then, but it is a bit of a hassle to have to build the toSpend and toSign transactions and verifying them using consensus rules. On the other hand, Schnorr signatures are more compact and their verification is much simpler given that you just have to take the hash of the message and verify the signature on it. Given that Leather aims to provide support for signing arbitrary pieces of data, I think providing the option for Schnorr signatures which are accepted by the Bitcoin community a good feature.
@vitsalis Thanks for the additional context here and request. I've filed Schnorr signatures as a possible enhancement here for us to evaluate: https://github.com/leather-wallet/extension/issues/4238