-
Notifications
You must be signed in to change notification settings - Fork 82
Add multisig 1-of-n account with ed25519 signing and stellar-cli plugin #372
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
Merged
Merged
Changes from 51 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
051c3f9
add multisig 1-of-n account contract example
leighmcculloch 4eab20a
add tests for 1-of-n account
leighmcculloch ddf9641
update docstring for multi-sig account contract
leighmcculloch dfcc9a6
move multisig_1_of_n_account files to contract directory
leighmcculloch 1ba7dd2
wip of cli sign plugin
leighmcculloch 778e131
it works
leighmcculloch a878e1b
update sign-ed25519 README and plugin documentation
leighmcculloch d0c00bb
add sign step for issuer to pay transaction fee
leighmcculloch 8954044
add SkipWhitespace wrapper to filter input
leighmcculloch 260be8e
rename plugin to sign-auth-ed25519
leighmcculloch 400793e
add clap CLI to sign-auth-ed25519 tool
leighmcculloch 7599076
update sign-auth-ed25519 plugin usage in README
leighmcculloch 9f2f208
refactored to reduce indenting
leighmcculloch f0b25da
add comments explaining multisig 1-of-n signing process
leighmcculloch 73a1e26
add multisig 1-of-n account with ed25519 signing
leighmcculloch 71fea55
remove $ from code example in README
leighmcculloch 9295fa2
set patch path for stellar-xdr dependency
leighmcculloch fc38c45
fmt
leighmcculloch 67a24e2
rename cli plugin
leighmcculloch 231d470
update stellar-xdr to 22.2.0 and remove patch
leighmcculloch b9d3a3f
add js (deno) cli plugin
leighmcculloch c08d660
add io module for stdin, stderr, stdout functions
leighmcculloch 8a37e26
refactor
leighmcculloch 6802713
change format of payload hash debug output
leighmcculloch 08df6e4
fmt
leighmcculloch 6f5113a
set permission to deno script
leighmcculloch d04ca3b
hook into ci
leighmcculloch b5817f1
explicitly type auth mapping tuple in multisig account
leighmcculloch 74c3167
fmt
leighmcculloch c40a185
update gitignore for stellar and out directories
leighmcculloch 0b03202
fix deno setup condition in rust workflow
leighmcculloch 5fdff16
make fmt with git diff check in CI workflow
leighmcculloch d2b1256
add sequence diagram to multisig 1-of-n account
leighmcculloch 3145a34
update mermaid diagram labels
leighmcculloch a07abf6
rename signing tool to signing cli plugin in diagram
leighmcculloch 60eb591
improve multisig account diagrams and documentation
leighmcculloch f5764f2
add deno setup step to github workflow
leighmcculloch 663f5c1
simplify hashFiles condition in github workflow
leighmcculloch 8bf93e8
comment out deno setup condition in workflow
leighmcculloch 2aa50ab
remove todo comments in github workflow file
leighmcculloch e8a7eaf
add rust version requirement to sign-auth-ed25519
leighmcculloch 7de443e
update minimum rust version from 1.79.0 to 1.80.0
leighmcculloch a82c5e7
replace unimplemented with explicit error message
leighmcculloch 083a176
remove colored dependency from auth signing tool
leighmcculloch 5cedd06
disable colors in CLI output
leighmcculloch fca2ced
fmt readme lines for better readability
leighmcculloch 0f49585
add install targets for CLI commands
leighmcculloch 1f604da
update @std/encoding import in stellar-cli-sign-auth-ed25519-js
leighmcculloch 4045e3f
update encoding package to version 1.0.7
leighmcculloch 30c4b79
remove diagram
leighmcculloch 2a08961
move signature verification after signer check
leighmcculloch 5c1aec0
add multisig 1-of-n account setup instructionsgp
leighmcculloch d60ba6b
fix name of stellar-sign-auth-ed25519 binary in docs
leighmcculloch f1672cb
small deno tweaks
kalepail f28941b
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail 08e2814
Update README.md
kalepail 6efeb37
change key generation command syntax to be global
leighmcculloch 941d2cf
Update deno.json
kalepail 6386e1a
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail d643dfe
remove bash prompt markers and add cd contract step and keys local
leighmcculloch b324b47
swap network setup and directory change steps
leighmcculloch 0336075
revert stdin change
kalepail 2ab47ea
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail fa1bedd
remove compiler options from deno.json
leighmcculloch 99f5fb8
remove compilerOptions
kalepail 7dc3151
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail bced2ab
add detailed deno installation instructions to README
leighmcculloch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ target/ | |
/.sccache/ | ||
.DS_Store | ||
.soroban | ||
.stellar/ | ||
out/ | ||
test_snapshots | ||
z-dc-build-info/* | ||
**1pass.tmp** | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Multisig 1-of-n Contract Account | ||
|
||
This example contains a custom contract account that authorizes when one ed25519 | ||
signature is provided, where the signature was produced by a ed25519 key | ||
configured in the contract. The contract may hold any number of keys, and any | ||
key may authorize for it. | ||
|
||
The example also contains a stellar-cli plugin that signs authorizations using | ||
an ed25519. | ||
|
||
## Usage | ||
|
||
The example below sets up an asset with the contract account as the admin. The | ||
admin authorizes with ed25519 keys. | ||
|
||
The ed25519 keys used in the example below are: | ||
|
||
- Secret Key: | ||
`0000000000000000000000000000000000000000000000000000000000000000`\ | ||
Public Key: `3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29` | ||
- Secret Key: | ||
`0000000000000000000000000000000000000000000000000000000000000001`\ | ||
Public Key: `4cb5abf6ad79fbf5abbccafcc269d85cd2651ed4b885b5869f241aedf0a5ba29` | ||
|
||
These keys are publicly viewable and not random. Do not use these keys for any | ||
purpose. Select your own keys and update them in the commands below when | ||
executing. | ||
|
||
### Install the `stellar sign-auth-ed25519` plugin | ||
|
||
Install one of the stellar sign-auth-ed25519 plugin implementations. | ||
|
||
#### Rust | ||
|
||
``` | ||
cd stellar-cli-sign-auth-ed25519 | ||
cargo install --locked --path . | ||
``` | ||
|
||
#### JavaScript (Deno) | ||
|
||
``` | ||
cd stellar-cli-sign-auth-ed25519-js | ||
deno install \ | ||
--global \ | ||
--name stellar-sign-auth-ed25519 \ | ||
--config deno.json \ | ||
--allow-read --no-prompt \ | ||
--force \ | ||
main.ts | ||
``` | ||
|
||
Note: By default Deno scripts when installed have no permissions and cannot read | ||
or files, read environment variables, access the network, cannot execute | ||
commands. The `--allow-read` flag is specified to give the script permission to | ||
read files so that it can read .wasm dependencies in the | ||
`@stellar/stellar-xdr-json` package which is a Rust-built-to-wasm npm package. | ||
|
||
### Deploy the contract account | ||
|
||
``` | ||
cd contract | ||
stellar contract build --out-dir out/ | ||
stellar contract deploy \ | ||
--alias admin \ | ||
--wasm out/soroban_multisig_1_of_n_account_contract.wasm \ | ||
-- \ | ||
--signers '[ | ||
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29", | ||
"4cb5abf6ad79fbf5abbccafcc269d85cd2651ed4b885b5869f241aedf0a5ba29" | ||
]' | ||
leighmcculloch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Deploy asset | ||
|
||
``` | ||
stellar keys generate issuer --fund | ||
leighmcculloch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stellar contract asset deploy \ | ||
--alias asset \ | ||
--asset ABC:issuer | ||
``` | ||
|
||
### List of contracts | ||
|
||
``` | ||
stellar contract alias ls | ||
``` | ||
|
||
### Set admin | ||
|
||
``` | ||
stellar contract invoke --id asset -- \ | ||
set_admin \ | ||
--new_admin admin | ||
leighmcculloch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Mint | ||
|
||
Call mint, sending to an address. The invocation will be signed by the admin | ||
using one of the ed25519 keys set in the constructor. Choose which key signs by | ||
setting the `--secret-key` option to one of the two keys above. | ||
|
||
``` | ||
stellar contract invoke --id asset --build-only -- \ | ||
mint \ | ||
--to CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4 \ | ||
--amount 123 \ | ||
| stellar tx simulate \ | ||
| stellar sign-auth-ed25519 \ | ||
leighmcculloch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--secret-key 0000000000000000000000000000000000000000000000000000000000000001 \ | ||
--signature-expiration-ledger 2296800 \ | ||
| stellar tx simulate \ | ||
| stellar tx sign --sign-with-key issuer \ | ||
| stellar tx send | ||
leighmcculloch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
Note: The issuer is signing the transaction to pay the fee, but the admin | ||
signature produced by the `sign-auth-ed25519` plugin is what is authorizing the | ||
mint. Any account could pay for the fee. | ||
|
||
### View Balance | ||
|
||
``` | ||
stellar contract invoke --id asset -- \ | ||
balance \ | ||
--id CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4 | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.