Skip to content

Commit

Permalink
chore: switch to noble-hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluard committed Apr 22, 2024
1 parent 3b4db7d commit d56f56d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
},
"dependencies": {
"@chainsafe/bls-keygen": "^0.4.0",
"@noble/hashes": "^1.4.0",
"bls-eth-wasm": "^1.1.1"
},
"devDependencies": {
Expand Down Expand Up @@ -127,5 +128,6 @@
"@chainsafe/blst": {
"optional": true
}
}
},
"packageManager": "[email protected]+sha256.dbed5b7e10c552ba0e1a545c948d5473bc6c5a28ce22a8fd27e493e3e5eb6370"
}
4 changes: 2 additions & 2 deletions src/blst-native/secretKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import blst from "@chainsafe/blst";
import crypto from "crypto";
import {randomBytes} from "@noble/hashes/utils";
import {bytesToHex, hexToBytes, isZeroUint8Array} from "../helpers/index.js";
import {SECRET_KEY_LENGTH} from "../constants.js";
import {SecretKey as ISecretKey} from "../types.js";
Expand All @@ -25,7 +25,7 @@ export class SecretKey implements ISecretKey {
}

static fromKeygen(entropy?: Uint8Array): SecretKey {
const sk = blst.SecretKey.fromKeygen(entropy || crypto.randomBytes(SECRET_KEY_LENGTH));
const sk = blst.SecretKey.fromKeygen(entropy || randomBytes(SECRET_KEY_LENGTH));
return new SecretKey(sk);
}

Expand Down
4 changes: 2 additions & 2 deletions test/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import crypto from "crypto";
import {randomBytes} from "@noble/hashes/utils";

export function randomMessage(): Uint8Array {
return crypto.randomBytes(32);
return randomBytes(32);
}

export function getN<T>(n: number, getter: () => T): T[] {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.0.0.tgz#d5e38bfbdaba174805a4e649f13be9a9ed3351ae"
integrity sha512-DZVbtY62kc3kkBtMHqwCOfXrT/hnoORy5BJ4+HU1IR59X0KWAOqsfzQPcUl/lQLlG7qXbe/fZ3r/emxtAl+sqg==

"@noble/hashes@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"
integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down

0 comments on commit d56f56d

Please sign in to comment.