diff --git a/ts/test-node/util/zkgroup_test.ts b/ts/test-node/util/zkgroup_test.ts new file mode 100644 index 000000000000..f17a6a36566b --- /dev/null +++ b/ts/test-node/util/zkgroup_test.ts @@ -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); + } + }); +});