From 5ab95006630269d9662e6f89bbaa7b370869bbe4 Mon Sep 17 00:00:00 2001 From: Cedoor Date: Sun, 29 Oct 2023 22:36:30 +0000 Subject: [PATCH] feat: Return cached curves early if available (#130) --- src/bls12381.js | 2 +- src/bn128.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bls12381.js b/src/bls12381.js index 7aa51ac..ce012b8 100644 --- a/src/bls12381.js +++ b/src/bls12381.js @@ -6,6 +6,7 @@ import { ModuleBuilder } from "wasmbuilder"; globalThis.curve_bls12381 = null; export default async function buildBls12381(singleThread, plugins) { + if ((!singleThread) && (globalThis.curve_bls12381)) return globalThis.curve_bls12381; const moduleBuilder = new ModuleBuilder(); moduleBuilder.setMemory(25); @@ -33,7 +34,6 @@ export default async function buildBls12381(singleThread, plugins) { bls12381wasm.r = moduleBuilder.modules.bls12381.r; - if ((!singleThread) && (globalThis.curve_bls12381)) return globalThis.curve_bls12381; const params = { name: "bls12381", wasm: bls12381wasm, diff --git a/src/bn128.js b/src/bn128.js index 8462348..7a421c1 100644 --- a/src/bn128.js +++ b/src/bn128.js @@ -6,6 +6,7 @@ import { ModuleBuilder } from "wasmbuilder"; globalThis.curve_bn128 = null; export default async function buildBn128(singleThread, plugins) { + if ((!singleThread) && (globalThis.curve_bn128)) return globalThis.curve_bn128; const moduleBuilder = new ModuleBuilder(); moduleBuilder.setMemory(25); @@ -32,7 +33,6 @@ export default async function buildBn128(singleThread, plugins) { bn128wasm.q = moduleBuilder.modules.bn128.q; bn128wasm.r = moduleBuilder.modules.bn128.r; - if ((!singleThread) && (globalThis.curve_bn128)) return globalThis.curve_bn128; const params = { name: "bn128", wasm: bn128wasm,