Merge branch 'master' into bls-keygen-private-keys

This commit is contained in:
Gerald Nash 2020-01-16 15:05:39 -05:00 committed by GitHub
commit 042e2f3098
6 changed files with 13 additions and 13 deletions

View File

@ -2,7 +2,7 @@
[![Build Status](https://travis-ci.org/ChainSafe/lodestar.svg?branch=master)](https://travis-ci.org/ChainSafe/lodestar)
[![codecov](https://codecov.io/gh/ChainSafe/lodestar/branch/master/graph/badge.svg)](https://codecov.io/gh/ChainSafe/lodestar)
![ETH2.0_Spec_Version 0.8.3](https://img.shields.io/badge/ETH2.0_Spec_Version-0.8.3-2e86c1.svg)
![ETH2.0_Spec_Version 0.9.2](https://img.shields.io/badge/ETH2.0_Spec_Version-0.8.2-2e86c1.svg)
This is a Javascript library that implements BLS (Boneh-Lynn-Shacham) signatures and supports signature aggregation.

View File

@ -40,7 +40,7 @@
"dependencies": {
"@chainsafe/bls-keygen": "^0.0.2",
"@chainsafe/eth2-bls-wasm": "^0.2.0",
"@chainsafe/eth2.0-types": "^0.1.0",
"@chainsafe/eth2.0-types": "^0.2.0",
"assert": "^1.4.1",
"bls-wasm": "^0.2.7"
},

View File

@ -2,7 +2,7 @@ import {Keypair} from "./keypair";
import {PrivateKey} from "./privateKey";
import {PublicKey} from "./publicKey";
import {Signature} from "./signature";
import {BLSPubkey, BLSSecretKey, BLSSignature, Domain, Hash} from "@chainsafe/eth2.0-types";
import {BLSPubkey, BLSSecretKey, BLSSignature, Domain, bytes32} from "@chainsafe/eth2.0-types";
import {PUBLIC_KEY_LENGTH} from "./constants";
import assert from "assert";
@ -33,7 +33,7 @@ export function generatePublicKey(secretKey: BLSSecretKey): BLSPubkey {
* @param messageHash
* @param domain
*/
export function sign(secretKey: BLSSecretKey, messageHash: Hash, domain: Domain): BLSSignature {
export function sign(secretKey: BLSSecretKey, messageHash: bytes32, domain: Domain): BLSSignature {
assert(secretKey, "secretKey is null or undefined");
assert(messageHash, "messageHash is null or undefined");
assert(domain, "domain is null or undefined");
@ -80,7 +80,7 @@ export function aggregatePubkeys(publicKeys: BLSPubkey[]): BLSPubkey {
* @param signature
* @param domain
*/
export function verify(publicKey: BLSPubkey, messageHash: Hash, signature: BLSSignature, domain: Domain): boolean {
export function verify(publicKey: BLSPubkey, messageHash: bytes32, signature: BLSSignature, domain: Domain): boolean {
assert(publicKey, "publicKey is null or undefined");
assert(messageHash, "messageHash is null or undefined");
assert(signature, "signature is null or undefined");
@ -103,7 +103,7 @@ export function verify(publicKey: BLSPubkey, messageHash: Hash, signature: BLSSi
*/
export function verifyMultiple(
publicKeys: BLSPubkey[],
messageHashes: Hash[],
messageHashes: bytes32[],
signature: BLSSignature,
domain: Domain
): boolean {

View File

@ -1,6 +1,6 @@
import {SECRET_KEY_LENGTH} from "./constants";
import assert from "assert";
import {BLSSecretKey, Domain, Hash} from "@chainsafe/eth2.0-types";
import {BLSSecretKey, Domain, bytes32} from "@chainsafe/eth2.0-types";
import {SecretKeyType} from "@chainsafe/eth2-bls-wasm";
import {generateRandomSecretKey} from "@chainsafe/bls-keygen";
import {getContext} from "./context";
@ -51,7 +51,7 @@ export class PrivateKey {
// return Signature.fromValue(this.value.sign(message));
// }
public signMessage(message: Hash, domain: Domain): Signature {
public signMessage(message: bytes32, domain: Domain): Signature {
domain = padLeft(domain, 8);
return Signature.fromValue(this.value.signHashWithDomain(Buffer.concat([message, domain])));
}

View File

@ -1,5 +1,5 @@
import {PrivateKey} from "./privateKey";
import {BLSPubkey, Domain, Hash} from "@chainsafe/eth2.0-types";
import {BLSPubkey, Domain, bytes32} from "@chainsafe/eth2.0-types";
import {PublicKeyType} from "@chainsafe/eth2-bls-wasm";
import {getContext} from "./context";
import {PUBLIC_KEY_LENGTH} from "./constants";
@ -49,7 +49,7 @@ export class PublicKey {
return agg;
}
public verifyMessage(signature: Signature, messageHash: Hash, domain: Domain): boolean {
public verifyMessage(signature: Signature, messageHash: bytes32, domain: Domain): boolean {
return this.value.verifyHashWithDomain(signature.getValue(), Buffer.concat([messageHash, domain]));
}

View File

@ -1,6 +1,6 @@
import assert from "assert";
import {FP_POINT_LENGTH} from "./constants";
import {BLSSignature, Domain, Hash} from "@chainsafe/eth2.0-types";
import {BLSSignature, Domain, bytes32} from "@chainsafe/eth2.0-types";
import {SignatureType} from "@chainsafe/eth2-bls-wasm";
import {getContext} from "./context";
import {PublicKey} from "./publicKey";
@ -43,12 +43,12 @@ export class Signature {
return this.value;
}
public verify(publicKey: PublicKey, message: Hash, domain: Domain): boolean {
public verify(publicKey: PublicKey, message: bytes32, domain: Domain): boolean {
domain = padLeft(domain, 8);
return publicKey.verifyMessage(this, message, domain);
}
public verifyMultiple(publicKeys: PublicKey[], messages: Hash[], domain: Domain): boolean {
public verifyMultiple(publicKeys: PublicKey[], messages: bytes32[], domain: Domain): boolean {
domain = padLeft(domain, 8);
return this.value.verifyAggregatedHashWithDomain(
publicKeys.map((key) => key.getValue()),