Skip to content

Commit 67c7105

Browse files
Merge pull request #1213 from dfinity/jessiemongeon1-patch-44
add: Deploy to ICP Ninja + Standardize README
2 parents f1b44d0 + 36de585 commit 67c7105

File tree

1 file changed

+17
-86
lines changed

1 file changed

+17
-86
lines changed

rust/threshold-ecdsa/README.md

Lines changed: 17 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Threshold ECDSA sample
22

3-
We present a minimal example canister smart contract for showcasing the [threshold ECDSA](https://internetcomputer.org/docs/current/developer-docs/integrations/t-ecdsa) API.
3+
We present a minimal example canister smart contract for showcasing the [threshold ECDSA](https://internetcomputer.org/docs/building-apps/network-features/signatures/t-ecdsa) API.
44

55
The example canister is a signing oracle that creates ECDSA signatures with keys derived from an input string.
66

@@ -10,61 +10,13 @@ More specifically:
1010
- The sample canister hashes the message and uses the key derivation string for the derivation path.
1111
- The sample canister uses the above to request a signature from the threshold ECDSA [subnet](https://wiki.internetcomputer.org/wiki/Subnet_blockchain) (the threshold ECDSA is a subnet specializing in generating threshold ECDSA signatures).
1212

13-
This tutorial gives a complete overview of the development, starting with downloading the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/index.md), up to the deployment and trying out the code on the IC mainnet.
13+
## Deploying from ICP Ninja
1414

15-
> [!TIP]
16-
> This walkthrough focuses on the version of the sample canister code written in the Rust programming language. There is also a [Motoko](https://internetcomputer.org/docs/current/developer-docs/backend/motoko/index.md) version available in the same repo and follows the same commands for deploying.
15+
[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/editor?g=https://github.com/dfinity/examples/tree/master/rust/threshold-ecdsa)
1716

18-
## Prerequisites
19-
This example requires an installation of:
17+
### 1. Update source code with the right key ID.
2018

21-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install) v0.11.0 or newer.
22-
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
23-
24-
## Local deployment
25-
26-
Begin by opening a terminal window.
27-
28-
### Step 1: Setup the project environment
29-
30-
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
31-
32-
```bash
33-
cd examples/rust/threshold-ecdsa
34-
dfx start --background
35-
```
36-
37-
### Step 2: Deploy the canisters
38-
39-
```bash
40-
dfx deploy
41-
```
42-
43-
If successful, you should see something like this:
44-
45-
```bash
46-
Deployed canisters.
47-
URLs:
48-
Backend canister via Candid interface:
49-
ecdsa_example_rust: http://127.0.0.1:4943/?canisterId=t6rzw-2iaaa-aaaaa-aaama-cai&id=st75y-vaaaa-aaaaa-aaalq-cai
50-
```
51-
52-
If you open the URL in a web browser, you will see a web UI that shows the public methods the canister exposes. Since the canister exposes `public_key` and `sign` methods, those are rendered in the web UI.
53-
54-
## Deploying the canister on the mainnet
55-
56-
To deploy this canister to the mainnet, one needs to do two things:
57-
58-
- Acquire cycles (the equivalent of "gas" on other blockchains). This is necessary for all canisters.
59-
- Update the sample source code to have the right key ID. This is unique to this canister.
60-
61-
### Acquire cycles to deploy
62-
63-
Deploying to the Internet Computer requires [cycles](https://internetcomputer.org/docs/current/developer-docs/getting-started/tokens-and-cycles) (the equivalent of "gas" on other blockchains).
64-
65-
### Update source code with the right key ID
66-
67-
To deploy the sample code, the canister needs the right key ID for the right environment. Specifically, one needs to replace the value of the `key_id` in the `src/ecdsa_example_rust/src/lib.rs` file of the sample code. Before deploying to the mainnet, one should modify the code to use the right name of the `key_id`.
19+
To deploy the sample code on ICP Ninja, the canister needs the right key ID for the right environment. Specifically, one needs to replace the value of the `key_id` in the `src/ecdsa_example_rust/src/lib.rs` file of the sample code. Before deploying to the mainnet from ICP Ninja, one should modify the code to use the right name of the `key_id`.
6820

6921
There are three options:
7022

@@ -75,40 +27,23 @@ There are three options:
7527
> [!WARNING]
7628
> To deploy to IC mainnet, one needs to replace the value in `key_id `fields with the values `EcdsaKeyIds::TestKeyLocalDevelopment.to_key_id()` (mapping to `dfx_test_key`) to instead have either `EcdsaKeyIds::TestKey1.to_key_id()` (mapping to `test_key_1`) or `EcdsaKeyIds::ProductionKey1.to_key_id()` (mapping to `key_1`) depending on the desired intent.
7729
78-
### Deploying
30+
## Build and deploy from the command-line
7931

80-
To [deploy via mainnet](https://internetcomputer.org/docs/current/developer-docs/setup/deploy-mainnet.md), run the following commands:
32+
### 1. [Download and install the IC SDK.](https://internetcomputer.org/docs/building-apps/getting-started/install)
8133

82-
```bash
83-
dfx deploy --network ic
84-
```
85-
If successful, you should see something like this:
34+
### 2. Download your project from ICP Ninja using the 'Download files' button on the upper left corner, or [clone the GitHub examples repository.](https://github.com/dfinity/examples/)
8635

87-
```bash
88-
Deployed canisters.
89-
URLs:
90-
Backend canister via Candid interface:
91-
ecdsa_example_rust: https://a3gq9-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=736w4-cyaaa-aaaal-qb3wq-cai
92-
```
36+
### 3. Navigate into the project's directory.
9337

94-
In the example above, `ecdsa_example_rust` has the URL https://a3gq9-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=736w4-cyaaa-aaaal-qb3wq-cai and serves up the Candid web UI for this particular canister deployed on mainnet.
38+
### 4. Deploy the project to your local environment:
9539

96-
## Obtaining public keys
97-
98-
### Using the Candid UI
99-
100-
If you deployed your canister locally or to the mainnet, you should have a URL to the Candid web UI where you can access the public methods. We can call the `public-key` method.
40+
```
41+
dfx start --background --clean && dfx deploy
42+
```
10143

102-
In the example below, the method returns `03c22bef676644dba524d4a24132ea8463221a55540a27fc86d690fda8e688e31a` as the public key.
44+
## Obtaining public keys
10345

104-
```json
105-
{
106-
"Ok":
107-
{
108-
"public_key_hex": "03c22bef676644dba524d4a24132ea8463221a55540a27fc86d690fda8e688e31a"
109-
}
110-
}
111-
```
46+
If you deployed your canister locally or to the mainnet, you should have a URL to the Candid web UI where you can access the public methods. You can call the `public-key` method.
11247

11348
### Canister root public key
11449

@@ -143,10 +78,6 @@ The call to `ecdsaVerify` function should always return `true`.
14378

14479
Similar verifications can be done in many other languages with the help of cryptographic libraries that support the `secp256k1` curve.
14580

146-
## Conclusion
147-
148-
In this walkthrough, we deployed a sample smart contract that:
81+
## Security considerations and best practices
14982

150-
* Signed with private ECDSA keys even though **canisters do not hold ECDSA keys themselves**.
151-
* Requested a public key.
152-
* Performed signature verification.
83+
If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/building-apps/security/overview) for developing on ICP. This example may not implement all the best practices.

0 commit comments

Comments
 (0)