@puzzlehq/aleo-wasm-nodejs
Version:
Aleo SDK WASM
1,436 lines (1,358 loc) • 369 kB
JavaScript
import { readFile } from 'fs/promises';
import { fileURLToPath } from 'url';
import path from 'path';
function spawnWorker(url, module, memory, address) {
return new Promise((resolve) => {
const worker = new Worker(url, {
type: "module",
});
worker.addEventListener("message", (event) => {
// This is needed in Node to wait one extra tick, so that way
// the Worker can fully initialize before we return.
setTimeout(() => {
resolve(worker);
// When running in Node, this allows the process to exit
// even though the Worker is still running.
if (worker.unref) {
worker.unref();
}
}, 0);
}, {
capture: true,
once: true,
});
worker.postMessage({
module,
memory,
address,
});
});
}
let wasm;
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
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;
}
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(); }
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.buffer !== wasm.memory.buffer) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().slice(ptr, ptr + len));
}
function handleError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
wasm.__wbindgen_export_1(addHeapObject(e));
}
}
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
function isLikeNone(x) {
return x === undefined || x === null;
}
let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedDataViewMemory0;
}
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(state => {
wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b);
});
function makeMutClosure(arg0, arg1, dtor, f) {
const state = { a: arg0, b: arg1, cnt: 1, dtor };
const real = (...args) => {
// First up with a closure we increment the internal reference
// count. This ensures that the Rust closure environment won't
// be deallocated while we're invoking it.
state.cnt++;
const a = state.a;
state.a = 0;
try {
return f(a, state.b, ...args);
} finally {
if (--state.cnt === 0) {
wasm.__wbindgen_export_5.get(state.dtor)(a, state.b);
CLOSURE_DTORS.unregister(state);
} else {
state.a = a;
}
}
};
real.original = state;
CLOSURE_DTORS.register(real, state, state);
return real;
}
function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8ArrayMemory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
/**
* Verify an execution. Executions with multiple transitions must have the program source code and
* verifying keys of imported functions supplied from outside to correctly verify. Also, this does
* not verify that the state root of the execution is included in the Aleo Network ledger.
*
* @param {Execution} execution The function execution to verify
* @param {VerifyingKey} verifying_key The verifying key for the function
* @param {Program} program The program that the function execution belongs to
* @param {String} function_id The name of the function that was executed
* @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
* @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
* @returns {boolean} True if the execution is valid, false otherwise
* @param {Execution} execution
* @param {VerifyingKey} verifying_key
* @param {Program} program
* @param {string} function_id
* @param {object | null | undefined} imports
* @param {object | null | undefined} imported_verifying_keys
* @param {number} block_height
* @returns {boolean}
*/
function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(execution, Execution);
_assertClass(verifying_key, VerifyingKey);
_assertClass(program, Program);
const ptr0 = passStringToWasm0(function_id, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.verifyFunctionExecution(retptr, execution.__wbg_ptr, verifying_key.__wbg_ptr, program.__wbg_ptr, ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports), isLikeNone(imported_verifying_keys) ? 0 : addHeapObject(imported_verifying_keys), block_height);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return r0 !== 0;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}
let stack_pointer = 128;
function addBorrowedObject(obj) {
if (stack_pointer == 1) throw new Error('out of js stack');
heap[--stack_pointer] = obj;
return stack_pointer;
}
/**
* @param {number} receiver
*/
function runRayonThread(receiver) {
wasm.runRayonThread(receiver);
}
/**
* @param {URL} url
* @param {number} num_threads
* @returns {Promise<void>}
*/
function initThreadPool$1(url, num_threads) {
const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
return takeObject(ret);
}
function __wbg_adapter_40(arg0, arg1) {
wasm.__wbindgen_export_6(arg0, arg1);
}
function __wbg_adapter_43(arg0, arg1, arg2) {
wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_606(arg0, arg1, arg2, arg3) {
wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
const AddressFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_address_free(ptr >>> 0, 1));
/**
* Public address of an Aleo account
*/
class Address {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(Address.prototype);
obj.__wbg_ptr = ptr;
AddressFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
AddressFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_address_free(ptr, 0);
}
/**
* Derive an Aleo address from a private key
*
* @param {PrivateKey} private_key The private key to derive the address from
* @returns {Address} Address corresponding to the private key
* @param {PrivateKey} private_key
* @returns {Address}
*/
static from_private_key(private_key) {
_assertClass(private_key, PrivateKey);
const ret = wasm.address_from_private_key(private_key.__wbg_ptr);
return Address.__wrap(ret);
}
/**
* Derive an Aleo address from a view key
*
* @param {ViewKey} view_key The view key to derive the address from
* @returns {Address} Address corresponding to the view key
* @param {ViewKey} view_key
* @returns {Address}
*/
static from_view_key(view_key) {
_assertClass(view_key, ViewKey);
const ret = wasm.address_from_view_key(view_key.__wbg_ptr);
return Address.__wrap(ret);
}
/**
* Derive an Aleo address from a compute key.
*
* @param {ComputeKey} compute_key The compute key to derive the address from
* @param {ComputeKey} compute_key
* @returns {Address}
*/
static from_compute_key(compute_key) {
_assertClass(compute_key, ComputeKey);
const ret = wasm.address_from_compute_key(compute_key.__wbg_ptr);
return Address.__wrap(ret);
}
/**
* Get an address from a series of bytes.
*
* @param {Uint8Array} bytes A left endian byte array representing the address.
*
* @returns {Address} The address object.
* @param {Uint8Array} bytes
* @returns {Address}
*/
static fromBytesLe(bytes) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.address_fromBytesLe(retptr, addHeapObject(bytes));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Address.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the left endian byte array representation of the address.
* @returns {Uint8Array}
*/
toBytesLe() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.address_toBytesLe(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get an address from a series of bits represented as a boolean array.
*
* @param {Array} bits A left endian boolean array representing the bits of the address.
*
* @returns {Address} The address object.
* @param {Array<any>} bits
* @returns {Address}
*/
static fromBitsLe(bits) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.address_fromBitsLe(retptr, addHeapObject(bits));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Address.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the left endian boolean array representation of the bits of the address.
* @returns {Array<any>}
*/
toBitsLe() {
const ret = wasm.address_toBitsLe(this.__wbg_ptr);
return takeObject(ret);
}
/**
* Get an address object from an array of fields.
*
* @param {Array} fields An array of fields.
*
* @returns {Plaintext} The address object.
* @param {Array<any>} fields
* @returns {Address}
*/
static fromFields(fields) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.address_fromFields(retptr, addHeapObject(fields));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Address.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the field array representation of the address.
* @returns {Array<any>}
*/
toFields() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.address_toFields(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get an address object from a group.
*
* @param {Group} group The group object.
*
* @returns {Address} The address object.
* @param {Group} group
* @returns {Address}
*/
static fromGroup(group) {
_assertClass(group, Group);
var ptr0 = group.__destroy_into_raw();
const ret = wasm.address_fromGroup(ptr0);
return Address.__wrap(ret);
}
/**
* Get the group representation of the address object.
* @returns {Group}
*/
toGroup() {
const ret = wasm.address_toGroup(this.__wbg_ptr);
return Group.__wrap(ret);
}
/**
* Create an aleo address object from a string representation of an address
*
* @param {string} address String representation of an addressm
* @returns {Address} Address
* @param {string} address
* @returns {Address}
*/
static from_string(address) {
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.address_from_string(ptr0, len0);
return Address.__wrap(ret);
}
/**
* Get a string representation of an Aleo address object
*
* @param {Address} Address
* @returns {string} String representation of the address
* @returns {string}
*/
to_string() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.address_to_string(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
}
}
/**
* Get the plaintext representation of the address.
* @returns {Plaintext}
*/
toPlaintext() {
const ret = wasm.address_toPlaintext(this.__wbg_ptr);
return Plaintext.__wrap(ret);
}
/**
* Verify a signature for a message signed by the address
*
* @param {Uint8Array} Byte array representing a message signed by the address
* @returns {boolean} Boolean representing whether or not the signature is valid
* @param {Uint8Array} message
* @param {Signature} signature
* @returns {boolean}
*/
verify(message, signature) {
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_export_3);
const len0 = WASM_VECTOR_LEN;
_assertClass(signature, Signature);
const ret = wasm.address_verify(this.__wbg_ptr, ptr0, len0, signature.__wbg_ptr);
return ret !== 0;
}
}
const AuthorizationFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_authorization_free(ptr >>> 0, 1));
/**
* Authorization object containing the authorization for a transaction.
*/
class Authorization {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(Authorization.prototype);
obj.__wbg_ptr = ptr;
AuthorizationFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
AuthorizationFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_authorization_free(ptr, 0);
}
/**
* Create a new authorization from a request object.
*
* @param {ExecutionRequest} request The ExecutionRequest to build the authorization from.
* @param {ExecutionRequest} request
* @returns {Authorization}
*/
static new(request) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(request, ExecutionRequest);
var ptr0 = request.__destroy_into_raw();
wasm.authorization_new(retptr, ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Authorization.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a new and independent replica of the Authorization.
* @returns {Authorization}
*/
replicate() {
const ret = wasm.authorization_replicate(this.__wbg_ptr);
return Authorization.__wrap(ret);
}
/**
* Returns the string representation of the Authorization.
* @returns {string}
*/
toString() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.authorization_toString(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
}
}
/**
* Reconstructs an Authorization object from its string representation.
*
* @param {String} authorization The string representation of the Authorization.
* @param {string} authorization
* @returns {Authorization}
*/
static fromString(authorization) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(authorization, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.authorization_fromString(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Authorization.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns the left-endian byte representation of the Authorization.
* @returns {Uint8Array}
*/
toBytesLe() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.authorization_toBytesLe(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Creates an authorization object from a left-endian byte representation of an Authorization.
*
* @param {Uint8Array} bytes Left-endian bytes representing the Authorization.
* @param {Uint8Array} bytes
* @returns {Authorization}
*/
static fromBytesLe(bytes) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.authorization_fromBytesLe(retptr, addHeapObject(bytes));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Authorization.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Check if an Authorization object is the same as another.
*
* @param {Authorization} other The Authorization object to determine equality with.
* @param {Authorization} other
* @returns {boolean}
*/
equals(other) {
_assertClass(other, Authorization);
const ret = wasm.authorization_equals(this.__wbg_ptr, other.__wbg_ptr);
return ret !== 0;
}
/**
* Returns the number of `Request`s in the Authorization.
* @returns {number}
*/
len() {
const ret = wasm.authorization_len(this.__wbg_ptr);
return ret >>> 0;
}
/**
* Return `true` if the Authorization is empty.
* @returns {boolean}
*/
isEmpty() {
const ret = wasm.authorization_isEmpty(this.__wbg_ptr);
return ret !== 0;
}
/**
* Returns `true` if the Authorization is for `credits.aleo/fee_private`.
* @returns {boolean}
*/
isFeePrivate() {
const ret = wasm.authorization_isFeePrivate(this.__wbg_ptr);
return ret !== 0;
}
/**
* Returns `true` if the Authorization is for `credits.aleo/fee_public`.
* @returns {boolean}
*/
isFeePublic() {
const ret = wasm.authorization_isFeePublic(this.__wbg_ptr);
return ret !== 0;
}
/**
* Returns `true` if the Authorization is for `credits.aleo/split`.
* @returns {boolean}
*/
isSplit() {
const ret = wasm.authorization_isSplit(this.__wbg_ptr);
return ret !== 0;
}
/**
* Insert a transition into the Authorization.
*
* @param {Transition} transition The transition object to insert into the Authorization.
* @param {Transition} transition
*/
insertTransition(transition) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(transition, Transition);
var ptr0 = transition.__destroy_into_raw();
wasm.authorization_insertTransition(retptr, this.__wbg_ptr, ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
if (r1) {
throw takeObject(r0);
}
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the transitions in an Authorization.
*
* @returns {Array<Transition>} Array of transition objects
* @returns {Array<any>}
*/
transitions() {
const ret = wasm.authorization_transitions(this.__wbg_ptr);
return takeObject(ret);
}
/**
* Returns the execution ID for the Authorization.
*
* @returns {Field} The execution ID for the Authorization, call toString() after this result to get the string representation.
* @returns {Field}
*/
toExecutionId() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.authorization_toExecutionId(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const BHP1024Finalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_bhp1024_free(ptr >>> 0, 1));
class BHP1024 {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BHP1024.prototype);
obj.__wbg_ptr = ptr;
BHP1024Finalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BHP1024Finalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bhp1024_free(ptr, 0);
}
/**
* Create a BHP hasher with an input size of 1024 bits.
*/
constructor() {
const ret = wasm.bhp1024_new();
this.__wbg_ptr = ret >>> 0;
BHP1024Finalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* Create a BHP hasher with an input size of 1024 bits with a custom domain separator.
* @param {string} domain_separator
* @returns {BHP1024}
*/
static setup(domain_separator) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.bhp1024_setup(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return BHP1024.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns the BHP hash with an input hasher of 1024 bits.
* @param {Array<any>} input
* @returns {Field}
*/
hash(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp1024_hash(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP hash with an input hasher of 1024 bits.
* @param {Array<any>} input
* @returns {Group}
*/
hashToGroup(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp1024_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 1024 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Field}
*/
commit(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp1024_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 1024 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Group}
*/
commitToGroup(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp1024_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const BHP256Finalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_bhp256_free(ptr >>> 0, 1));
class BHP256 {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BHP256.prototype);
obj.__wbg_ptr = ptr;
BHP256Finalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BHP256Finalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bhp256_free(ptr, 0);
}
/**
* Create a BHP hasher with an input size of 256 bits.
*/
constructor() {
const ret = wasm.bhp256_new();
this.__wbg_ptr = ret >>> 0;
BHP256Finalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* Create a BHP hasher with an input size of 256 bits with a custom domain separator.
* @param {string} domain_separator
* @returns {BHP256}
*/
static setup(domain_separator) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.bhp256_setup(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return BHP256.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns the BHP hash with an input hasher of 256 bits.
* @param {Array<any>} input
* @returns {Field}
*/
hash(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp256_hash(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP hash with an input hasher of 256 bits.
* @param {Array<any>} input
* @returns {Group}
*/
hashToGroup(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp256_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 256 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Field}
*/
commit(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp256_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 256 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Group}
*/
commitToGroup(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp256_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const BHP512Finalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_bhp512_free(ptr >>> 0, 1));
class BHP512 {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BHP512.prototype);
obj.__wbg_ptr = ptr;
BHP512Finalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BHP512Finalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bhp512_free(ptr, 0);
}
/**
* Create a BHP hasher with an input size of 512 bits.
*/
constructor() {
const ret = wasm.bhp512_new();
this.__wbg_ptr = ret >>> 0;
BHP512Finalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* Create a BHP hasher with an input size of 512 bits with a custom domain separator.
* @param {string} domain_separator
* @returns {BHP512}
*/
static setup(domain_separator) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.bhp512_setup(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return BHP512.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns the BHP hash with an input hasher of 512 bits.
* @param {Array<any>} input
* @returns {Field}
*/
hash(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp512_hash(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP hash with an input hasher of 512 bits.
* @param {Array<any>} input
* @returns {Group}
*/
hashToGroup(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp512_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 512 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Field}
*/
commit(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp512_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 512 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Group}
*/
commitToGroup(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp512_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const BHP768Finalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_bhp768_free(ptr >>> 0, 1));
class BHP768 {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(BHP768.prototype);
obj.__wbg_ptr = ptr;
BHP768Finalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BHP768Finalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bhp768_free(ptr, 0);
}
/**
* Create a BHP hasher with an input size of 768 bits.
*/
constructor() {
const ret = wasm.bhp768_new();
this.__wbg_ptr = ret >>> 0;
BHP768Finalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* Create a BHP hasher with an input size of 768 bits with a custom domain separator.
* @param {string} domain_separator
* @returns {BHP768}
*/
static setup(domain_separator) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.bhp768_setup(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return BHP768.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns the BHP hash with an input hasher of 768 bits.
* @param {Array<any>} input
* @returns {Field}
*/
hash(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp768_hash(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP hash with an input hasher of 768 bits.
* @param {Array<any>} input
* @returns {Group}
*/
hashToGroup(input) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bhp768_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 768 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Field}
*/
commit(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp768_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Field.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Returns a BHP commitment with an input hasher of 768 bits and randomizer.
* @param {Array<any>} input
* @param {Scalar} randomizer
* @returns {Group}
*/
commitToGroup(input, randomizer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
_assertClass(randomizer, Scalar);
var ptr0 = randomizer.__destroy_into_raw();
wasm.bhp768_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return Group.__wrap(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const BooleanFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_boolean_free(ptr >>> 0, 1));
/**
* Boolean element.
*/
class Boolean {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(Boolean.prototype);
obj.__wbg_ptr = ptr;
BooleanFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BooleanFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_boolean_free(ptr, 0);
}
/**
* Creates a Boolean from a native JS bool.
* @param {boolean} value
*/
constructor(value) {
const ret = wasm.boolean_new(value);
this.__wbg_ptr = ret >>> 0;
BooleanFinalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* Creates a boolean object from a string representation ("true"/"false").
* @param {string} boolean
* @returns {Boolean}
*/
static fromString(boolean) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(boolean, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
const len0 = WASM_VECTOR_LEN;
wasm.boolean_fromString(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return B