Add comments and tests for libsignal-protocol curve validation

This commit is contained in:
Evan Hahn 2020-11-04 11:42:50 -06:00 committed by Evan Hahn
commit 8e598688e7
2 changed files with 87 additions and 12 deletions

View file

@ -23624,6 +23624,8 @@ var Internal = Internal || {};
return res.buffer;
},
// This returns `true` if verification fails and `false` if it succeeds,
// which may be surprising.
verify: function(pubKey, message, sig) {
// Get a pointer to their public key
var publicKey_ptr = _allocate(new Uint8Array(pubKey));
@ -23808,6 +23810,8 @@ Curve25519Worker.prototype = {
return curve25519.sign(privKey, message);
},
// This returns `true` if verification fails and `false` if it succeeds,
// which may be surprising.
Ed25519Verify: function(pubKey, msg, sig) {
pubKey = validatePubKeyFormat(pubKey);
@ -24487,6 +24491,7 @@ SessionBuilder.prototype = {
device.signedPreKey.signature
);
}).then(didVerificationFail => {
// Ed25519Verify returns `false` when verification succeeds and `true` if it fails.
if (didVerificationFail) {
throw new Error('Signature verification failed');
}