diff options
| author | Adam Soltys <[email protected]> | 2022-12-21 15:48:14 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-12-21 15:48:14 -0800 |
| commit | 6ae27be919808df935fb140fd56bb6ae010a219b (patch) | |
| tree | ba9f5d862cc48abf5b49acfdbd32b87216eadba1 /src/lib | |
| parent | 5c0675fa6815a70033c17a9310d0fa1f9c569e92 (diff) | |
| download | coinos-ui-6ae27be919808df935fb140fd56bb6ae010a219b.tar.gz coinos-ui-6ae27be919808df935fb140fd56bb6ae010a219b.zip | |
add nostr message field to user profile page
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/utils.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js index f59b6359..14646ad0 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -1,3 +1,5 @@ +import * as ecc from 'tiny-secp256k1'; +import { BIP32Factory } from 'bip32'; import { browser } from '$app/environment'; import { toast } from '@zerodevx/svelte-toast'; import { goto } from '$app/navigation'; @@ -168,3 +170,25 @@ export const wait = async (f, s = 300) => { if (i >= s) throw new Error('timeout'); return f(); }; + +export const stretch = async (password, salt) => + crypto.subtle.deriveKey( + { + name: 'PBKDF2', + salt, + iterations: 100000, + hash: 'SHA-256' + }, + await crypto.subtle.importKey( + 'raw', + new TextEncoder().encode(password), + { name: 'PBKDF2' }, + false, + ['deriveBits', 'deriveKey'] + ), + { name: 'AES-GCM', length: 256 }, + true, + ['encrypt', 'decrypt'] + ); + +export const bip32 = await BIP32Factory(ecc); |
