Test that the zkgroup serverPublicParams are up to date

This commit is contained in:
Jordan Rose 2022-08-17 16:31:18 -07:00 committed by GitHub
parent 0b5d643b9a
commit d15ae63396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import * as fs from 'node:fs';
import path from 'node:path';
import { ServerPublicParams } from '@signalapp/libsignal-client/zkgroup';
describe('zkgroup', () => {
describe('serverPublicParams', () => {
const configDir = 'config';
for (const file of fs.readdirSync(configDir)) {
if (!file.endsWith('.json')) {
continue;
}
const contents = fs.readFileSync(path.join(configDir, file), {
encoding: 'utf-8',
});
const serverPublicParamsBase64: string | undefined =
JSON.parse(contents).serverPublicParams;
let test: (() => void) | undefined;
if (serverPublicParamsBase64 !== undefined) {
test = () => {
const serverPublicParams = new ServerPublicParams(
Buffer.from(serverPublicParamsBase64, 'base64')
);
assert(serverPublicParams);
};
} else {
// Mark as "pending" / skipped to show we didn't miss a file.
test = undefined;
}
it(`valid in ${file}`, test);
}
});
});