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
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/vetkeys/basic_bls_signing)
4
+
5
+
Also available in: [Rust](../../../rust/vetkeys/basic_bls_signing)
6
+
7
+
The **Basic BLS signing** example demonstrates how to use **[VetKeys](https://docs.internetcomputer.org/concepts/vetkeys)** to implement a threshold BLS signing service on the **Internet Computer (IC)**, where every authenticated user can ask the canister to produce signatures, with the **Internet Identity Principal** identifying the signer. The canister ensures a user can only produce signatures for their own principal, not for someone else's. Furthermore, the vetKeys in this app can only be produced upon a user request, as specified in the canister code — the canister cannot produce signatures for arbitrary users or messages.
8
+
9
+
To confirm the canister can only produce signatures in the intended way, users need to inspect the code installed in the canister. For this, it is crucial that canisters using VetKeys have their code public.
10
+
11
+

12
+
13
+
## Features
14
+
15
+
-**Signer Authorization**: Only authorized users can produce signatures, and only for their own identity.
16
+
-**Frontend Signature Verification**: Any user can publish a signature from their principal in the canister storage, and the frontend automatically checks its validity.
This example uses `test_key_1` by default. To use a different [available master key](https://docs.internetcomputer.org/concepts/vetkeys/#api-overview), change the `init_args` value in `icp.yaml` before deploying.
29
+
30
+
### Install
31
+
32
+
```bash
33
+
git clone https://github.com/dfinity/examples
34
+
cd examples/motoko/vetkeys/basic_bls_signing
35
+
```
36
+
37
+
### Deploy
38
+
39
+
```bash
40
+
icp network start -d
41
+
icp deploy
42
+
```
43
+
44
+
Open the frontend URL printed by `icp deploy`.
45
+
46
+
To run the frontend in development mode with hot reloading (after `icp deploy`):
47
+
48
+
```bash
49
+
npm run dev
50
+
```
51
+
52
+
When done, stop the local network to free up the port for other projects:
53
+
54
+
```bash
55
+
icp network stop
56
+
```
57
+
58
+
## Example components
59
+
60
+
### Backend (`backend/`)
61
+
62
+
A single Motoko canister that:
63
+
- Produces BLS signatures upon a user request.
64
+
- Lets users retrieve the public key used to verify their signatures.
65
+
- Lets users store signatures (real or fake) in a log data structure.
66
+
67
+
### Frontend (`frontend/`)
68
+
69
+
A vanilla TypeScript application providing a simple interface for signing, showing the signatures stored in the canister, and verifying a signature. Canister bindings are generated from `backend/backend.did` at build time by the `@icp-sdk/bindgen` Vite plugin.
70
+
71
+
## Updating the Candid interface
72
+
73
+
`backend/backend.did` defines the backend's public interface; the frontend bindings are generated from it during the build. If you change the backend's public API, regenerate it:
74
+
75
+
```bash
76
+
mops generate candid backend
77
+
```
78
+
79
+
## Additional resources
80
+
81
+
-**[What are VetKeys](https://docs.internetcomputer.org/concepts/vetkeys)** — more information about VetKeys and VetKD.
82
+
-[Security best practices](https://docs.internetcomputer.org/guides/security/overview/)
0 commit comments