fix: curve verification return boolean

This commit is contained in:
Adhiraj Singh
2022-04-23 17:46:59 +05:30
parent b3e8b38917
commit 40abd71d2e
2 changed files with 9 additions and 4 deletions

View File

@@ -27,9 +27,14 @@ export const Curve = {
sign: (privateKey: Uint8Array, buf: Uint8Array) => (
libsignal.curve.calculateSignature(privateKey, buf)
),
verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => (
libsignal.curve.verifySignature(generateSignalPubKey(pubKey), message, signature)
)
verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => {
try {
libsignal.curve.verifySignature(generateSignalPubKey(pubKey), message, signature)
return true
} catch(error) {
return false
}
}
}
export const signedKeyPair = (identityKeyPair: KeyPair, keyId: number) => {

View File

@@ -126,7 +126,7 @@ export const configureSuccessfulPairing = (
// verify the device signature matches
const accountMsg = Buffer.concat([ Buffer.from([6, 0]), deviceDetails, signedIdentityKey.public ])
if(!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
// throw new Boom('Failed to verify account signature')
throw new Boom('Failed to verify account signature')
}
// sign the details with our identity key