diff options
| author | Adam Soltys <[email protected]> | 2026-02-16 13:17:43 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-16 13:17:43 -0800 |
| commit | ac06683100e089ad589661b14ebaf5dc9582a256 (patch) | |
| tree | f561f90aa09f3a6a3747cd703984043f028f9067 /src/components | |
| parent | e39bf4f977bba2952a7de4a307b14c5ec862a3a7 (diff) | |
| download | coinos-ui-ac06683100e089ad589661b14ebaf5dc9582a256.tar.gz coinos-ui-ac06683100e089ad589661b14ebaf5dc9582a256.zip | |
passkey tweaks
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Account.svelte | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/components/Account.svelte b/src/components/Account.svelte index 064f153f..5ba1bedd 100644 --- a/src/components/Account.svelte +++ b/src/components/Account.svelte @@ -10,7 +10,8 @@ import { versions, s, f, loc, toFiat } from "$lib/utils"; import { fiat } from "$lib/store"; import { arkkey, arkaid } from "$lib/ark"; - import { getRememberedWalletPassword, forgetWalletPassword } from "$lib/passwordCache"; + import { getRememberedWalletPassword, forgetWalletPassword, getCachedPrfKey } from "$lib/passwordCache"; + import { isPrfEncrypted, prfDecrypt } from "$lib/crypto"; let { user, rates, account }: any = $props(); let currency = $derived(account.currency || user.currency); @@ -28,6 +29,29 @@ }); let tryUnlockArk = async () => { + // Try PRF key first + const prfKey = getCachedPrfKey(); + if (prfKey && user.seed && isPrfEncrypted(user.seed)) { + try { + const [{ HDKey }, { entropyToMnemonic, mnemonicToSeed }, { wordlist }] = await Promise.all([ + import("@scure/bip32"), + import("@scure/bip39"), + import("@scure/bip39/wordlists/english.js"), + ]); + const entropy = await prfDecrypt(prfKey, user.seed); + const mnemonic = entropyToMnemonic(entropy, wordlist); + const s = await mnemonicToSeed(mnemonic); + const master = HDKey.fromMasterSeed(s, versions); + const arkChild = master.derive("m/86'/0'/0'/0/0"); + $arkkey = bytesToHex(arkChild.privateKey!); + $arkaid = id; + return true; + } catch (e) { + console.log("PRF unlock failed", e); + } + } + + // Then try cached wallet password const cached = getRememberedWalletPassword(); if (!cached) return false; try { |
