-
Notifications
You must be signed in to change notification settings - Fork 3
/
decrypt.js
32 lines (27 loc) · 1.14 KB
/
decrypt.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
const NetworkLayer = require('./src/layers/network-layer');
const LowerTransportLayer = require('./src/layers/lower-transport-layer');
const UpperTransportLayer = require('./src/layers/upper-transport-layer');
const AccessLayer = require('./src/layers/access-layer');
const SeqProvider = require('./src/utils/seq-provider');
const Keychain = require('./src/keychain');
const keychain = new Keychain();
keychain.load(require('./keychain.json'));
const networkLayer = new NetworkLayer(keychain);
const lowerLayer = new LowerTransportLayer(keychain);
const upperLayer = new UpperTransportLayer();
const accessLayer = new AccessLayer();
// Connect all the layers together
networkLayer.on('incoming', networkMessage => {
lowerLayer.handleIncoming(networkMessage);
});
lowerLayer.on('incoming', lowerTransportMessage => {
upperLayer.handleIncoming(lowerTransportMessage);
});
upperLayer.on('incoming', accessMessage => {
accessLayer.handleIncoming(accessMessage);
});
accessLayer.on('incoming', message => {
console.log(JSON.stringify(message, null, 2));
});
SeqProvider.setTransient(true);
networkLayer.handleIncoming(Buffer.from(process.argv[2], 'hex'));