diff --git a/ts/util/safetyNumber.ts b/ts/util/safetyNumber.ts index 57be84508..8356d9f05 100644 --- a/ts/util/safetyNumber.ts +++ b/ts/util/safetyNumber.ts @@ -1,6 +1,7 @@ // Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only +import { PublicKey, Fingerprint } from 'libsignal-client'; import { ConversationType } from '../state/ducks/conversations'; export async function generateSecurityNumber( @@ -9,12 +10,22 @@ export async function generateSecurityNumber( theirNumber: string, theirKey: ArrayBuffer ): Promise { - return new window.libsignal.FingerprintGenerator(5200).createFor( - ourNumber, - ourKey, - theirNumber, - theirKey + const ourNumberBuf = Buffer.from(ourNumber); + const ourKeyObj = PublicKey.deserialize(Buffer.from(ourKey)); + const theirNumberBuf = Buffer.from(theirNumber); + const theirKeyObj = PublicKey.deserialize(Buffer.from(theirKey)); + + const fingerprint = Fingerprint.new( + 5200, + 2, + ourNumberBuf, + ourKeyObj, + theirNumberBuf, + theirKeyObj ); + + const fingerprintString = fingerprint.displayableFingerprint().toString(); + return Promise.resolve(fingerprintString); } export function getPlaceholder(): string {