diff --git a/.gitignore b/.gitignore index 435d202..6da32d7 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ typings/ dist/ lib/ +benchmark-reports diff --git a/test/benchmarks/suites/verifyValidAggregatedSignature.ts b/test/benchmarks/suites/verifyValidAggregatedSignature.ts index 7636872..5bca5f1 100644 --- a/test/benchmarks/suites/verifyValidAggregatedSignature.ts +++ b/test/benchmarks/suites/verifyValidAggregatedSignature.ts @@ -1,5 +1,5 @@ import {BenchSuite} from "@chainsafe/benchmark-utils"; -import {aggregateSignatures, verifyMultiple} from "../../../src"; +import {aggregateSignatures, Keypair, verifyMultiple} from "../../../src"; // eslint-disable-next-line @typescript-eslint/no-namespace @@ -8,6 +8,7 @@ declare namespace global { export let messages: Buffer[]; export let signature: Buffer; export let publicKeys: Buffer[]; + export let keypairs: Keypair[]; export let verify: Function; } @@ -19,29 +20,34 @@ global.verify = verifyMultiple; export function verifyValidAggregatedSignature(dir: string): BenchSuite { + global.publicKeys = []; + global.keypairs = []; + for(let i = 0; i < 128; i++) { + const keypair = Keypair.generate(); + global.keypairs.push(keypair); + global.publicKeys.push(keypair.publicKey.toBytesCompressed()); + } + // Set the function test const FUNCTION_NAME = "verifyValidAggregatedSignature"; // PLEASE FILL THIS OUT const verifyValidAggregatedSignature = function (): void { - console.log(global.verify(global.publicKeys, global.messages, global.signature, global.domain)); + global.verify(global.publicKeys, global.messages, global.signature, global.domain) }; return { testFunctions: [verifyValidAggregatedSignature], setup: function() { - const {Keypair, aggregateSignatures} = require("../../../src"); - const {sha256} = require('js-sha256'); - const signatures = []; - global.publicKeys = []; + const sha256 = require('js-sha256'); + const {aggregateSignatures} = require("../../../src"); const message = Buffer.from(sha256.arrayBuffer(Math.random().toString(36))); - for(let i = 0; i < 128; i++) { - const keypair = Keypair.generate(); - global.publicKeys.push(keypair.publicKey.toBytesCompressed()); - signatures.push(keypair.privateKey.signMessage(Buffer.from(message), global.domain).toBytesCompressed()); - } - global.messages = global.publicKeys.map(() => message); + const signatures = []; + global.messages = []; + global.keypairs.forEach((keypair) => { + signatures.push(keypair.privateKey.signMessage(message, global.domain).toBytesCompressed()); + global.messages.push(message); + }); global.signature = aggregateSignatures(signatures); - global.publicKeys.map(() => message); }, file: dir + FUNCTION_NAME + ".txt", // profile: true,