ecdh test

This commit is contained in:
2025-02-19 16:01:20 +01:00
parent 7732504136
commit 2fe9b83876
3 changed files with 32 additions and 0 deletions

16
tests/ecdh.test.js Normal file
View File

@ -0,0 +1,16 @@
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);
});
});