From 7f0baaa8742c71bbeccf858ad6cede4ff22babad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Tue, 10 Dec 2019 11:55:30 +0100 Subject: [PATCH 1/2] enable bls compressed spec tests --- test/spec/msg_hash_compressed.test.ts | 74 ++++++++++++++------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/test/spec/msg_hash_compressed.test.ts b/test/spec/msg_hash_compressed.test.ts index 1fdd651..56a65dc 100644 --- a/test/spec/msg_hash_compressed.test.ts +++ b/test/spec/msg_hash_compressed.test.ts @@ -1,36 +1,38 @@ -// import path from "path"; -// import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; -// -// interface IMsgHHashCOmpressed { -// data: { -// input: { -// message: string; -// domain: string; -// }; -// output: string[]; -// }; -// } -// -// describeDirectorySpecTest( -// "msg_hash_compressed", -// path.join( -// __dirname, -// "../../../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/msg_hash_compressed/small" -// ), -// (testCase => { -// const domain = Buffer.from(testCase.data.input.domain.replace("0x", ""), "hex"); -// 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 +import path from "path"; +import {describeDirectorySpecTest, InputType} from "@chainsafe/eth2.0-spec-test-util/lib/single"; +import {PrivateKey} from "../../src"; +import {padLeft} from "../../src/helpers/utils"; + +interface IMsgHHashCOmpressed { + data: { + input: { + message: string; + domain: string; + }; + output: string[]; + }; +} + +describeDirectorySpecTest( + "msg_hash_compressed", + path.join( + __dirname, + "../../../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/msg_hash_compressed/small" + ), + (testCase => { + const domain = Buffer.from(testCase.data.input.domain.replace("0x", ""), "hex"); + const input = Buffer.from(testCase.data.input.message.replace("0x", ""), "hex"); + const result = PrivateKey.fromInt(1).signMessage(input, domain).toBytesCompressed().toString("hex"); + return `0x${result}`; + }), + { + 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 From c7e8f59273b189a1e8e6a5faa827a891629ac3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Tue, 10 Dec 2019 14:04:23 +0100 Subject: [PATCH 2/2] bump bls-wasm version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 793cf72..1aa0606 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "benchmark": "node -r ./.babel-register test/benchmarks" }, "dependencies": { - "@chainsafe/eth2-bls-wasm": "^0.1.0", + "@chainsafe/eth2-bls-wasm": "^0.2.0", "@chainsafe/eth2.0-types": "^0.1.0", "assert": "^1.4.1", "bls-wasm": "^0.2.7"