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

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-02-26 08:19:15 +00:00
import path from "path";
import bls, {initBLS} from "../../src";
import {describeDirectorySpecTest, InputType} from "@chainsafe/lodestar-spec-test-util";
interface AggregateSigsVerifyTestCase {
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;
};
}
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/aggregate_verify/small"
),
(testCase => {
2020-05-21 10:52:11 +00:00
const pubkeys = testCase.data.input.pubkeys.map(pubkey => {
return Buffer.from(pubkey.replace("0x", ""), "hex");
2020-02-26 08:19:15 +00:00
});
2020-05-21 10:52:11 +00:00
const messages = testCase.data.input.messages.map(msg => {
return Buffer.from(msg.replace("0x", ""), "hex");
2020-02-26 08:19:15 +00:00
});
return bls.verifyMultiple(
pubkeys,
messages,
Buffer.from(testCase.data.input.signature.replace("0x", ""), "hex"),
);
}),
{
inputTypes: {
data: InputType.YAML,
},
getExpected: (testCase => testCase.data.output)
}
);