Fix the javascript wasm compile

This commit is contained in:
Daniel Tehrani
2023-04-24 11:01:29 +02:00
parent b7e9c32e05
commit 84a54098b5
2 changed files with 97 additions and 67 deletions

View File

@@ -1,33 +1,62 @@
/* tslint:disable */
/* eslint-disable */
/**
*/
*/
export function init_panic_hook(): void;
/**
* @param {Uint8Array} circuit
* @param {Uint8Array} vars
* @param {Uint8Array} public_inputs
* @returns {Uint8Array}
*/
export function prove(circuit: Uint8Array, vars: Uint8Array, public_inputs: Uint8Array): Uint8Array;
* @param {Uint8Array} circuit
* @param {Uint8Array} vars
* @param {Uint8Array} public_inputs
* @returns {Uint8Array}
*/
export function prove(
circuit: Uint8Array,
vars: Uint8Array,
public_inputs: Uint8Array
): Uint8Array;
/**
* @param {Uint8Array} circuit
* @param {Uint8Array} proof
* @param {Uint8Array} public_input
* @returns {boolean}
*/
export function verify(circuit: Uint8Array, proof: Uint8Array, public_input: Uint8Array): boolean;
* @param {Uint8Array} circuit
* @param {Uint8Array} proof
* @param {Uint8Array} public_input
* @returns {boolean}
*/
export function verify(
circuit: Uint8Array,
proof: Uint8Array,
public_input: Uint8Array
): boolean;
/**
* @param {Uint8Array} input_bytes
* @returns {Uint8Array}
*/
* @param {Uint8Array} input_bytes
* @returns {Uint8Array}
*/
export function poseidon(input_bytes: Uint8Array): Uint8Array;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
export type InitInput =
| RequestInfo
| URL
| Response
| BufferSource
| WebAssembly.Module;
export interface InitOutput {
readonly prove: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
readonly verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
readonly prove: (
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
g: number
) => void;
readonly verify: (
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
g: number
) => void;
readonly poseidon: (a: number, b: number, c: number) => void;
readonly init_panic_hook: () => void;
readonly memory: WebAssembly.Memory;
@@ -36,29 +65,35 @@ export interface InitOutput {
readonly __wbindgen_free: (a: number, b: number) => void;
readonly __wbindgen_exn_store: (a: number) => void;
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
readonly __wbindgen_thread_destroy: () => void;
readonly __wbindgen_thread_destroy: (a: number, b: number) => void;
readonly __wbindgen_start: () => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {SyncInitInput} module
* @param {WebAssembly.Memory} maybe_memory
*
* @returns {InitOutput}
*/
export function initSync(module: SyncInitInput, maybe_memory?: WebAssembly.Memory): InitOutput;
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {SyncInitInput} module
* @param {WebAssembly.Memory} maybe_memory
*
* @returns {InitOutput}
*/
export function initSync(
module: SyncInitInput,
maybe_memory?: WebAssembly.Memory
): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {InitInput | Promise<InitInput>} module_or_path
* @param {WebAssembly.Memory} maybe_memory
*
* @returns {Promise<InitOutput>}
*/
export default function init (module_or_path?: InitInput | Promise<InitInput>, maybe_memory?: WebAssembly.Memory): Promise<InitOutput>;
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {InitInput | Promise<InitInput>} module_or_path
* @param {WebAssembly.Memory} maybe_memory
*
* @returns {Promise<InitOutput>}
*/
export default function init(
module_or_path?: InitInput | Promise<InitInput>,
maybe_memory?: WebAssembly.Memory
): Promise<InitOutput>;

View File

@@ -247,16 +247,16 @@ async function load(module, imports) {
function getImports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbg_randomFillSync_6894564c2c334c42 = function() { return handleError(function (arg0, arg1, arg2) {
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
imports.wbg.__wbg_getRandomValues_3774744e221a22ad = function() { return handleError(function (arg0, arg1) {
getObject(arg0).getRandomValues(getObject(arg1));
}, arguments) };
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbg_getRandomValues_805f1c3d65988a5a = function() { return handleError(function (arg0, arg1) {
getObject(arg0).getRandomValues(getObject(arg1));
imports.wbg.__wbg_randomFillSync_e950366c42764a07 = function() { return handleError(function (arg0, arg1) {
getObject(arg0).randomFillSync(takeObject(arg1));
}, arguments) };
imports.wbg.__wbg_crypto_e1d53a1d73fb10b8 = function(arg0) {
imports.wbg.__wbg_crypto_70a96de3b6b73dac = function(arg0) {
const ret = getObject(arg0).crypto;
return addHeapObject(ret);
};
@@ -265,15 +265,15 @@ function getImports() {
const ret = typeof(val) === 'object' && val !== null;
return ret;
};
imports.wbg.__wbg_process_038c26bf42b093f8 = function(arg0) {
imports.wbg.__wbg_process_dd1577445152112e = function(arg0) {
const ret = getObject(arg0).process;
return addHeapObject(ret);
};
imports.wbg.__wbg_versions_ab37218d2f0b24a8 = function(arg0) {
imports.wbg.__wbg_versions_58036bec3add9e6f = function(arg0) {
const ret = getObject(arg0).versions;
return addHeapObject(ret);
};
imports.wbg.__wbg_node_080f4b19d15bc1fe = function(arg0) {
imports.wbg.__wbg_node_6a9d28205ed5b0d8 = function(arg0) {
const ret = getObject(arg0).node;
return addHeapObject(ret);
};
@@ -281,11 +281,11 @@ function getImports() {
const ret = typeof(getObject(arg0)) === 'string';
return ret;
};
imports.wbg.__wbg_msCrypto_6e7d3e1f92610cbb = function(arg0) {
imports.wbg.__wbg_msCrypto_adbc770ec9eca9c7 = function(arg0) {
const ret = getObject(arg0).msCrypto;
return addHeapObject(ret);
};
imports.wbg.__wbg_require_78a3dcfbdba9cbce = function() { return handleError(function () {
imports.wbg.__wbg_require_f05d779769764e82 = function() { return handleError(function () {
const ret = module.require;
return addHeapObject(ret);
}, arguments) };
@@ -337,6 +337,10 @@ function getImports() {
const ret = getObject(arg0).buffer;
return addHeapObject(ret);
};
imports.wbg.__wbg_newwithbyteoffsetandlength_9fb2f11355ecadf5 = function(arg0, arg1, arg2) {
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_new_537b7341ce90bb31 = function(arg0) {
const ret = new Uint8Array(getObject(arg0));
return addHeapObject(ret);
@@ -344,10 +348,6 @@ function getImports() {
imports.wbg.__wbg_set_17499e8aa4003ebd = function(arg0, arg1, arg2) {
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
};
imports.wbg.__wbg_length_27a2afe8ab42b09f = function(arg0) {
const ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_newwithlength_b56c882b57805732 = function(arg0) {
const ret = new Uint8Array(arg0 >>> 0);
return addHeapObject(ret);
@@ -399,23 +399,18 @@ function finalizeInit(instance, module) {
return wasm;
}
async function initSync(module, maybe_memory) {
if (!wasm) {
const imports = getImports();
function initSync(module, maybe_memory) {
const imports = getImports();
initMemory(imports, maybe_memory);
/*
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
*/
const compiled = WebAssembly.compile(module);
const instance = await WebAssembly.instantiate(await compiled, imports);
return finalizeInit(instance, module);
initMemory(imports, maybe_memory);
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, imports);
return finalizeInit(instance, module);
}
async function init(input, maybe_memory) {