ecash-lib
Version:
Library for eCash transaction building
728 lines (676 loc) • 23.9 kB
JavaScript
let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder, TextEncoder } = require(`util`);
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
let cachedUint8Memory0 = null;
function getUint8Memory0() {
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
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;
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachedInt32Memory0 = null;
function getInt32Memory0() {
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachedInt32Memory0;
}
function getObject(idx) { return heap[idx]; }
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;
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
let cachedTextEncoder = new TextEncoder('utf-8');
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: 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;
getUint8Memory0().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 = getUint8Memory0();
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 = getUint8Memory0().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;
}
/**
* Verify a signature for the given cryptographic algorithm.
* Intended to be used in X509 certificate verification.
* Throw an exception if the algorithm is not supported.
* @param {string} algo_oid
* @param {string | undefined} params
* @param {Uint8Array} sig
* @param {Uint8Array} msg
* @param {Uint8Array} pk
*/
module.exports.publicKeyCryptoVerify = function(algo_oid, params, sig, msg, pk) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(algo_oid, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
const len0 = WASM_VECTOR_LEN;
var ptr1 = isLikeNone(params) ? 0 : passStringToWasm0(params, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
var len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(sig, wasm.__wbindgen_export_0);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len3 = WASM_VECTOR_LEN;
const ptr4 = passArray8ToWasm0(pk, wasm.__wbindgen_export_0);
const len4 = WASM_VECTOR_LEN;
wasm.publicKeyCryptoVerify(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
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);
}
};
/**
* Throw an exception if the given algo is not supported, otherwise do nothing.
* @param {string} algo_oid
* @param {string | undefined} [params]
*/
module.exports.publicKeyCryptoAlgoSupported = function(algo_oid, params) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(algo_oid, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
const len0 = WASM_VECTOR_LEN;
var ptr1 = isLikeNone(params) ? 0 : passStringToWasm0(params, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
var len1 = WASM_VECTOR_LEN;
wasm.publicKeyCryptoAlgoSupported(retptr, ptr0, len0, ptr1, len1);
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);
}
};
/**
* Calculate SHA512(data).
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
module.exports.sha512 = function(data) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
wasm.sha512(retptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var v2 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
};
/**
* Calculate SHA256(SHA256(data)).
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
module.exports.sha256d = function(data) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
wasm.sha256d(retptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var v2 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
};
/**
* Calculate SHA256(data).
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
module.exports.sha256 = function(data) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
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_export_1(r0, r1 * 1, 1);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
};
/**
* Calculate RIPEMD160(SHA256(data)), commonly used as address hash.
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
module.exports.shaRmd160 = function(data) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
wasm.shaRmd160(retptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var v2 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
};
const EccFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_ecc_free(ptr >>> 0));
/**
* ECC signatures with libsecp256k1.
*/
class Ecc {
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
EccFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_ecc_free(ptr);
}
/**
* Create a new Ecc instance.
*/
constructor() {
const ret = wasm.ecc_new();
this.__wbg_ptr = ret >>> 0;
return this;
}
/**
* Derive a public key from secret key.
* @param {Uint8Array} seckey
* @returns {Uint8Array}
*/
derivePubkey(seckey) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
wasm.ecc_derivePubkey(retptr, this.__wbg_ptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v2 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Sign an ECDSA signature.
* @param {Uint8Array} seckey
* @param {Uint8Array} msg
* @returns {Uint8Array}
*/
ecdsaSign(seckey, msg) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
wasm.ecc_ecdsaSign(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Verify an ECDSA signature.
* @param {Uint8Array} sig
* @param {Uint8Array} msg
* @param {Uint8Array} pk
*/
ecdsaVerify(sig, msg, pk) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(sig, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(pk, wasm.__wbindgen_export_0);
const len2 = WASM_VECTOR_LEN;
wasm.ecc_ecdsaVerify(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
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);
}
}
/**
* Sign a Schnorr signature.
* @param {Uint8Array} seckey
* @param {Uint8Array} msg
* @returns {Uint8Array}
*/
schnorrSign(seckey, msg) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
wasm.ecc_schnorrSign(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Verify a Schnorr signature.
* @param {Uint8Array} sig
* @param {Uint8Array} msg
* @param {Uint8Array} pk
*/
schnorrVerify(sig, msg, pk) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(sig, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(pk, wasm.__wbindgen_export_0);
const len2 = WASM_VECTOR_LEN;
wasm.ecc_schnorrVerify(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
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);
}
}
/**
* Return whether the given secret key is valid, i.e. whether is of correct
* length (32 bytes) and is on the curve.
* @param {Uint8Array} seckey
* @returns {boolean}
*/
isValidSeckey(seckey) {
const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.ecc_isValidSeckey(this.__wbg_ptr, ptr0, len0);
return ret !== 0;
}
/**
* Add a scalar to a secret key.
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {Uint8Array}
*/
seckeyAdd(a, b) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
wasm.ecc_seckeyAdd(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Add a scalar to a public key (adding G*b).
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {Uint8Array}
*/
pubkeyAdd(a, b) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
wasm.ecc_pubkeyAdd(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Create a compact ECDSA signature (65 bytes), which allows reconstructing
* the used public key.
* The format is one header byte, followed by two times 32 bytes for the
* serialized r and s values.
* The header byte: 0x1B = first key with even y,
* 0x1C = first key with odd y,
* 0x1D = second key with even y,
* 0x1E = second key with odd y,
* add 0x04 for compressed keys.
* @param {Uint8Array} seckey
* @param {Uint8Array} msg
* @returns {Uint8Array}
*/
signRecoverable(seckey, msg) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
wasm.ecc_signRecoverable(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Recover the public key of a signature signed by signRecoverable.
* @param {Uint8Array} sig
* @param {Uint8Array} msg
* @returns {Uint8Array}
*/
recoverSig(sig, msg) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(sig, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
const len1 = WASM_VECTOR_LEN;
wasm.ecc_recoverSig(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
module.exports.Ecc = Ecc;
const Sha256HFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_sha256h_free(ptr >>> 0));
/**
* Instance to calculate SHA256 in a streaming fashion
*/
class Sha256H {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(Sha256H.prototype);
obj.__wbg_ptr = ptr;
Sha256HFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
Sha256HFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_sha256h_free(ptr);
}
/**
* Create new hasher instance
*/
constructor() {
const ret = wasm.sha256h_new();
this.__wbg_ptr = ret >>> 0;
return this;
}
/**
* Feed bytes into the hasher
* @param {Uint8Array} data
*/
update(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
wasm.sha256h_update(this.__wbg_ptr, ptr0, len0);
}
/**
* Finalize the hash and return the result
* @returns {Uint8Array}
*/
finalize() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.sha256h_finalize(retptr, this.__wbg_ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Clone the hasher
* @returns {Sha256H}
*/
clone() {
const ret = wasm.sha256h_clone(this.__wbg_ptr);
return Sha256H.__wrap(ret);
}
}
module.exports.Sha256H = Sha256H;
const Sha512HFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_sha512h_free(ptr >>> 0));
/**
* Instance to calculate SHA512 in a streaming fashion
*/
class Sha512H {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(Sha512H.prototype);
obj.__wbg_ptr = ptr;
Sha512HFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
Sha512HFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_sha512h_free(ptr);
}
/**
* Create new hasher instance
*/
constructor() {
const ret = wasm.sha512h_new();
this.__wbg_ptr = ret >>> 0;
return this;
}
/**
* Feed bytes into the hasher
* @param {Uint8Array} data
*/
update(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
const len0 = WASM_VECTOR_LEN;
wasm.sha512h_update(this.__wbg_ptr, ptr0, len0);
}
/**
* Finalize the hash and return the result
* @returns {Uint8Array}
*/
finalize() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.sha512h_finalize(retptr, this.__wbg_ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_export_1(r0, r1 * 1, 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Clone the hasher
* @returns {Sha512H}
*/
clone() {
const ret = wasm.sha512h_clone(this.__wbg_ptr);
return Sha512H.__wrap(ret);
}
}
module.exports.Sha512H = Sha512H;
module.exports.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
module.exports.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
const path = require('path').join(__dirname, 'ecash_lib_wasm_bg_nodejs.wasm');
const bytes = require('fs').readFileSync(path);
const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
wasm = wasmInstance.exports;
module.exports.__wasm = wasm;