From 84488456de90643d05965f698f50c903b60e05ec Mon Sep 17 00:00:00 2001 From: dapplion Date: Thu, 3 Dec 2020 00:24:30 +0000 Subject: [PATCH] Patch herumi's multiVerify() on browsers --- src/herumi/context.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/herumi/context.ts b/src/herumi/context.ts index 7780283..5a56065 100644 --- a/src/herumi/context.ts +++ b/src/herumi/context.ts @@ -9,6 +9,16 @@ let blsGlobalPromise: Promise | null = null; export async function setupBls(): Promise { 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; } }