You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
4
4
5
5
The example canister is a signing oracle that creates ECDSA signatures with keys derived from an input string.
6
6
@@ -10,61 +10,13 @@ More specifically:
10
10
- The sample canister hashes the message and uses the key derivation string for the derivation path.
11
11
- 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).
12
12
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
14
14
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.
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`.
68
20
69
21
There are three options:
70
22
@@ -75,40 +27,23 @@ There are three options:
75
27
> [!WARNING]
76
28
> 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.
77
29
78
-
### Deploying
30
+
##Build and deploy from the command-line
79
31
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)
81
33
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/)
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:
95
39
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
+
```
101
43
102
-
In the example below, the method returns `03c22bef676644dba524d4a24132ea8463221a55540a27fc86d690fda8e688e31a` as the public key.
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.
112
47
113
48
### Canister root public key
114
49
@@ -143,10 +78,6 @@ The call to `ecdsaVerify` function should always return `true`.
143
78
144
79
Similar verifications can be done in many other languages with the help of cryptographic libraries that support the `secp256k1` curve.
145
80
146
-
## Conclusion
147
-
148
-
In this walkthrough, we deployed a sample smart contract that:
81
+
## Security considerations and best practices
149
82
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