Skip to content

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 67 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
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 Apr 30, 2025
4eab20a
add tests for 1-of-n account
leighmcculloch Apr 30, 2025
ddf9641
update docstring for multi-sig account contract
leighmcculloch Apr 30, 2025
dfcc9a6
move multisig_1_of_n_account files to contract directory
leighmcculloch Apr 30, 2025
1ba7dd2
wip of cli sign plugin
leighmcculloch Apr 30, 2025
778e131
it works
leighmcculloch Apr 30, 2025
a878e1b
update sign-ed25519 README and plugin documentation
leighmcculloch Apr 30, 2025
d0c00bb
add sign step for issuer to pay transaction fee
leighmcculloch Apr 30, 2025
8954044
add SkipWhitespace wrapper to filter input
leighmcculloch Apr 30, 2025
260be8e
rename plugin to sign-auth-ed25519
leighmcculloch Apr 30, 2025
400793e
add clap CLI to sign-auth-ed25519 tool
leighmcculloch Apr 30, 2025
7599076
update sign-auth-ed25519 plugin usage in README
leighmcculloch Apr 30, 2025
9f2f208
refactored to reduce indenting
leighmcculloch Apr 30, 2025
f0b25da
add comments explaining multisig 1-of-n signing process
leighmcculloch Apr 30, 2025
73a1e26
add multisig 1-of-n account with ed25519 signing
leighmcculloch Apr 30, 2025
71fea55
remove $ from code example in README
leighmcculloch Apr 30, 2025
9295fa2
set patch path for stellar-xdr dependency
leighmcculloch Apr 30, 2025
fc38c45
fmt
leighmcculloch Apr 30, 2025
67a24e2
rename cli plugin
leighmcculloch Apr 30, 2025
231d470
update stellar-xdr to 22.2.0 and remove patch
leighmcculloch Apr 30, 2025
b9d3a3f
add js (deno) cli plugin
leighmcculloch Apr 30, 2025
c08d660
add io module for stdin, stderr, stdout functions
leighmcculloch Apr 30, 2025
8a37e26
refactor
leighmcculloch Apr 30, 2025
6802713
change format of payload hash debug output
leighmcculloch Apr 30, 2025
08df6e4
fmt
leighmcculloch May 1, 2025
6f5113a
set permission to deno script
leighmcculloch May 1, 2025
d04ca3b
hook into ci
leighmcculloch May 1, 2025
b5817f1
explicitly type auth mapping tuple in multisig account
leighmcculloch May 1, 2025
74c3167
fmt
leighmcculloch May 1, 2025
c40a185
update gitignore for stellar and out directories
leighmcculloch May 1, 2025
0b03202
fix deno setup condition in rust workflow
leighmcculloch May 1, 2025
5fdff16
make fmt with git diff check in CI workflow
leighmcculloch May 1, 2025
d2b1256
add sequence diagram to multisig 1-of-n account
leighmcculloch May 1, 2025
3145a34
update mermaid diagram labels
leighmcculloch May 1, 2025
a07abf6
rename signing tool to signing cli plugin in diagram
leighmcculloch May 1, 2025
60eb591
improve multisig account diagrams and documentation
leighmcculloch May 1, 2025
f5764f2
add deno setup step to github workflow
leighmcculloch May 1, 2025
663f5c1
simplify hashFiles condition in github workflow
leighmcculloch May 1, 2025
8bf93e8
comment out deno setup condition in workflow
leighmcculloch May 1, 2025
2aa50ab
remove todo comments in github workflow file
leighmcculloch May 1, 2025
e8a7eaf
add rust version requirement to sign-auth-ed25519
leighmcculloch May 1, 2025
7de443e
update minimum rust version from 1.79.0 to 1.80.0
leighmcculloch May 1, 2025
a82c5e7
replace unimplemented with explicit error message
leighmcculloch May 1, 2025
083a176
remove colored dependency from auth signing tool
leighmcculloch May 1, 2025
5cedd06
disable colors in CLI output
leighmcculloch May 1, 2025
fca2ced
fmt readme lines for better readability
leighmcculloch May 1, 2025
0f49585
add install targets for CLI commands
leighmcculloch May 1, 2025
1f604da
update @std/encoding import in stellar-cli-sign-auth-ed25519-js
leighmcculloch May 1, 2025
4045e3f
update encoding package to version 1.0.7
leighmcculloch May 1, 2025
30c4b79
remove diagram
leighmcculloch May 2, 2025
2a08961
move signature verification after signer check
leighmcculloch May 2, 2025
5c1aec0
add multisig 1-of-n account setup instructionsgp
leighmcculloch May 2, 2025
d60ba6b
fix name of stellar-sign-auth-ed25519 binary in docs
leighmcculloch May 2, 2025
f1672cb
small deno tweaks
kalepail May 2, 2025
f28941b
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail May 2, 2025
08e2814
Update README.md
kalepail May 2, 2025
6efeb37
change key generation command syntax to be global
leighmcculloch May 2, 2025
941d2cf
Update deno.json
kalepail May 2, 2025
6386e1a
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail May 2, 2025
d643dfe
remove bash prompt markers and add cd contract step and keys local
leighmcculloch May 2, 2025
b324b47
swap network setup and directory change steps
leighmcculloch May 2, 2025
0336075
revert stdin change
kalepail May 2, 2025
2ab47ea
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail May 2, 2025
fa1bedd
remove compiler options from deno.json
leighmcculloch May 2, 2025
99f5fb8
remove compilerOptions
kalepail May 2, 2025
7dc3151
Merge branch 'add-multisig-1-of-n-account' of https://github.com/stel…
kalepail May 2, 2025
bced2ab
add detailed deno installation instructions to README
leighmcculloch May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

env:
MINIMUM_RUST_VERSION: 1.79.0
MINIMUM_RUST_VERSION: 1.80.0

jobs:

Expand Down Expand Up @@ -45,8 +45,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Setup Rust
- run: rustup update
- run: cargo fmt --all --check

# Setup Deno
- uses: denoland/setup-deno@909cc5acb0fdd60627fb858598759246509fa755 # v2.0.2
with:
deno-version: v2.x

# Fmt
- run: make fmt
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code

build-and-test:
needs: dirs
Expand All @@ -64,6 +75,8 @@ jobs:
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3

# Setup Rust
- uses: stellar/actions/rust-cache@main
- name: Use the minimum supported Rust version
if: matrix.rust == 'msrv'
Expand All @@ -79,7 +92,16 @@ jobs:
- run: cargo version
- run: rustup target add ${{ matrix.sys.target }}
- run: rustup target add wasm32-unknown-unknown

# Setup Deno
- uses: denoland/setup-deno@909cc5acb0fdd60627fb858598759246509fa755 # v2.0.2
with:
deno-version: v2.x

# Setup Stellar CLI
- uses: stellar/stellar-cli@v22.5.0

# Build and Test
- run: make test
env:
CARGO_BUILD_TARGET: ${{ matrix.sys.target }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ target/
/.sccache/
.DS_Store
.soroban
.stellar/
out/
test_snapshots
z-dc-build-info/*
**1pass.tmp**
Expand Down
127 changes: 127 additions & 0 deletions multisig_1_of_n_account/README.md
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"
]'
```

### Deploy asset

```
stellar keys generate issuer --fund
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
```

### 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 \
--secret-key 0000000000000000000000000000000000000000000000000000000000000001 \
--signature-expiration-ledger 2296800 \
| stellar tx simulate \
| stellar tx sign --sign-with-key issuer \
| stellar tx send
```

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
```
Loading