17 lines
533 B
JavaScript
17 lines
533 B
JavaScript
import { genKeys, sharedKey } from '../src/public/ecdh.js';
|
|
import { arrayToHex } from '../src/stringutils.js';
|
|
|
|
describe('ecdh.js functions', () => {
|
|
|
|
it('key exchange test', () => {
|
|
const keysA= genKeys();
|
|
const keysB = genKeys();
|
|
const sharedA = sharedKey(keysA.privkey, keysB.pubkey);
|
|
const sharedB = sharedKey(keysB.privkey, keysA.pubkey);
|
|
const sharedAhex = arrayToHex(sharedA);
|
|
const sharedBhex = arrayToHex(sharedB);
|
|
expect(sharedAhex === sharedBhex);
|
|
});
|
|
|
|
});
|