Socket
Socket
Sign inDemoInstall

@noir-lang/acvm_js

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@noir-lang/acvm_js - npm Package Compare versions

Comparing version 0.41.0 to 0.42.0

16

nodejs/acvm_js_bg.wasm.d.ts
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function keccak256(a: number, b: number, c: number): void;
export function blake2s256(a: number, b: number, c: number): void;
export function sha256(a: number, b: number, c: number): void;
export function xor(a: number, b: number): number;
export function and(a: number, b: number): number;
export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;

@@ -11,12 +18,5 @@ export function executeCircuit(a: number, b: number, c: number, d: number): number;

export function getReturnWitness(a: number, b: number, c: number, d: number): void;
export function initLogLevel(a: number, b: number, c: number): void;
export function decompressWitness(a: number, b: number, c: number): void;
export function compressWitness(a: number, b: number): void;
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function keccak256(a: number, b: number, c: number): void;
export function blake2s256(a: number, b: number, c: number): void;
export function sha256(a: number, b: number, c: number): void;
export function xor(a: number, b: number): number;
export function and(a: number, b: number): number;
export function initLogLevel(a: number, b: number, c: number): void;
export function buildInfo(): number;

@@ -23,0 +23,0 @@ export function __wbg_trap_free(a: number): void;

/* tslint:disable */
/* eslint-disable */
/**
* 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;
/**
* 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;
/**
* Calculates the Keccak256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function keccak256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the Blake2s256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function blake2s256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the SHA256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function sha256(inputs: Uint8Array): Uint8Array;
/**
* 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;
/**
* 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;
/**
* Executes an ACIR circuit to generate the solved witness from the initial witness.

@@ -12,3 +62,3 @@ *

*/
export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
/**

@@ -22,3 +72,3 @@ * Executes an ACIR circuit to generate the solved witness from the initial witness.

*/
export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
/**

@@ -34,7 +84,7 @@ * @returns {Promise<WasmBlackBoxFunctionSolver>}

* @returns {WitnessMap} A witness map containing the circuit's public inputs.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
export function getPublicWitness(circuit: Uint8Array, solved_witness: WitnessMap): WitnessMap;
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
/**

@@ -46,7 +96,7 @@ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.

* @returns {WitnessMap} A witness map containing the circuit's public parameters.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
export function getPublicParametersWitness(circuit: Uint8Array, solved_witness: WitnessMap): WitnessMap;
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
/**

@@ -58,8 +108,14 @@ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.

* @returns {WitnessMap} A witness map containing the circuit's return values.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} witness_map
* @returns {WitnessMap}
*/
export function getReturnWitness(circuit: Uint8Array, witness_map: WitnessMap): WitnessMap;
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
/**
* Sets the package's logging level.
*
* @param {LogLevel} level - The maximum level of logging to be emitted.
*/
export function initLogLevel(filter: string): void;
/**
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.

@@ -79,58 +135,2 @@ *

/**
* 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;
/**
* 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;
/**
* Calculates the Keccak256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function keccak256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the Blake2s256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function blake2s256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the SHA256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function sha256(inputs: Uint8Array): Uint8Array;
/**
* 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;
/**
* 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;
/**
* 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.

@@ -141,2 +141,13 @@ * @returns {BuildInfo} - Information on how the installed package was built.

export type ExecutionError = Error & {
callStack?: string[];
};
// Map from witness index to hex string value of witness.
export type WitnessMap = Map<number, string>;
export type ForeignCallInput = string[]

@@ -156,13 +167,2 @@ export type ForeignCallOutput = string | string[]

// Map from witness index to hex string value of witness.
export type WitnessMap = Map<number, string>;
export type ExecutionError = Error & {
callStack?: string[];
};
/**

@@ -169,0 +169,0 @@ * @typedef {Object} BuildInfo - Information about how the installed package was built

let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder, TextEncoder } = require(`util`);
const { TextEncoder, TextDecoder } = require(`util`);

@@ -26,6 +26,13 @@ const heap = new Array(128).fill(undefined);

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
cachedTextDecoder.decode();
heap[idx] = obj;
return idx;
}
let WASM_VECTOR_LEN = 0;
let cachedUint8Memory0 = null;

@@ -40,18 +47,2 @@

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
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;
let cachedTextEncoder = new TextEncoder('utf-8');

@@ -123,2 +114,11 @@

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let cachedFloat64Memory0 = null;

@@ -235,9 +235,2 @@

function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
return instance.ptr;
}
function passArray8ToWasm0(arg, malloc) {

@@ -250,2 +243,139 @@ const ptr = malloc(arg.length * 1) >>> 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;
};
/**
* 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;
};
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**
* 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);
}
};
/**
* 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 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);
}
};
/**
* 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);
};
/**
* 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);
};
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.

@@ -259,5 +389,5 @@ *

*/
module.exports.executeCircuitWithBlackBoxSolver = function(solver, circuit, initial_witness, foreign_call_handler) {
module.exports.executeCircuitWithBlackBoxSolver = function(solver, program, initial_witness, foreign_call_handler) {
_assertClass(solver, WasmBlackBoxFunctionSolver);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -276,4 +406,4 @@ const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));

*/
module.exports.executeCircuit = function(circuit, initial_witness, foreign_call_handler) {
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -298,10 +428,10 @@ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));

* @returns {WitnessMap} A witness map containing the circuit's public inputs.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
module.exports.getPublicWitness = function(circuit, solved_witness) {
module.exports.getPublicWitness = function(program, solved_witness) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -327,10 +457,10 @@ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));

* @returns {WitnessMap} A witness map containing the circuit's public parameters.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
module.exports.getPublicParametersWitness = function(circuit, solved_witness) {
module.exports.getPublicParametersWitness = function(program, solved_witness) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -356,10 +486,10 @@ wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));

* @returns {WitnessMap} A witness map containing the circuit's return values.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} witness_map
* @returns {WitnessMap}
*/
module.exports.getReturnWitness = function(circuit, witness_map) {
module.exports.getReturnWitness = function(program, witness_map) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -380,2 +510,23 @@ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));

/**
* 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);
}
};
/**
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.

@@ -404,6 +555,2 @@ *

function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**

@@ -435,150 +582,2 @@ * Compresses a `WitnessMap` into the binary format outputted by Nargo.

/**
* 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;
};
/**
* 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;
};
/**
* 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);
}
};
/**
* 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 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);
}
};
/**
* 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);
};
/**
* 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);
};
/**
* 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.

@@ -658,7 +657,2 @@ * @returns {BuildInfo} - Information on how the installed package was built.

module.exports.__wbindgen_error_new = function(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
module.exports.__wbindgen_object_clone_ref = function(arg0) {

@@ -669,23 +663,3 @@ const ret = getObject(arg0);

module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
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;
};
module.exports.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
module.exports.__wbg_new_ab82e8584bdd2143 = function() {
module.exports.__wbg_new_0d2c031c3755a625 = function() {
const ret = new Map();

@@ -709,3 +683,3 @@ return addHeapObject(ret);

module.exports.__wbg_constructor_d9cb984c4e2c6bcd = function(arg0) {
module.exports.__wbg_constructor_9a4af6ecd5050c55 = function(arg0) {
const ret = new Error(takeObject(arg0));

@@ -715,2 +689,17 @@ return addHeapObject(ret);

module.exports.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
return addHeapObject(ret);
};
module.exports.__wbindgen_error_new = function(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
module.exports.__wbindgen_number_get = function(arg0, arg1) {

@@ -738,2 +727,12 @@ const obj = getObject(arg1);

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;
};
module.exports.__wbg_new_abda76e883ba8a5f = function() {

@@ -1252,4 +1251,4 @@ const ret = new Error();

module.exports.__wbindgen_closure_wrapper1388 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 484, __wbg_adapter_52);
module.exports.__wbindgen_closure_wrapper1401 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 486, __wbg_adapter_52);
return addHeapObject(ret);

@@ -1256,0 +1255,0 @@ };

{
"name": "@noir-lang/acvm_js",
"version": "0.41.0",
"version": "0.42.0",
"publishConfig": {

@@ -44,12 +44,12 @@ "access": "public"

"@web/dev-server-esbuild": "^0.3.6",
"@web/test-runner": "^0.15.3",
"@web/test-runner": "^0.18.1",
"@web/test-runner-playwright": "^0.10.0",
"chai": "^4.3.7",
"eslint": "^8.56.0",
"eslint-plugin-prettier": "^5.0.0",
"chai": "^4.4.1",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"mocha": "^10.2.0",
"prettier": "3.0.3",
"prettier": "3.2.5",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"typescript": "^5.4.2"
}
}
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function keccak256(a: number, b: number, c: number): void;
export function blake2s256(a: number, b: number, c: number): void;
export function sha256(a: number, b: number, c: number): void;
export function xor(a: number, b: number): number;
export function and(a: number, b: number): number;
export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;

@@ -11,12 +18,5 @@ export function executeCircuit(a: number, b: number, c: number, d: number): number;

export function getReturnWitness(a: number, b: number, c: number, d: number): void;
export function initLogLevel(a: number, b: number, c: number): void;
export function decompressWitness(a: number, b: number, c: number): void;
export function compressWitness(a: number, b: number): void;
export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
export function keccak256(a: number, b: number, c: number): void;
export function blake2s256(a: number, b: number, c: number): void;
export function sha256(a: number, b: number, c: number): void;
export function xor(a: number, b: number): number;
export function and(a: number, b: number): number;
export function initLogLevel(a: number, b: number, c: number): void;
export function buildInfo(): number;

@@ -23,0 +23,0 @@ export function __wbg_trap_free(a: number): void;

/* tslint:disable */
/* eslint-disable */
/**
* 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;
/**
* 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;
/**
* Calculates the Keccak256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function keccak256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the Blake2s256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function blake2s256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the SHA256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function sha256(inputs: Uint8Array): Uint8Array;
/**
* 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;
/**
* 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;
/**
* Executes an ACIR circuit to generate the solved witness from the initial witness.

@@ -12,3 +62,3 @@ *

*/
export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
/**

@@ -22,3 +72,3 @@ * Executes an ACIR circuit to generate the solved witness from the initial witness.

*/
export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
/**

@@ -34,7 +84,7 @@ * @returns {Promise<WasmBlackBoxFunctionSolver>}

* @returns {WitnessMap} A witness map containing the circuit's public inputs.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
export function getPublicWitness(circuit: Uint8Array, solved_witness: WitnessMap): WitnessMap;
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
/**

@@ -46,7 +96,7 @@ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.

* @returns {WitnessMap} A witness map containing the circuit's public parameters.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
export function getPublicParametersWitness(circuit: Uint8Array, solved_witness: WitnessMap): WitnessMap;
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
/**

@@ -58,8 +108,14 @@ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.

* @returns {WitnessMap} A witness map containing the circuit's return values.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} witness_map
* @returns {WitnessMap}
*/
export function getReturnWitness(circuit: Uint8Array, witness_map: WitnessMap): WitnessMap;
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
/**
* Sets the package's logging level.
*
* @param {LogLevel} level - The maximum level of logging to be emitted.
*/
export function initLogLevel(filter: string): void;
/**
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.

@@ -79,58 +135,2 @@ *

/**
* 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;
/**
* 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;
/**
* Calculates the Keccak256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function keccak256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the Blake2s256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function blake2s256(inputs: Uint8Array): Uint8Array;
/**
* Calculates the SHA256 hash of the input bytes
* @param {Uint8Array} inputs
* @returns {Uint8Array}
*/
export function sha256(inputs: Uint8Array): Uint8Array;
/**
* 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;
/**
* 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;
/**
* 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.

@@ -141,2 +141,13 @@ * @returns {BuildInfo} - Information on how the installed package was built.

export type ExecutionError = Error & {
callStack?: string[];
};
// Map from witness index to hex string value of witness.
export type WitnessMap = Map<number, string>;
export type ForeignCallInput = string[]

@@ -156,13 +167,2 @@ export type ForeignCallOutput = string | string[]

// Map from witness index to hex string value of witness.
export type WitnessMap = Map<number, string>;
export type ExecutionError = Error & {
callStack?: string[];
};
/**

@@ -191,2 +191,9 @@ * @typedef {Object} BuildInfo - Information about how the installed package was built

readonly memory: WebAssembly.Memory;
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
readonly keccak256: (a: number, b: number, c: number) => void;
readonly blake2s256: (a: number, b: number, c: number) => void;
readonly sha256: (a: number, b: number, c: number) => void;
readonly xor: (a: number, b: number) => number;
readonly and: (a: number, b: number) => number;
readonly executeCircuitWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;

@@ -199,12 +206,5 @@ readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;

readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
readonly initLogLevel: (a: number, b: number, c: number) => void;
readonly decompressWitness: (a: number, b: number, c: number) => void;
readonly compressWitness: (a: number, b: number) => void;
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
readonly keccak256: (a: number, b: number, c: number) => void;
readonly blake2s256: (a: number, b: number, c: number) => void;
readonly sha256: (a: number, b: number, c: number) => void;
readonly xor: (a: number, b: number) => number;
readonly and: (a: number, b: number) => number;
readonly initLogLevel: (a: number, b: number, c: number) => void;
readonly buildInfo: () => number;

@@ -211,0 +211,0 @@ readonly __wbg_trap_free: (a: number) => void;

@@ -23,6 +23,13 @@ let wasm;

const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
heap[idx] = obj;
return idx;
}
let WASM_VECTOR_LEN = 0;
let cachedUint8Memory0 = null;

@@ -37,18 +44,2 @@

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
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;
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );

@@ -120,2 +111,11 @@

const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let cachedFloat64Memory0 = null;

@@ -232,9 +232,2 @@

function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
return instance.ptr;
}
function passArray8ToWasm0(arg, malloc) {

@@ -247,2 +240,139 @@ const ptr = malloc(arg.length * 1) >>> 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;
}
/**
* 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;
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**
* 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);
}
}
/**
* 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 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);
}
}
/**
* 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);
}
/**
* 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);
}
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.

@@ -256,5 +386,5 @@ *

*/
export function executeCircuitWithBlackBoxSolver(solver, circuit, initial_witness, foreign_call_handler) {
export function executeCircuitWithBlackBoxSolver(solver, program, initial_witness, foreign_call_handler) {
_assertClass(solver, WasmBlackBoxFunctionSolver);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -273,4 +403,4 @@ const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));

*/
export function executeCircuit(circuit, initial_witness, foreign_call_handler) {
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
export function executeCircuit(program, initial_witness, foreign_call_handler) {
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -295,10 +425,10 @@ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));

* @returns {WitnessMap} A witness map containing the circuit's public inputs.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
export function getPublicWitness(circuit, solved_witness) {
export function getPublicWitness(program, solved_witness) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -324,10 +454,10 @@ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));

* @returns {WitnessMap} A witness map containing the circuit's public parameters.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} solved_witness
* @returns {WitnessMap}
*/
export function getPublicParametersWitness(circuit, solved_witness) {
export function getPublicParametersWitness(program, solved_witness) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -353,10 +483,10 @@ wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));

* @returns {WitnessMap} A witness map containing the circuit's return values.
* @param {Uint8Array} circuit
* @param {Uint8Array} program
* @param {WitnessMap} witness_map
* @returns {WitnessMap}
*/
export function getReturnWitness(circuit, witness_map) {
export function getReturnWitness(program, witness_map) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;

@@ -377,2 +507,23 @@ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));

/**
* 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);
}
}
/**
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.

@@ -401,6 +552,2 @@ *

function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**

@@ -432,150 +579,2 @@ * Compresses a `WitnessMap` into the binary format outputted by Nargo.

/**
* 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;
}
/**
* 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;
}
/**
* 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);
}
}
/**
* 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 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);
}
}
/**
* 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);
}
/**
* 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);
}
/**
* 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.

@@ -686,6 +685,2 @@ * @returns {BuildInfo} - Information on how the installed package was built.

};
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {

@@ -695,20 +690,3 @@ const ret = getObject(arg0);

};
imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
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;
};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbg_new_ab82e8584bdd2143 = function() {
imports.wbg.__wbg_new_0d2c031c3755a625 = function() {
const ret = new Map();

@@ -729,6 +707,18 @@ return addHeapObject(ret);

};
imports.wbg.__wbg_constructor_d9cb984c4e2c6bcd = function(arg0) {
imports.wbg.__wbg_constructor_9a4af6ecd5050c55 = 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_wasmblackboxfunctionsolver_new = function(arg0) {
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {

@@ -752,2 +742,11 @@ const obj = getObject(arg1);

};
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;
};
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {

@@ -1177,4 +1176,4 @@ const ret = new Error();

};
imports.wbg.__wbindgen_closure_wrapper1388 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 484, __wbg_adapter_52);
imports.wbg.__wbindgen_closure_wrapper1401 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 486, __wbg_adapter_52);
return addHeapObject(ret);

@@ -1181,0 +1180,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc