fix: swallow exception while doing tryMatchBlindWithStandardKey

pull/2482/head
Audric Ackermann 3 years ago
parent cdb010ac47
commit d2472007b8

@ -151,6 +151,10 @@ export function tryMatchBlindWithStandardKey(
if (!blindedSessionId.startsWith(KeyPrefixType.blinded)) {
throw new Error('blindedKey must be a blinded key (starting with 15)');
}
// We don't want to stop iterating even if an error happens while looking for a blind/standard match.
// That's why we catch any errors and return false if it happens.
try {
// tslint:disable: no-bitwise
const sessionIdNoPrefix = PubKey.removePrefixIfNeeded(PubKey.cast(standardSessionId).key);
@ -172,13 +176,18 @@ export function tryMatchBlindWithStandardKey(
const pk2 = cloneDeep(pk1);
pk2[31] = pk1[31] ^ 0b1000_0000;
const match = isEqual(blindedIdNoPrefix, to_hex(pk1)) || isEqual(blindedIdNoPrefix, to_hex(pk2));
const match =
isEqual(blindedIdNoPrefix, to_hex(pk1)) || isEqual(blindedIdNoPrefix, to_hex(pk2));
if (!match) {
return false;
}
return true;
} catch (e) {
window.log.warn('Failed to do crypto tryMatchBlindWithStandardKey with ', e.message);
return false;
}
}
/**

Loading…
Cancel
Save