Skip to content

Consider encrypted wallet export/import and optional passphrase protection #3

@DJ-Champion

Description

@DJ-Champion

BrowserCoin currently stores the wallet keypair in browser storage and allows wallet export/import as a JSON file. This is very convenient for an experimental browser-native chain, but it may be worth adding an optional encrypted wallet format before users become attached to their balances.

Potential concern:

If exported wallet files contain raw private key material, anyone who obtains the file can immediately spend the funds.
Since the wallet also lives in browser storage, malicious scripts, compromised dependencies, browser extensions, or local profile access could expose the private key.
Even though BrowserCoin is experimental and not a financial instrument, users may still treat their coins as valuable once they have mined them.

Possible improvement:

Add an “Encrypt wallet export” option using a user-supplied passphrase.
Derive an encryption key with a browser-friendly KDF such as Argon2id, PBKDF2, or scrypt.
Encrypt the private key using WebCrypto AES-GCM.
Store metadata in the exported JSON, for example:
{
"version": 2,
"encrypted": true,
"kdf": "PBKDF2 or Argon2id",
"salt": "...",
"iterations_or_params": "...",
"cipher": "AES-GCM",
"iv": "...",
"ciphertext": "..."
}

Suggested UX:

Keep the current plain JSON export available only as an “advanced / unencrypted” option, with a warning.
Make encrypted export the default.
On import, detect whether the wallet file is encrypted and prompt for the passphrase if needed.
Consider adding a short warning near wallet export: “Anyone with this file can spend your BRC unless it is encrypted.”

This would not solve all browser-wallet risks, especially localStorage or malicious-extension access, but it would make backups and wallet transfers much safer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions