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";
|
2020-11-28 19:52:32 +00:00
|
|
|
import {hexToBytes} from "../../src/helpers";
|
2020-11-19 13:22:41 +00:00
|
|
|
import {SPEC_TESTS_DIR} from "../params";
|
2020-11-20 19:35:32 +00:00
|
|
|
import {describeForAllImplementations} from "../switch";
|
2021-04-05 20:38:12 +00:00
|
|
|
import {CoordType} from "@chainsafe/blst";
|
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: {
|
|
|
|
pubkeys: string[];
|
|
|
|
message: string;
|
|
|
|
signature: string;
|
|
|
|
};
|
|
|
|
output: boolean;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-11-20 19:35:32 +00:00
|
|
|
describeForAllImplementations((bls) => {
|
2020-11-19 13:22:41 +00:00
|
|
|
describeDirectorySpecTest<IAggregateSigsVerifyTestCase, boolean>(
|
2020-11-19 14:41:45 +00:00
|
|
|
"bls/fast_aggregate_verify/small",
|
2020-12-01 08:17:25 +00:00
|
|
|
path.join(SPEC_TESTS_DIR, "tests/general/phase0/bls/fast_aggregate_verify/small"),
|
2020-11-19 13:22:41 +00:00
|
|
|
(testCase) => {
|
|
|
|
const {pubkeys, message, signature} = testCase.data.input;
|
2021-04-05 20:38:12 +00:00
|
|
|
try {
|
|
|
|
return bls.Signature.fromBytes(hexToBytes(signature)).verifyAggregate(
|
|
|
|
pubkeys.map((hex) => bls.PublicKey.fromBytes(hexToBytes(hex), CoordType.jacobian, true)),
|
|
|
|
hexToBytes(message)
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
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,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|