Use bls-keygen to generate random private keys
This commit is contained in:
parent
645f88ffec
commit
4966e0beab
|
@ -38,6 +38,7 @@
|
||||||
"benchmark": "node -r ./.babel-register test/benchmarks"
|
"benchmark": "node -r ./.babel-register test/benchmarks"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@chainsafe/bls-keygen": "^0.0.2",
|
||||||
"@chainsafe/eth2-bls-wasm": "^0.2.0",
|
"@chainsafe/eth2-bls-wasm": "^0.2.0",
|
||||||
"@chainsafe/eth2.0-types": "^0.1.0",
|
"@chainsafe/eth2.0-types": "^0.1.0",
|
||||||
"assert": "^1.4.1",
|
"assert": "^1.4.1",
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {SECRET_KEY_LENGTH} from "./constants";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import {BLSSecretKey, Domain, Hash} from "@chainsafe/eth2.0-types";
|
import {BLSSecretKey, Domain, Hash} from "@chainsafe/eth2.0-types";
|
||||||
import {SecretKeyType} from "@chainsafe/eth2-bls-wasm";
|
import {SecretKeyType} from "@chainsafe/eth2-bls-wasm";
|
||||||
|
import {generateRandomSecretKey} from "@chainsafe/bls-keygen";
|
||||||
import {getContext} from "./context";
|
import {getContext} from "./context";
|
||||||
import {PublicKey} from "./publicKey";
|
import {PublicKey} from "./publicKey";
|
||||||
import {Signature} from "./signature";
|
import {Signature} from "./signature";
|
||||||
|
@ -38,10 +39,8 @@ export class PrivateKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static random(): PrivateKey {
|
public static random(): PrivateKey {
|
||||||
const context = getContext();
|
const randomKey: Buffer = generateRandomSecretKey();
|
||||||
const secretKey = new context.SecretKey();
|
return this.fromBytes(randomKey);
|
||||||
secretKey.setByCSPRNG();
|
|
||||||
return new PrivateKey(secretKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getValue(): SecretKeyType {
|
public getValue(): SecretKeyType {
|
||||||
|
|
Reference in New Issue