diff --git a/src/context.ts b/src/context.ts index 03bdd12..98b56d5 100644 --- a/src/context.ts +++ b/src/context.ts @@ -4,7 +4,7 @@ import { IBls } from "./interface"; export type Backing = "herumi" | "blst-native" | "blst-wasm"; -let backing: Backing|undefined = undefined; +let contextBacking: Backing|undefined = undefined; let context: IBls|undefined = undefined; //to maintain api compatible, add all backing context to return type @@ -13,7 +13,7 @@ export async function init(backing: Backing = "herumi"): Promise { switch(backing) { case "herumi": { context = await herumiToIBls(); - backing = backing; + contextBacking = backing; } break; default: throw new Error(`Unsupported backing - ${backing}`) } @@ -27,7 +27,7 @@ export function destroy(): void { context.destroy(); } context = undefined; - backing = undefined; + contextBacking = undefined; } export function getContext(): IBls { @@ -36,3 +36,11 @@ export function getContext(): IBls { } return context; } + + +export function getContextBacking(): Backing { + if (!context) { + throw new Error("BLS not initialized"); + } + return contextBacking; +}