UNPKG

o1js

Version:

TypeScript framework for zk-SNARKs and zkApps

1,642 lines (1,497 loc) 273 kB
let imports = {}; imports['__wbindgen_placeholder__'] = module.exports; let wasm; const { TextDecoder, TextEncoder } = require(`util`); function addToExternrefTable0(obj) { const idx = wasm.__externref_table_alloc(); wasm.__wbindgen_export_2.set(idx, obj); return idx; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { const idx = addToExternrefTable0(e); wasm.__wbindgen_exn_store(idx); } } let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.buffer !== wasm.memory.buffer) { cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8ArrayMemory0; } function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0; return cachedTextDecoder.decode(getUint8ArrayMemory0().slice(ptr, ptr + len)); } let WASM_VECTOR_LEN = 0; let cachedTextEncoder = new TextEncoder('utf-8'); const encodeString = function (arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length }; }; function passStringToWasm0(arg, malloc, realloc) { if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length, 1) >>> 0; getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr; } let len = arg.length; let ptr = malloc(len, 1) >>> 0; const mem = getUint8ArrayMemory0(); let offset = 0; for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 0x7F) break; mem[ptr + offset] = code; } if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; } let cachedDataViewMemory0 = null; function getDataViewMemory0() { if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer !== wasm.memory.buffer) { cachedDataViewMemory0 = new DataView(wasm.memory.buffer); } return cachedDataViewMemory0; } function isLikeNone(x) { return x === undefined || x === null; } function debugString(val) { // primitive types const type = typeof val; if (type == 'number' || type == 'boolean' || val == null) { return `${val}`; } if (type == 'string') { return `"${val}"`; } if (type == 'symbol') { const description = val.description; if (description == null) { return 'Symbol'; } else { return `Symbol(${description})`; } } if (type == 'function') { const name = val.name; if (typeof name == 'string' && name.length > 0) { return `Function(${name})`; } else { return 'Function'; } } // objects if (Array.isArray(val)) { const length = val.length; let debug = '['; if (length > 0) { debug += debugString(val[0]); } for(let i = 1; i < length; i++) { debug += ', ' + debugString(val[i]); } debug += ']'; return debug; } // Test for built-in const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); let className; if (builtInMatches && builtInMatches.length > 1) { className = builtInMatches[1]; } else { // Failed to match the standard '[object ClassName]' return toString.call(val); } if (className == 'Object') { // we're a user defined class or Object // JSON.stringify avoids problems with cycles, and is generally much // easier than looping through ownProperties of `val`. try { return 'Object(' + JSON.stringify(val) + ')'; } catch (_) { return 'Object'; } } // errors if (val instanceof Error) { return `${val.name}: ${val.message}\n${val.stack}`; } // TODO we could test for more things here, like `Set`s and `Map`s. return className; } function getArrayU8FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1, 1) >>> 0; getUint8ArrayMemory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } /** * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_one = function() { const ret = wasm.caml_pallas_one(); return WasmPallasGProjective.__wrap(ret); }; function _assertClass(instance, klass) { if (!(instance instanceof klass)) { throw new Error(`expected instance of ${klass.name}`); } } /** * @param {WasmPallasGProjective} x * @param {WasmPallasGProjective} y * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_add = function(x, y) { _assertClass(x, WasmPallasGProjective); _assertClass(y, WasmPallasGProjective); const ret = wasm.caml_pallas_add(x.__wbg_ptr, y.__wbg_ptr); return WasmPallasGProjective.__wrap(ret); }; /** * @param {WasmPallasGProjective} x * @param {WasmPallasGProjective} y * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_sub = function(x, y) { _assertClass(x, WasmPallasGProjective); _assertClass(y, WasmPallasGProjective); const ret = wasm.caml_pallas_sub(x.__wbg_ptr, y.__wbg_ptr); return WasmPallasGProjective.__wrap(ret); }; /** * @param {WasmPallasGProjective} x * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_negate = function(x) { _assertClass(x, WasmPallasGProjective); const ret = wasm.caml_pallas_negate(x.__wbg_ptr); return WasmPallasGProjective.__wrap(ret); }; /** * @param {Uint8Array} x * @param {Uint8Array} y * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_of_affine_coordinates = function(x, y) { const ptr0 = passArray8ToWasm0(x, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray8ToWasm0(y, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.caml_pallas_of_affine_coordinates(ptr0, len0, ptr1, len1); return WasmPallasGProjective.__wrap(ret); }; /** * @param {WasmGPallas} x * @returns {WasmGPallas} */ module.exports.caml_pallas_affine_deep_copy = function(x) { _assertClass(x, WasmGPallas); var ptr0 = x.__destroy_into_raw(); const ret = wasm.caml_pallas_affine_deep_copy(ptr0); return WasmGPallas.__wrap(ret); }; /** * @param {WasmPallasGProjective} x * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_double = function(x) { _assertClass(x, WasmPallasGProjective); const ret = wasm.caml_pallas_double(x.__wbg_ptr); return WasmPallasGProjective.__wrap(ret); }; /** * @param {WasmPallasGProjective} x * @param {Uint8Array} y * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_scale = function(x, y) { _assertClass(x, WasmPallasGProjective); const ptr0 = passArray8ToWasm0(y, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pallas_scale(x.__wbg_ptr, ptr0, len0); return WasmPallasGProjective.__wrap(ret); }; /** * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_random = function() { const ret = wasm.caml_pallas_random(); return WasmPallasGProjective.__wrap(ret); }; /** * @param {number} i * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_rng = function(i) { const ret = wasm.caml_pallas_rng(i); return WasmPallasGProjective.__wrap(ret); }; /** * @returns {Uint8Array} */ module.exports.caml_pallas_endo_base = function() { const ret = wasm.caml_pallas_endo_base(); var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @returns {Uint8Array} */ module.exports.caml_pallas_endo_scalar = function() { const ret = wasm.caml_pallas_endo_scalar(); var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @param {WasmPallasGProjective} x * @returns {WasmGPallas} */ module.exports.caml_pallas_to_affine = function(x) { _assertClass(x, WasmPallasGProjective); const ret = wasm.caml_pallas_to_affine(x.__wbg_ptr); return WasmGPallas.__wrap(ret); }; /** * @param {WasmGPallas} x * @returns {WasmPallasGProjective} */ module.exports.caml_pallas_of_affine = function(x) { _assertClass(x, WasmGPallas); var ptr0 = x.__destroy_into_raw(); const ret = wasm.caml_pallas_of_affine(ptr0); return WasmPallasGProjective.__wrap(ret); }; /** * @param {number} num_threads * @param {string} worker_source * @returns {Promise<any>} */ module.exports.initThreadPool = function(num_threads, worker_source) { const ret = wasm.initThreadPool(num_threads, worker_source); return ret; }; /** * @returns {Promise<any>} */ module.exports.exitThreadPool = function() { const ret = wasm.exitThreadPool(); return ret; }; /** * @param {number} receiver */ module.exports.wbg_rayon_start_worker = function(receiver) { wasm.wbg_rayon_start_worker(receiver); }; let cachedUint32ArrayMemory0 = null; function getUint32ArrayMemory0() { if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.buffer !== wasm.memory.buffer) { cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer); } return cachedUint32ArrayMemory0; } function passArray32ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 4, 4) >>> 0; getUint32ArrayMemory0().set(arg, ptr / 4); WASM_VECTOR_LEN = arg.length; return ptr; } function takeFromExternrefTable0(idx) { const value = wasm.__wbindgen_export_2.get(idx); wasm.__externref_table_dealloc(idx); return value; } /** * @param {Uint32Array} lgr_comm * @param {WasmFpPlonkVerifierIndex} index * @param {WasmFpProverProof} proof * @returns {WasmFpOracles} */ module.exports.fp_oracles_create = function(lgr_comm, index, proof) { const ptr0 = passArray32ToWasm0(lgr_comm, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; _assertClass(index, WasmFpPlonkVerifierIndex); var ptr1 = index.__destroy_into_raw(); _assertClass(proof, WasmFpProverProof); var ptr2 = proof.__destroy_into_raw(); const ret = wasm.fp_oracles_create(ptr0, len0, ptr1, ptr2); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFpOracles.__wrap(ret[0]); }; /** * @returns {WasmFpOracles} */ module.exports.fp_oracles_dummy = function() { const ret = wasm.fp_oracles_dummy(); return WasmFpOracles.__wrap(ret); }; /** * @param {WasmFpProverProof} x * @returns {WasmFpProverProof} */ module.exports.fp_oracles_deep_copy = function(x) { _assertClass(x, WasmFpProverProof); var ptr0 = x.__destroy_into_raw(); const ret = wasm.fp_oracles_deep_copy(ptr0); return WasmFpProverProof.__wrap(ret); }; /** * @param {boolean | null | undefined} append * @param {WasmPastaFpPlonkIndex} index * @param {string} path */ module.exports.caml_pasta_fp_plonk_index_write = function(append, index, path) { _assertClass(index, WasmPastaFpPlonkIndex); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_index_write(isLikeNone(append) ? 0xFFFFFF : append ? 1 : 0, index.__wbg_ptr, ptr0, len0); if (ret[1]) { throw takeFromExternrefTable0(ret[0]); } }; /** * @param {WasmFpGateVector} gates * @param {number} public_ * @param {Uint32Array} lookup_tables * @param {Uint32Array} runtime_table_cfgs * @param {number} prev_challenges * @param {WasmFpSrs} srs * @param {boolean} lazy_mode * @returns {WasmPastaFpPlonkIndex} */ module.exports.caml_pasta_fp_plonk_index_create = function(gates, public_, lookup_tables, runtime_table_cfgs, prev_challenges, srs, lazy_mode) { _assertClass(gates, WasmFpGateVector); const ptr0 = passArray32ToWasm0(lookup_tables, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray32ToWasm0(runtime_table_cfgs, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; _assertClass(srs, WasmFpSrs); const ret = wasm.caml_pasta_fp_plonk_index_create(gates.__wbg_ptr, public_, ptr0, len0, ptr1, len1, prev_challenges, srs.__wbg_ptr, lazy_mode); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmPastaFpPlonkIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fp_plonk_index_max_degree = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_max_degree(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fp_plonk_index_public_inputs = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_public_inputs(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fp_plonk_index_domain_d1_size = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_domain_d1_size(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fp_plonk_index_domain_d4_size = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_domain_d4_size(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fp_plonk_index_domain_d8_size = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_domain_d8_size(index.__wbg_ptr); return ret; }; /** * @param {Uint8Array} bytes * @param {WasmFpSrs} srs * @returns {WasmPastaFpPlonkIndex} */ module.exports.caml_pasta_fp_plonk_index_decode = function(bytes, srs) { const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; _assertClass(srs, WasmFpSrs); const ret = wasm.caml_pasta_fp_plonk_index_decode(ptr0, len0, srs.__wbg_ptr); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmPastaFpPlonkIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {Uint8Array} */ module.exports.caml_pasta_fp_plonk_index_encode = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_encode(index.__wbg_ptr); if (ret[3]) { throw takeFromExternrefTable0(ret[2]); } var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @param {number | null | undefined} offset * @param {WasmFpSrs} srs * @param {string} path * @returns {WasmPastaFpPlonkIndex} */ module.exports.caml_pasta_fp_plonk_index_read = function(offset, srs, path) { _assertClass(srs, WasmFpSrs); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_index_read(isLikeNone(offset) ? 0x100000001 : (offset) >> 0, srs.__wbg_ptr, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmPastaFpPlonkIndex.__wrap(ret[0]); }; /** * @param {boolean | null | undefined} append * @param {WasmPastaFqPlonkIndex} index * @param {string} path */ module.exports.caml_pasta_fq_plonk_index_write = function(append, index, path) { _assertClass(index, WasmPastaFqPlonkIndex); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_index_write(isLikeNone(append) ? 0xFFFFFF : append ? 1 : 0, index.__wbg_ptr, ptr0, len0); if (ret[1]) { throw takeFromExternrefTable0(ret[0]); } }; /** * @param {WasmFqGateVector} gates * @param {number} public_ * @param {Uint32Array} lookup_tables * @param {Uint32Array} runtime_table_cfgs * @param {number} prev_challenges * @param {WasmFqSrs} srs * @param {boolean} lazy_mode * @returns {WasmPastaFqPlonkIndex} */ module.exports.caml_pasta_fq_plonk_index_create = function(gates, public_, lookup_tables, runtime_table_cfgs, prev_challenges, srs, lazy_mode) { _assertClass(gates, WasmFqGateVector); const ptr0 = passArray32ToWasm0(lookup_tables, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray32ToWasm0(runtime_table_cfgs, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; _assertClass(srs, WasmFqSrs); const ret = wasm.caml_pasta_fq_plonk_index_create(gates.__wbg_ptr, public_, ptr0, len0, ptr1, len1, prev_challenges, srs.__wbg_ptr, lazy_mode); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmPastaFqPlonkIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fq_plonk_index_max_degree = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_max_degree(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fq_plonk_index_public_inputs = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_public_inputs(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fq_plonk_index_domain_d1_size = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_domain_d1_size(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fq_plonk_index_domain_d4_size = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_domain_d4_size(index.__wbg_ptr); return ret; }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {number} */ module.exports.caml_pasta_fq_plonk_index_domain_d8_size = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_index_domain_d8_size(index.__wbg_ptr); return ret; }; /** * @param {Uint8Array} bytes * @param {WasmFqSrs} srs * @returns {WasmPastaFqPlonkIndex} */ module.exports.caml_pasta_fq_plonk_index_decode = function(bytes, srs) { const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; _assertClass(srs, WasmFqSrs); const ret = wasm.caml_pasta_fq_plonk_index_decode(ptr0, len0, srs.__wbg_ptr); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmPastaFqPlonkIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {Uint8Array} */ module.exports.caml_pasta_fq_plonk_index_encode = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fq_plonk_index_encode(index.__wbg_ptr); if (ret[3]) { throw takeFromExternrefTable0(ret[2]); } var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @param {number | null | undefined} offset * @param {WasmFqSrs} srs * @param {string} path * @returns {WasmPastaFqPlonkIndex} */ module.exports.caml_pasta_fq_plonk_index_read = function(offset, srs, path) { _assertClass(srs, WasmFqSrs); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_index_read(isLikeNone(offset) ? 0x100000001 : (offset) >> 0, srs.__wbg_ptr, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmPastaFqPlonkIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFpPlonkIndex} prover_index * @returns {string} */ module.exports.prover_to_json = function(prover_index) { let deferred1_0; let deferred1_1; try { _assertClass(prover_index, WasmPastaFpPlonkIndex); const ret = wasm.prover_to_json(prover_index.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } }; /** * @returns {WasmFpProverProof} */ module.exports.caml_pasta_fp_plonk_proof_dummy = function() { const ret = wasm.caml_pasta_fp_plonk_proof_dummy(); return WasmFpProverProof.__wrap(ret); }; /** * @param {WasmFpProverProof} x * @returns {WasmFpProverProof} */ module.exports.caml_pasta_fp_plonk_proof_deep_copy = function(x) { _assertClass(x, WasmFpProverProof); var ptr0 = x.__destroy_into_raw(); const ret = wasm.caml_pasta_fp_plonk_proof_deep_copy(ptr0); return WasmFpProverProof.__wrap(ret); }; /** * @param {WasmPastaFpPlonkIndex} index * @param {WasmVecVecFp} witness * @param {Uint32Array} wasm_runtime_tables * @param {Uint8Array} prev_challenges * @param {Uint32Array} prev_sgs * @returns {WasmFpProverProof} */ module.exports.caml_pasta_fp_plonk_proof_create = function(index, witness, wasm_runtime_tables, prev_challenges, prev_sgs) { _assertClass(index, WasmPastaFpPlonkIndex); _assertClass(witness, WasmVecVecFp); var ptr0 = witness.__destroy_into_raw(); const ptr1 = passArray32ToWasm0(wasm_runtime_tables, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ptr2 = passArray8ToWasm0(prev_challenges, wasm.__wbindgen_malloc); const len2 = WASM_VECTOR_LEN; const ptr3 = passArray32ToWasm0(prev_sgs, wasm.__wbindgen_malloc); const len3 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_proof_create(index.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFpProverProof.__wrap(ret[0]); }; /** * @param {WasmFpPlonkVerifierIndex} index * @param {WasmFpProverProof} proof * @returns {boolean} */ module.exports.caml_pasta_fp_plonk_proof_verify = function(index, proof) { _assertClass(index, WasmFpPlonkVerifierIndex); var ptr0 = index.__destroy_into_raw(); _assertClass(proof, WasmFpProverProof); var ptr1 = proof.__destroy_into_raw(); const ret = wasm.caml_pasta_fp_plonk_proof_verify(ptr0, ptr1); return ret !== 0; }; /** * @param {Uint32Array} indexes * @param {Uint32Array} proofs * @returns {boolean} */ module.exports.caml_pasta_fp_plonk_proof_batch_verify = function(indexes, proofs) { const ptr0 = passArray32ToWasm0(indexes, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray32ToWasm0(proofs, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_proof_batch_verify(ptr0, len0, ptr1, len1); return ret !== 0; }; /** * @param {number | null | undefined} offset * @param {WasmFpSrs} srs * @param {string} path * @returns {WasmFpPlonkVerifierIndex} */ module.exports.caml_pasta_fp_plonk_verifier_index_read = function(offset, srs, path) { _assertClass(srs, WasmFpSrs); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_verifier_index_read(isLikeNone(offset) ? 0x100000001 : (offset) >> 0, srs.__wbg_ptr, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFpPlonkVerifierIndex.__wrap(ret[0]); }; /** * @param {boolean | null | undefined} append * @param {WasmFpPlonkVerifierIndex} index * @param {string} path */ module.exports.caml_pasta_fp_plonk_verifier_index_write = function(append, index, path) { _assertClass(index, WasmFpPlonkVerifierIndex); var ptr0 = index.__destroy_into_raw(); const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_verifier_index_write(isLikeNone(append) ? 0xFFFFFF : append ? 1 : 0, ptr0, ptr1, len1); if (ret[1]) { throw takeFromExternrefTable0(ret[0]); } }; /** * @param {WasmFpPlonkVerifierIndex} index * @returns {string} */ module.exports.caml_pasta_fp_plonk_verifier_index_serialize = function(index) { let deferred2_0; let deferred2_1; try { _assertClass(index, WasmFpPlonkVerifierIndex); var ptr0 = index.__destroy_into_raw(); const ret = wasm.caml_pasta_fp_plonk_verifier_index_serialize(ptr0); deferred2_0 = ret[0]; deferred2_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); } }; /** * @param {WasmFpSrs} srs * @param {string} index * @returns {WasmFpPlonkVerifierIndex} */ module.exports.caml_pasta_fp_plonk_verifier_index_deserialize = function(srs, index) { _assertClass(srs, WasmFpSrs); const ptr0 = passStringToWasm0(index, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_plonk_verifier_index_deserialize(srs.__wbg_ptr, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFpPlonkVerifierIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFpPlonkIndex} index * @returns {WasmFpPlonkVerifierIndex} */ module.exports.caml_pasta_fp_plonk_verifier_index_create = function(index) { _assertClass(index, WasmPastaFpPlonkIndex); const ret = wasm.caml_pasta_fp_plonk_verifier_index_create(index.__wbg_ptr); return WasmFpPlonkVerifierIndex.__wrap(ret); }; /** * @param {number} log2_size * @returns {WasmFpShifts} */ module.exports.caml_pasta_fp_plonk_verifier_index_shifts = function(log2_size) { const ret = wasm.caml_pasta_fp_plonk_verifier_index_shifts(log2_size); return WasmFpShifts.__wrap(ret); }; /** * @returns {WasmFpPlonkVerifierIndex} */ module.exports.caml_pasta_fp_plonk_verifier_index_dummy = function() { const ret = wasm.caml_pasta_fp_plonk_verifier_index_dummy(); return WasmFpPlonkVerifierIndex.__wrap(ret); }; /** * @param {WasmFpPlonkVerifierIndex} x * @returns {WasmFpPlonkVerifierIndex} */ module.exports.caml_pasta_fp_plonk_verifier_index_deep_copy = function(x) { _assertClass(x, WasmFpPlonkVerifierIndex); const ret = wasm.caml_pasta_fp_plonk_verifier_index_deep_copy(x.__wbg_ptr); return WasmFpPlonkVerifierIndex.__wrap(ret); }; /** * @param {number | null | undefined} offset * @param {WasmFqSrs} srs * @param {string} path * @returns {WasmFqPlonkVerifierIndex} */ module.exports.caml_pasta_fq_plonk_verifier_index_read = function(offset, srs, path) { _assertClass(srs, WasmFqSrs); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_verifier_index_read(isLikeNone(offset) ? 0x100000001 : (offset) >> 0, srs.__wbg_ptr, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFqPlonkVerifierIndex.__wrap(ret[0]); }; /** * @param {boolean | null | undefined} append * @param {WasmFqPlonkVerifierIndex} index * @param {string} path */ module.exports.caml_pasta_fq_plonk_verifier_index_write = function(append, index, path) { _assertClass(index, WasmFqPlonkVerifierIndex); var ptr0 = index.__destroy_into_raw(); const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_verifier_index_write(isLikeNone(append) ? 0xFFFFFF : append ? 1 : 0, ptr0, ptr1, len1); if (ret[1]) { throw takeFromExternrefTable0(ret[0]); } }; /** * @param {WasmFqPlonkVerifierIndex} index * @returns {string} */ module.exports.caml_pasta_fq_plonk_verifier_index_serialize = function(index) { let deferred2_0; let deferred2_1; try { _assertClass(index, WasmFqPlonkVerifierIndex); var ptr0 = index.__destroy_into_raw(); const ret = wasm.caml_pasta_fq_plonk_verifier_index_serialize(ptr0); deferred2_0 = ret[0]; deferred2_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); } }; /** * @param {WasmFqSrs} srs * @param {string} index * @returns {WasmFqPlonkVerifierIndex} */ module.exports.caml_pasta_fq_plonk_verifier_index_deserialize = function(srs, index) { _assertClass(srs, WasmFqSrs); const ptr0 = passStringToWasm0(index, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_verifier_index_deserialize(srs.__wbg_ptr, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFqPlonkVerifierIndex.__wrap(ret[0]); }; /** * @param {WasmPastaFqPlonkIndex} index * @returns {WasmFqPlonkVerifierIndex} */ module.exports.caml_pasta_fq_plonk_verifier_index_create = function(index) { _assertClass(index, WasmPastaFqPlonkIndex); const ret = wasm.caml_pasta_fq_plonk_verifier_index_create(index.__wbg_ptr); return WasmFqPlonkVerifierIndex.__wrap(ret); }; /** * @param {number} log2_size * @returns {WasmFqShifts} */ module.exports.caml_pasta_fq_plonk_verifier_index_shifts = function(log2_size) { const ret = wasm.caml_pasta_fq_plonk_verifier_index_shifts(log2_size); return WasmFqShifts.__wrap(ret); }; /** * @returns {WasmFqPlonkVerifierIndex} */ module.exports.caml_pasta_fq_plonk_verifier_index_dummy = function() { const ret = wasm.caml_pasta_fq_plonk_verifier_index_dummy(); return WasmFqPlonkVerifierIndex.__wrap(ret); }; /** * @param {WasmFqPlonkVerifierIndex} x * @returns {WasmFqPlonkVerifierIndex} */ module.exports.caml_pasta_fq_plonk_verifier_index_deep_copy = function(x) { _assertClass(x, WasmFqPlonkVerifierIndex); const ret = wasm.caml_pasta_fq_plonk_verifier_index_deep_copy(x.__wbg_ptr); return WasmFqPlonkVerifierIndex.__wrap(ret); }; function getArrayU32FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); } /** * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_one = function() { const ret = wasm.caml_vesta_one(); return WasmVestaGProjective.__wrap(ret); }; /** * @param {WasmVestaGProjective} x * @param {WasmVestaGProjective} y * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_add = function(x, y) { _assertClass(x, WasmVestaGProjective); _assertClass(y, WasmVestaGProjective); const ret = wasm.caml_vesta_add(x.__wbg_ptr, y.__wbg_ptr); return WasmVestaGProjective.__wrap(ret); }; /** * @param {WasmVestaGProjective} x * @param {WasmVestaGProjective} y * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_sub = function(x, y) { _assertClass(x, WasmVestaGProjective); _assertClass(y, WasmVestaGProjective); const ret = wasm.caml_vesta_sub(x.__wbg_ptr, y.__wbg_ptr); return WasmVestaGProjective.__wrap(ret); }; /** * @param {WasmVestaGProjective} x * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_negate = function(x) { _assertClass(x, WasmVestaGProjective); const ret = wasm.caml_vesta_negate(x.__wbg_ptr); return WasmVestaGProjective.__wrap(ret); }; /** * @param {Uint8Array} x * @param {Uint8Array} y * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_of_affine_coordinates = function(x, y) { const ptr0 = passArray8ToWasm0(x, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray8ToWasm0(y, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.caml_vesta_of_affine_coordinates(ptr0, len0, ptr1, len1); return WasmVestaGProjective.__wrap(ret); }; /** * @param {WasmGVesta} x * @returns {WasmGVesta} */ module.exports.caml_vesta_affine_deep_copy = function(x) { _assertClass(x, WasmGVesta); var ptr0 = x.__destroy_into_raw(); const ret = wasm.caml_vesta_affine_deep_copy(ptr0); return WasmGVesta.__wrap(ret); }; /** * @param {WasmVestaGProjective} x * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_double = function(x) { _assertClass(x, WasmVestaGProjective); const ret = wasm.caml_vesta_double(x.__wbg_ptr); return WasmVestaGProjective.__wrap(ret); }; /** * @param {WasmVestaGProjective} x * @param {Uint8Array} y * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_scale = function(x, y) { _assertClass(x, WasmVestaGProjective); const ptr0 = passArray8ToWasm0(y, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_vesta_scale(x.__wbg_ptr, ptr0, len0); return WasmVestaGProjective.__wrap(ret); }; /** * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_random = function() { const ret = wasm.caml_vesta_random(); return WasmVestaGProjective.__wrap(ret); }; /** * @param {number} i * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_rng = function(i) { const ret = wasm.caml_vesta_rng(i); return WasmVestaGProjective.__wrap(ret); }; /** * @returns {Uint8Array} */ module.exports.caml_vesta_endo_base = function() { const ret = wasm.caml_vesta_endo_base(); var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @returns {Uint8Array} */ module.exports.caml_vesta_endo_scalar = function() { const ret = wasm.caml_vesta_endo_scalar(); var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @param {WasmVestaGProjective} x * @returns {WasmGVesta} */ module.exports.caml_vesta_to_affine = function(x) { _assertClass(x, WasmVestaGProjective); const ret = wasm.caml_vesta_to_affine(x.__wbg_ptr); return WasmGVesta.__wrap(ret); }; /** * @param {WasmGVesta} x * @returns {WasmVestaGProjective} */ module.exports.caml_vesta_of_affine = function(x) { _assertClass(x, WasmGVesta); var ptr0 = x.__destroy_into_raw(); const ret = wasm.caml_vesta_of_affine(ptr0); return WasmVestaGProjective.__wrap(ret); }; /** * @param {string} s */ module.exports.console_log = function(s) { const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; wasm.console_log(ptr0, len0); }; /** * @returns {number} */ module.exports.create_zero_u32_ptr = function() { const ret = wasm.create_zero_u32_ptr(); return ret >>> 0; }; /** * Free a pointer. This method is exported in the WebAssembly module to be used * on the JavaScript side, see `web-backend.js`. * * # Safety * * See * `<https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref>` * @param {number} ptr */ module.exports.free_u32_ptr = function(ptr) { wasm.free_u32_ptr(ptr); }; /** * Set the value of a pointer. This method is exported in the WebAssembly * module to be used on the JavaScript side, see `web-backend.js`. * * # Safety * * See * `<https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref>` * @param {number} ptr * @param {number} arg */ module.exports.set_u32_ptr = function(ptr, arg) { wasm.set_u32_ptr(ptr, arg); }; /** * This method is exported in the WebAssembly to be used on the JavaScript * side, see `web-backend.js`. * * # Safety * * See * `<https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref>` * @param {number} ptr * @returns {number} */ module.exports.wait_until_non_zero = function(ptr) { const ret = wasm.wait_until_non_zero(ptr); return ret >>> 0; }; /** * This method is exported in the WebAssembly to check the memory used on the * JavaScript * @returns {any} */ module.exports.get_memory = function() { const ret = wasm.get_memory(); return ret; }; /** * Returns the number of bytes used by the WebAssembly memory. * @returns {number} */ module.exports.get_memory_byte_length = function() { const ret = wasm.get_memory_byte_length(); return ret >>> 0; }; /** * @param {Uint8Array} state * @returns {Uint8Array} */ module.exports.caml_pasta_fp_poseidon_block_cipher = function(state) { const ptr0 = passArray8ToWasm0(state, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fp_poseidon_block_cipher(ptr0, len0); var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v2; }; /** * @param {Uint8Array} state * @returns {Uint8Array} */ module.exports.caml_pasta_fq_poseidon_block_cipher = function(state) { const ptr0 = passArray8ToWasm0(state, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_poseidon_block_cipher(ptr0, len0); var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v2; }; /** * @returns {WasmFpGateVector} */ module.exports.caml_pasta_fp_plonk_gate_vector_create = function() { const ret = wasm.caml_pasta_fp_plonk_gate_vector_create(); return WasmFpGateVector.__wrap(ret); }; /** * @param {WasmFpGateVector} v * @param {WasmFpGate} gate */ module.exports.caml_pasta_fp_plonk_gate_vector_add = function(v, gate) { _assertClass(v, WasmFpGateVector); _assertClass(gate, WasmFpGate); var ptr0 = gate.__destroy_into_raw(); wasm.caml_pasta_fp_plonk_gate_vector_add(v.__wbg_ptr, ptr0); }; /** * @param {WasmFpGateVector} v * @param {number} i * @returns {WasmFpGate} */ module.exports.caml_pasta_fp_plonk_gate_vector_get = function(v, i) { _assertClass(v, WasmFpGateVector); const ret = wasm.caml_pasta_fp_plonk_gate_vector_get(v.__wbg_ptr, i); return WasmFpGate.__wrap(ret); }; /** * @param {WasmFpGateVector} v * @returns {number} */ module.exports.caml_pasta_fp_plonk_gate_vector_len = function(v) { _assertClass(v, WasmFpGateVector); const ret = wasm.caml_pasta_fp_plonk_gate_vector_len(v.__wbg_ptr); return ret >>> 0; }; /** * @param {WasmFpGateVector} v * @param {Wire} t * @param {Wire} h */ module.exports.caml_pasta_fp_plonk_gate_vector_wrap = function(v, t, h) { _assertClass(v, WasmFpGateVector); _assertClass(t, Wire); var ptr0 = t.__destroy_into_raw(); _assertClass(h, Wire); var ptr1 = h.__destroy_into_raw(); wasm.caml_pasta_fp_plonk_gate_vector_wrap(v.__wbg_ptr, ptr0, ptr1); }; /** * @param {number} public_input_size * @param {WasmFpGateVector} v * @returns {Uint8Array} */ module.exports.caml_pasta_fp_plonk_gate_vector_digest = function(public_input_size, v) { _assertClass(v, WasmFpGateVector); const ret = wasm.caml_pasta_fp_plonk_gate_vector_digest(public_input_size, v.__wbg_ptr); var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @param {number} public_input_size * @param {WasmFpGateVector} v * @returns {string} */ module.exports.caml_pasta_fp_plonk_circuit_serialize = function(public_input_size, v) { let deferred1_0; let deferred1_1; try { _assertClass(v, WasmFpGateVector); const ret = wasm.caml_pasta_fp_plonk_circuit_serialize(public_input_size, v.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } }; /** * @returns {WasmFqGateVector} */ module.exports.caml_pasta_fq_plonk_gate_vector_create = function() { const ret = wasm.caml_pasta_fp_plonk_gate_vector_create(); return WasmFqGateVector.__wrap(ret); }; /** * @param {WasmFqGateVector} v * @param {WasmFqGate} gate */ module.exports.caml_pasta_fq_plonk_gate_vector_add = function(v, gate) { _assertClass(v, WasmFqGateVector); _assertClass(gate, WasmFqGate); var ptr0 = gate.__destroy_into_raw(); wasm.caml_pasta_fq_plonk_gate_vector_add(v.__wbg_ptr, ptr0); }; /** * @param {WasmFqGateVector} v * @param {number} i * @returns {WasmFqGate} */ module.exports.caml_pasta_fq_plonk_gate_vector_get = function(v, i) { _assertClass(v, WasmFqGateVector); const ret = wasm.caml_pasta_fq_plonk_gate_vector_get(v.__wbg_ptr, i); return WasmFqGate.__wrap(ret); }; /** * @param {WasmFqGateVector} v * @returns {number} */ module.exports.caml_pasta_fq_plonk_gate_vector_len = function(v) { _assertClass(v, WasmFqGateVector); const ret = wasm.caml_pasta_fp_plonk_gate_vector_len(v.__wbg_ptr); return ret >>> 0; }; /** * @param {WasmFqGateVector} v * @param {Wire} t * @param {Wire} h */ module.exports.caml_pasta_fq_plonk_gate_vector_wrap = function(v, t, h) { _assertClass(v, WasmFqGateVector); _assertClass(t, Wire); var ptr0 = t.__destroy_into_raw(); _assertClass(h, Wire); var ptr1 = h.__destroy_into_raw(); wasm.caml_pasta_fp_plonk_gate_vector_wrap(v.__wbg_ptr, ptr0, ptr1); }; /** * @param {number} public_input_size * @param {WasmFqGateVector} v * @returns {Uint8Array} */ module.exports.caml_pasta_fq_plonk_gate_vector_digest = function(public_input_size, v) { _assertClass(v, WasmFqGateVector); const ret = wasm.caml_pasta_fq_plonk_gate_vector_digest(public_input_size, v.__wbg_ptr); var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v1; }; /** * @param {number} public_input_size * @param {WasmFqGateVector} v * @returns {string} */ module.exports.caml_pasta_fq_plonk_circuit_serialize = function(public_input_size, v) { let deferred1_0; let deferred1_1; try { _assertClass(v, WasmFqGateVector); const ret = wasm.caml_pasta_fq_plonk_circuit_serialize(public_input_size, v.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } }; /** * @returns {WasmFqProverProof} */ module.exports.caml_pasta_fq_plonk_proof_dummy = function() { const ret = wasm.caml_pasta_fq_plonk_proof_dummy(); return WasmFqProverProof.__wrap(ret); }; /** * @param {WasmFqProverProof} x * @returns {WasmFqProverProof} */ module.exports.caml_pasta_fq_plonk_proof_deep_copy = function(x) { _assertClass(x, WasmFqProverProof); var ptr0 = x.__destroy_into_raw(); const ret = wasm.caml_pasta_fq_plonk_proof_deep_copy(ptr0); return WasmFqProverProof.__wrap(ret); }; /** * @param {WasmPastaFqPlonkIndex} index * @param {WasmVecVecFq} witness * @param {Uint32Array} wasm_runtime_tables * @param {Uint8Array} prev_challenges * @param {Uint32Array} prev_sgs * @returns {WasmFqProverProof} */ module.exports.caml_pasta_fq_plonk_proof_create = function(index, witness, wasm_runtime_tables, prev_challenges, prev_sgs) { _assertClass(index, WasmPastaFqPlonkIndex); _assertClass(witness, WasmVecVecFq); var ptr0 = witness.__destroy_into_raw(); const ptr1 = passArray32ToWasm0(wasm_runtime_tables, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ptr2 = passArray8ToWasm0(prev_challenges, wasm.__wbindgen_malloc); const len2 = WASM_VECTOR_LEN; const ptr3 = passArray32ToWasm0(prev_sgs, wasm.__wbindgen_malloc); const len3 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_proof_create(index.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return WasmFqProverProof.__wrap(ret[0]); }; /** * @param {WasmFqPlonkVerifierIndex} index * @param {WasmFqProverProof} proof * @returns {boolean} */ module.exports.caml_pasta_fq_plonk_proof_verify = function(index, proof) { _assertClass(index, WasmFqPlonkVerifierIndex); var ptr0 = index.__destroy_into_raw(); _assertClass(proof, WasmFqProverProof); var ptr1 = proof.__destroy_into_raw(); const ret = wasm.caml_pasta_fq_plonk_proof_verify(ptr0, ptr1); return ret !== 0; }; /** * @param {Uint32Array} indexes * @param {Uint32Array} proofs * @returns {boolean} */ module.exports.caml_pasta_fq_plonk_proof_batch_verify = function(indexes, proofs) { const ptr0 = passArray32ToWasm0(indexes, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray32ToWasm0(proofs, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.caml_pasta_fq_plonk_proof_batch_verify(ptr0, len0, ptr1, len1); return ret !== 0; }; /** * @param {number} depth * @returns {WasmFpSrs} */ module.exports.caml_fp_srs_create = function(depth) { const ret = wasm.caml_fp_srs_create(depth); return WasmFpSrs.__wrap(ret); }; /** * @param {WasmFpSrs} srs * @param {number} log2_size */ module.exports.caml_fp_srs_add_lagrange_basis = function(srs, log2_size) { _assertClass(srs, WasmFpSrs); wasm.caml_fp_srs_add_lagrange_basis(srs.__wbg_ptr, log2_size); }; /** * @param {boolean | null | undefined} append * @param {WasmFpSrs} srs * @param {string} path */ module.exports.caml_fp_srs_write = function(append, srs, path) { _assertClass(srs, WasmFpSrs); const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_fp_srs_write(isLikeNone(append) ? 0xFFFFFF : append ? 1 : 0, srs.__wbg_ptr, ptr0, len0); if (ret[1]) { throw takeFromExternrefTable0(ret[0]); } }; /** * @param {WasmFpSrs} srs * @returns {WasmGVesta} */ module.exports.caml_fp_srs_h = function(srs) { _assertClass(srs, WasmFpSrs); const ret = wasm.caml_fp_srs_h(srs.__wbg_ptr); return WasmGVesta.__wrap(ret); }; /** * @param {number} depth * @returns {WasmFpSrs} */ module.exports.caml_fp_srs_create_parallel = function(depth) { const ret = wasm.caml_fp_srs_create_parallel(depth); return WasmFpSrs.__wrap(ret); }; /** * @param {WasmFpSrs} srs * @returns {Uint32Array} */ module.exports.caml_fp_srs_get = function(srs) { _assertClass(srs, WasmFpSrs); const ret = wasm.caml_fp_srs_get(srs.__wbg_ptr); var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); return v1; }; /** * @param {Uint32Array} h_and_gs * @returns {WasmFpSrs} */ module.exports.caml_fp_srs_set = function(h_and_gs) { const ptr0 = passArray32ToWasm0(h_and_gs, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_fp_srs_set(ptr0, len0); return WasmFpSrs.__wrap(ret); }; /** * @param {WasmFpSrs} srs * @param {number} domain_size * @param {number} i * @returns {WasmFpPolyComm | undefined} */ module.exports.caml_fp_srs_maybe_lagrange_commitment = function(srs, domain_size, i) { _assertClass(srs, WasmFpSrs); const ret = wasm.caml_fp_srs_maybe_lagrange_commitment(srs.__wbg_ptr, domain_size, i); return ret === 0 ? undefined : WasmFpPolyComm.__wrap(ret); }; /** * @param {WasmFpSrs} srs * @param {number} domain_size * @param {Uint32Array} input_bases */ module.exports.caml_fp_srs_set_lagrange_basis = function(srs, domain_size, input_bases) { _assertClass(srs, WasmFpSrs); const ptr0 = passArray32ToWasm0(input_bases, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; wasm.caml_fp_srs_set_lagrange_basis(srs.__wbg_ptr, domain_size, ptr0, len0); }; /** * @param {WasmFpSrs} srs * @param {number} domain_size * @returns {Uint32Array} */ module.exports.caml_fp_srs_get_lagrange_basis = function(srs, domain_size) { _assertClass(srs, WasmFpSrs); const ret = wasm.caml_fp_srs_get_lagrange_basis(srs.__wbg_ptr, domain_size); var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); return v1; }; /** * @param {number | null | undefined} offset * @param {string} path * @returns {WasmFpSrs | undefined} */ module.exports.caml_fp_srs_read = function(offset, path) { const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.caml_fp_srs_read(isLikeNone(offset) ? 0x100000001 : (offset) >> 0, ptr0, len0); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return ret[0] === 0 ? undefined : WasmFpSrs.__wrap(ret[0]); }; /** * @param {WasmFpSrs} srs * @param {number} domain_size * @returns {number} */ module.exports.caml_fp_srs_lagrange_commitments_whole_domain_ptr = function(srs, domain_size) { _assertClass(srs, WasmFpSrs); const ret = wasm.caml_fp_srs_lagrange_commitments_whole_domain_ptr(srs.__wbg_ptr, domain_size); return ret >>> 0; }; /** * Reads the lagrange commitments from a raw pointer. * * # Safety * * This function is unsafe because it might dereference a * raw pointer. * @param {number} ptr * @returns {Ui