From 45e687f25e6c7e32ae50115af02c970eebd72474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Thu, 5 Sep 2019 15:06:46 +0200 Subject: [PATCH 1/3] upgrade bls tests to 0.8.3 --- package.json | 2 +- test/spec/aggregate_pubkeys.test.ts | 44 ++++++++++++++------------ test/spec/aggregate_sigs.test.ts | 42 ++++++++++++++----------- test/spec/g2_compressed.test.ts | 23 -------------- test/spec/g2_uncompressed.test.ts | 28 ----------------- test/spec/msg_hash_compressed.ts | 40 ++++++++++++++++++++++++ test/spec/msg_hash_uncompressed.ts | 35 +++++++++++++++++++++ test/spec/priv_to_public.test.ts | 33 +++++++++++++------- test/spec/sign_message.test.ts | 48 +++++++++++++++++++---------- 9 files changed, 178 insertions(+), 117 deletions(-) delete mode 100644 test/spec/g2_compressed.test.ts delete mode 100644 test/spec/g2_uncompressed.test.ts create mode 100644 test/spec/msg_hash_compressed.ts create mode 100644 test/spec/msg_hash_uncompressed.ts diff --git a/package.json b/package.json index 6846aa8..e3f3e9e 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@babel/register": "^7.0.0", "@babel/runtime": "^7.4.4", "@chainsafe/benchmark-utils": "^0.1.0", - "@chainsafe/eth2.0-spec-test-util": "^0.2.3", + "@chainsafe/eth2.0-spec-test-util": "0.4.1", "@types/assert": "^1.4.2", "@types/chai": "^4.1.7", "@types/mocha": "^5.2.5", diff --git a/test/spec/aggregate_pubkeys.test.ts b/test/spec/aggregate_pubkeys.test.ts index 09a911f..d905331 100644 --- a/test/spec/aggregate_pubkeys.test.ts +++ b/test/spec/aggregate_pubkeys.test.ts @@ -1,21 +1,27 @@ -import {join} from "path"; -import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util"; -import bls from "../../src"; -import {BLSSignature} from "@chainsafe/eth2.0-types"; +import bls, {PublicKey} from "../../src"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; +import path from "path"; -describeSpecTest( - join(__dirname, "../../../spec-test-cases/tests/bls/aggregate_pubkeys/aggregate_pubkeys.yaml"), - bls.aggregatePubkeys, - ({input}) => { - const sigs: BLSSignature[] = []; - input.forEach((sig: string) => { - sigs.push(Buffer.from(sig.replace('0x', ''), 'hex')); - }); - return [ - sigs - ]; - }, - ({output}) => output, - (result) => `0x${result.toString('hex')}`, - () => false, +interface AggregatePubKeysTestCase { + data: { + input: string[]; + output: string; + }; +} + +describeDirectorySpecTest( + "aggregate pubkeys", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/aggregate_pubkeys/small"), + (testCase => { + const result = bls.aggregatePubkeys(testCase.data.input.map(pubKey => { + return Buffer.from(pubKey.replace("0x", ""), "hex"); + })); + return `0x${result.toString('hex')}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => testCase.data.output) + } ); diff --git a/test/spec/aggregate_sigs.test.ts b/test/spec/aggregate_sigs.test.ts index 4a494a2..4df88df 100644 --- a/test/spec/aggregate_sigs.test.ts +++ b/test/spec/aggregate_sigs.test.ts @@ -1,21 +1,27 @@ -import {join} from "path"; -import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util"; +import path from "path"; import bls from "../../src"; -import {BLSPubkey} from "../../src/types"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; -describeSpecTest( - join(__dirname, "../../../spec-test-cases/tests/bls/aggregate_sigs/aggregate_sigs.yaml"), - bls.aggregateSignatures, - ({input}) => { - const pubKeys: BLSPubkey[] = []; - input.forEach((pubKey: string) => { - pubKeys.push(Buffer.from(pubKey.replace('0x', ''), 'hex')); - }); - return [ - pubKeys - ]; - }, - ({output}) => output, - (result) => `0x${result.toString('hex')}`, - () => false, +interface AggregateSigsTestCase { + data: { + input: string[]; + output: string; + }; +} + +describeDirectorySpecTest( + "aggregate sigs", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/aggregate_sigs/small"), + (testCase => { + const result = bls.aggregateSignatures(testCase.data.input.map(pubKey => { + return Buffer.from(pubKey.replace("0x", ""), "hex"); + })); + return `0x${result.toString('hex')}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => testCase.data.output) + } ); diff --git a/test/spec/g2_compressed.test.ts b/test/spec/g2_compressed.test.ts deleted file mode 100644 index e0cf37f..0000000 --- a/test/spec/g2_compressed.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {join} from "path"; -import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util"; -import {padLeft} from "../../src/helpers/utils"; -import {G2point} from "../../src/helpers/g2point"; - -describeSpecTest( - join(__dirname, "../../../spec-test-cases/tests/bls/msg_hash_g2_compressed/g2_compressed.yaml"), - G2point.hashToG2, - ({input}) => { - const domain = padLeft(Buffer.from(input.domain.replace('0x', ''), 'hex'), 8); - return [ - Buffer.from(input.message.replace('0x', ''), 'hex'), - domain - ]; - }, - ({output}) => { - const xReExpected = padLeft(Buffer.from(output[0].replace('0x', ''), 'hex'), 48); - const xImExpected = padLeft(Buffer.from(output[1].replace('0x', ''), 'hex'), 48); - return '0x' + Buffer.concat([xReExpected, xImExpected]).toString('hex'); - }, - (result: G2point) => `0x${result.toBytesCompressed().toString('hex')}`, - () => false, -); diff --git a/test/spec/g2_uncompressed.test.ts b/test/spec/g2_uncompressed.test.ts deleted file mode 100644 index ec9550b..0000000 --- a/test/spec/g2_uncompressed.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {join} from "path"; -import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util"; -import {padLeft} from "../../src/helpers/utils"; -import {G2point} from "../../src/helpers/g2point"; - -describeSpecTest( - join(__dirname, "../../../spec-test-cases/tests/bls/msg_hash_g2_uncompressed/g2_uncompressed.yaml"), - G2point.hashToG2, - ({input}) => { - const domain = padLeft(Buffer.from(input.domain.replace('0x', ''), 'hex'), 8); - return [ - Buffer.from(input.message.replace('0x', ''), 'hex'), - domain - ]; - }, - ({output}) => { - return '0x' + G2point.fromUncompressedInput( - Buffer.from(output[0][0].replace('0x', ''), 'hex'), - Buffer.from(output[0][1].replace('0x', ''), 'hex'), - Buffer.from(output[1][0].replace('0x', ''), 'hex'), - Buffer.from(output[1][1].replace('0x', ''), 'hex'), - Buffer.from(output[2][0].replace('0x', ''), 'hex'), - Buffer.from(output[2][1].replace('0x', ''), 'hex'), - ).toBytesCompressed().toString('hex'); - }, - (result: G2point) => `0x${result.toBytesCompressed().toString('hex')}`, - () => false, -); diff --git a/test/spec/msg_hash_compressed.ts b/test/spec/msg_hash_compressed.ts new file mode 100644 index 0000000..a5d738c --- /dev/null +++ b/test/spec/msg_hash_compressed.ts @@ -0,0 +1,40 @@ +import path from "path"; +import {padLeft} from "../../src/helpers/utils"; +import {G2point} from "../../src/helpers/g2point"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; + +interface MsgHHashUnCompressed { + data: { + input: { + message: string, + domain: string + }; + output: string[][]; + }; +} + +describeDirectorySpecTest( + "msg_hash_uncompressed", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/msg_hash_uncompressed/small"), + (testCase => { + const domain = padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8); + const input = Buffer.from(testCase.data.input.message, "hex"); + const result = G2point.hashToG2(input, domain); + return `0x${result.toBytesCompressed().toString('hex')}` + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => { + return '0x' + G2point.fromUncompressedInput( + Buffer.from(testCase.data.output[0][0].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[0][1].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[1][0].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[1][1].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[2][0].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[2][1].replace('0x', ''), 'hex'), + ).toBytesCompressed().toString('hex'); + }) + } +); \ No newline at end of file diff --git a/test/spec/msg_hash_uncompressed.ts b/test/spec/msg_hash_uncompressed.ts new file mode 100644 index 0000000..3a9b2f6 --- /dev/null +++ b/test/spec/msg_hash_uncompressed.ts @@ -0,0 +1,35 @@ +import path from "path"; +import {padLeft} from "../../src/helpers/utils"; +import {G2point} from "../../src/helpers/g2point"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; + +interface MsgHHashCOmpressed { + data: { + input: { + message: string, + domain: string + }; + output: string[]; + }; +} + +describeDirectorySpecTest( + "msg_hash_compressed", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/msg_hash_compressed/small"), + (testCase => { + const domain = padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8); + const input = Buffer.from(testCase.data.input.message, "hex"); + const result = G2point.hashToG2(input, domain); + return `0x${result.toBytesCompressed().toString('hex')}` + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => { + const xReExpected = padLeft(Buffer.from(testCase.data.output[0].replace('0x', ''), 'hex'), 48); + const xImExpected = padLeft(Buffer.from(testCase.data.output[1].replace('0x', ''), 'hex'), 48); + return '0x' + Buffer.concat([xReExpected, xImExpected]).toString('hex'); + }) + } +); \ No newline at end of file diff --git a/test/spec/priv_to_public.test.ts b/test/spec/priv_to_public.test.ts index 75b08f8..edd6c0d 100644 --- a/test/spec/priv_to_public.test.ts +++ b/test/spec/priv_to_public.test.ts @@ -1,14 +1,25 @@ -import {join} from "path"; -import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util"; import bls from "../../src"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; +import path from "path"; -describeSpecTest( - join(__dirname, "../../../spec-test-cases/tests/bls/priv_to_pub/priv_to_pub.yaml"), - bls.generatePublicKey, - ({input}) => { - return [Buffer.from(input.replace('0x', ''), 'hex')]; - }, - ({output}) => output, - (result) => `0x${result.toString('hex')}`, - () => false, +interface PrivToPubTestCase { + data: { + input: string; + output: string; + }; +} + +describeDirectorySpecTest( + "priv_to_pub", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/priv_to_pub/small"), + (testCase => { + const result = bls.generatePublicKey(Buffer.from(testCase.data.input.replace('0x', ''), 'hex')); + return `0x${result.toString('hex')}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => testCase.data.output) + } ); diff --git a/test/spec/sign_message.test.ts b/test/spec/sign_message.test.ts index 1117838..ffabf54 100644 --- a/test/spec/sign_message.test.ts +++ b/test/spec/sign_message.test.ts @@ -1,20 +1,34 @@ -import {join} from "path"; -import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util"; +import path from "path"; import bls from "../../src"; import {padLeft} from "../../src/helpers/utils"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; -describeSpecTest( - join(__dirname, "../../../spec-test-cases/tests/bls/sign_msg/sign_msg.yaml"), - bls.sign, - ({input}) => { - const domain = padLeft(Buffer.from(input.domain.replace('0x', ''), 'hex'), 8); - return [ - Buffer.from(input.privkey.replace('0x', ''), 'hex'), - Buffer.from(input.message.replace('0x', ''), 'hex'), - domain - ]; - }, - ({output}) => output, - (result) => `0x${result.toString('hex')}`, - () => false, -); +interface SignMessageTestCase { + data: { + input: { + privkey: string, + message: string, + domain: string + }; + output: string; + }; +} + +describeDirectorySpecTest( + "priv_to_pub", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/sign_msg/small"), + (testCase => { + const signature = bls.sign( + Buffer.from(testCase.data.input.privkey.replace("0x", ""), "hex"), + Buffer.from(testCase.data.input.message.replace("0x", ""), "hex"), + padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8) + ); + return `0x${signature.toString("hex")}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => testCase.data.output) + } +); \ No newline at end of file From 8ef2ac2ac0d93d1b3bccf989d83cd70226348d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Thu, 5 Sep 2019 18:51:27 -0400 Subject: [PATCH 2/3] working bls on 0.8.3 tests --- package.json | 4 +-- test/spec/aggregate_pubkeys.test.ts | 2 +- test/spec/msg_hash_compressed.test.ts | 35 +++++++++++++++++++ test/spec/msg_hash_compressed.ts | 40 --------------------- test/spec/msg_hash_uncompressed.test.ts | 40 +++++++++++++++++++++ test/spec/msg_hash_uncompressed.ts | 35 ------------------- test/spec/sign_message.test.ts | 46 ++++++++++++------------- 7 files changed, 101 insertions(+), 101 deletions(-) create mode 100644 test/spec/msg_hash_compressed.test.ts delete mode 100644 test/spec/msg_hash_compressed.ts create mode 100644 test/spec/msg_hash_uncompressed.test.ts delete mode 100644 test/spec/msg_hash_uncompressed.ts diff --git a/package.json b/package.json index e3f3e9e..a02a004 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "pretest": "yarn check-types", "prepublishOnly": "yarn build", "test:unit": "nyc --cache-dir .nyc_output/.cache -r lcov -e .ts mocha --colors -r ./.babel-register 'test/unit/**/*.test.ts' && nyc report", - "test:spec": "mocha --colors -r ./.babel-register 'test/spec/**/*.test.ts'", + "test:spec": "mocha --colors -r ts-node/register 'test/spec/**/*.test.ts'", "test:spec-min": "yarn run test:spec", "test": "yarn test:unit && yarn test:spec", "coverage": "codecov -F bls", @@ -64,7 +64,7 @@ "codecov": "^3.1.0", "eslint": "^5.14.1", "js-yaml": "^3.13.1", - "mocha": "^5.2.0", + "mocha": "^6.2.0", "nyc": "^13.3.0", "sinon": "^7.2.7", "supertest": "^4.0.2", diff --git a/test/spec/aggregate_pubkeys.test.ts b/test/spec/aggregate_pubkeys.test.ts index d905331..76d7b03 100644 --- a/test/spec/aggregate_pubkeys.test.ts +++ b/test/spec/aggregate_pubkeys.test.ts @@ -1,4 +1,4 @@ -import bls, {PublicKey} from "../../src"; +import bls from "../../src"; import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; import path from "path"; diff --git a/test/spec/msg_hash_compressed.test.ts b/test/spec/msg_hash_compressed.test.ts new file mode 100644 index 0000000..31b81a7 --- /dev/null +++ b/test/spec/msg_hash_compressed.test.ts @@ -0,0 +1,35 @@ +import path from "path"; +import {padLeft} from "../../src/helpers/utils"; +import {G2point} from "../../src/helpers/g2point"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; + +interface MsgHHashCOmpressed { + data: { + input: { + message: string; + domain: string; + }; + output: string[]; + }; +} + +describeDirectorySpecTest( + "msg_hash_compressed", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/msg_hash_compressed/small"), + (testCase => { + const domain = padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8); + const input = Buffer.from(testCase.data.input.message.replace('0x', ''), "hex"); + const result = G2point.hashToG2(input, domain); + return `0x${result.toBytesCompressed().toString('hex')}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => { + const xReExpected = padLeft(Buffer.from(testCase.data.output[0].replace('0x', ''), 'hex'), 48); + const xImExpected = padLeft(Buffer.from(testCase.data.output[1].replace('0x', ''), 'hex'), 48); + return '0x' + Buffer.concat([xReExpected, xImExpected]).toString('hex'); + }) + } +); \ No newline at end of file diff --git a/test/spec/msg_hash_compressed.ts b/test/spec/msg_hash_compressed.ts deleted file mode 100644 index a5d738c..0000000 --- a/test/spec/msg_hash_compressed.ts +++ /dev/null @@ -1,40 +0,0 @@ -import path from "path"; -import {padLeft} from "../../src/helpers/utils"; -import {G2point} from "../../src/helpers/g2point"; -import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; - -interface MsgHHashUnCompressed { - data: { - input: { - message: string, - domain: string - }; - output: string[][]; - }; -} - -describeDirectorySpecTest( - "msg_hash_uncompressed", - path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/msg_hash_uncompressed/small"), - (testCase => { - const domain = padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8); - const input = Buffer.from(testCase.data.input.message, "hex"); - const result = G2point.hashToG2(input, domain); - return `0x${result.toBytesCompressed().toString('hex')}` - }), - { - inputTypes: { - data: InputType.YAML, - }, - getExpected: (testCase => { - return '0x' + G2point.fromUncompressedInput( - Buffer.from(testCase.data.output[0][0].replace('0x', ''), 'hex'), - Buffer.from(testCase.data.output[0][1].replace('0x', ''), 'hex'), - Buffer.from(testCase.data.output[1][0].replace('0x', ''), 'hex'), - Buffer.from(testCase.data.output[1][1].replace('0x', ''), 'hex'), - Buffer.from(testCase.data.output[2][0].replace('0x', ''), 'hex'), - Buffer.from(testCase.data.output[2][1].replace('0x', ''), 'hex'), - ).toBytesCompressed().toString('hex'); - }) - } -); \ No newline at end of file diff --git a/test/spec/msg_hash_uncompressed.test.ts b/test/spec/msg_hash_uncompressed.test.ts new file mode 100644 index 0000000..b589909 --- /dev/null +++ b/test/spec/msg_hash_uncompressed.test.ts @@ -0,0 +1,40 @@ +import path from "path"; +import {padLeft} from "../../src/helpers/utils"; +import {G2point} from "../../src/helpers/g2point"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; + +interface MsgHHashUnCompressed { + data: { + input: { + message: string; + domain: string; + }; + output: string[][]; + }; +} + +describeDirectorySpecTest( + "msg_hash_uncompressed", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/msg_hash_uncompressed/small"), + (testCase => { + const domain = padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8); + const input = Buffer.from(testCase.data.input.message.replace("0x", ""), "hex"); + const result = G2point.hashToG2(input, domain); + return `0x${result.toBytesCompressed().toString('hex')}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => { + return '0x' + G2point.fromUncompressedInput( + Buffer.from(testCase.data.output[0][0].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[0][1].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[1][0].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[1][1].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[2][0].replace('0x', ''), 'hex'), + Buffer.from(testCase.data.output[2][1].replace('0x', ''), 'hex'), + ).toBytesCompressed().toString('hex'); + }) + } +); \ No newline at end of file diff --git a/test/spec/msg_hash_uncompressed.ts b/test/spec/msg_hash_uncompressed.ts deleted file mode 100644 index 3a9b2f6..0000000 --- a/test/spec/msg_hash_uncompressed.ts +++ /dev/null @@ -1,35 +0,0 @@ -import path from "path"; -import {padLeft} from "../../src/helpers/utils"; -import {G2point} from "../../src/helpers/g2point"; -import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; - -interface MsgHHashCOmpressed { - data: { - input: { - message: string, - domain: string - }; - output: string[]; - }; -} - -describeDirectorySpecTest( - "msg_hash_compressed", - path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/msg_hash_compressed/small"), - (testCase => { - const domain = padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8); - const input = Buffer.from(testCase.data.input.message, "hex"); - const result = G2point.hashToG2(input, domain); - return `0x${result.toBytesCompressed().toString('hex')}` - }), - { - inputTypes: { - data: InputType.YAML, - }, - getExpected: (testCase => { - const xReExpected = padLeft(Buffer.from(testCase.data.output[0].replace('0x', ''), 'hex'), 48); - const xImExpected = padLeft(Buffer.from(testCase.data.output[1].replace('0x', ''), 'hex'), 48); - return '0x' + Buffer.concat([xReExpected, xImExpected]).toString('hex'); - }) - } -); \ No newline at end of file diff --git a/test/spec/sign_message.test.ts b/test/spec/sign_message.test.ts index ffabf54..5aebb9e 100644 --- a/test/spec/sign_message.test.ts +++ b/test/spec/sign_message.test.ts @@ -4,31 +4,31 @@ import {padLeft} from "../../src/helpers/utils"; import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; interface SignMessageTestCase { - data: { - input: { - privkey: string, - message: string, - domain: string - }; - output: string; + data: { + input: { + privkey: string; + message: string; + domain: string; }; + output: string; + }; } describeDirectorySpecTest( - "priv_to_pub", - path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/sign_msg/small"), - (testCase => { - const signature = bls.sign( - Buffer.from(testCase.data.input.privkey.replace("0x", ""), "hex"), - Buffer.from(testCase.data.input.message.replace("0x", ""), "hex"), - padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8) - ); - return `0x${signature.toString("hex")}`; - }), - { - inputTypes: { - data: InputType.YAML, - }, - getExpected: (testCase => testCase.data.output) - } + "priv_to_pub", + path.join(__dirname, "../../../spec-test-cases/tests/general/phase0/bls/sign_msg/small"), + (testCase => { + const signature = bls.sign( + Buffer.from(testCase.data.input.privkey.replace("0x", ""), "hex"), + Buffer.from(testCase.data.input.message.replace("0x", ""), "hex"), + padLeft(Buffer.from(testCase.data.input.domain.replace('0x', ''), 'hex'), 8) + ); + return `0x${signature.toString("hex")}`; + }), + { + inputTypes: { + data: InputType.YAML, + }, + getExpected: (testCase => testCase.data.output) + } ); \ No newline at end of file From b515bea50f4564e67311b3610c096838732900b2 Mon Sep 17 00:00:00 2001 From: Cayman Date: Sat, 21 Sep 2019 13:59:48 -0500 Subject: [PATCH 3/3] Add additional bls types root --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index fcad19a..10d11e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "include": ["src"], "compilerOptions": { "typeRoots": [ + "src/@types", "../../node_modules/@types" ] }