Sample Motoko and Rust code on how to use the upcoming threshold ECDSA signing features of the Internet Computer.
The API of the IC Management Canister specifies two functions, ecdsa_public_key
and sign_with_ecdsa
that can be called from a canister (not from a user).
One must attach enough cycles with the call when using sign_with_ecdsa
.
More specifically, the examples demonstrate:
- How to specify the
key_id
that is provided by default in a localdfx
environment. You will need to change it if deploying to main net. - How to specify a
derivation_path
when querying public key or making a signature. The example here is to use caller's principal, but any byte arrays will do. - How to verify the result signature against the returned public key (in Javascript).
To run the demo, you will need a working installation of the DFINITY SDK version 0.11 or above, nodejs and also Rust toolchain such as rustup.
To run with Motoko only, please comment out the ecdsa_example_rust
section in dfx.json
before proceed.
The command below build and deploy all canisters including a frontend asset canister:
dfx deploy
If all is successful, you may point your browser to the asset canister's URL and see the frontend UI of this demo.