forked from tniessen/node-pqclean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
25 lines (21 loc) · 776 Bytes
/
index.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
'use strict';
let kem, sign, KEM, Sign;
try {
// Try to load native bindings first.
({ kem, sign, KEM, Sign } = require('bindings')('node_pqclean'));
} catch (err) {
// If native bindings are not available, use WebAssembly instead.
({ kem, sign, KEM, Sign } = require('./wasm/'));
process.emitWarning(`Using WebAssembly backend: ${err.message}`);
}
// TODO: should we deep-freeze these?
Object.freeze(kem.supportedAlgorithms);
Object.freeze(sign.supportedAlgorithms);
Object.freeze(KEM.supportedAlgorithms);
Object.freeze(Sign.supportedAlgorithms);
Object.defineProperties(module.exports, {
kem: { value: kem, enumerable: true },
sign: { value: sign, enumerable: true },
KEM: { value: KEM, enumerable: true },
Sign: { value: Sign, enumerable: true }
});