Crates.io | entropy-test-cli |
lib.rs | entropy-test-cli |
version | 0.2.0 |
source | src |
created_at | 2024-01-04 10:06:59.380958 |
updated_at | 2024-07-11 21:25:11.526724 |
description | Simple command line interface client for testing Entropy |
homepage | https://entropy.xyz/ |
repository | https://github.com/entropyxyz/entropy-core |
max_upload_size | |
id | 1088320 |
size | 190,304 |
This is a simple CLI for testing Entropy.
Note that this client has no secure private key storage and is only intended for use with test networks. For a fully featured command line client see entropyxyz/cli.
To use it you need to have access to a deployment of the Entropy network, with at least two chain nodes and two TSS servers.
This could be either:
ENTROPY_DEVNET
environment variable or using the --chain-endpoint
or -c
command line argument
to for example ws://54.175.228.156:9944
.ws://localhost:9944
.When using the local docker compose setup, be aware you need to set the TSS hostnames in your
/etc/hosts
file by adding the lines:
127.0.0.1 alice-tss-server
127.0.0.1 bob-tss-server
You'll also need the following packages:
OpenSSL:
# Debian/Ubuntu
sudo apt install libssl-dev
# MacOS
brew install openssl
pkg-config
:
# Debian/Ubuntu
sudo apt install pkg-config
# MacOS
brew install pkg-config
cargo install entropy-test-cli
As this is a test client, there is no private key storage. Instead we pass in a mnemonic that can be stored as an enviroment variable or passed in on the command line
To see usage information you can run the help
command:
entropy-test-cli -- help
You can also display help for a specific command:
entropy-test-cli -- help register
To see if you have access to a successfully configured deployment you can try the status
command
which will list the currently registered entropy accounts and stored programs:
entropy-test-cli -- status
To register an entropy account you need three things:
Alice
.register
command takes programs as either the hex-encoded hash
of an existing program on chain, or the local path to a .wasm
file containing the compiled
program.
device-key-proxy
program is always available with the zero hash: 0000000000000000000000000000000000000000000000000000000000000000
.testing-utils
crate contains some ready to use compiled programs, the simplest of which is
template_barebones.wasm
which allow you to sign any message which is more than 10 bytes long.programs
crate for more example programs as well as
instructions on how to write and build your own programs.You also need to decide which 'access mode' or 'key visibility' you want to register with: private or public. If you are not sure, 'public' is the simplest 'vanilla' access mode.
For example, to register with //Alice
as the signature request account in public access mode, using the template_barebones
program:
entropy-test-cli register public template_barebones.wasm -m //Alice
Example of registering in public access mode, with two programs, one given as a binary file and one given as a hash of an existing program:
entropy-test-cli register public my-program.wasm 3b3993c957ed9342cbb011eb9029c53fb253345114eff7da5951e98a41ba5ad5 -m //Alice
If registration was successful you will see the verifying key of your account, which is the public
secp256k1 key of your distributed keypair. You will need this in order to specify the account when
requesting to sign a message. If you run the status
command again and you should see the account
you registered.
The sign
command takes the verifying key of the account, given as hex, and a message to be signed,
given as a UTF-8 string.
entropy-test-cli -- sign 039fa2a16982fa6176e3fa9ae8dc408386ff040bf91196d3ec0aa981e5ba3fc1bb 'My message to sign'
If the program you have set takes additional auxiliary data, you can provided it as a hex encoded string:
entropy-test-cli -- sign 039fa2a16982fa6176e3fa9ae8dc408386ff040bf91196d3ec0aa981e5ba3fc1bb 'My message to sign' deadbeef1234
If signing is successful, a RecoverableSignature
object will be displayed containing the 64 byte secp256k1 signature encoded as hex, as well as a RecoveryId
.
As we saw above the register
command can store a program when you register. If you just want to store
a program you can use the store-program
command.
You need to give the account which will store the program, and the path to a program binary file you wish to store, for example:
entropy-test-cli store-program ./crates/testing-utils/example_barebones_with_auxilary.wasm //Alice
The update-programs
command is used to change the programs associated with a registered Entropy
account. It takes the signature verifying key, and the program modification account, and a list of
programs to evaluate when signing. Programs may be given as either the path to a .wasm binary file
or hashes of existing programs.
entropy-test-cli update-programs 039fa2a16982fa6176e3fa9ae8dc408386ff040bf91196d3ec0aa981e5ba3fc1bb my-new-program.wasm -m //Alice
Note that the program modification account must be funded for this to work.