From c93b5c130baf86f8f0f12d3f94bcc5bcc38cd72d Mon Sep 17 00:00:00 2001 From: Cayman Date: Thu, 20 Feb 2020 13:27:06 -0600 Subject: [PATCH] Remove benchmark-utils dependency --- package.json | 1 - test/benchmarks/index.ts | 13 ----- test/benchmarks/suites/index.ts | 5 -- .../benchmarks/suites/signatureAggregation.ts | 40 ------------- .../suites/verifyInValidSignature.ts | 43 -------------- .../verifyInvalidAggregatedSignature.ts | 49 ---------------- .../suites/verifyValidAggregatedSignature.ts | 56 ------------------- .../benchmarks/suites/verifyValidSignature.ts | 49 ---------------- 8 files changed, 256 deletions(-) delete mode 100644 test/benchmarks/index.ts delete mode 100644 test/benchmarks/suites/index.ts delete mode 100644 test/benchmarks/suites/signatureAggregation.ts delete mode 100644 test/benchmarks/suites/verifyInValidSignature.ts delete mode 100644 test/benchmarks/suites/verifyInvalidAggregatedSignature.ts delete mode 100644 test/benchmarks/suites/verifyValidAggregatedSignature.ts delete mode 100644 test/benchmarks/suites/verifyValidSignature.ts diff --git a/package.json b/package.json index 1006cbe..71e5305 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "assert": "^1.4.1" }, "devDependencies": { - "@chainsafe/benchmark-utils": "^0.1.0", "js-sha256": "^0.9.0", "js-yaml": "^3.13.1", "karma": "^4.4.1", diff --git a/test/benchmarks/index.ts b/test/benchmarks/index.ts deleted file mode 100644 index 2666c5e..0000000 --- a/test/benchmarks/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Import benchmarks -import * as suites from "./suites"; -import {createReportDir, runSuite} from "@chainsafe/benchmark-utils"; -import {initBLS} from "../../src"; -// Create file -const directory: string = createReportDir(); - -initBLS().then(() => { - // Run benchmarks - Object.values(suites).forEach((suite) => { - runSuite(suite(directory)); - }); -}); \ No newline at end of file diff --git a/test/benchmarks/suites/index.ts b/test/benchmarks/suites/index.ts deleted file mode 100644 index 031b168..0000000 --- a/test/benchmarks/suites/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// export {verifyInValidSignatureBenchmark} from "./verifyInValidSignature"; -export {verifyValidSignatureBenchmark} from "./verifyValidSignature"; -// export {verifyValidAggregatedSignature} from "./verifyValidAggregatedSignature"; -// export {verifyInvalidAggregatedSignature} from "./verifyInvalidAggregatedSignature"; -// export {aggregateSignaturesBenchmark} from "./signatureAggregation"; \ No newline at end of file diff --git a/test/benchmarks/suites/signatureAggregation.ts b/test/benchmarks/suites/signatureAggregation.ts deleted file mode 100644 index b7d6e38..0000000 --- a/test/benchmarks/suites/signatureAggregation.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires */ - -import {BenchSuite} from "@chainsafe/benchmark-utils"; -import {aggregateSignatures} from "../../../src"; - - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace global { - export let signatures: Buffer[]; - export let aggregateSignatures: Function; -} - -// @ts-ignore -global.require = require; - -global.aggregateSignatures = aggregateSignatures; - -export function aggregateSignaturesBenchmark(dir: string): BenchSuite { - - // Set the function test - const FUNCTION_NAME = "verifyValidSignature"; // PLEASE FILL THIS OUT - - const aggregateSignatures = function (): void { - global.aggregateSignatures(global.signatures); - }; - - return { - name: FUNCTION_NAME, - testFunctions: [aggregateSignatures], - setup: function() { - global.signatures = []; - const {Keypair} = require("../../../src"); - const {sha256} = require('js-sha256'); - const keypair = Keypair.generate(); - const message = Buffer.from(sha256.arrayBuffer(Math.random().toString(36))); - global.signatures.push(keypair.privateKey.signMessage(Buffer.from(message), Buffer.alloc(8)).toBytesCompressed()); - }, - file: dir + FUNCTION_NAME + ".txt" - }; -} \ No newline at end of file diff --git a/test/benchmarks/suites/verifyInValidSignature.ts b/test/benchmarks/suites/verifyInValidSignature.ts deleted file mode 100644 index 2091d9f..0000000 --- a/test/benchmarks/suites/verifyInValidSignature.ts +++ /dev/null @@ -1,43 +0,0 @@ -import {BenchSuite} from "@chainsafe/benchmark-utils"; -import {verify} from "../../../src"; - - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace global { - export let domain: Buffer; - export let message: Buffer; - export let signature: Buffer; - export let publicKey: Buffer; - export let verify: Function; -} - -// @ts-ignore -global.require = require; - -global.domain = Buffer.alloc(8); -global.verify = verify; - -export function verifyInValidSignatureBenchmark(dir: string): BenchSuite { - - // Set the function test - const FUNCTION_NAME = "verifyInValidSignature"; // PLEASE FILL THIS OUT - - const verifyInValidSignature = function (): void { - global.verify(global.publicKey, global.message, global.signature, global.domain); - }; - - return { - name: FUNCTION_NAME, - testFunctions: [verifyInValidSignature], - setup: function() { - const {Keypair} = require("../../../src"); - const {sha256} = require('js-sha256'); - const keypair = Keypair.generate(); - const keypair2 = Keypair.generate(); - global.publicKey = keypair2.publicKey.toBytesCompressed(); - global.message = Buffer.from(sha256.arrayBuffer(Math.random().toString(36))); - global.signature = keypair.privateKey.signMessage(Buffer.from(global.message), global.domain).toBytesCompressed(); - }, - file: dir + FUNCTION_NAME + ".txt" - }; -} \ No newline at end of file diff --git a/test/benchmarks/suites/verifyInvalidAggregatedSignature.ts b/test/benchmarks/suites/verifyInvalidAggregatedSignature.ts deleted file mode 100644 index 5137c39..0000000 --- a/test/benchmarks/suites/verifyInvalidAggregatedSignature.ts +++ /dev/null @@ -1,49 +0,0 @@ -import {BenchSuite} from "@chainsafe/benchmark-utils"; -import {aggregateSignatures, verifyMultiple} from "../../../src"; - - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace global { - export let domain: Buffer; - export let messages: Buffer[]; - export let signature: Buffer; - export let publicKeys: Buffer[]; - export let verify: Function; -} - -// @ts-ignore -global.require = require; - -global.domain = Buffer.alloc(8); -global.verify = verifyMultiple; - -export function verifyInvalidAggregatedSignature(dir: string): BenchSuite { - - // Set the function test - const FUNCTION_NAME = "verifyInvalidAggregatedSignature"; // PLEASE FILL THIS OUT - - const verifyInvalidAggregatedSignature = function (): void { - global.verify(global.publicKeys, global.messages, global.signature, global.domain); - }; - - return { - name: FUNCTION_NAME, - testFunctions: [verifyInvalidAggregatedSignature], - setup: function() { - const {Keypair, aggregateSignatures} = require("../../../src"); - const {sha256} = require('js-sha256'); - const signatures = []; - global.publicKeys = []; - const message = Buffer.from(sha256.arrayBuffer(Math.random().toString(36))); - const message2 = 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(() => message2); - global.signature = aggregateSignatures(signatures); - }, - file: dir + FUNCTION_NAME + ".txt" - }; -} \ No newline at end of file diff --git a/test/benchmarks/suites/verifyValidAggregatedSignature.ts b/test/benchmarks/suites/verifyValidAggregatedSignature.ts deleted file mode 100644 index 88eaca6..0000000 --- a/test/benchmarks/suites/verifyValidAggregatedSignature.ts +++ /dev/null @@ -1,56 +0,0 @@ -import {BenchSuite} from "@chainsafe/benchmark-utils"; -import {aggregateSignatures, Keypair, verifyMultiple} from "../../../src"; - - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace global { - export let domain: Buffer; - export let messages: Buffer[]; - export let signature: Buffer; - export let publicKeys: Buffer[]; - export let keypairs: Keypair[]; - export let verify: Function; -} - -// @ts-ignore -global.require = require; - -global.domain = Buffer.alloc(8); -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 { - global.verify(global.publicKeys, global.messages, global.signature, global.domain); - }; - - return { - testFunctions: [verifyValidAggregatedSignature], - setup: function() { - const sha256 = require("js-sha256"); - const {aggregateSignatures} = require("../../../src"); - const message = Buffer.from(sha256.arrayBuffer(Math.random().toString(36))); - const signatures: any[] = []; - global.messages = []; - global.keypairs.forEach((keypair) => { - signatures.push(keypair.privateKey.signMessage(message, global.domain).toBytesCompressed()); - global.messages.push(message); - }); - global.signature = aggregateSignatures(signatures); - }, - file: dir + FUNCTION_NAME + ".txt", - // profile: true, - name: FUNCTION_NAME, - }; -} \ No newline at end of file diff --git a/test/benchmarks/suites/verifyValidSignature.ts b/test/benchmarks/suites/verifyValidSignature.ts deleted file mode 100644 index 7b7341a..0000000 --- a/test/benchmarks/suites/verifyValidSignature.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires */ - -import {BenchSuite} from "@chainsafe/benchmark-utils"; -import {verify} from "../../../src"; -import {sha256} from "js-sha256"; - - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace global { - export let domain: Buffer; - export let message: Buffer; - export let signature: Buffer; - export let publicKey: Buffer; - export let verify: Function; -} - -// @ts-ignore -global.require = require; - -global.domain = Buffer.alloc(8); -global.verify = verify; - -global.message = Buffer.from(sha256.arrayBuffer(Math.random().toString(36))); - - - -export function verifyValidSignatureBenchmark(dir: string): BenchSuite { - - // Set the function test - const FUNCTION_NAME = "verifyValidSignature"; // PLEASE FILL THIS OUT - - const verifyValidSignature = function (): void { - global.verify(global.publicKey, global.message, global.signature, global.domain); - }; - - return { - name: FUNCTION_NAME, - testFunctions: [verifyValidSignature], - setup: function() { - let i = 0; - const {Keypair, PrivateKey} = require("../../../src"); - const keypair = new Keypair(PrivateKey.fromInt(i)); - i = i+1; - global.publicKey = keypair.publicKey.toBytesCompressed(); - global.signature = keypair.privateKey.signMessage(Buffer.from(global.message), global.domain).toBytesCompressed(); - }, - file: dir + FUNCTION_NAME + ".txt" - }; -} \ No newline at end of file