Use bls-keygen to generate random private keys

This commit is contained in:
Gerald Nash 2020-01-15 15:55:26 -05:00
parent 645f88ffec
commit 4966e0beab
2 changed files with 4 additions and 4 deletions

View File

@ -38,6 +38,7 @@
"benchmark": "node -r ./.babel-register test/benchmarks"
},
"dependencies": {
"@chainsafe/bls-keygen": "^0.0.2",
"@chainsafe/eth2-bls-wasm": "^0.2.0",
"@chainsafe/eth2.0-types": "^0.1.0",
"assert": "^1.4.1",

View File

@ -2,6 +2,7 @@ import {SECRET_KEY_LENGTH} from "./constants";
import assert from "assert";
import {BLSSecretKey, Domain, Hash} from "@chainsafe/eth2.0-types";
import {SecretKeyType} from "@chainsafe/eth2-bls-wasm";
import {generateRandomSecretKey} from "@chainsafe/bls-keygen";
import {getContext} from "./context";
import {PublicKey} from "./publicKey";
import {Signature} from "./signature";
@ -38,10 +39,8 @@ export class PrivateKey {
}
public static random(): PrivateKey {
const context = getContext();
const secretKey = new context.SecretKey();
secretKey.setByCSPRNG();
return new PrivateKey(secretKey);
const randomKey: Buffer = generateRandomSecretKey();
return this.fromBytes(randomKey);
}
public getValue(): SecretKeyType {