-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Objective
- Implement a session based mechanism to access the encrypted seed stored in the vault in order to sign transactions without having to ask the user's password each time during a session.
- User should enter his password once, then for each transaction that he has to sign, he shouldn't have to enter his password again during this session. A session is active as long as the user is not idle for more than 15 minutes (TBD) (i.e. not using the wallet's UI). A session is automatically ended if the user closes his browser. Starting a new session means prompting the user's password again.
Architecture
Storage strategy
- Persistent layer (
chrome.storage.local): Stores the vault. This includes the encrypted seed, a unique random salt, and the initialization vector. - Ephemeral layer (
chrome.storage.session): Stores the master encryption key derived via PBKDF2. This is a RAM-only storage area that survives service worker sleep cycles but is wiped when the browser is closed.
Key lifecycle & session management
- Unlock: Upon password entry, we will derive the master encryption key using PBKDF2 (user's password + salt). We verify that we can decrypt the vault with this key, then we persist the key in
chrome.storage.session. - Transaction Signing: The service worker retrieves the master encryption key from
chrome.storage.sessionto decrypt the seed phrase only at the moment of signing. All raw secrets are wiped from memory immediately after the signature is generated. - Auto-lock: We will implement the
chrome.alarmsAPI to callchrome.storage.session.clear()after 15 minutes of inactivity, which will wipe the master encryption key from the storage, thus "locking" the wallet.
TrustWallet refactor
To optimize performance and security we should refactor how we use @trustwallet/wallet-core.
- Current:
- TrustWallet's
KeyStoreis used for both storage and blockchain operations.
- TrustWallet's
- After refactor:
- Vault management: Use
browser-passworderlibrary (AES-GCM) for initial vault encryption/decryption. This avoids, for every session, initializing TrustWallet's Wasm binary just to check a password or unlock a UI feature. - Signing engine: Use TrustWallet strictly as a "signing engine". It will be initialized only when a transaction is pending, taking the decrypted seed phrase to derive chain specific private keys (we only use ethereum for now) and sign payloads.
- Vault management: Use
- Security benefits:
- No raw seed phrases or master keys are ever written to the hard drive.
- No user password stored in RAM. If we used TrustWallet only to implement this feature, it would require us to store the user's password in RAM as TrustWallet's
KeyStorerequires the original password to be decrypted.
References
browser-passworder: https://github.com/MetaMask/browser-passworder@trustwallet/wallet-core/keystoreAPI: https://trustwallet.github.io/docc/documentation/walletcore/keystorechrome.storageAPI: https://developer.chrome.com/docs/extensions/reference/api/storagechrome.alarmsAPI: https://developer.chrome.com/docs/extensions/reference/api/alarms- Rainbow Extension repo (manifest v3 browser wallet): https://github.com/rainbow-me/browser-extension
- Linked to Integrate LI.FI provider #697
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
In Progress