Skip to content

Commit 3a7dc73

Browse files
authored
feat: CRP-2761 CRP-2850 copy encrypted notes dapp from examples repo and prepare for deploying to ICP Ninja (#162)
1 parent dff229a commit 3a7dc73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+21473
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: examples-encrypted-notes-dapp
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths:
8+
- examples/encrypted_notes_dapp_vetkd/**
9+
- backend/**
10+
- Cargo.toml
11+
- Cargo.lock
12+
- frontend/ic_vetkeys/**
13+
- package.json
14+
- package-lock.json
15+
- .github/workflows/provision-darwin.sh
16+
- .github/workflows/provision-linux.sh
17+
- .github/workflows/examples-encrypted-notes-dapp.yml
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
jobs:
22+
examples-encrypted-notes-dapp-rust-darwin:
23+
runs-on: macos-15
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Provision Darwin
27+
run: |
28+
bash .github/workflows/provision-darwin.sh
29+
- name: Deploy Encrypted Notes Dapp VetKD Darwin
30+
run: |
31+
set -eExuo pipefail
32+
cd examples/encrypted_notes_dapp_vetkd/rust
33+
dfx start --background && dfx deploy
34+
examples-encrypted-notes-dapp-rust-linux:
35+
runs-on: ubuntu-24.04
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Provision Linux
39+
run: bash .github/workflows/provision-linux.sh
40+
- name: Deploy Encrypted Notes Dapp VetKD Linux
41+
run: |
42+
set -eExuo pipefail
43+
cd examples/encrypted_notes_dapp_vetkd/rust
44+
dfx start --background && dfx deploy
45+
examples-encrypted-notes-dapp-motoko-darwin:
46+
runs-on: macos-15
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Provision Darwin
50+
run: |
51+
bash .github/workflows/provision-darwin.sh
52+
- name: Deploy Encrypted Notes Dapp VetKD Darwin
53+
run: |
54+
set -eExuo pipefail
55+
cd examples/encrypted_notes_dapp_vetkd/motoko
56+
dfx start --background && dfx deploy
57+
examples-encrypted-notes-dapp-motoko-linux:
58+
runs-on: ubuntu-24.04
59+
steps:
60+
- uses: actions/checkout@v4
61+
- name: Provision Linux
62+
run: bash .github/workflows/provision-linux.sh
63+
- name: Deploy Encrypted Notes Dapp VetKD Linux
64+
run: |
65+
set -eExuo pipefail
66+
cd examples/encrypted_notes_dapp_vetkd/motoko
67+
dfx start --background && dfx deploy
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Encrypted notes: vetKD
2+
3+
This is a copy of the [`encrypted-notes-dapp` example](https://github.com/dfinity/examples/tree/master/motoko/encrypted-notes-dapp), adapted to use [vetKeys](https://internetcomputer.org/docs/building-apps/network-features/vetkeys/introduction) and add sharing of notes between users.
4+
5+
In particular, instead of creating a principal-specific AES key and syncing it across devices (using device-specific RSA keys), the notes are encrypted with an AES key that is derived (directly in the browser) from a note-ID-specific vetKey obtained from the backend canister (in encrypted form, using an ephemeral transport key), which itself obtains it from the vetKD system API. This way, there is no need for any device management in the dapp, plus sharing of notes becomes possible.
6+
7+
The vetKey used to encrypt and decrypt a note is note-ID-specific (and not, for example, principal-specific) to enable the sharing of notes between users. The derived AES keys are stored as non-extractable CryptoKeys in an IndexedDB in the browser for efficiency so that their respective vetKey only has to be fetched from the server once. To improve the security even further, the vetKeys' derivation information could be adapted to include a (numeric) epoch that advances each time the list of users with which the note is shared is changed.
8+
9+
Currently, the only way to use this dapp is via manual local deployment (see below).
10+
11+
Please also see the [README of the original encrypted-notes-dapp](https://github.com/dfinity/examples/tree/master/motoko/encrypted-notes-dapp/README.md) for further details.
12+
13+
## Prerequisites
14+
15+
This example requires an installation of:
16+
17+
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
18+
- [x] Install [npm](https://www.npmjs.com/package/npm).
19+
20+
## Deploy the Canisters
21+
22+
If you want to deploy this project locally with a Motoko backend, then run:
23+
```bash
24+
dfx start --background && dfx deploy
25+
```
26+
from the `motoko` folder.
27+
28+
To use the Rust backend instead of Motoko, run the same command in the rust folder.
29+
30+
## Troubleshooting
31+
32+
If you run into issues, clearing all the application-specific IndexedDBs in the browser (which are used to store Internet Identity information and the derived non-extractable AES keys) might help fix the issue. For example in Chrome, go to Inspect → Application → Local Storage → `http://localhost:3000/` → Clear All, and then reload.

0 commit comments

Comments
 (0)