This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
4 changed files with
7 additions and
19 deletions
|
|
|
@ -48,7 +48,7 @@
|
|
|
|
|
},
|
|
|
|
|
"dependencies": {
|
|
|
|
|
"@chainsafe/bls-keygen": "^0.3.0",
|
|
|
|
|
"bls-eth-wasm": "^0.4.4",
|
|
|
|
|
"bls-eth-wasm": "^0.4.6",
|
|
|
|
|
"randombytes": "^2.1.0"
|
|
|
|
|
},
|
|
|
|
|
"devDependencies": {
|
|
|
|
|
|
|
|
@ -6,26 +6,9 @@ type Bls = typeof bls;
|
|
|
|
|
let blsGlobal: Bls | null = null;
|
|
|
|
|
let blsGlobalPromise: Promise<void> | null = null;
|
|
|
|
|
|
|
|
|
|
// Patch to fix multiVerify() calls on a browser with polyfilled NodeJS crypto
|
|
|
|
|
declare global {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
|
|
|
|
interface Window {
|
|
|
|
|
msCrypto: typeof window["crypto"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function setupBls(): Promise<void> {
|
|
|
|
|
if (!blsGlobal) {
|
|
|
|
|
await bls.init(bls.BLS12_381);
|
|
|
|
|
|
|
|
|
|
// Patch to fix multiVerify() calls on a browser with polyfilled NodeJS crypto
|
|
|
|
|
if (typeof window === "object") {
|
|
|
|
|
const crypto = window.crypto || window.msCrypto;
|
|
|
|
|
// getRandomValues is not typed in `bls-eth-wasm` because it's not meant to be exposed
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
bls.getRandomValues = (x) => crypto.getRandomValues(x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
blsGlobal = bls;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
"target": "esnext",
|
|
|
|
|
"module": "commonjs",
|
|
|
|
|
"pretty": true,
|
|
|
|
|
"lib": ["esnext.bigint", "DOM"],
|
|
|
|
|
"lib": ["esnext.bigint"],
|
|
|
|
|
"typeRoots": ["./node_modules/@types"],
|
|
|
|
|
"declaration": true,
|
|
|
|
|
"strict": true,
|
|
|
|
|
|
|
|
@ -1603,6 +1603,11 @@ bls-eth-wasm@^0.4.4:
|
|
|
|
|
resolved "https://registry.yarnpkg.com/bls-eth-wasm/-/bls-eth-wasm-0.4.4.tgz#3d4c99f8ddee6df23e188dc756125268a0f4d525"
|
|
|
|
|
integrity sha512-S6XwscKuxxYTANHZX8tZQxZKvj9IhG3aOCEuy1EnNdsAOfuH2pdRIgWrORwpKd4SLdvmPWap9I+TbJRnFx1Yng==
|
|
|
|
|
|
|
|
|
|
bls-eth-wasm@^0.4.6:
|
|
|
|
|
version "0.4.6"
|
|
|
|
|
resolved "https://registry.yarnpkg.com/bls-eth-wasm/-/bls-eth-wasm-0.4.6.tgz#6159b8aee9eeb1aa24ebe2dc2e9aae4a65a0b8d3"
|
|
|
|
|
integrity sha512-ZHPnEcgtuCFj4exMN7ZInR6acOMkTAe3gVfjihzB/wE6twlFElLVY1S7CFYSMttzuhdCFU0OV/rjfRwZEselNQ==
|
|
|
|
|
|
|
|
|
|
bluebird@^3.3.0, bluebird@^3.5.5:
|
|
|
|
|
version "3.7.2"
|
|
|
|
|
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
|
|
|
|
|