Remove crypto from common helpers
This commit is contained in:
parent
530e86d98f
commit
847ec46ac9
|
@ -1,5 +1,6 @@
|
|||
import crypto from "crypto";
|
||||
import * as blst from "@chainsafe/blst";
|
||||
import {bytesToHex, getRandomBytes, hexToBytes} from "../helpers/utils";
|
||||
import {bytesToHex, hexToBytes} from "../helpers/utils";
|
||||
import {IPrivateKey} from "../interface";
|
||||
import {PublicKey} from "./publicKey";
|
||||
import {Signature} from "./signature";
|
||||
|
@ -21,7 +22,7 @@ export class PrivateKey implements IPrivateKey {
|
|||
}
|
||||
|
||||
static fromKeygen(entropy?: Uint8Array): PrivateKey {
|
||||
const sk = blst.SecretKey.fromKeygen(entropy || getRandomBytes(32));
|
||||
const sk = blst.SecretKey.fromKeygen(entropy || crypto.randomBytes(32));
|
||||
return new PrivateKey(sk);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import assert from "assert";
|
||||
import {assert} from "./helpers";
|
||||
import {IBls} from "./interface";
|
||||
|
||||
// Returned type is enforced at each implementation's index
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import crypto from "crypto";
|
||||
|
||||
export function assert(condition: unknown, message = "Assertion failed"): asserts condition {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
|
@ -14,10 +12,6 @@ export function bytesToHex(bytes: Uint8Array): string {
|
|||
return "0x" + Buffer.from(bytes).toString("hex");
|
||||
}
|
||||
|
||||
export function getRandomBytes(size: number): Uint8Array {
|
||||
return Uint8Array.from(crypto.randomBytes(size));
|
||||
}
|
||||
|
||||
export function isEqualBytes(a: Buffer | Uint8Array, b: Buffer | Uint8Array): boolean {
|
||||
return Buffer.from(a).equals(Buffer.from(b));
|
||||
}
|
||||
|
|
Reference in New Issue