Patch herumi's multiVerify() on browsers

This commit is contained in:
dapplion 2020-12-03 00:24:30 +00:00
parent 2a27b19287
commit 84488456de
1 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,16 @@ let blsGlobalPromise: Promise<void> | null = null;
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
// @ts-ignore
if (typeof window === "object") {
// @ts-ignore
const crypto = window.crypto || window.msCrypto;
// @ts-ignore
bls.getRandomValues = (x) => crypto.getRandomValues(x);
}
blsGlobal = bls;
}
}