This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
chainsafe-bls/test/spec/aggregate_verify.test.ts

32 lines
994 B
TypeScript

import path from "path";
import {describeDirectorySpecTest, InputType} from "@chainsafe/lodestar-spec-test-util";
import {hexToBytes} from "../../src/helpers/index.js";
import {SPEC_TESTS_DIR} from "../params.js";
import {describeForAllImplementations} from "../switch.js";
interface IAggregateSigsVerifyTestCase {
data: {
input: {
pubkeys: string[];
messages: string[];
signature: string;
};
output: boolean;
};
}
describeForAllImplementations((bls) => {
describeDirectorySpecTest<IAggregateSigsVerifyTestCase, boolean>(
"bls/aggregate_verify/small",
path.join(SPEC_TESTS_DIR, "tests/general/phase0/bls/aggregate_verify/small"),
(testCase) => {
const {pubkeys, messages, signature} = testCase.data.input;
return bls.verifyMultiple(pubkeys.map(hexToBytes), messages.map(hexToBytes), hexToBytes(signature));
},
{
inputTypes: {data: InputType.YAML},
getExpected: (testCase) => testCase.data.output,
}
);
});