mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: curve verification return boolean
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user