|
| 1 | +# VetKey Password Manager (Motoko) |
| 2 | + |
| 3 | +[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/vetkeys/password_manager) |
| 4 | + |
| 5 | +Also available in: [Rust](../../../rust/vetkeys/password_manager) |
| 6 | + |
| 7 | +The **VetKey Password Manager** is an example application demonstrating how to use **VetKeys** and **Encrypted Maps** to build a secure, decentralized password manager on the **Internet Computer (IC)**. This application allows users to create password vaults, store encrypted passwords, and share vaults with other users via their **Internet Identity Principal**. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Secure Password Storage**: Uses VetKey to encrypt passwords before storing them in Encrypted Maps. |
| 12 | +- **Vault-Based Organization**: Users can create multiple vaults, each containing multiple passwords. |
| 13 | +- **Access Control**: Vaults can be shared with other users via their **Internet Identity Principal**. |
| 14 | + |
| 15 | +## Build and deploy from the command line |
| 16 | + |
| 17 | +### Prerequisites |
| 18 | + |
| 19 | +- Install [Node.js](https://nodejs.org/en/download/) |
| 20 | +- Install [icp-cli](https://cli.internetcomputer.org): `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` |
| 21 | +- Install [ic-mops](https://mops.one): `npm install -g ic-mops` |
| 22 | + |
| 23 | +### (Optionally) choose a different master key |
| 24 | + |
| 25 | +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. |
| 26 | + |
| 27 | +### Install |
| 28 | + |
| 29 | +```bash |
| 30 | +git clone https://github.com/dfinity/examples |
| 31 | +cd examples/motoko/vetkeys/password_manager |
| 32 | +``` |
| 33 | + |
| 34 | +### Deploy |
| 35 | + |
| 36 | +```bash |
| 37 | +icp network start -d |
| 38 | +icp deploy |
| 39 | +``` |
| 40 | + |
| 41 | +Open the frontend URL printed by `icp deploy`. |
| 42 | + |
| 43 | +To run the frontend in development mode with hot reloading (after `icp deploy`): |
| 44 | + |
| 45 | +```bash |
| 46 | +npm run dev |
| 47 | +``` |
| 48 | + |
| 49 | +When done, stop the local network to free up the port for other projects: |
| 50 | + |
| 51 | +```bash |
| 52 | +icp network stop |
| 53 | +``` |
| 54 | + |
| 55 | +## Example components |
| 56 | + |
| 57 | +### Backend (`backend/`) |
| 58 | + |
| 59 | +An **Encrypted Maps**-enabled Motoko canister that securely stores passwords. |
| 60 | + |
| 61 | +> **Note on naming.** The backend methods are snake_case (rather than the usual Motoko camelCase) because the `@icp-sdk/vetkeys` Encrypted Maps client calls the canister by these exact names — renaming them would break the frontend. The delegation methods are hand-written for now; an upstream Motoko actor mixin that generates this endpoint set automatically is in progress ([dfinity/vetkeys#405](https://github.com/dfinity/vetkeys/pull/405)). |
| 62 | +
|
| 63 | +### Frontend (`frontend/`) |
| 64 | + |
| 65 | +A **Svelte** application providing a user-friendly interface for managing vaults and passwords. It talks to the backend through the `@icp-sdk/vetkeys` Encrypted Maps client. |
| 66 | + |
| 67 | +## Limitations |
| 68 | + |
| 69 | +This example app does not implement key rotation, which is strongly recommended in a production environment. Key rotation involves periodically changing encryption keys and re-encrypting data to enhance security. In a production app, key rotation would be useful to limit the impact of a potential key compromise, or to limit access when users are added to or removed from sharing. |
| 70 | + |
| 71 | +## Additional resources |
| 72 | + |
| 73 | +- **[Password Manager with Metadata](../../../rust/vetkeys/password_manager_with_metadata)** — if you need to store additional metadata alongside passwords. |
| 74 | +- **[What are VetKeys](https://docs.internetcomputer.org/concepts/vetkeys)** — more information about VetKeys and VetKD. |
| 75 | +- [Security best practices](https://docs.internetcomputer.org/guides/security/overview/) |
0 commit comments