Add test for calculateAgreement

This commit is contained in:
Scott Nonnenberg 2021-04-26 17:42:12 -07:00
parent 7ed54111e2
commit 76dd2026e2

View file

@ -15,6 +15,7 @@ import {
clampPrivateKey,
createKeyPair,
copyArrayBuffer,
calculateAgreement,
generateKeyPair,
generatePreKey,
generateSignedPreKey,
@ -32,6 +33,16 @@ describe('Curve', () => {
assert.isTrue(verified);
});
it('calculateAgreement roundtrip', () => {
const alice = generateKeyPair();
const bob = generateKeyPair();
const sharedSecretAlice = calculateAgreement(bob.pubKey, alice.privKey);
const sharedSecretBob = calculateAgreement(alice.pubKey, bob.privKey);
assert.isTrue(constantTimeEqual(sharedSecretAlice, sharedSecretBob));
});
describe('#isNonNegativeInteger', () => {
it('returns false for -1, Infinity, NaN, a string, etc.', () => {
assert.isFalse(isNonNegativeInteger(-1));