2020-02-26 08:19:15 +00:00
|
|
|
import path from "path";
|
2020-11-04 17:40:36 +00:00
|
|
|
import bls, { initBLS } from "../../src";
|
|
|
|
import {
|
|
|
|
describeDirectorySpecTest,
|
|
|
|
InputType,
|
|
|
|
} from "@chainsafe/lodestar-spec-test-util";
|
2020-02-26 08:19:15 +00:00
|
|
|
|
|
|
|
interface AggregateSigsVerifyTestCase {
|
|
|
|
data: {
|
|
|
|
input: {
|
|
|
|
pubkeys: string[];
|
|
|
|
message: string;
|
|
|
|
signature: string;
|
|
|
|
};
|
|
|
|
output: boolean;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
before(async function f() {
|
|
|
|
try {
|
|
|
|
await initBLS();
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describeDirectorySpecTest<AggregateSigsVerifyTestCase, boolean>(
|
|
|
|
"BLS - aggregate sigs verify",
|
|
|
|
path.join(
|
|
|
|
__dirname,
|
|
|
|
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/fast_aggregate_verify/small"
|
|
|
|
),
|
2020-11-04 17:40:36 +00:00
|
|
|
(testCase) => {
|
2020-02-26 08:19:15 +00:00
|
|
|
return bls.verifyAggregate(
|
2020-11-04 17:40:36 +00:00
|
|
|
testCase.data.input.pubkeys.map((key) =>
|
|
|
|
Buffer.from(key.replace("0x", ""), "hex")
|
|
|
|
),
|
2020-02-26 08:19:15 +00:00
|
|
|
Buffer.from(testCase.data.input.message.replace("0x", ""), "hex"),
|
2020-11-04 17:40:36 +00:00
|
|
|
Buffer.from(testCase.data.input.signature.replace("0x", ""), "hex")
|
2020-02-26 08:19:15 +00:00
|
|
|
);
|
2020-11-04 17:40:36 +00:00
|
|
|
},
|
2020-02-26 08:19:15 +00:00
|
|
|
{
|
|
|
|
inputTypes: {
|
|
|
|
data: InputType.YAML,
|
|
|
|
},
|
2020-11-04 17:40:36 +00:00
|
|
|
getExpected: (testCase) => testCase.data.output,
|
2020-02-26 08:19:15 +00:00
|
|
|
}
|
|
|
|
);
|