Add test for calculateAgreement
This commit is contained in:
parent
7ed54111e2
commit
76dd2026e2
1 changed files with 11 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue