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-blst/aggregate_sigs.test.ts

30 lines
929 B
TypeScript
Raw Normal View History

2020-11-13 21:43:20 +00:00
import path from "path";
import {describeDirectorySpecTest, InputType} from "@chainsafe/lodestar-spec-test-util";
import {AggregateSignature} from "@chainsafe/blst-ts";
import {fromHexString, toHexString} from "../util";
interface IAggregateSigsTestCase {
data: {
input: string[];
output: string;
};
}
describeDirectorySpecTest<IAggregateSigsTestCase, string>(
"BLS - aggregate sigs",
path.join(__dirname, "../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate/small"),
(testCase) => {
const signaturesHex = testCase.data.input;
const signaturesBytes = signaturesHex.map(fromHexString);
const aggSig = AggregateSignature.fromSignaturesBytes(signaturesBytes);
const aggSigHex = aggSig.toSignature().toBytes();
return toHexString(aggSigHex);
},
{
inputTypes: {
data: InputType.YAML,
},
getExpected: (testCase) => testCase.data.output,
}
);