import { NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'\r
\r
-test('locking and unlocking a Bip44Wallet', async () => {\r
- test('should succeed with a password', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
-\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, '')\r
- assert.equals(wallet.seed, '')\r
-\r
- const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- assert.equals(unlockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
-\r
- test('should succeed with a random CryptoKey', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
- const lockResult = await wallet.lock(key)\r
-\r
- assert.ok(lockResult)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, '')\r
- assert.equals(wallet.seed, '')\r
-\r
- const unlockResult = await wallet.unlock(key)\r
-\r
- assert.equals(unlockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
-\r
- test('should fail to unlock with different passwords', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const lockResult = await wallet.lock(TREZOR_TEST_VECTORS.PASSWORD)\r
-\r
- await assert.rejects(wallet.unlock(NANO_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' })\r
- assert.equals(lockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
-\r
- test('should fail to unlock with different keys', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
- const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
- const lockResult = await wallet.lock(rightKey)\r
-\r
- await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' })\r
- assert.equals(lockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
-\r
- test('should fail to unlock with different valid inputs', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
- const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
-\r
- await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
-\r
- test('should fail with no input', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
-\r
- await wallet.lock('password')\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
-\r
- test('should fail with invalid input', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
-\r
- await wallet.lock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
- assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- })\r
+test('locking and unlocking a Bip44Wallet with a password', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, '')\r
+ assert.equals(wallet.seed, '')\r
+\r
+ const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ assert.equals(unlockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('locking and unlocking a Bip44Wallet with a random CryptoKey', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+ const lockResult = await wallet.lock(key)\r
+\r
+ assert.ok(lockResult)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, '')\r
+ assert.equals(wallet.seed, '')\r
+\r
+ const unlockResult = await wallet.unlock(key)\r
+\r
+ assert.equals(unlockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('fail to unlock a Bip44Wallet with different passwords', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const lockResult = await wallet.lock(TREZOR_TEST_VECTORS.PASSWORD)\r
+\r
+ await assert.rejects(wallet.unlock(NANO_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' })\r
+ assert.equals(lockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('fail to unlock a Bip44Wallet with different keys', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+ const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+ const lockResult = await wallet.lock(rightKey)\r
+\r
+ await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' })\r
+ assert.equals(lockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('fail to unlock a Bip44Wallet with different valid inputs', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+ const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+\r
+ await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('fail to unlock a Bip44Wallet with no input', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+\r
+ await wallet.lock('password')\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('fail to unlock a Bip44Wallet with invalid input', async () => {\r
+ const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+\r
+ await wallet.lock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
+ assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+})\r
+\r
+test('locking and unlocking a Blake2bWallet with a password', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)\r
+\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, '')\r
+ assert.equals(wallet.seed, '')\r
+\r
+ const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ assert.equals(unlockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0)\r
+ assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0)\r
+})\r
+\r
+test('locking and unlocking a Blake2bWallet with a random CryptoKey', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+ const lockResult = await wallet.lock(key)\r
+\r
+ assert.equals(lockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, '')\r
+ assert.equals(wallet.seed, '')\r
+\r
+ const unlockResult = await wallet.unlock(key)\r
+\r
+ assert.equals(lockResult, true)\r
+ assert.equals(unlockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+})\r
+\r
+test('fail to unlock a Blake2bWallet with different passwords', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+\r
+ await assert.rejects(wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+})\r
+\r
+test('fail to unlock a Blake2bWallet with different keys', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+ const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+ const lockResult = await wallet.lock(rightKey)\r
+\r
+ await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' })\r
+ assert.equals(lockResult, true)\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+})\r
+\r
+test('fail to unlock a Blake2bWallet with different valid inputs', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+ const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
+\r
+ await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+})\r
+\r
+test('fail to unlock a Blake2bWallet with no input', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+\r
+ await wallet.lock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r
\r
-test('locking and unlocking a Blake2bWallet', async () => {\r
- test('should succeed with a password', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)\r
-\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, '')\r
- assert.equals(wallet.seed, '')\r
-\r
- const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- assert.equals(unlockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0)\r
- assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0)\r
- })\r
-\r
- test('should succeed with a random CryptoKey', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
- const lockResult = await wallet.lock(key)\r
-\r
- assert.equals(lockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, '')\r
- assert.equals(wallet.seed, '')\r
-\r
- const unlockResult = await wallet.unlock(key)\r
-\r
- assert.equals(lockResult, true)\r
- assert.equals(unlockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- })\r
-\r
- test('should fail to unlock with different passwords', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
-\r
- await assert.rejects(wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- })\r
-\r
- test('should fail to unlock with different keys', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
- const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
- const lockResult = await wallet.lock(rightKey)\r
-\r
- await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' })\r
- assert.equals(lockResult, true)\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- })\r
-\r
- test('should fail to unlock with different valid inputs', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
-\r
- await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- })\r
-\r
- test('should fail with no input', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
-\r
- await wallet.lock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- })\r
-\r
- test('should fail with invalid input', async () => {\r
- const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
-\r
- await wallet.lock(NANO_TEST_VECTORS.PASSWORD)\r
-\r
- //@ts-expect-error\r
- await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' })\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
- assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
- })\r
+test('fail to unlock a Blake2bWallet with invalid input', async () => {\r
+ const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
+\r
+ await wallet.lock(NANO_TEST_VECTORS.PASSWORD)\r
+\r
+ //@ts-expect-error\r
+ await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' })\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
+ assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r