proof-of-concept(wallet): opt in to kv-store encryption-at-rest#18
Open
mverzilli wants to merge 1 commit intomartin/sqlite-opfs-wiringfrom
Open
proof-of-concept(wallet): opt in to kv-store encryption-at-rest#18mverzilli wants to merge 1 commit intomartin/sqlite-opfs-wiringfrom
mverzilli wants to merge 1 commit intomartin/sqlite-opfs-wiringfrom
Conversation
Wires the new AesGcmCipher from @aztec/kv-store/sqlite-opfs into the PXE + walletDB stores. A 32-byte master seed is generated once and persisted in localStorage under `aztec-kv-cipher-seed-v1`; subsequent loads reuse it so the encrypted OPFS data remains readable across reloads. Changes - walletService.ts: build a shared AesGcmCipher (RawKeyProvider over the persisted seed) and pass it to both AztecSQLiteOPFSStore.open calls. The wallet + PXE get the same HKDF-derived sub-keys. - walletService.ts: VITE_KV_ENCRYPT=0 (or "false") disables the cipher — useful for A/B diagnosis and as a safety escape hatch. Default is on. - walletService.ts: registerSqliteInspectors runs BEFORE EmbeddedWallet.create so the DevTools helpers are reachable even if wallet init hangs or throws. - sqliteInspector.ts: new peekEncryption() reports per-container valueEncrypted / keyLooksHmacd flags at a glance, so you can visually confirm the cipher is active and opaque-keys containers actually HMAC their keys on disk. Fixed summarize()'s reliance on SQLite's `rowid` — the data table is WITHOUT ROWID, so the old query syntax failed. Key provider caveat This is a dev-grade key source: the seed survives page reloads (localStorage) but not device loss or same-origin XSS. A proper IndexedDB-backed unextractable CryptoKey provider — or WebAuthn-PRF — is follow-up work. Validated end-to-end Ran a full swap + claim on testnet with encryption on, then confirmed via peekEncryption() that every audit-flagged container is HMAC'd (32-byte keys): map:notes, map:note_nullifiers_by_contract, map:note_block_number_to_nullifier, map:pending_indexes, map:last_finalized_indexes, map:highest_aged_index, map:highest_finalized_index, map:complete_address_index, map:accounts, map:account_aliases. All 22 populated containers show valueEncrypted: true. Depends on aztec-packages martin/sqlite-with-encryption-at-rest (PR AztecProtocol/aztec-packages#22683). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Wires the new AesGcmCipher from @aztec/kv-store/sqlite-opfs into the PXE + walletDB stores. A 32-byte master seed is generated once and persisted in localStorage under
aztec-kv-cipher-seed-v1; subsequent loads reuse it so the encrypted OPFS data remains readable across reloads.Changes
rowid— the data table is WITHOUT ROWID, so the old query syntax failed.Key provider caveat
This is a dev-grade key source: the seed survives page reloads (localStorage) but not device loss or same-origin XSS. A proper IndexedDB-backed unextractable CryptoKey provider — or WebAuthn-PRF — is follow-up work.
Validated end-to-end
Ran a full swap + claim on testnet with encryption on, then confirmed via peekEncryption() that every audit-flagged container is HMAC'd (32-byte keys): map:notes, map:note_nullifiers_by_contract, map:note_block_number_to_nullifier, map:pending_indexes, map:last_finalized_indexes, map:highest_aged_index, map:highest_finalized_index, map:complete_address_index, map:accounts, map:account_aliases. All 22 populated containers show valueEncrypted: true.
Depends on aztec-packages martin/sqlite-with-encryption-at-rest (PR AztecProtocol/aztec-packages#22683).