@noir-lang/acvm_js
Advanced tools
Comparing version 0.46.0-23a6477.nightly to 0.46.0-2e543b4.nightly
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
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 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 initLogLevel(a: number, b: number, c: number): void; | ||
export function and(a: number, b: number): number; | ||
@@ -11,18 +22,3 @@ export function xor(a: number, b: number): number; | ||
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; | ||
export function __wbg_wasmblackboxfunctionsolver_free(a: number): void; | ||
export function createBlackBoxSolver(): number; | ||
export function executeCircuit(a: number, b: number, c: number, d: number): number; | ||
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number, e: number): number; | ||
export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number; | ||
export function executeProgram(a: number, b: number, c: number, d: number): number; | ||
export function executeProgramWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number; | ||
export function initLogLevel(a: number, b: number, c: number): void; | ||
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 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 __wbindgen_malloc(a: number): number; | ||
@@ -29,0 +25,0 @@ export function __wbindgen_realloc(a: number, b: number, c: number): number; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function and(lhs: string, rhs: string): string; | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function xor(lhs: string, rhs: string): string; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function sha256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function blake2s256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function keccak256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* @returns {Promise<WasmBlackBoxFunctionSolver>} | ||
*/ | ||
export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>; | ||
/** | ||
* 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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(_solver: WasmBlackBoxFunctionSolver, 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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 executeCircuitWithBlackBoxSolver(_solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>; | ||
/** | ||
*/ | ||
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>; | ||
/** | ||
*/ | ||
export function executeProgramWithBlackBoxSolver(_solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: 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; | ||
/** | ||
* 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(): BuildInfo; | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
@@ -166,2 +65,91 @@ * | ||
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap; | ||
/** | ||
* 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; | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function and(lhs: string, rhs: string): string; | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function xor(lhs: string, rhs: string): string; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function sha256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function blake2s256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function keccak256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* 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(): BuildInfo; | ||
@@ -193,16 +181,2 @@ export type RawAssertionPayload = { | ||
/** | ||
* @typedef {Object} BuildInfo - Information about how the installed package was built | ||
* @property {string} gitHash - The hash of the git commit from which the package was built. | ||
* @property {string} version - The version of the package at the built git commit. | ||
* @property {boolean} dirty - Whether the package contained uncommitted changes when built. | ||
*/ | ||
export type BuildInfo = { | ||
gitHash: string; | ||
version: string; | ||
dirty: string; | ||
} | ||
// Map from witness index to hex string value of witness. | ||
@@ -231,6 +205,15 @@ export type WitnessMap = Map<number, string>; | ||
/** | ||
*/ | ||
export class WasmBlackBoxFunctionSolver { | ||
free(): void; | ||
* @typedef {Object} BuildInfo - Information about how the installed package was built | ||
* @property {string} gitHash - The hash of the git commit from which the package was built. | ||
* @property {string} version - The version of the package at the built git commit. | ||
* @property {boolean} dirty - Whether the package contained uncommitted changes when built. | ||
*/ | ||
export type BuildInfo = { | ||
gitHash: string; | ||
version: string; | ||
dirty: string; | ||
} | ||
@@ -26,24 +26,2 @@ let imports = {}; | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
} | ||
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 }); | ||
@@ -131,2 +109,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) { | ||
@@ -225,31 +225,2 @@ // primitive types | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
module.exports.and = function(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} | ||
*/ | ||
module.exports.xor = function(lhs, rhs) { | ||
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs)); | ||
return takeObject(ret); | ||
}; | ||
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) { | ||
@@ -260,220 +231,2 @@ ptr = ptr >>> 0; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
module.exports.sha256 = function(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.sha256(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); | ||
} | ||
}; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
module.exports.blake2s256 = function(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); | ||
} | ||
}; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
module.exports.keccak256 = function(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.keccak256(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} | ||
*/ | ||
module.exports.ecdsa_secp256k1_verify = function(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} | ||
*/ | ||
module.exports.ecdsa_secp256r1_verify = function(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 {Promise<WasmBlackBoxFunctionSolver>} | ||
*/ | ||
module.exports.createBlackBoxSolver = function() { | ||
const ret = wasm.createBlackBoxSolver(); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* 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); | ||
}; | ||
function _assertClass(instance, klass) { | ||
if (!(instance instanceof klass)) { | ||
throw new Error(`expected instance of ${klass.name}`); | ||
} | ||
return instance.ptr; | ||
} | ||
/** | ||
* 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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(_solver, program, initial_witness, foreign_call_handler) { | ||
_assertClass(_solver, WasmBlackBoxFunctionSolver); | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithReturnWitness(_solver.__wbg_ptr, 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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.executeCircuitWithBlackBoxSolver = function(_solver, program, initial_witness, foreign_call_handler) { | ||
_assertClass(_solver, WasmBlackBoxFunctionSolver); | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithBlackBoxSolver(_solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
*/ | ||
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); | ||
}; | ||
/** | ||
*/ | ||
module.exports.executeProgramWithBlackBoxSolver = function(_solver, program, initial_witness, foreign_call_executor) { | ||
_assertClass(_solver, WasmBlackBoxFunctionSolver); | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeProgramWithBlackBoxSolver(_solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor)); | ||
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); | ||
} | ||
}; | ||
/** | ||
* Returns the `BuildInfo` object containing information about how the installed package was built. | ||
* @returns {BuildInfo} - Information on how the installed package was built. | ||
*/ | ||
module.exports.buildInfo = function() { | ||
const ret = wasm.buildInfo(); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
@@ -503,2 +256,8 @@ * | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1) >>> 0; | ||
getUint8Memory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
/** | ||
@@ -662,42 +421,219 @@ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3, arg4) { | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
} | ||
/** | ||
* 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); | ||
}; | ||
function handleError(f, args) { | ||
/** | ||
* 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 { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
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 __wbg_adapter_98(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
}; | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
class WasmBlackBoxFunctionSolver { | ||
module.exports.and = function(lhs, rhs) { | ||
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs)); | ||
return takeObject(ret); | ||
}; | ||
static __wrap(ptr) { | ||
ptr = ptr >>> 0; | ||
const obj = Object.create(WasmBlackBoxFunctionSolver.prototype); | ||
obj.__wbg_ptr = ptr; | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
module.exports.xor = function(lhs, rhs) { | ||
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs)); | ||
return takeObject(ret); | ||
}; | ||
return obj; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
module.exports.sha256 = function(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.sha256(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); | ||
} | ||
}; | ||
__destroy_into_raw() { | ||
const ptr = this.__wbg_ptr; | ||
this.__wbg_ptr = 0; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
module.exports.blake2s256 = function(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); | ||
} | ||
}; | ||
return ptr; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
module.exports.keccak256 = function(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.keccak256(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); | ||
} | ||
}; | ||
free() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_wasmblackboxfunctionsolver_free(ptr); | ||
/** | ||
* 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} | ||
*/ | ||
module.exports.ecdsa_secp256k1_verify = function(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} | ||
*/ | ||
module.exports.ecdsa_secp256r1_verify = function(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. | ||
*/ | ||
module.exports.buildInfo = function() { | ||
const ret = wasm.buildInfo(); | ||
return takeObject(ret); | ||
}; | ||
function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) { | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
} | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
module.exports.WasmBlackBoxFunctionSolver = WasmBlackBoxFunctionSolver; | ||
function __wbg_adapter_93(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -708,12 +644,10 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) { | ||
module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) { | ||
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0); | ||
module.exports.__wbg_constructor_81b34c49dcbdd2af = function(arg0) { | ||
const ret = new Error(takeObject(arg0)); | ||
return addHeapObject(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.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
@@ -736,17 +670,2 @@ | ||
module.exports.__wbindgen_is_string = function(arg0) { | ||
const ret = typeof(getObject(arg0)) === 'string'; | ||
return ret; | ||
}; | ||
module.exports.__wbg_constructor_81b34c49dcbdd2af = function(arg0) { | ||
const ret = new Error(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_new_6f6c75f9324b78e8 = function() { | ||
@@ -771,2 +690,9 @@ const ret = new Map(); | ||
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_ee5ac63ff3b0fa4d = function() { | ||
@@ -777,2 +703,7 @@ const ret = new Array(); | ||
module.exports.__wbindgen_is_string = function(arg0) { | ||
const ret = typeof(getObject(arg0)) === 'string'; | ||
return ret; | ||
}; | ||
module.exports.__wbg_new_abda76e883ba8a5f = function() { | ||
@@ -867,3 +798,3 @@ const ret = new Error(); | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1, arg2); | ||
return __wbg_adapter_76(a, state0.b, arg0, arg1, arg2); | ||
} finally { | ||
@@ -915,3 +846,3 @@ state0.a = a; | ||
try { | ||
return __wbg_adapter_98(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_93(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -949,3 +880,3 @@ state0.a = a; | ||
try { | ||
return __wbg_adapter_98(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_93(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -999,4 +930,4 @@ state0.a = a; | ||
module.exports.__wbindgen_closure_wrapper493 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 201, __wbg_adapter_22); | ||
module.exports.__wbindgen_closure_wrapper739 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 240, __wbg_adapter_22); | ||
return addHeapObject(ret); | ||
@@ -1003,0 +934,0 @@ }; |
{ | ||
"name": "@noir-lang/acvm_js", | ||
"version": "0.46.0-23a6477.nightly", | ||
"version": "0.46.0-2e543b4.nightly", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
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 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 initLogLevel(a: number, b: number, c: number): void; | ||
export function and(a: number, b: number): number; | ||
@@ -11,18 +22,3 @@ export function xor(a: number, b: number): number; | ||
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; | ||
export function __wbg_wasmblackboxfunctionsolver_free(a: number): void; | ||
export function createBlackBoxSolver(): number; | ||
export function executeCircuit(a: number, b: number, c: number, d: number): number; | ||
export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number, e: number): number; | ||
export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number; | ||
export function executeProgram(a: number, b: number, c: number, d: number): number; | ||
export function executeProgramWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number; | ||
export function initLogLevel(a: number, b: number, c: number): void; | ||
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 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 __wbindgen_malloc(a: number): number; | ||
@@ -29,0 +25,0 @@ export function __wbindgen_realloc(a: number, b: number, c: number): number; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function and(lhs: string, rhs: string): string; | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function xor(lhs: string, rhs: string): string; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function sha256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function blake2s256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function keccak256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* @returns {Promise<WasmBlackBoxFunctionSolver>} | ||
*/ | ||
export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>; | ||
/** | ||
* 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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(_solver: WasmBlackBoxFunctionSolver, 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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 executeCircuitWithBlackBoxSolver(_solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>; | ||
/** | ||
*/ | ||
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>; | ||
/** | ||
*/ | ||
export function executeProgramWithBlackBoxSolver(_solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: 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; | ||
/** | ||
* 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(): BuildInfo; | ||
/** | ||
* Compresses a `WitnessMap` into the binary format outputted by Nargo. | ||
@@ -166,2 +65,91 @@ * | ||
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap; | ||
/** | ||
* 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; | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function and(lhs: string, rhs: string): string; | ||
/** | ||
* Performs a bitwise XOR operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
export function xor(lhs: string, rhs: string): string; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function sha256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Blake2s256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function blake2s256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function keccak256(inputs: Uint8Array): Uint8Array; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* 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: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean; | ||
/** | ||
* 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(): BuildInfo; | ||
@@ -193,16 +181,2 @@ export type RawAssertionPayload = { | ||
/** | ||
* @typedef {Object} BuildInfo - Information about how the installed package was built | ||
* @property {string} gitHash - The hash of the git commit from which the package was built. | ||
* @property {string} version - The version of the package at the built git commit. | ||
* @property {boolean} dirty - Whether the package contained uncommitted changes when built. | ||
*/ | ||
export type BuildInfo = { | ||
gitHash: string; | ||
version: string; | ||
dirty: string; | ||
} | ||
// Map from witness index to hex string value of witness. | ||
@@ -231,8 +205,17 @@ export type WitnessMap = Map<number, string>; | ||
/** | ||
*/ | ||
export class WasmBlackBoxFunctionSolver { | ||
free(): void; | ||
* @typedef {Object} BuildInfo - Information about how the installed package was built | ||
* @property {string} gitHash - The hash of the git commit from which the package was built. | ||
* @property {string} version - The version of the package at the built git commit. | ||
* @property {boolean} dirty - Whether the package contained uncommitted changes when built. | ||
*/ | ||
export type BuildInfo = { | ||
gitHash: string; | ||
version: string; | ||
dirty: string; | ||
} | ||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
@@ -242,2 +225,13 @@ | ||
readonly memory: WebAssembly.Memory; | ||
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 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 initLogLevel: (a: number, b: number, c: number) => void; | ||
readonly and: (a: number, b: number) => number; | ||
@@ -250,18 +244,3 @@ readonly xor: (a: number, b: number) => number; | ||
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number; | ||
readonly __wbg_wasmblackboxfunctionsolver_free: (a: number) => void; | ||
readonly createBlackBoxSolver: () => number; | ||
readonly executeCircuit: (a: number, b: number, c: number, d: number) => number; | ||
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number, e: number) => number; | ||
readonly executeCircuitWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number; | ||
readonly executeProgram: (a: number, b: number, c: number, d: number) => number; | ||
readonly executeProgramWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number; | ||
readonly initLogLevel: (a: number, b: number, c: number) => void; | ||
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 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 __wbindgen_malloc: (a: number) => number; | ||
@@ -268,0 +247,0 @@ readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; |
@@ -23,24 +23,2 @@ let wasm; | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
} | ||
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') } } ); | ||
@@ -128,2 +106,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) { | ||
@@ -222,31 +222,2 @@ // primitive types | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
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); | ||
} | ||
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) { | ||
@@ -257,220 +228,2 @@ ptr = ptr >>> 0; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function sha256(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.sha256(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); | ||
} | ||
} | ||
/** | ||
* 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); | ||
} | ||
} | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function keccak256(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.keccak256(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 {Promise<WasmBlackBoxFunctionSolver>} | ||
*/ | ||
export function createBlackBoxSolver() { | ||
const ret = wasm.createBlackBoxSolver(); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* 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); | ||
} | ||
function _assertClass(instance, klass) { | ||
if (!(instance instanceof klass)) { | ||
throw new Error(`expected instance of ${klass.name}`); | ||
} | ||
return instance.ptr; | ||
} | ||
/** | ||
* 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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(_solver, program, initial_witness, foreign_call_handler) { | ||
_assertClass(_solver, WasmBlackBoxFunctionSolver); | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithReturnWitness(_solver.__wbg_ptr, 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 {&WasmBlackBoxFunctionSolver} solver - A black box solver. | ||
* @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 executeCircuitWithBlackBoxSolver(_solver, program, initial_witness, foreign_call_handler) { | ||
_assertClass(_solver, WasmBlackBoxFunctionSolver); | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeCircuitWithBlackBoxSolver(_solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler)); | ||
return takeObject(ret); | ||
} | ||
/** | ||
*/ | ||
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); | ||
} | ||
/** | ||
*/ | ||
export function executeProgramWithBlackBoxSolver(_solver, program, initial_witness, foreign_call_executor) { | ||
_assertClass(_solver, WasmBlackBoxFunctionSolver); | ||
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.executeProgramWithBlackBoxSolver(_solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor)); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function initLogLevel(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); | ||
} | ||
} | ||
/** | ||
* 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. | ||
@@ -500,2 +253,8 @@ * | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1) >>> 0; | ||
getUint8Memory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
return ptr; | ||
} | ||
/** | ||
@@ -659,41 +418,219 @@ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`. | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3, arg4) { | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
/** | ||
* 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); | ||
} | ||
function handleError(f, args) { | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* Sets the package's logging level. | ||
* | ||
* @param {LogLevel} level - The maximum level of logging to be emitted. | ||
*/ | ||
export function initLogLevel(filter) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
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 __wbg_adapter_98(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
/** | ||
* Performs a bitwise AND operation between `lhs` and `rhs` | ||
* @param {string} lhs | ||
* @param {string} rhs | ||
* @returns {string} | ||
*/ | ||
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 class WasmBlackBoxFunctionSolver { | ||
export function xor(lhs, rhs) { | ||
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs)); | ||
return takeObject(ret); | ||
} | ||
static __wrap(ptr) { | ||
ptr = ptr >>> 0; | ||
const obj = Object.create(WasmBlackBoxFunctionSolver.prototype); | ||
obj.__wbg_ptr = ptr; | ||
/** | ||
* Calculates the SHA256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function sha256(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.sha256(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); | ||
} | ||
} | ||
return obj; | ||
/** | ||
* 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); | ||
} | ||
} | ||
__destroy_into_raw() { | ||
const ptr = this.__wbg_ptr; | ||
this.__wbg_ptr = 0; | ||
return ptr; | ||
/** | ||
* Calculates the Keccak256 hash of the input bytes | ||
* @param {Uint8Array} inputs | ||
* @returns {Uint8Array} | ||
*/ | ||
export function keccak256(inputs) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.keccak256(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); | ||
} | ||
} | ||
free() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_wasmblackboxfunctionsolver_free(ptr); | ||
/** | ||
* 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); | ||
} | ||
function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) { | ||
wasm.wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); | ||
} | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
function __wbg_adapter_93(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -737,11 +674,9 @@ async function __wbg_load(module, imports) { | ||
}; | ||
imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) { | ||
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0); | ||
imports.wbg.__wbg_constructor_81b34c49dcbdd2af = function(arg0) { | ||
const ret = new Error(takeObject(arg0)); | ||
return addHeapObject(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.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
@@ -761,14 +696,2 @@ imports.wbg.__wbindgen_cb_drop = function(arg0) { | ||
}; | ||
imports.wbg.__wbindgen_is_string = function(arg0) { | ||
const ret = typeof(getObject(arg0)) === 'string'; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_constructor_81b34c49dcbdd2af = function(arg0) { | ||
const ret = new Error(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_6f6c75f9324b78e8 = function() { | ||
@@ -790,2 +713,8 @@ const ret = new Map(); | ||
}; | ||
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_ee5ac63ff3b0fa4d = function() { | ||
@@ -795,2 +724,6 @@ const ret = new Array(); | ||
}; | ||
imports.wbg.__wbindgen_is_string = function(arg0) { | ||
const ret = typeof(getObject(arg0)) === 'string'; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_new_abda76e883ba8a5f = function() { | ||
@@ -869,3 +802,3 @@ const ret = new Error(); | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1, arg2); | ||
return __wbg_adapter_76(a, state0.b, arg0, arg1, arg2); | ||
} finally { | ||
@@ -910,3 +843,3 @@ state0.a = a; | ||
try { | ||
return __wbg_adapter_98(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_93(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -940,3 +873,3 @@ state0.a = a; | ||
try { | ||
return __wbg_adapter_98(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_93(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -982,4 +915,4 @@ state0.a = a; | ||
}; | ||
imports.wbg.__wbindgen_closure_wrapper493 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 201, __wbg_adapter_22); | ||
imports.wbg.__wbindgen_closure_wrapper739 = function(arg0, arg1, arg2) { | ||
const ret = makeMutClosure(arg0, arg1, 240, __wbg_adapter_22); | ||
return addHeapObject(ret); | ||
@@ -986,0 +919,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4042497
2212