bugfixes
This commit is contained in:
parent
1154be87ac
commit
50f5ac45c8
15
package.json
15
package.json
|
@ -45,23 +45,8 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@chainsafe/benchmark-utils": "^0.1.0",
|
||||
"@types/assert": "^1.4.2",
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/mocha": "^5.2.5",
|
||||
"@types/node": "^12.7.2",
|
||||
"@typescript-eslint/eslint-plugin": "^1.3.0",
|
||||
"@typescript-eslint/parser": "^1.3.0",
|
||||
"chai": "^4.2.0",
|
||||
"codecov": "^3.1.0",
|
||||
"eslint": "^5.14.1",
|
||||
"js-sha256": "^0.9.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"mocha": "^6.2.0",
|
||||
"nyc": "^13.3.0",
|
||||
"sinon": "^7.2.7",
|
||||
"supertest": "^4.0.2",
|
||||
"ts-node": "^7.0.1",
|
||||
"typescript": "^3.2.1",
|
||||
"webpack": "^4.30.0",
|
||||
"webpack-cli": "^3.3.2"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export const SECRET_KEY_LENGTH = 32;
|
||||
export const SIGNATURE_LENGTH = 96;
|
||||
export const FP_POINT_LENGTH = 48;
|
||||
export const PUBLIC_KEY_LENGTH = FP_POINT_LENGTH;
|
||||
export const G2_HASH_PADDING = 16;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import blsWasmWrapper from "@chainsafe/eth2-bls-wasm";
|
||||
|
||||
let blsWrapper: typeof blsWasmWrapper | null = null;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import assert from "assert";
|
||||
import {PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH} from "../constants";
|
||||
|
||||
/**
|
||||
* Pads byte array with zeroes on left side up to desired length.
|
||||
|
@ -11,4 +12,7 @@ export function padLeft(source: Buffer, length: number): Buffer {
|
|||
const result = Buffer.alloc(length, 0);
|
||||
source.copy(result, length - source.length);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const EMPTY_PUBLIC_KEY = Buffer.alloc(PUBLIC_KEY_LENGTH);
|
||||
export const EMPTY_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH);
|
|
@ -5,6 +5,7 @@ import {getContext} from "./context";
|
|||
import {PUBLIC_KEY_LENGTH} from "./constants";
|
||||
import assert from "assert";
|
||||
import {Signature} from "./signature";
|
||||
import {EMPTY_PUBLIC_KEY} from "./helpers/utils";
|
||||
|
||||
export class PublicKey {
|
||||
|
||||
|
@ -21,7 +22,9 @@ export class PublicKey {
|
|||
public static fromBytes(bytes: BLSPubkey): PublicKey {
|
||||
const context = getContext();
|
||||
const publicKey = new context.PublicKey();
|
||||
publicKey.deserialize(bytes);
|
||||
if(!bytes.equals(EMPTY_PUBLIC_KEY)) {
|
||||
publicKey.deserialize(bytes);
|
||||
}
|
||||
return new PublicKey(
|
||||
publicKey
|
||||
);
|
||||
|
|
|
@ -4,7 +4,7 @@ import {BLSSignature, Domain, Hash} from "@chainsafe/eth2.0-types";
|
|||
import {SignatureType} from "@chainsafe/eth2-bls-wasm";
|
||||
import {getContext} from "./context";
|
||||
import {PublicKey} from "./publicKey";
|
||||
import {padLeft} from "./helpers/utils";
|
||||
import {EMPTY_SIGNATURE, padLeft} from "./helpers/utils";
|
||||
|
||||
export class Signature {
|
||||
|
||||
|
@ -21,7 +21,9 @@ export class Signature {
|
|||
);
|
||||
const context = getContext();
|
||||
const signature = new context.Signature();
|
||||
signature.deserialize(value);
|
||||
if(!value.equals(EMPTY_SIGNATURE)) {
|
||||
signature.deserialize(value);
|
||||
}
|
||||
return new Signature(signature);
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue