import * as crypto from "./wasi_crypto"; // @ts-ignore: decorator @lazy const mem64: u64[] = [0]; // @ts-ignore: cast export let buf: usize = changetype(mem64).dataStart; export type ptr = crypto.ptr; export namespace error { // @ts-ignore: decorator export let last: crypto.crypto_errno = 0; function reset(): void { last = 0; } } export function fromWasiArray(arrayOutput: crypto.array_output): ArrayBuffer | null { if ((error.last = crypto.array_output_len(arrayOutput, buf))) { return null; } let out = new ArrayBuffer(load(buf) as i32); crypto.array_output_pull(arrayOutput, changetype>(out), out.byteLength, buf); return out; }