Conversation
|
Thanks for thinking about this. Some thoughts:
The ability to store the signing plugins config for a key is where a ton of value is. Without it the But, if we add the ability to store these plugin configs alongside keys, that flow could be pretty amazing. So I think it is worth hashing that out as part of this proof-of-concept because that's where some of the value will be.
+1 Another thing to consider is: can a plugin utilise the key storage of the cli. The examples above hint that maybe that should be possible. In the multisig example where it has Another thing to consider is: how should a plugin that requires asynchronous / detached signing work. That is something the current piping flow naturally supports today because you can build, simulate, then send the tx to someone else, then get it back and continue. The composability and asynchrony is particularly powerful. |
The example doesn't show this, but the CLI will wait for the singing plugin process to terminate, and it does attach stderr so the plugin process can send prompts / URLs / etc to the user.
I agree. I can explore this next.
We could export this logic as a standalone crate, in which case they could. Otherwise they would need to duplicate the code. IMO if we allow keys/contract aliases to store singing plugin info, this wouldn't be needed. One thing we could consider here is making signing plugins a bit more CLI like. E.g. they have to support the following: Then, plugins could define their own "set-args" logic so ppl have help text, using the stellar CLI under the hood. |
This flow will work for short lived asynchronous signing, but not asynchronous signing. But, as long as the signing plugins can also be used with |
Another option is to expose the stellar cli binary path to the sub-process via an environment variable so the sub-process knows how to call the stellar binary to use the keys command. For example, like how inside a Makefile you can use $(MAKE) to call the make command. |
What
Add signer plugins that can be invoked during the transaction submission process to add arbitrary logic while signing authorization entries or transaction envelopes.
Why
Writing custom code to support signing for non-standard account types is not well supported today. A few methods have emerged:
Having an integration point within the transaction submission process would simplify the process of writing, sharing, and using plugins made for signing. Further, these could be supported by future plugins as well, like protocol specific ones that help interact with protocols, e.g. stellar-private-payments.
Closes: #2026
How
NOTE: CLI API under construction. The current version is just a proof of concept that writing the plugin is reasonable. Please provide feedback!
Two new arguments are added to
sign_with.rsto allow users to specify singing plugins for a given Address/Alias.--sign-with-plugin- Takes in aplugin_name=Addressthat ensures each time Address is required to sign, the given plugin withplugin_nameis invoked, such that the plugin is an executable atstellar-signer-{plugin_name}. Multiple relationships can be created.--plugin-arg- Takes in a string ofplugin_name:arg_name=value, such that each timeplugin_nameis called, in the arg json string provided,{ arg_name: value }is included.Plugins need to support two different signing methods, each with a different JSON-string provided as an argument.
Sign Authorization Entries
{ "mode": "sign_auth", "network_passphrase": "Test...", "address": "ScAddress as a Base64 XDR string", "nonce": 0, "signature_expiration_ledger": 100, "root_invocation": "SorobanAuthorizedInvocation as a Base64 XDR string", "args": {// based on --plugin-arg fields} }Sign Transaction
{ "mode": "sign_tx", "network_passphrase": "Test...", "tx_env_xdr": "TransactionEnvelope as a Base64 XDR string", "tx_hash": "hex encoded tx_hash", "args": {// based on --plugin-arg fields} }Try It Out
An example signer plugin was created for Stellar multisig accounts (
cmd/crates/stellar-multisig-plugin). The same plugin was also created for comparison purposes that works with the existing CLI, using nested commands (cmd/crates/stellar-old-multisig-plugin).Setup CLI
Checkout this branch!
Install Stellar CLI:
Setup test environment
Create two funded stellar accounts on a standalone or test network. 1 should be a multisig where the master key cannot submit a transaction (
alicein this example). 1 should be a regular stellar account (bobin this example).Deploy the
hello-worldcontract:Custom Signing for Source Account
Custom Signing for Authorization Entries
TODO
Explore allowing "key/contract" config to store signing plugin data and arguments. That is, you would setup signing plugins directly on the key/contract itself,
stellar keys use-plugin alice --name multisig -- --signers S..,S.., preventing the need for the weird plugin arg CLI API to be used. This is likely to touch a lot of code, so was omitted until we decide on a directionSupport different arguments based if more than one address uses the same plugin. Currently, the same arguments are passed to all invocations of a singing plugin.
General code polishing / testing
Remove plugin examples from CLI repo