@noir-lang/acvm_js
Advanced tools
Comparing version 1.0.0-beta.1-203242c.nightly to 1.0.0-beta.1-25b989f.nightly
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function executeCircuit(a: number, b: number, c: number, d: number): number; | ||
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number; | ||
export function executeProgram(a: number, b: number, c: number, d: number): number; | ||
export function initLogLevel(a: number, b: number, c: number): void; | ||
export function compressWitness(a: number, b: number): void; | ||
export function decompressWitness(a: number, b: number, c: number): void; | ||
export function compressWitnessStack(a: number, b: number): void; | ||
export function decompressWitnessStack(a: number, b: number, c: number): void; | ||
export function and(a: number, b: number): number; | ||
@@ -11,21 +19,13 @@ export function xor(a: number, b: number): number; | ||
export function buildInfo(): number; | ||
export function compressWitness(a: number, b: number): void; | ||
export function decompressWitness(a: number, b: number, c: number): void; | ||
export function compressWitnessStack(a: number, b: number): void; | ||
export function decompressWitnessStack(a: number, b: number, c: number): void; | ||
export function initLogLevel(a: number, b: number, c: number): void; | ||
export function getReturnWitness(a: number, b: number, c: number, d: number): void; | ||
export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void; | ||
export function getPublicWitness(a: number, b: number, c: number, d: number): void; | ||
export function executeCircuit(a: number, b: number, c: number, d: number): number; | ||
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number; | ||
export function executeProgram(a: number, b: number, c: number, d: number): number; | ||
export function __wbindgen_malloc(a: number): number; | ||
export function __wbindgen_realloc(a: number, b: number, c: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function wasm_bindgen__convert__closures__invoke1_mut__h7f1511a2915e72e7(a: number, b: number, c: number): void; | ||
export function wasm_bindgen__convert__closures__invoke1_mut__h0d2f2cab014f8c52(a: number, b: number, c: number): void; | ||
export function __wbindgen_add_to_stack_pointer(a: number): number; | ||
export function __wbindgen_free(a: number, b: number): void; | ||
export function wasm_bindgen__convert__closures__invoke3_mut__h0ccbefcb4d729e69(a: number, b: number, c: number, d: number, e: number): void; | ||
export function wasm_bindgen__convert__closures__invoke3_mut__h2e8a0e541cb0c3bc(a: number, b: number, c: number, d: number, e: number): void; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h2ed79be2e23ac22f(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h56728cbaf4bbea81(a: number, b: number, c: number, d: number): void; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
*/ | ||
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>; | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function initLogLevel(filter: string): void; | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessMap} witness_map - A witness map. | ||
* @returns {Uint8Array} A compressed witness map | ||
*/ | ||
export function compressWitness(witness_map: WitnessMap): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
* This should be used to only fetch the witness map for the main function. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessMap} The decompressed witness map. | ||
*/ | ||
export function decompressWitness(compressed_witness: Uint8Array): WitnessMap; | ||
/** | ||
* Compresses a `WitnessStack` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessStack} witness_stack - A witness stack. | ||
* @returns {Uint8Array} A compressed witness stack | ||
*/ | ||
export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessStack} The decompressed witness stack. | ||
*/ | ||
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack; | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
@@ -54,37 +117,2 @@ * @param {string} lhs | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessMap} witness_map - A witness map. | ||
* @returns {Uint8Array} A compressed witness map | ||
*/ | ||
export function compressWitness(witness_map: WitnessMap): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
* This should be used to only fetch the witness map for the main function. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessMap} The decompressed witness map. | ||
*/ | ||
export function decompressWitness(compressed_witness: Uint8Array): WitnessMap; | ||
/** | ||
* Compresses a `WitnessStack` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessStack} witness_stack - A witness stack. | ||
* @returns {Uint8Array} A compressed witness stack | ||
*/ | ||
export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessStack} The decompressed witness stack. | ||
*/ | ||
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack; | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function initLogLevel(filter: string): void; | ||
/** | ||
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values. | ||
@@ -122,31 +150,32 @@ * | ||
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap; | ||
// Map from witness index to hex string value of witness. | ||
export type WitnessMap = Map<number, string>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>; | ||
* An execution result containing two witnesses. | ||
* 1. The full solved witness of the execution. | ||
* 2. The return witness which contains the given public return values within the full witness. | ||
*/ | ||
export type SolvedAndReturnWitness = { | ||
solvedWitness: WitnessMap; | ||
returnWitness: WitnessMap; | ||
} | ||
export type ForeignCallInput = string[] | ||
export type ForeignCallOutput = string | string[] | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
* A callback which performs an foreign call and returns the response. | ||
* @callback ForeignCallHandler | ||
* @param {string} name - The identifier for the type of foreign call being performed. | ||
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call. | ||
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call. | ||
*/ | ||
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>; | ||
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>; | ||
/** | ||
@@ -179,17 +208,2 @@ * @typedef {Object} BuildInfo - Information about how the installed package was built | ||
// Map from witness index to hex string value of witness. | ||
export type WitnessMap = Map<number, string>; | ||
/** | ||
* An execution result containing two witnesses. | ||
* 1. The full solved witness of the execution. | ||
* 2. The return witness which contains the given public return values within the full witness. | ||
*/ | ||
export type SolvedAndReturnWitness = { | ||
solvedWitness: WitnessMap; | ||
returnWitness: WitnessMap; | ||
} | ||
export type StackItem = { | ||
@@ -203,15 +217,1 @@ index: number; | ||
export type ForeignCallInput = string[] | ||
export type ForeignCallOutput = string | string[] | ||
/** | ||
* A callback which performs an foreign call and returns the response. | ||
* @callback ForeignCallHandler | ||
* @param {string} name - The identifier for the type of foreign call being performed. | ||
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call. | ||
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call. | ||
*/ | ||
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>; | ||
@@ -26,24 +26,11 @@ let imports = {}; | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
@@ -67,11 +54,2 @@ | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
@@ -132,2 +110,24 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
} | ||
function debugString(val) { | ||
@@ -223,6 +223,182 @@ // primitive types | ||
function __wbg_adapter_22(arg0, arg1, arg2) { | ||
wasm.wasm_bindgen__convert__closures__invoke1_mut__h7f1511a2915e72e7(arg0, arg1, addHeapObject(arg2)); | ||
wasm.wasm_bindgen__convert__closures__invoke1_mut__h0d2f2cab014f8c52(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1) >>> 0; | ||
getUint8Memory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
*/ | ||
module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
module.exports.initLogLevel = function(filter) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.initLogLevel(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
function getArrayU8FromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); | ||
} | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessMap} witness_map - A witness map. | ||
* @returns {Uint8Array} A compressed witness map | ||
*/ | ||
module.exports.compressWitness = function(witness_map) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.compressWitness(retptr, addHeapObject(witness_map)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
if (r3) { | ||
throw takeObject(r2); | ||
} | ||
var v1 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v1; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
* This should be used to only fetch the witness map for the main function. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessMap} The decompressed witness map. | ||
*/ | ||
module.exports.decompressWitness = function(compressed_witness) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.decompressWitness(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Compresses a `WitnessStack` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessStack} witness_stack - A witness stack. | ||
* @returns {Uint8Array} A compressed witness stack | ||
*/ | ||
module.exports.compressWitnessStack = function(witness_stack) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.compressWitnessStack(retptr, addHeapObject(witness_stack)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
if (r3) { | ||
throw takeObject(r2); | ||
} | ||
var v1 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v1; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessStack} The decompressed witness stack. | ||
*/ | ||
module.exports.decompressWitnessStack = function(compressed_witness) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.decompressWitnessStack(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
@@ -293,13 +469,2 @@ * @param {string} lhs | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1) >>> 0; | ||
getUint8Memory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
function getArrayU8FromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); | ||
} | ||
/** | ||
@@ -378,122 +543,2 @@ * Calculates the Blake2s256 hash of the input bytes | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessMap} witness_map - A witness map. | ||
* @returns {Uint8Array} A compressed witness map | ||
*/ | ||
module.exports.compressWitness = function(witness_map) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.compressWitness(retptr, addHeapObject(witness_map)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
if (r3) { | ||
throw takeObject(r2); | ||
} | ||
var v1 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v1; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
* This should be used to only fetch the witness map for the main function. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessMap} The decompressed witness map. | ||
*/ | ||
module.exports.decompressWitness = function(compressed_witness) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.decompressWitness(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Compresses a `WitnessStack` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessStack} witness_stack - A witness stack. | ||
* @returns {Uint8Array} A compressed witness stack | ||
*/ | ||
module.exports.compressWitnessStack = function(witness_stack) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.compressWitnessStack(retptr, addHeapObject(witness_stack)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
if (r3) { | ||
throw takeObject(r2); | ||
} | ||
var v1 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v1; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessStack} The decompressed witness stack. | ||
*/ | ||
module.exports.decompressWitnessStack = function(compressed_witness) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.decompressWitnessStack(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
module.exports.initLogLevel = function(filter) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.initLogLevel(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
/** | ||
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values. | ||
@@ -582,50 +627,4 @@ * | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
*/ | ||
module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) { | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h0ccbefcb4d729e69(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h2e8a0e541cb0c3bc(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
} | ||
@@ -641,3 +640,3 @@ | ||
function __wbg_adapter_92(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h2ed79be2e23ac22f(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h56728cbaf4bbea81(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -649,19 +648,7 @@ | ||
module.exports.__wbindgen_cb_drop = function(arg0) { | ||
const obj = takeObject(arg0).original; | ||
if (obj.cnt-- == 1) { | ||
obj.a = 0; | ||
return true; | ||
} | ||
const ret = false; | ||
module.exports.__wbindgen_is_array = function(arg0) { | ||
const ret = Array.isArray(getObject(arg0)); | ||
return ret; | ||
}; | ||
module.exports.__wbindgen_number_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = typeof(obj) === 'number' ? obj : undefined; | ||
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; | ||
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); | ||
}; | ||
module.exports.__wbg_constructor_a10f2b77c63b8d5e = function(arg0) { | ||
@@ -672,12 +659,2 @@ const ret = new Error(takeObject(arg0)); | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_is_array = function(arg0) { | ||
const ret = Array.isArray(getObject(arg0)); | ||
return ret; | ||
}; | ||
module.exports.__wbg_new_d86d15722f6b14a4 = function() { | ||
@@ -693,2 +670,7 @@ const ret = new Map(); | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_string_get = function(arg0, arg1) { | ||
@@ -703,5 +685,10 @@ const obj = getObject(arg1); | ||
module.exports.__wbg_new_a16954212d33afab = function() { | ||
const ret = new Array(); | ||
return addHeapObject(ret); | ||
module.exports.__wbindgen_cb_drop = function(arg0) { | ||
const obj = takeObject(arg0).original; | ||
if (obj.cnt-- == 1) { | ||
obj.a = 0; | ||
return true; | ||
} | ||
const ret = false; | ||
return ret; | ||
}; | ||
@@ -714,2 +701,14 @@ | ||
module.exports.__wbindgen_number_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = typeof(obj) === 'number' ? obj : undefined; | ||
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; | ||
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); | ||
}; | ||
module.exports.__wbg_new_a16954212d33afab = function() { | ||
const ret = new Array(); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_new_abda76e883ba8a5f = function() { | ||
@@ -933,4 +932,4 @@ const ret = new Error(); | ||
module.exports.__wbindgen_closure_wrapper766 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 303, __wbg_adapter_22); | ||
module.exports.__wbindgen_closure_wrapper767 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 301, __wbg_adapter_22); | ||
return addHeapObject(ret); | ||
@@ -937,0 +936,0 @@ }; |
{ | ||
"name": "@noir-lang/acvm_js", | ||
"version": "1.0.0-beta.1-203242c.nightly", | ||
"version": "1.0.0-beta.1-25b989f.nightly", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function executeCircuit(a: number, b: number, c: number, d: number): number; | ||
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number; | ||
export function executeProgram(a: number, b: number, c: number, d: number): number; | ||
export function initLogLevel(a: number, b: number, c: number): void; | ||
export function compressWitness(a: number, b: number): void; | ||
export function decompressWitness(a: number, b: number, c: number): void; | ||
export function compressWitnessStack(a: number, b: number): void; | ||
export function decompressWitnessStack(a: number, b: number, c: number): void; | ||
export function and(a: number, b: number): number; | ||
@@ -11,21 +19,13 @@ export function xor(a: number, b: number): number; | ||
export function buildInfo(): number; | ||
export function compressWitness(a: number, b: number): void; | ||
export function decompressWitness(a: number, b: number, c: number): void; | ||
export function compressWitnessStack(a: number, b: number): void; | ||
export function decompressWitnessStack(a: number, b: number, c: number): void; | ||
export function initLogLevel(a: number, b: number, c: number): void; | ||
export function getReturnWitness(a: number, b: number, c: number, d: number): void; | ||
export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void; | ||
export function getPublicWitness(a: number, b: number, c: number, d: number): void; | ||
export function executeCircuit(a: number, b: number, c: number, d: number): number; | ||
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number; | ||
export function executeProgram(a: number, b: number, c: number, d: number): number; | ||
export function __wbindgen_malloc(a: number): number; | ||
export function __wbindgen_realloc(a: number, b: number, c: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function wasm_bindgen__convert__closures__invoke1_mut__h7f1511a2915e72e7(a: number, b: number, c: number): void; | ||
export function wasm_bindgen__convert__closures__invoke1_mut__h0d2f2cab014f8c52(a: number, b: number, c: number): void; | ||
export function __wbindgen_add_to_stack_pointer(a: number): number; | ||
export function __wbindgen_free(a: number, b: number): void; | ||
export function wasm_bindgen__convert__closures__invoke3_mut__h0ccbefcb4d729e69(a: number, b: number, c: number, d: number, e: number): void; | ||
export function wasm_bindgen__convert__closures__invoke3_mut__h2e8a0e541cb0c3bc(a: number, b: number, c: number, d: number, e: number): void; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h2ed79be2e23ac22f(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h56728cbaf4bbea81(a: number, b: number, c: number, d: number): void; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
*/ | ||
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>; | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function initLogLevel(filter: string): void; | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessMap} witness_map - A witness map. | ||
* @returns {Uint8Array} A compressed witness map | ||
*/ | ||
export function compressWitness(witness_map: WitnessMap): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
* This should be used to only fetch the witness map for the main function. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessMap} The decompressed witness map. | ||
*/ | ||
export function decompressWitness(compressed_witness: Uint8Array): WitnessMap; | ||
/** | ||
* Compresses a `WitnessStack` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessStack} witness_stack - A witness stack. | ||
* @returns {Uint8Array} A compressed witness stack | ||
*/ | ||
export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessStack} The decompressed witness stack. | ||
*/ | ||
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack; | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
@@ -54,37 +117,2 @@ * @param {string} lhs | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessMap} witness_map - A witness map. | ||
* @returns {Uint8Array} A compressed witness map | ||
*/ | ||
export function compressWitness(witness_map: WitnessMap): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
* This should be used to only fetch the witness map for the main function. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessMap} The decompressed witness map. | ||
*/ | ||
export function decompressWitness(compressed_witness: Uint8Array): WitnessMap; | ||
/** | ||
* Compresses a `WitnessStack` into the binary format outputted by Nargo. | ||
* | ||
* @param {WitnessStack} witness_stack - A witness stack. | ||
* @returns {Uint8Array} A compressed witness stack | ||
*/ | ||
export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array; | ||
/** | ||
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`. | ||
* | ||
* @param {Uint8Array} compressed_witness - A compressed witness. | ||
* @returns {WitnessStack} The decompressed witness stack. | ||
*/ | ||
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack; | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function initLogLevel(filter: string): void; | ||
/** | ||
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values. | ||
@@ -122,31 +150,32 @@ * | ||
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap; | ||
// Map from witness index to hex string value of witness. | ||
export type WitnessMap = Map<number, string>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>; | ||
* An execution result containing two witnesses. | ||
* 1. The full solved witness of the execution. | ||
* 2. The return witness which contains the given public return values within the full witness. | ||
*/ | ||
export type SolvedAndReturnWitness = { | ||
solvedWitness: WitnessMap; | ||
returnWitness: WitnessMap; | ||
} | ||
export type ForeignCallInput = string[] | ||
export type ForeignCallOutput = string | string[] | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
* A callback which performs an foreign call and returns the response. | ||
* @callback ForeignCallHandler | ||
* @param {string} name - The identifier for the type of foreign call being performed. | ||
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call. | ||
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call. | ||
*/ | ||
export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>; | ||
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>; | ||
/** | ||
@@ -179,17 +208,2 @@ * @typedef {Object} BuildInfo - Information about how the installed package was built | ||
// Map from witness index to hex string value of witness. | ||
export type WitnessMap = Map<number, string>; | ||
/** | ||
* An execution result containing two witnesses. | ||
* 1. The full solved witness of the execution. | ||
* 2. The return witness which contains the given public return values within the full witness. | ||
*/ | ||
export type SolvedAndReturnWitness = { | ||
solvedWitness: WitnessMap; | ||
returnWitness: WitnessMap; | ||
} | ||
export type StackItem = { | ||
@@ -204,16 +218,2 @@ index: number; | ||
export type ForeignCallInput = string[] | ||
export type ForeignCallOutput = string | string[] | ||
/** | ||
* A callback which performs an foreign call and returns the response. | ||
* @callback ForeignCallHandler | ||
* @param {string} name - The identifier for the type of foreign call being performed. | ||
* @param {string[][]} inputs - An array of hex encoded inputs to the foreign call. | ||
* @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call. | ||
*/ | ||
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>; | ||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
@@ -223,2 +223,10 @@ | ||
readonly memory: WebAssembly.Memory; | ||
readonly executeCircuit: (a: number, b: number, c: number, d: number) => number; | ||
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number; | ||
readonly executeProgram: (a: number, b: number, c: number, d: number) => number; | ||
readonly initLogLevel: (a: number, b: number, c: number) => void; | ||
readonly compressWitness: (a: number, b: number) => void; | ||
readonly decompressWitness: (a: number, b: number, c: number) => void; | ||
readonly compressWitnessStack: (a: number, b: number) => void; | ||
readonly decompressWitnessStack: (a: number, b: number, c: number) => void; | ||
readonly and: (a: number, b: number) => number; | ||
@@ -231,22 +239,14 @@ readonly xor: (a: number, b: number) => number; | ||
readonly buildInfo: () => number; | ||
readonly compressWitness: (a: number, b: number) => void; | ||
readonly decompressWitness: (a: number, b: number, c: number) => void; | ||
readonly compressWitnessStack: (a: number, b: number) => void; | ||
readonly decompressWitnessStack: (a: number, b: number, c: number) => void; | ||
readonly initLogLevel: (a: number, b: number, c: number) => void; | ||
readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void; | ||
readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void; | ||
readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void; | ||
readonly executeCircuit: (a: number, b: number, c: number, d: number) => number; | ||
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number; | ||
readonly executeProgram: (a: number, b: number, c: number, d: number) => number; | ||
readonly __wbindgen_malloc: (a: number) => number; | ||
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; | ||
readonly __wbindgen_export_2: WebAssembly.Table; | ||
readonly wasm_bindgen__convert__closures__invoke1_mut__h7f1511a2915e72e7: (a: number, b: number, c: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke1_mut__h0d2f2cab014f8c52: (a: number, b: number, c: number) => void; | ||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number; | ||
readonly __wbindgen_free: (a: number, b: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke3_mut__h0ccbefcb4d729e69: (a: number, b: number, c: number, d: number, e: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke3_mut__h2e8a0e541cb0c3bc: (a: number, b: number, c: number, d: number, e: number) => void; | ||
readonly __wbindgen_exn_store: (a: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h2ed79be2e23ac22f: (a: number, b: number, c: number, d: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h56728cbaf4bbea81: (a: number, b: number, c: number, d: number) => void; | ||
} | ||
@@ -253,0 +253,0 @@ |
@@ -23,24 +23,11 @@ let wasm; | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); | ||
@@ -64,11 +51,2 @@ | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
@@ -129,2 +107,24 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
} | ||
function debugString(val) { | ||
@@ -220,13 +220,23 @@ // primitive types | ||
function __wbg_adapter_22(arg0, arg1, arg2) { | ||
wasm.wasm_bindgen__convert__closures__invoke1_mut__h7f1511a2915e72e7(arg0, arg1, addHeapObject(arg2)); | ||
wasm.wasm_bindgen__convert__closures__invoke1_mut__h0d2f2cab014f8c52(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1) >>> 0; | ||
getUint8Memory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
export function and(lhs, rhs) { | ||
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs)); | ||
export function executeCircuit(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
@@ -236,51 +246,48 @@ } | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
*/ | ||
export function xor(lhs, rhs) { | ||
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs)); | ||
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
} | ||
let cachedUint32Memory0 = null; | ||
function getUint32Memory0() { | ||
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) { | ||
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer); | ||
} | ||
return cachedUint32Memory0; | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
export function executeProgram(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
} | ||
function passArray32ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 4) >>> 0; | ||
getUint32Memory0().set(arg, ptr / 4); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
function getArrayU32FromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len); | ||
} | ||
/** | ||
* Sha256 compression function | ||
* @param {Uint32Array} inputs | ||
* @param {Uint32Array} state | ||
* @returns {Uint32Array} | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function sha256_compression(inputs, state) { | ||
export function initLogLevel(filter) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1); | ||
wasm.initLogLevel(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var v3 = getArrayU32FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 4); | ||
return v3; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
@@ -291,9 +298,2 @@ wasm.__wbindgen_add_to_stack_pointer(16); | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1) >>> 0; | ||
getUint8Memory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
function getArrayU8FromWasm0(ptr, len) { | ||
@@ -304,74 +304,2 @@ ptr = ptr >>> 0; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function blake2s256(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.blake2s256(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var v2 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v2; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Verifies a ECDSA signature over the secp256k1 curve. | ||
* @param {Uint8Array} hashed_msg | ||
* @param {Uint8Array} public_key_x_bytes | ||
* @param {Uint8Array} public_key_y_bytes | ||
* @param {Uint8Array} signature | ||
* @returns {boolean} | ||
*/ | ||
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) { | ||
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc); | ||
const len2 = WASM_VECTOR_LEN; | ||
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); | ||
const len3 = WASM_VECTOR_LEN; | ||
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); | ||
return ret !== 0; | ||
} | ||
/** | ||
* Verifies a ECDSA signature over the secp256r1 curve. | ||
* @param {Uint8Array} hashed_msg | ||
* @param {Uint8Array} public_key_x_bytes | ||
* @param {Uint8Array} public_key_y_bytes | ||
* @param {Uint8Array} signature | ||
* @returns {boolean} | ||
*/ | ||
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) { | ||
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc); | ||
const len2 = WASM_VECTOR_LEN; | ||
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); | ||
const len3 = WASM_VECTOR_LEN; | ||
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); | ||
return ret !== 0; | ||
} | ||
/** | ||
* Returns the `BuildInfo` object containing information about how the installed package was built. | ||
* @returns {BuildInfo} - Information on how the installed package was built. | ||
*/ | ||
export function buildInfo() { | ||
const ret = wasm.buildInfo(); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
@@ -476,17 +404,62 @@ * | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function initLogLevel(filter) { | ||
export function and(lhs, rhs) { | ||
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs)); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function xor(lhs, rhs) { | ||
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs)); | ||
return takeObject(ret); | ||
} | ||
let cachedUint32Memory0 = null; | ||
function getUint32Memory0() { | ||
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) { | ||
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer); | ||
} | ||
return cachedUint32Memory0; | ||
} | ||
function passArray32ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 4) >>> 0; | ||
getUint32Memory0().set(arg, ptr / 4); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
function getArrayU32FromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len); | ||
} | ||
/** | ||
* Sha256 compression function | ||
* @param {Uint32Array} inputs | ||
* @param {Uint32Array} state | ||
* @returns {Uint32Array} | ||
*/ | ||
export function sha256_compression(inputs, state) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.initLogLevel(retptr, ptr0, len0); | ||
const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
var v3 = getArrayU32FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 4); | ||
return v3; | ||
} finally { | ||
@@ -498,2 +471,74 @@ wasm.__wbindgen_add_to_stack_pointer(16); | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function blake2s256(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.blake2s256(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var v2 = getArrayU8FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
return v2; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Verifies a ECDSA signature over the secp256k1 curve. | ||
* @param {Uint8Array} hashed_msg | ||
* @param {Uint8Array} public_key_x_bytes | ||
* @param {Uint8Array} public_key_y_bytes | ||
* @param {Uint8Array} signature | ||
* @returns {boolean} | ||
*/ | ||
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) { | ||
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc); | ||
const len2 = WASM_VECTOR_LEN; | ||
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); | ||
const len3 = WASM_VECTOR_LEN; | ||
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); | ||
return ret !== 0; | ||
} | ||
/** | ||
* Verifies a ECDSA signature over the secp256r1 curve. | ||
* @param {Uint8Array} hashed_msg | ||
* @param {Uint8Array} public_key_x_bytes | ||
* @param {Uint8Array} public_key_y_bytes | ||
* @param {Uint8Array} signature | ||
* @returns {boolean} | ||
*/ | ||
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) { | ||
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc); | ||
const len2 = WASM_VECTOR_LEN; | ||
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); | ||
const len3 = WASM_VECTOR_LEN; | ||
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); | ||
return ret !== 0; | ||
} | ||
/** | ||
* Returns the `BuildInfo` object containing information about how the installed package was built. | ||
* @returns {BuildInfo} - Information on how the installed package was built. | ||
*/ | ||
export function buildInfo() { | ||
const ret = wasm.buildInfo(); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values. | ||
@@ -582,50 +627,4 @@ * | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs. | ||
*/ | ||
export function executeCircuit(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* This method also extracts the public return values from the solved witness into its own return witness. | ||
* | ||
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`.. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit. | ||
* @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit. | ||
*/ | ||
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* Executes an ACIR circuit to generate the solved witness from the initial witness. | ||
* | ||
* @param {Uint8Array} program - A serialized representation of an ACIR program | ||
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`. | ||
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program. | ||
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs. | ||
*/ | ||
export function executeProgram(program, initial_witness, foreign_call_handler) { | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
} | ||
function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) { | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h0ccbefcb4d729e69(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h2e8a0e541cb0c3bc(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
} | ||
@@ -641,3 +640,3 @@ | ||
function __wbg_adapter_92(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h2ed79be2e23ac22f(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h56728cbaf4bbea81(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -682,17 +681,6 @@ | ||
}; | ||
imports.wbg.__wbindgen_cb_drop = function(arg0) { | ||
const obj = takeObject(arg0).original; | ||
if (obj.cnt-- == 1) { | ||
obj.a = 0; | ||
return true; | ||
} | ||
const ret = false; | ||
imports.wbg.__wbindgen_is_array = function(arg0) { | ||
const ret = Array.isArray(getObject(arg0)); | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_number_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = typeof(obj) === 'number' ? obj : undefined; | ||
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; | ||
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); | ||
}; | ||
imports.wbg.__wbg_constructor_a10f2b77c63b8d5e = function(arg0) { | ||
@@ -702,10 +690,2 @@ const ret = new Error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_is_array = function(arg0) { | ||
const ret = Array.isArray(getObject(arg0)); | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_new_d86d15722f6b14a4 = function() { | ||
@@ -719,2 +699,6 @@ const ret = new Map(); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
@@ -728,5 +712,10 @@ const obj = getObject(arg1); | ||
}; | ||
imports.wbg.__wbg_new_a16954212d33afab = function() { | ||
const ret = new Array(); | ||
return addHeapObject(ret); | ||
imports.wbg.__wbindgen_cb_drop = function(arg0) { | ||
const obj = takeObject(arg0).original; | ||
if (obj.cnt-- == 1) { | ||
obj.a = 0; | ||
return true; | ||
} | ||
const ret = false; | ||
return ret; | ||
}; | ||
@@ -737,2 +726,12 @@ imports.wbg.__wbindgen_is_string = function(arg0) { | ||
}; | ||
imports.wbg.__wbindgen_number_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = typeof(obj) === 'number' ? obj : undefined; | ||
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; | ||
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); | ||
}; | ||
imports.wbg.__wbg_new_a16954212d33afab = function() { | ||
const ret = new Array(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_abda76e883ba8a5f = function() { | ||
@@ -921,4 +920,4 @@ const ret = new Error(); | ||
}; | ||
imports.wbg.__wbindgen_closure_wrapper766 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 303, __wbg_adapter_22); | ||
imports.wbg.__wbindgen_closure_wrapper767 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 301, __wbg_adapter_22); | ||
return addHeapObject(ret); | ||
@@ -925,0 +924,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4083104