chore(rust): update vetkeys examples to ic-vetkeys 0.8.1 and @icp-sdk/vetkeys 0.5.0 - #1456
Open
marc0olo wants to merge 4 commits into
Open
chore(rust): update vetkeys examples to ic-vetkeys 0.8.1 and @icp-sdk/vetkeys 0.5.0#1456marc0olo wants to merge 4 commits into
marc0olo wants to merge 4 commits into
Conversation
…/vetkeys 0.5.0 Backend (ic-vetkeys 0.7.0 -> 0.8.1): - password_manager: replace the hand-written EncryptedMaps pass-through canister with the new `ic_vetkeys::export_encrypted_maps_canister!` macro (~311 -> ~30 lines). The macro owns the endpoint set, so the Candid matches the frontend by construction. Regenerated backend.did (interface unchanged; the newer crate now emits doc comments into the Candid). - basic_ibe, basic_timelock_ibe, basic_bls_signing, password_manager_with_metadata: version bump only (no breaking API changes since 0.7.0). - password_manager_with_metadata deliberately stays hand-written: it keeps a second, backend-authoritative metadata map in sync with the encrypted values, so it must NOT expose the plain insert/remove mutators the macro would generate (they would let a value be written without its metadata row and desync the two stores). See dfinity/vetkeys issue linked in the PR. Frontend (@icp-sdk/vetkeys ^0.5.0-beta.0 -> ^0.5.0): - All 7 Rust frontends bumped to the final 0.5.0 release. - password_manager and password_manager_with_metadata: opt back into IndexedDB persistence (in-memory is the new 0.5.0 default) via IndexedDbDerivedKeyMaterialCache, namespaced per identity, and call EncryptedMaps.clearCache() on logout to drop cached key material. Motoko examples untouched (Rust-only change, per request). Verified: cargo check on all 5 backends; wasm build + candid diff for password_manager; npm build for all 7 frontends. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… on logout Explain the IndexedDB opt-in (per-identity namespace) and that clearCache() empties the derived-key-material store rather than deleting the database, so an empty vetkeys-<principal> DB remaining is expected. Add the DevTools steps to verify (incl. the Refresh-database gotcha) and clarify the unrelated icp-sdk-<host> subnetNodeKeys DB. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…metadata The METADATA StableBTreeMap was initialized with StableBTreeMap::new, which overwrites the backing memory with an empty map every time the thread-local is re-created after an upgrade. Because the read path zips the metadata iterator against the (surviving) encrypted values, an empty metadata map made every password disappear from the UI after an upgrade while the vault still listed as non-empty. Use StableBTreeMap::init so the persisted map is loaded instead. Pre-existing bug, unrelated to the 0.8.1 bump; surfaced during upgrade testing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates the Rust vetKeys examples to current ic-vetkeys / @icp-sdk/vetkeys releases, adopting the new export_encrypted_maps_canister! backend macro where applicable and adjusting password-manager frontends for the v0.5.0 derived-key caching behavior.
Changes:
- Bump Rust backends to
ic-vetkeys = 0.8.1, including migratingpassword_managerbackend to the generated Encrypted Maps canister macro. - Update password-manager frontends to persist derived-key material via
IndexedDbDerivedKeyMaterialCacheand clear cached material on logout. - Bump all Rust vetKeys frontends from
@icp-sdk/vetkeys^0.5.0-beta.0to^0.5.0, plus related docs updates.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/vetkeys/password_manager/README.md | Document macro-generated backend and derived-key caching behavior. |
| rust/vetkeys/password_manager/frontend/src/store/auth.ts | Clear EncryptedMaps cache on logout; adjust EncryptedMaps creation call signature. |
| rust/vetkeys/password_manager/frontend/src/lib/encrypted_maps.ts | Create EncryptedMaps with per-principal IndexedDB cache; API updated to accept Identity. |
| rust/vetkeys/password_manager/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/password_manager/Cargo.toml | Bump ic-vetkeys to 0.8.1. |
| rust/vetkeys/password_manager/backend/src/lib.rs | Replace handwritten canister with ic_vetkeys::export_encrypted_maps_canister! macro usage. |
| rust/vetkeys/password_manager/backend/backend.did | Regenerate .did (doc comments updated by newer crate). |
| rust/vetkeys/password_manager_with_metadata/README.md | Explain why this example stays handwritten; document derived-key caching behavior. |
| rust/vetkeys/password_manager_with_metadata/frontend/src/store/auth.ts | Clear derived-key material cache on logout; adjust PasswordManager creation call signature. |
| rust/vetkeys/password_manager_with_metadata/frontend/src/lib/password_manager.ts | Update PasswordManager factory to take an Identity and wire cache namespacing. |
| rust/vetkeys/password_manager_with_metadata/frontend/src/lib/encrypted_maps.ts | Create EncryptedMaps with per-principal IndexedDB cache. |
| rust/vetkeys/password_manager_with_metadata/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/password_manager_with_metadata/backend/src/lib.rs | Fix metadata persistence by switching StableBTreeMap::new → ::init. |
| rust/vetkeys/password_manager_with_metadata/backend/Cargo.toml | Bump ic-vetkeys to 0.8.1. |
| rust/vetkeys/encrypted_notes_app_vetkd/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/basic_vetkd/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/basic_timelock_ibe/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/basic_timelock_ibe/backend/Cargo.toml | Bump ic-vetkeys to 0.8.1. |
| rust/vetkeys/basic_ibe/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/basic_ibe/backend/Cargo.toml | Bump ic-vetkeys to 0.8.1. |
| rust/vetkeys/basic_bls_signing/frontend/package.json | Bump @icp-sdk/vetkeys to ^0.5.0. |
| rust/vetkeys/basic_bls_signing/backend/Cargo.toml | Bump ic-vetkeys to 0.8.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…hing docs Address PR review feedback: - password_manager and password_manager_with_metadata: clear the derived-key cache best-effort on logout so sign-out still completes if IndexedDB is unavailable (private mode, quota, blocked storage). - READMEs and code comments: refer to clearCache() as an instance method and drop the "identity change" wording — the apps only clear on logout, and the per-identity cache namespace already isolates identities. - password_manager backend: reword the macro comment so the domain-separator string argument is no longer conflated with the config memory slot. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mraszyk
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Updates the Rust vetKeys examples to the current library releases, adopts the new EncryptedMaps canister macro where it fits, and migrates the frontends for the 0.5.0 caching change.
Backend —
ic-vetkeys0.7.0 → 0.8.1password_manager: the hand-written EncryptedMaps pass-through canister is replaced by theic_vetkeys::export_encrypted_maps_canister!macro (backend/src/lib.rs, ~311 → ~30 lines). The canister owns theMemoryManagerand passes EncryptedMaps its fourMemoryinstances; the macro emits#[init]/#[post_upgrade]and every endpoint, so the Candid matches the@icp-sdk/vetkeysfrontend by construction.backend.didregenerated — the interface is unchanged; the only delta is doc comments the newer crate emits into the Candid.password_manager_with_metadata: version bump, plus a persistence fix — itsMETADATAstable map is now initialized withStableBTreeMap::initinstead of::new.::newreset the map every time the thread-local was re-created after an upgrade, wiping all metadata; because the read path zips metadata against the (surviving) encrypted values, every password disappeared from the UI after an upgrade while the vault still listed as non-empty.initloads the persisted map.basic_ibe,basic_timelock_ibe,basic_bls_signing: dependency version bump only.Why
password_manager_with_metadatakeeps a hand-written canisterThe macro is all-or-nothing. This example maintains a second, backend-authoritative metadata map that must stay 1:1 with the encrypted values, so it must not expose the plain
insert_encrypted_value/remove_encrypted_valuemutators the macro would generate (they'd let a value be written with no metadata row and desync the two stores). Filed upstream about closing that gap: dfinity/vetkeys#423.Frontend —
@icp-sdk/vetkeys^0.5.0-beta.0→^0.5.0All 7 Rust frontends move to the final 0.5.0 release. 0.5.0 makes derived-key caching in-memory by default; the two password-manager frontends:
IndexedDbDerivedKeyMaterialCache, namespaced per identity (vetkeys-<principal>) so one identity's keys are never served to another on the same origin;EncryptedMaps.clearCache()on logout to drop cached key material.The other 5 (
basic_*,encrypted_notes_app_vetkd) are version-bump only — they don't use the EncryptedMaps client.Docs
Both password-manager READMEs updated: macro-vs-hand-written rationale, and a "derived-key caching" section explaining the IndexedDB opt-in and how to verify
clearCache()on logout (thevetkeys-<principal>store is emptied, not deleted).Scope
Rust examples only; the Motoko vetKeys examples are unchanged.
Verification
cargo checkon all 5 backends;password_managerwasm build +candid-extractordiff against the committed.did(service surface identical).npm run buildon all 7 frontends against the real0.5.0.password_manager: create/read/share password; logout empties thevetkeys-<principal>cache; upgrade (--mode upgrade) preserves data and existing passwords still decrypt.password_manager_with_metadata: metadata (timestamps, modification count, principal) persists across an upgrade.basic_ibe: encrypt → fetch vetKey → decrypt.🤖 Generated with Claude Code