Merge remote-tracking branch 'origin/dev' into mpetrunic/abstract-hermu

This commit is contained in:
Marin Petrunić 2020-11-24 21:08:46 +01:00
commit 5d92af17fc
No known key found for this signature in database
GPG Key ID: 834D07135E110DA5
8 changed files with 21 additions and 30 deletions

View File

@ -39,8 +39,7 @@
"benchmark": "node -r ./.babel-register test/benchmarks"
},
"dependencies": {
"@chainsafe/bls-keygen": "^0.2.0",
"assert": "^1.4.1",
"@chainsafe/bls-keygen": "^0.3.0",
"bls-eth-wasm": "^0.4.1"
},
"devDependencies": {

1
src/helpers/index.ts Normal file
View File

@ -0,0 +1 @@
export * from "./utils";

View File

@ -1,17 +1,9 @@
import assert from "assert";
import {PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH} from "../constants";
/**
* Pads byte array with zeroes on left side up to desired length.
* Throws if source is larger than desired result.
* @param source
* @param length
*/
export function padLeft(source: Uint8Array, length: number): Buffer {
assert(source.length <= length, "Given array must be smaller or equal to desired array size");
const result = Buffer.alloc(length, 0);
result.set(source, length - source.length);
return result;
export function assert(condition: unknown, message = "Assertion failed"): asserts condition {
if (!condition) {
throw new Error(message);
}
}
export const EMPTY_PUBLIC_KEY = Buffer.alloc(PUBLIC_KEY_LENGTH);

View File

@ -1,9 +1,9 @@
import {PUBLIC_KEY_LENGTH} from "./constants";
import assert from "assert";
import {Keypair} from "./keypair";
import {PrivateKey} from "./privateKey";
import {PublicKey} from "./publicKey";
import {Signature} from "./signature";
import {assert} from "./helpers";
export {Keypair, PrivateKey, PublicKey, Signature};

View File

@ -1,5 +1,5 @@
import {SECRET_KEY_LENGTH} from "./constants";
import assert from "assert";
import {assert} from "./helpers";
import {generateRandomSecretKey} from "@chainsafe/bls-keygen";
import {IPrivateKeyValue} from "./interface";
import {getContext} from "./context";

View File

@ -1,6 +1,6 @@
import {PrivateKey} from "./privateKey";
import {PUBLIC_KEY_LENGTH} from "./constants";
import assert from "assert";
import {assert} from "./helpers";
import {Signature} from "./signature";
import {EMPTY_PUBLIC_KEY} from "./helpers/utils";
import {IPublicKeyValue} from "./interface";

View File

@ -1,4 +1,4 @@
import assert from "assert";
import {assert} from "./helpers";
import {FP_POINT_LENGTH} from "./constants";
import {getContext} from "./context";
import {EMPTY_SIGNATURE} from "./helpers/utils";

View File

@ -799,26 +799,25 @@
"@assemblyscript/loader" "^0.9.2"
buffer "^5.4.3"
"@chainsafe/bls-hd-key@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@chainsafe/bls-hd-key/-/bls-hd-key-0.1.0.tgz#5e51de16801f4b4b421e418f0d1ef0692df0c585"
integrity sha512-VZj+Ml4YTPz+d/K2n9q/9bLlIJnTr/xdAC5w1eCvIFtcQrZCY1Zw+bCcXKX1q6sbZpO9xhyuoepJzJX9VkMPqw==
"@chainsafe/bls-hd-key@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@chainsafe/bls-hd-key/-/bls-hd-key-0.2.0.tgz#90aaf030150de64099e1fb27582b27bbe5ce5309"
integrity sha512-ps10jd99UWcm1qPo4spD/6hxFor9fsDgB0s2wJuFKqPdM2R+4LCowhv5kdGgGs3VIN1H8l+CgO08yC7X0WlBDQ==
dependencies:
assert "^2.0.0"
bcrypto "^5.0.4"
bn.js "^5.1.1"
buffer "^5.4.3"
"@chainsafe/bls-keygen@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@chainsafe/bls-keygen/-/bls-keygen-0.2.0.tgz#2089da875caff4334723c5ee45495e366dc57a2e"
integrity sha512-IcgOJ1UTiHX3T1FnSqTdf4gtavjpINPtmAwLZFQUxSuLPOfmxPPVN/yhAIYw5xCh9/mWkaFQ/dFUk6ys+BkfGQ==
"@chainsafe/bls-keygen@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@chainsafe/bls-keygen/-/bls-keygen-0.3.0.tgz#d7472a945f6f49b5cb357241bfba2f5c12a635c5"
integrity sha512-5Iq6E5E987hyio74G1fXPYI3t9iVeHxRX1tDMpnCV9T82rPz061yFsMz3W3aXE26+k6+fcz0bsYX3ijOizkx+A==
dependencies:
"@chainsafe/bls-hd-key" "^0.1.0"
assert "^2.0.0"
bcrypto "^5.0.4"
"@chainsafe/bls-hd-key" "^0.2.0"
bip39 "^3.0.2"
buffer "^5.4.3"
randombytes "^2.1.0"
"@chainsafe/eth2-spec-tests@0.12.0":
version "0.12.0"
@ -1323,7 +1322,7 @@ asn1.js@^4.0.0:
inherits "^2.0.1"
minimalistic-assert "^1.0.0"
assert@^1.1.1, assert@^1.4.1:
assert@^1.1.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb"
integrity sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==