forked from WebOfTrust/signify-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.test.ts
77 lines (65 loc) · 2.88 KB
/
controller.test.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { Controller } from '../../src/keri/app/controller';
import { strict as assert } from 'assert';
import libsodium from 'libsodium-wrappers-sumo';
import { openManager } from '../../src/keri/core/manager';
import { Signer } from '../../src/keri/core/signer';
import { MtrDex } from '../../src/keri/core/matter';
import { Tier, randomPasscode } from '../../src';
describe('Controller', () => {
it('manage account AID signing and agent verification', async () => {
await libsodium.ready;
let passcode = '0123456789abcdefghijk';
const mgr = openManager(passcode);
assert.equal(mgr.aeid, 'BMbZTXzB7LmWPT2TXLGV88PQz5vDEM2L2flUs2yxn3U9');
const raw = new Uint8Array([
187, 140, 234, 145, 219, 254, 20, 194, 16, 18, 97, 194, 140, 192,
61, 145, 222, 110, 59, 160, 152, 2, 72, 122, 87, 143, 109, 39, 98,
153, 192, 148,
]);
const agentSigner = new Signer({
raw: raw,
code: MtrDex.Ed25519_Seed,
transferable: false,
});
assert.equal(
agentSigner.verfer.qb64,
'BHptu91ecGv_mxO8T3b98vNQUCghT8nfYkWRkVqOZark'
);
// New account needed. Send to remote my name and encryption pubk and get back
// their pubk and and my encrypted account package
// let pkg = {}
let controller = new Controller(passcode, Tier.low);
assert.equal(
controller.pre,
'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose'
);
passcode = 'abcdefghijk0123456789';
controller = new Controller(passcode, Tier.low);
assert.equal(
controller.pre,
'EIIY2SgE_bqKLl2MlnREUawJ79jTuucvWwh-S6zsSUFo'
);
});
it('should generate unique controller AIDs per passcode', async () => {
await libsodium.ready;
const passcode1 = randomPasscode();
const passcode2 = randomPasscode();
const controller1 = new Controller(passcode1, Tier.low);
const controller2 = new Controller(passcode2, Tier.low);
assert.notEqual(controller1.pre, controller2.pre);
});
it('should generate unique controller AIDs per passcode', async () => {
await libsodium.ready;
const template = randomPasscode();
// Create new passcode where we know that the last character is different
const passcode1 = template.substring(0, template.length - 1) + 'a';
const passcode2 = template.substring(0, template.length - 1) + 'b';
console.log(template.length);
assert.equal(passcode1.length, template.length);
assert.equal(passcode2.length, template.length);
assert.notEqual(passcode1, passcode2);
const controller1 = new Controller(passcode1, Tier.low);
const controller2 = new Controller(passcode2, Tier.low);
assert.notEqual(controller1.pre, controller2.pre);
});
});