generated from docknetwork/es6-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.test.js
62 lines (52 loc) · 1.53 KB
/
keys.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import DockWallet from '../src/index';
import dock from '@docknetwork/sdk';
import {
getKeypairFromDerivedKey,
} from '../src/methods/keypairs';
import {
passwordToKey,
} from '../src/methods/password';
import {
KEY_HARDWARE,
KEY_REMOTE,
KEY_LOCAL,
KEY_JWK,
} from './constants/keys';
describe('Wallet - Key storage and usage', () => {
const wallet = new DockWallet();
beforeAll(async () => {
await dock.initKeyring();
});
test('Can add a local base58 key', () => {
wallet.add(KEY_LOCAL);
expect(wallet.has(KEY_LOCAL.id)).toBe(true);
// TODO: retrieve key from wallet by id as crpyto keypair class with helper method and ensure its valid
});
// // TODOS:
// test('Can add a JSON web key', () => {
// // TODO: this
// });
//
// test('Can add a remote KMS key', () => {
// // TODO: this
// });
//
// test('Can add a hardware key', () => {
// // TODO: this
// });
});
describe('Wallet - Key generation', () => {
let derivedKey;
beforeAll(async () => {
derivedKey = await passwordToKey('testpass');
await dock.initKeyring();
});
test('Can generate X25519KeyAgreementKey2019', async () => {
const keypair = await getKeypairFromDerivedKey(derivedKey, 'X25519KeyAgreementKey2019');
expect(keypair.type).toEqual('X25519KeyAgreementKey2019');
});
test('Can generate X25519KeyAgreementKey2020', async () => {
const keypair = await getKeypairFromDerivedKey(derivedKey, 'X25519KeyAgreementKey2020');
expect(keypair.type).toEqual('X25519KeyAgreementKey2020');
});
});