Repository navigation
Commit c73823d
feat(vetkeys): adopt EncryptedMaps mixins in the Motoko examples (ic-vetkeys 0.6.0) (#1475)
* feat(vetkeys): adopt EncryptedMaps mixins in the Motoko password managers
mops ic-vetkeys 0.6.0 adds the Motoko counterpart to the Rust macro, closing the
Motoko half of dfinity/vetkeys#423:
- `EncryptedMapsCanister` (mo:ic-vetkeys/encrypted_maps/Canister) contributes the
complete Encrypted Maps endpoint set. `password_manager` drops from 228 lines
of hand-written delegation to ~15.
- `EncryptedMapsControlPlaneCanister` (.../ControlPlaneCanister) contributes the
control-plane endpoints and the in-scope `encryptedMaps` object but none of the
value read/write endpoints. `password_manager_with_metadata` uses it, so the
plain insert/remove mutators — which would write a value with no metadata row
and desync the two stores — are never exposed, while the canister keeps its own
`*_with_metadata` endpoints.
Neither mixin declares stable state: the actor declares the `EncryptedMapsState`
and passes it in, keeping the persistent state a plain, visible stable variable
the canister owns and can migrate.
Both password managers become plain persistent actors that resolve the vetKD key
name from the `VETKD_KEY_NAME` canister environment variable (defaulting to
test_key_1 so init stays total), replacing the `actor class (keyName : Text)` and
its `init_args`. This follows the upstream reference canisters and removes the
actor class from the main canister. `icp.yaml` sets the variable under
`settings.environment_variables`; the generated Candid loses its `(text)` init
argument but exposes an identical 11-method interface.
Domain separators now name their own example: both Motoko password managers
shared `password_manager_example_app`, and are now `password_manager_app` and
`password_manager_with_metadata_app`, matching the Rust examples.
0.6.0 requires moc 1.13.0 and mo:core 2.6.1 (raised from 1.11.0 / 2.5.0), so all
five Motoko examples pinning ic-vetkeys move together. The new toolchain
surfaces warnings in basic_ibe, basic_bls_signing and basic_vetkd: dot notation
(auto-fixed), the deprecated Nat64.fromNat / Nat8.fromNat / Blob.fromArray, and
never-reassigned `var`s. Changing those to `let` needs no migration — matching
stable fields may differ in mutability.
Verified: mops check clean for all five; all backends build; local icp deploy
e2e on both password managers — insert/update/read with metadata, vault sharing
via the mixin-generated control plane, values and metadata surviving an upgrade,
and `insert_encrypted_value` correctly absent from the metadata canister
(IC0536).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat(vetkeys): resolve the vetKD key name from VETKD_KEY_NAME everywhere
The two password managers moved to the `VETKD_KEY_NAME` canister environment
variable when they adopted the Encrypted Maps mixins, which left the other
Motoko vetKeys examples on `actor class (keyName : Text)` + `init_args` — two
conventions side by side in one directory. This converts the rest:
- basic_ibe, basic_bls_signing: actor class parameter -> env var
- basic_vetkd: the key name was hardcoded to `test_key_1`; it is now
configurable through the same variable
- encrypted_notes_app_vetkd: also drops the actor class. Its
`shared ({ caller = initializer })` binding was never used, so nothing needed
replacing.
Each canister is now a plain actor reading the key at install with a
`?? "test_key_1"` default, so init stays total. `icp.yaml` sets the variable
under `settings.environment_variables`, and the READMEs document it — including
that the key cannot be changed once a canister holds data, since it feeds vetKD
key derivation.
Regenerated the committed Candid: every service loses its `(text)` init
argument, and the method sets are unchanged. basic_vetkd's file was previously
hand-formatted, so it also picks up the generator's parameter names and ordering.
Verified: mops check clean; local icp deploy for all four — IBE public key, BLS
sign + list, symmetric key verification, and a note round trip. Confirmed the
variable is genuinely delivered to the canister rather than silently falling
back to the default, by deploying basic_ibe with VETKD_KEY_NAME=no_such_key and
watching vetKD reject that key name.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs(vetkeys): align key-name docs and comments with actual behaviour
The `icp.yaml` comment claimed the key is read at install time, which is only
true for the password managers: they bake it into the stable EncryptedMapsState,
so a later change is ignored. The other four hold it in a `transient`, re-read on
every upgrade, so a changed variable does take effect — and orphans everything
encrypted under the old key. The code comments and READMEs of those four said
only "do not change it" without saying what happens; they now state it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(vetkeys): capture the vetKD key name in stable state, not a transient
basic_ibe, basic_bls_signing, basic_vetkd and encrypted_notes_app_vetkd held the
key name in a `transient`, which is re-read on every upgrade — so editing
VETKD_KEY_NAME and redeploying silently re-keyed the canister and orphaned
everything encrypted under the old key, with a green deploy and no error.
Dropping `transient` makes it a stable variable captured at the first install,
matching the password managers, where the key is baked into the EncryptedMapsState.
A later change to the variable is now ignored instead of destructive; only a
reinstall, which drops all data, switches keys.
This takes away no capability. Changing the key already destroyed the ability to
read the data — a migration could rewrite the field, but the canister only ever
sees ciphertext and cannot re-encrypt, so it would just yield a canister that
cannot read its own store. Real re-keying needs application-level key rotation,
which these examples do not implement and which their READMEs already note.
All six examples now behave identically, so the code comments, the icp.yaml
comments and the README paragraph are one shared wording that states when the key
is read, that later changes are ignored, and why reinstall is the only escape.
Verified: mops check and icp project show clean for all six; deployed basic_ibe,
then upgraded it with VETKD_KEY_NAME=no_such_key and confirmed the IBE public key
is unchanged — the misconfiguration is ignored rather than silently orphaning data.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs(vetkeys): make the Motoko canister headers doc comments
Mirrors the review feedback on #1474 for the Motoko side. The header block
describing each canister becomes `///`, matching how cert-var, random_maze and
canister_factory already document their `main.mo`.
Only the two headers change. Inline notes on individual declarations stay `//`:
they are implementation notes, not interface documentation.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs(vetkeys): finish the password_manager doc comment block
Review catch on #1475: the last two lines of the header stayed `//`, truncating
the doc comment mid-sentence. The script that converted the block ended it at the
first "actor " it found, which matched the words "this actor declares" inside the
prose rather than the declaration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 19dea9d commit c73823d
28 files changed
Lines changed: 354 additions & 502 deletions
File tree
- motoko/vetkeys
- basic_bls_signing
- backend
- basic_ibe
- backend
- basic_vetkd
- backend
- encrypted_notes_app_vetkd
- backend
- password_manager_with_metadata
- backend
- password_manager
- backend
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 1 | | |
8 | 2 | | |
9 | 3 | | |
10 | 4 | | |
11 | 5 | | |
12 | 6 | | |
13 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
12 | 28 | | |
13 | | - | |
14 | 29 | | |
15 | 30 | | |
16 | 31 | | |
| |||
37 | 52 | | |
38 | 53 | | |
39 | 54 | | |
40 | | - | |
| 55 | + | |
41 | 56 | | |
42 | 57 | | |
43 | 58 | | |
| |||
47 | 62 | | |
48 | 63 | | |
49 | 64 | | |
50 | | - | |
51 | | - | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | | - | |
55 | | - | |
| 69 | + | |
| 70 | + | |
56 | 71 | | |
57 | | - | |
58 | | - | |
| 72 | + | |
59 | 73 | | |
60 | 74 | | |
61 | 75 | | |
62 | | - | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
73 | 87 | | |
74 | 88 | | |
75 | 89 | | |
76 | | - | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| |||
87 | 101 | | |
88 | 102 | | |
89 | 103 | | |
90 | | - | |
| 104 | + | |
91 | 105 | | |
92 | 106 | | |
93 | 107 | | |
94 | | - | |
| 108 | + | |
95 | 109 | | |
96 | 110 | | |
97 | 111 | | |
98 | 112 | | |
99 | 113 | | |
100 | 114 | | |
101 | | - | |
| 115 | + | |
102 | 116 | | |
103 | | - | |
| 117 | + | |
104 | 118 | | |
105 | | - | |
| 119 | + | |
106 | 120 | | |
107 | 121 | | |
108 | 122 | | |
109 | | - | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | 1 | | |
10 | 2 | | |
11 | 3 | | |
| |||
23 | 15 | | |
24 | 16 | | |
25 | 17 | | |
26 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
12 | 28 | | |
13 | | - | |
14 | 29 | | |
15 | 30 | | |
16 | 31 | | |
| |||
64 | 79 | | |
65 | 80 | | |
66 | 81 | | |
67 | | - | |
| 82 | + | |
68 | 83 | | |
69 | 84 | | |
70 | 85 | | |
| |||
74 | 89 | | |
75 | 90 | | |
76 | 91 | | |
77 | | - | |
| 92 | + | |
78 | 93 | | |
79 | 94 | | |
80 | 95 | | |
81 | | - | |
| 96 | + | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
87 | | - | |
| 102 | + | |
88 | 103 | | |
89 | 104 | | |
90 | | - | |
| 105 | + | |
91 | 106 | | |
92 | | - | |
| 107 | + | |
93 | 108 | | |
94 | 109 | | |
95 | 110 | | |
| |||
101 | 116 | | |
102 | 117 | | |
103 | 118 | | |
104 | | - | |
| 119 | + | |
105 | 120 | | |
106 | 121 | | |
107 | 122 | | |
| |||
119 | 134 | | |
120 | 135 | | |
121 | 136 | | |
122 | | - | |
123 | | - | |
| 137 | + | |
| 138 | + | |
124 | 139 | | |
125 | 140 | | |
126 | 141 | | |
| |||
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
137 | | - | |
| 152 | + | |
138 | 153 | | |
139 | 154 | | |
140 | 155 | | |
141 | 156 | | |
142 | 157 | | |
143 | 158 | | |
144 | 159 | | |
145 | | - | |
| 160 | + | |
146 | 161 | | |
147 | 162 | | |
148 | 163 | | |
149 | 164 | | |
150 | | - | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | 168 | | |
| |||
158 | 173 | | |
159 | 174 | | |
160 | 175 | | |
161 | | - | |
| 176 | + | |
162 | 177 | | |
163 | 178 | | |
164 | 179 | | |
165 | | - | |
| 180 | + | |
166 | 181 | | |
167 | | - | |
| 182 | + | |
168 | 183 | | |
169 | 184 | | |
170 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
0 commit comments