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_sigs_verify.test.ts

32 lines
973 B
TypeScript
Raw Normal View History

2020-02-26 08:19:15 +00:00
import path from "path";
2020-11-05 20:55:25 +00:00
import {describeDirectorySpecTest, InputType} from "@chainsafe/lodestar-spec-test-util";
import {hexToBytes} from "../../src/helpers";
2020-11-19 13:22:41 +00:00
import {SPEC_TESTS_DIR} from "../params";
import {describeForAllImplementations} from "../switch";
2020-02-26 08:19:15 +00:00
2020-11-05 21:44:36 +00:00
interface IAggregateSigsVerifyTestCase {
2020-02-26 08:19:15 +00:00
data: {
input: {
2020-05-21 10:52:11 +00:00
pubkeys: string[];
messages: string[];
2020-02-26 08:19:15 +00:00
signature: string;
};
output: boolean;
};
}
describeForAllImplementations((bls) => {
2020-11-19 13:22:41 +00:00
describeDirectorySpecTest<IAggregateSigsVerifyTestCase, boolean>(
"bls/aggregate_verify/small",
2020-11-19 13:22:41 +00:00
path.join(SPEC_TESTS_DIR, "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));
2020-02-26 08:19:15 +00:00
},
2020-11-19 13:22:41 +00:00
{
inputTypes: {data: InputType.YAML},
getExpected: (testCase) => testCase.data.output,
}
);
});