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.
2019-11-27 18:21:37 +00:00
|
|
|
import blsWasmWrapper from "@chainsafe/eth2-bls-wasm";
|
|
|
|
|
|
|
|
let blsWrapper: typeof blsWasmWrapper | null = null;
|
|
|
|
|
|
|
|
export async function init(): Promise<typeof blsWasmWrapper> {
|
2019-11-28 11:13:20 +00:00
|
|
|
if(blsWrapper) return blsWrapper;
|
2019-11-27 18:21:37 +00:00
|
|
|
await blsWasmWrapper.init();
|
|
|
|
blsWrapper = blsWasmWrapper;
|
|
|
|
return blsWrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function destroy(): void {
|
|
|
|
blsWrapper = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getContext(): typeof blsWasmWrapper{
|
|
|
|
if(blsWrapper) {
|
|
|
|
return blsWrapper;
|
|
|
|
}
|
|
|
|
throw new Error("BLS not initialized");
|
|
|
|
}
|