diff --git a/src/Utils/noise-handler.ts b/src/Utils/noise-handler.ts index f57509f..96a65d4 100644 --- a/src/Utils/noise-handler.ts +++ b/src/Utils/noise-handler.ts @@ -18,7 +18,7 @@ export const makeNoiseHandler = ({ public: publicKey, private: privateKey }: Key const authenticate = (data: Uint8Array) => { if(!isFinished) { - hash = sha256(Buffer.from(Binary.build(hash, data).readByteArray())) + hash = sha256(Buffer.concat([hash, data])) } } @@ -84,7 +84,7 @@ export const makeNoiseHandler = ({ public: publicKey, private: privateKey }: Key isFinished = true } - const data = Binary.build(NOISE_MODE).readBuffer() + const data = Buffer.from(NOISE_MODE) let hash = Buffer.from(data.byteLength === 32 ? data : sha256(Buffer.from(data))) let salt = hash let encKey = hash diff --git a/src/Utils/validate-connection.ts b/src/Utils/validate-connection.ts index 3b0ca1b..9e25f92 100644 --- a/src/Utils/validate-connection.ts +++ b/src/Utils/validate-connection.ts @@ -2,7 +2,7 @@ import { Boom } from '@hapi/boom' import { createHash } from 'crypto' import { proto } from '../../WAProto' import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types' -import { Binary, BinaryNode, getAllBinaryNodeChildren, jidDecode, S_WHATSAPP_NET } from '../WABinary' +import { BinaryNode, getAllBinaryNodeChildren, jidDecode, S_WHATSAPP_NET } from '../WABinary' import { Curve, hmacSign } from './crypto' import { encodeInt } from './generics' import { createSignalIdentity } from './signal' @@ -116,12 +116,21 @@ export const configureSuccessfulPairing = ( const account = proto.ADVSignedDeviceIdentity.decode(details) const { accountSignatureKey, accountSignature } = account - const accountMsg = Binary.build(new Uint8Array([6, 0]), account.details, signedIdentityKey.public).readByteArray() + const accountMsg = Buffer.concat([ + Buffer.from([6, 0]), + account.details, + signedIdentityKey.public + ]) if(!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) { throw new Boom('Failed to verify account signature') } - const deviceMsg = Binary.build(new Uint8Array([6, 1]), account.details, signedIdentityKey.public, account.accountSignatureKey).readByteArray() + const deviceMsg = Buffer.concat([ + new Uint8Array([6, 1]), + account.details, + signedIdentityKey.public, + account.accountSignatureKey + ]) account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg) const identity = createSignalIdentity(jid, accountSignatureKey)