update tests
This commit is contained in:
parent
114a344fb6
commit
20121c330b
|
@ -47,7 +47,7 @@ export function sign(secretKey: Uint8Array, messageHash: Uint8Array): Buffer {
|
||||||
* @param signatures
|
* @param signatures
|
||||||
*/
|
*/
|
||||||
export function aggregateSignatures(signatures: Uint8Array[]): Buffer {
|
export function aggregateSignatures(signatures: Uint8Array[]): Buffer {
|
||||||
assert(signatures, "signatures is null or undefined");
|
assert(signatures && signatures.length > 0, "signatures is null or undefined or empty array");
|
||||||
return Signature.aggregate(
|
return Signature.aggregate(
|
||||||
signatures.map((signature): Signature => {
|
signatures.map((signature): Signature => {
|
||||||
return Signature.fromCompressedBytes(signature);
|
return Signature.fromCompressedBytes(signature);
|
||||||
|
|
|
@ -20,10 +20,17 @@ describeDirectorySpecTest<IAggregateSigsTestCase, string>(
|
||||||
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate/small"
|
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate/small"
|
||||||
),
|
),
|
||||||
(testCase => {
|
(testCase => {
|
||||||
const result = bls.aggregateSignatures(testCase.data.input.map(pubKey => {
|
try {
|
||||||
return Buffer.from(pubKey.replace("0x", ""), "hex");
|
const result = bls.aggregateSignatures(testCase.data.input.map(pubKey => {
|
||||||
}));
|
return Buffer.from(pubKey.replace("0x", ""), "hex");
|
||||||
return `0x${result.toString("hex")}`;
|
}));
|
||||||
|
return `0x${result.toString("hex")}`;
|
||||||
|
} catch (e) {
|
||||||
|
if(e.message === "signatures is null or undefined or empty array") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
inputTypes: {
|
inputTypes: {
|
||||||
|
|
|
@ -5,10 +5,8 @@ import {describeDirectorySpecTest, InputType} from "@chainsafe/lodestar-spec-tes
|
||||||
interface AggregateSigsVerifyTestCase {
|
interface AggregateSigsVerifyTestCase {
|
||||||
data: {
|
data: {
|
||||||
input: {
|
input: {
|
||||||
pairs: [{
|
pubkeys: string[];
|
||||||
pubkey: string;
|
messages: string[];
|
||||||
message: string;
|
|
||||||
}];
|
|
||||||
signature: string;
|
signature: string;
|
||||||
};
|
};
|
||||||
output: boolean;
|
output: boolean;
|
||||||
|
@ -30,11 +28,11 @@ describeDirectorySpecTest<AggregateSigsVerifyTestCase, boolean>(
|
||||||
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate_verify/small"
|
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate_verify/small"
|
||||||
),
|
),
|
||||||
(testCase => {
|
(testCase => {
|
||||||
const pubkeys = testCase.data.input.pairs.map(pair => {
|
const pubkeys = testCase.data.input.pubkeys.map(pubkey => {
|
||||||
return Buffer.from(pair.pubkey.replace("0x", ""), "hex");
|
return Buffer.from(pubkey.replace("0x", ""), "hex");
|
||||||
});
|
});
|
||||||
const messages = testCase.data.input.pairs.map(pair => {
|
const messages = testCase.data.input.messages.map(msg => {
|
||||||
return Buffer.from(pair.message.replace("0x", ""), "hex");
|
return Buffer.from(msg.replace("0x", ""), "hex");
|
||||||
});
|
});
|
||||||
return bls.verifyMultiple(
|
return bls.verifyMultiple(
|
||||||
pubkeys,
|
pubkeys,
|
||||||
|
|
Reference in New Issue