Add extra notary signature checks to zkgroup

This commit is contained in:
Fedor Indutny
2022-03-08 13:07:52 -08:00
committed by GitHub
parent 944d60f40b
commit feef67da5a
3 changed files with 86 additions and 23 deletions
+15
View File
@@ -16,6 +16,7 @@ import {
ProfileKeyCredentialResponse,
ServerPublicParams,
UuidCiphertext,
NotarySignature,
} from '@signalapp/signal-client/zkgroup';
import { UUID } from '../types/UUID';
import type { UUIDStringType } from '../types/UUID';
@@ -256,3 +257,17 @@ export function deriveProfileKeyCommitment(
return profileKey.getCommitment(uuid).contents.toString('base64');
}
export function verifyNotarySignature(
serverPublicParamsBase64: string,
message: Uint8Array,
signature: Uint8Array
): void {
const serverPublicParams = new ServerPublicParams(
Buffer.from(serverPublicParamsBase64, 'base64')
);
const notarySignature = new NotarySignature(Buffer.from(signature));
serverPublicParams.verifySignature(Buffer.from(message), notarySignature);
}