@otoplo/wallet-common 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otoplo/wallet-common",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Shared common library for internal use in Otoplo wallet",
5
5
  "license": "MIT",
6
6
  "author": "vgrunner",
package/src/utils/seed.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { gcm } from "@noble/ciphers/aes.js";
2
2
  import { argon2idAsync } from "@noble/hashes/argon2.js";
3
+ import { pbkdf2Async } from "@noble/hashes/pbkdf2.js";
4
+ import { scryptAsync } from "@noble/hashes/scrypt.js";
5
+ import { sha256 } from "@noble/hashes/sha2.js";
3
6
  import { generateMnemonic, validateMnemonic } from "@scure/bip39";
4
7
  import { wordlist } from "@scure/bip39/wordlists/english.js";
5
8
  import { BufferUtils } from "libnexa-ts";
@@ -12,8 +15,20 @@ export function isMnemonicValid(mnemonic: string): boolean {
12
15
  return validateMnemonic(mnemonic, wordlist);
13
16
  }
14
17
 
15
- function deriveKey(password: string, salt: Uint8Array): Promise<Uint8Array> {
16
- return argon2idAsync(password, salt, { t: 2, m: 19456, p: 1, dkLen: 32 });
18
+ async function deriveKey(password: string, salt: Uint8Array): Promise<Uint8Array> {
19
+ let start = performance.now();
20
+ const key = await argon2idAsync(password, salt, { t: 2, m: 19456, p: 1, dkLen: 32 });
21
+ console.log(performance.now() - start);
22
+
23
+ let start2 = performance.now();
24
+ const key2 = await scryptAsync(password, salt, { N: 2**17, r: 8, p: 1, dkLen: 32 });
25
+ console.log(performance.now() - start2);
26
+
27
+ let start3 = performance.now();
28
+ const key3 = await pbkdf2Async(sha256, password, salt, { c: 500000, dkLen: 32 });
29
+ console.log(performance.now() - start3);
30
+
31
+ return key;
17
32
  }
18
33
 
19
34
  export async function encryptMnemonic(phrase: string, password: string): Promise<string> {