Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow signing messages on liquid #203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jmastr
Copy link

@jmastr jmastr commented Feb 13, 2024

I can sign a message on Bitcoin:

$ green-cli --network electrum-testnet getnewaddress                                                                                                                                                                                                                                                             
2N3t2fZsYE6QVBAoG3Z8cpq2oadsp6Smv2h
$ green-cli --network electrum-testnet signmessage 2N3t2fZsYE6QVBAoG3Z8cpq2oadsp6Smv2h "Hello"                                                                                                                                                                                                                   
{
  "signature": "H29dlu1Ce+icNUMY6XfcgK6+z5140vbWHfQ1BoVpOWnDQa99pnojqLdUodJIrb4hKfDsbxob7Ap+xvvi3hYS16M="
}

But doing the same thing on liquid yields to an error:

$ green-cli --network electrum-testnet-liquid getnewaddress                                                                                                                                                                                                                                                      
vjTwMefCmqyvk7yFRN7ixCaEJRz9XKA9ie8nJDoo7TfQDF9jHZ3mEGvNXhNsHwriM7hqVtLZqDtT8SRe
$ green-cli --network electrum-testnet-liquid signmessage vjTwMefCmqyvk7yFRN7ixCaEJRz9XKA9ie8nJDoo7TfQDF9jHZ3mEGvNXhNsHwriM7hqVtLZqDtT8SRe "Hello"                                                                                                                                                               
...
RuntimeError: OrderedDict([('action', 'sign_message'), ('error', 'assertion failure: ga_auth_handlers.cpp:2101:Invalid network'), ('name', 'sign_message'), ('status', 'error')])

@jmastr
Copy link
Author

jmastr commented Feb 13, 2024

Maybe related to #23

@jmastr
Copy link
Author

jmastr commented Feb 14, 2024

After my patch:

$ green-cli --network electrum-testnet-liquid signmessage vjTxYGsEPr728szaqx8dFL8gnhVSeTXmJuTTBcG8S5TVfzc1an1kAfQgCVqrqtNcJiGMvjDkHM3Ku4nx "Hello"
{
  "signature": "IDBd37GMBxRZbmV8DVlJnWSpgwK/HqkKoUpEDaj4oNiZEezyE59OKWxnGf1guXkHE7l8kdu2YWy0NKD+FYywpMU="
}

@jmastr
Copy link
Author

jmastr commented Feb 14, 2024

With Jade too:

$ green-cli --network electrum-testnet-liquid --auth jade signmessage vjTyrmZQapgFd6aVGnyHhNvsgV1QaLTBt8F3GuMtv1wkWnvhhaU3eVdJbwvW14c98GQ3tMkAeVbtLt7p "Hello"
{
  "signature": "IO12QqcX2qgfetouM/wScTCQBSBrq64zC4FsK8svPa1uShykW1lxMaJi2/3FvQTg4+5Q1WGI9uOvfy1hN1dm+vU="
}

@jmastr
Copy link
Author

jmastr commented Feb 14, 2024

Hello @LeoComandini Would you be so kind to review this and maybe even release this as 0.70.1? That would really help out our project.

@LeoComandini
Copy link
Contributor

Hi @jmastr,

Your MR works however it has a couple of issues.

How do you verify the signed message?
With Bitcoin you can do it with Bitcoin Core (p2pkh only) or Electrum (p2pkh, p2sh-p2wpkh, p2wpkh).
With Liquid you can only do it with Elements Core (p2pkh only).
Thus we should restrict signing only to p2pkh accounts.
Or alternatively provide some way to verify the produced signatures.

In your PR the message is prefixed with "Bitcoin Signed Message:\n" (nothing has changed so it does the same as bitcoin).
Even though that's what Elements Core does, it's questionable.

Also should signmessage completely ignore the blinding key in the address?

Anyway I'll try to get this forward,
although given the other priorities,
it might take a bit.

@jmastr
Copy link
Author

jmastr commented Feb 15, 2024

Hi @LeoComandini Thanks for coming back to me that quickly. I try to answer your remarks one by one.

In your PR the message is prefixed with "Bitcoin Signed Message:\n" (nothing has changed so it does the same as bitcoin).
Even though that's what Elements Core does, it's questionable.

For my use case I need the compatibility to Elements Core, so this is intentional, although questionable. I agree.

With Liquid you can only do it with Elements Core (p2pkh only).

I am no expert on address types. With green-cli I use e.g. vjTyrmZQapgFd6aVGnyHhNvsgV1QaLTBt8F3GuMtv1wkWnvhhaU3eVdJbwvW14c98GQ3tMkAeVbtLt7p (p2sh) and with elements-cli I use dumpprivkey with e.g. tlq1qq289prur7etvnyysln69fue5qjlca84ft559gv3carnm9q0pl23tg5dxw04eqc2udcexnm43lltxf5q5mv2tke0pf6qtpauky (p2wpkh) and then signmessagewithprivkey to sign the message.

Also should signmessage completely ignore the blinding key in the address?

Again I need the compatibility to Elements Core, but I don't know what they do internally.

@jmastr
Copy link
Author

jmastr commented Feb 15, 2024

My use case is to map some arbitrary data to a user's private/public key. I can outline the verification process, but it is rather cumbersome.

Another idea that comes to mind is to use OP_RETURN to write an arbitrary message into an scriptPubKey transaction output, but I don't know if this is even possible on Liquid or only on Bitcoin. Trezor wallet for example offers this:

Wallet_OP_RETURN

@LeoComandini
Copy link
Contributor

@jmastr raised ElementsProject/elements#1319 to try to get the discussion going

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants