Add passphrase-encrypted wallet export flow#110
Draft
fainashalts wants to merge 9 commits intomainfrom
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a passphrase-encrypted wallet export flow that encrypts wallet mnemonics with a user-provided passphrase before transmission from the iframe. Users enter and confirm a passphrase through a new UI form, and the encrypted data is sent to the parent frame as base64-encoded content instead of plaintext.
Key changes:
- Implements AES-GCM-256 encryption with PBKDF2 key derivation (100,000 iterations)
- Adds a new
INJECT_WALLET_EXPORT_BUNDLE_ENCRYPTEDmessage type and corresponding handler - Creates a passphrase form UI with validation (8-character minimum, matching confirmation)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| export/index.template.html | Adds encryption/decryption utilities, passphrase form UI with styling, and message handler for encrypted wallet export flow |
| export/index.test.js | Adds 5 unit tests covering encryption, decryption, wrong passphrase handling, salt/IV randomness, and end-to-end base64 encoding |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Add passphrase-encrypted wallet export flow
Note: this PR is generated by Cursor using Claude Opus 4.5 based on the details provided in REQ-275. This is step 1, with additional work needed in the SDK and an example to be enumerated in mono.
Summary
This PR adds a new encrypted wallet export flow that allows users to encrypt their wallet mnemonic with a passphrase before it leaves the iframe. Instead of displaying the plaintext mnemonic in the DOM, users are prompted to enter and confirm a passphrase, and the encrypted result is sent to the parent frame as base64-encoded data.
Changes
New Encryption Utilities (TKHQ Module)
encryptWithPassphrase(buf, passphrase)- Encrypts aUint8Arrayusing:salt (16 bytes) || iv (12 bytes) || ciphertextdecryptWithPassphrase(encryptedBuf, passphrase)- Decrypts data encrypted by the above functionNew Message Type
INJECT_WALLET_EXPORT_BUNDLE_ENCRYPTED- New message type that triggers the passphrase-protected export flow instead of displaying the mnemonic directlyNew UI Component
displayPassphraseForm(mnemonic, requestId)- Renders a form with:New Output Message
ENCRYPTED_WALLET_EXPORT- Sent to parent frame with base64-encoded encrypted wallet data upon successful encryptionStyling
Testing
Added 5 new tests:
encryptWithPassphrasecorrectlyAll 23 tests passing.
Usage
Parent frame sends:
Parent frame receives (after user enters passphrase):
Security Notes