mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-04 06:33:09 +00:00
fix: use zerokit-rln-wasm and remove zerokit output files from project (#12)
This commit is contained in:
parent
aa8921046e
commit
af3dc15d82
10641
example/package-lock.json
generated
10641
example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,9 +11,9 @@
|
||||
"@waku/rln": "file:../"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack": "^4.29.3",
|
||||
"webpack-cli": "^3.1.0",
|
||||
"webpack-dev-server": "^3.1.5",
|
||||
"copy-webpack-plugin": "^5.0.0"
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"copy-webpack-plugin": "^11.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,8 +7,14 @@ module.exports = {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "index.js",
|
||||
},
|
||||
experiments: {
|
||||
asyncWebAssembly: true,
|
||||
syncWebAssembly: true
|
||||
},
|
||||
mode: "development",
|
||||
plugins: [
|
||||
new CopyWebpackPlugin(['index.html'])
|
||||
new CopyWebpackPlugin({
|
||||
patterns: ['index.html']
|
||||
})
|
||||
],
|
||||
};
|
||||
|
||||
43
package-lock.json
generated
43
package-lock.json
generated
@ -8,6 +8,9 @@
|
||||
"name": "@waku/rln",
|
||||
"version": "0.0.4",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@waku/zerokit-rln-wasm": "^0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^22.0.2",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
@ -1098,6 +1101,11 @@
|
||||
"integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@waku/zerokit-rln-wasm": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@waku/zerokit-rln-wasm/-/zerokit-rln-wasm-0.0.1.tgz",
|
||||
"integrity": "sha512-VOcjGDK+uZ33e0S7EGigyHDsWH0/5L4WvQkLtlunJrS2yfCOGpmerfhfnpf/empd2KsOHGBeXZiIoC/KCAIOlA=="
|
||||
},
|
||||
"node_modules/@webassemblyjs/ast": {
|
||||
"version": "1.11.1",
|
||||
"dev": true,
|
||||
@ -8631,8 +8639,7 @@
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-wasm/-/plugin-wasm-5.2.0.tgz",
|
||||
"integrity": "sha512-PR3ff67ls2Kr9H04pZ24wJYPZq0YV+UHySpk7OuAJxyc7o5Q8NHFdwi4pfMtJkJkqfN1/QY/nq46SoRDoDvK2w==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"@rollup/pluginutils": {
|
||||
"version": "3.1.0",
|
||||
@ -8924,6 +8931,11 @@
|
||||
"integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==",
|
||||
"dev": true
|
||||
},
|
||||
"@waku/zerokit-rln-wasm": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@waku/zerokit-rln-wasm/-/zerokit-rln-wasm-0.0.1.tgz",
|
||||
"integrity": "sha512-VOcjGDK+uZ33e0S7EGigyHDsWH0/5L4WvQkLtlunJrS2yfCOGpmerfhfnpf/empd2KsOHGBeXZiIoC/KCAIOlA=="
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
"version": "1.11.1",
|
||||
"dev": true,
|
||||
@ -9082,13 +9094,11 @@
|
||||
},
|
||||
"acorn-import-assertions": {
|
||||
"version": "1.8.0",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "5.3.2",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"acorn-walk": {
|
||||
"version": "7.2.0",
|
||||
@ -9121,8 +9131,7 @@
|
||||
},
|
||||
"ajv-keywords": {
|
||||
"version": "3.5.2",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"ansi-colors": {
|
||||
"version": "4.1.1",
|
||||
@ -9977,8 +9986,7 @@
|
||||
"version": "8.2.3",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
|
||||
"integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -10181,8 +10189,7 @@
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"version": "8.5.0",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"eslint-import-resolver-node": {
|
||||
"version": "0.3.6",
|
||||
@ -11236,8 +11243,7 @@
|
||||
},
|
||||
"jsdom-global": {
|
||||
"version": "3.0.2",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"json-parse-better-errors": {
|
||||
"version": "1.0.2",
|
||||
@ -12245,8 +12251,7 @@
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
|
||||
"integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -12270,8 +12275,7 @@
|
||||
"dependencies": {
|
||||
"ws": {
|
||||
"version": "8.5.0",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -13454,8 +13458,7 @@
|
||||
},
|
||||
"ws": {
|
||||
"version": "8.8.1",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"xdg-basedir": {
|
||||
"version": "4.0.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@waku/rln",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"description": "Rate Limit Nullifier for js-waku",
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
@ -121,5 +121,8 @@
|
||||
"*.{ts,md,json,conf*.*js}": [
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@waku/zerokit-rln-wasm": "^0.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import init, * as zerokitRLN from "@waku/zerokit-rln-wasm";
|
||||
|
||||
import * as resources from "./resources.js";
|
||||
import * as wc from "./witness_calculator.js";
|
||||
import * as zerokitRLN from "./zerokit/rln_wasm.js";
|
||||
|
||||
/**
|
||||
* Convert a base64 string into uint8Array
|
||||
@ -41,13 +42,14 @@ const VERIFICATION_KEY = base64ToUint8Array(resources.verification_key);
|
||||
const ZKEY = base64ToUint8Array(resources.zkey);
|
||||
const CIRCUIT = base64ToUint8Array(resources.circuit);
|
||||
|
||||
zerokitRLN.init_panic_hook();
|
||||
|
||||
/**
|
||||
* Create an instance of RLN
|
||||
* @returns RLNInstance
|
||||
*/
|
||||
export async function create(): Promise<RLNInstance> {
|
||||
await init();
|
||||
zerokitRLN.init_panic_hook();
|
||||
|
||||
const witnessCalculator = await wc.builder(CIRCUIT, false);
|
||||
const zkRLN = zerokitRLN.newRLN(DEPTH, ZKEY, VERIFICATION_KEY);
|
||||
return new RLNInstance(zkRLN, witnessCalculator);
|
||||
|
||||
73
src/zerokit/rln_wasm.d.ts
vendored
73
src/zerokit/rln_wasm.d.ts
vendored
@ -1,73 +0,0 @@
|
||||
/* tslint:disable */
|
||||
|
||||
/**
|
||||
*/
|
||||
export function init_panic_hook(): void;
|
||||
/**
|
||||
* @param {number} tree_height
|
||||
* @param {Uint8Array} zkey
|
||||
* @param {Uint8Array} vk
|
||||
* @returns {number}
|
||||
*/
|
||||
export function newRLN(
|
||||
tree_height: number,
|
||||
zkey: Uint8Array,
|
||||
vk: Uint8Array
|
||||
): number;
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} input
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function getSerializedRLNWitness(
|
||||
ctx: number,
|
||||
input: Uint8Array
|
||||
): Uint8Array;
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} input
|
||||
*/
|
||||
export function insertMember(ctx: number, input: Uint8Array): void;
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} serialized_witness
|
||||
* @returns {object}
|
||||
*/
|
||||
export function RLNWitnessToJson(
|
||||
ctx: number,
|
||||
serialized_witness: Uint8Array
|
||||
): object;
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {(bigint)[]} calculated_witness
|
||||
* @param {Uint8Array} serialized_witness
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function generate_rln_proof_with_witness(
|
||||
ctx: number,
|
||||
calculated_witness: bigint[],
|
||||
serialized_witness: Uint8Array
|
||||
): Uint8Array;
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function generateMembershipKey(ctx: number): Uint8Array;
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} proof
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function verifyProof(ctx: number, proof: Uint8Array): boolean;
|
||||
/**
|
||||
*/
|
||||
export class RLN {
|
||||
free(): void;
|
||||
}
|
||||
/**
|
||||
* A struct representing an aborted instruction execution, with a message
|
||||
* indicating the cause.
|
||||
*/
|
||||
export class WasmerRuntimeError {
|
||||
free(): void;
|
||||
}
|
||||
@ -1,2 +0,0 @@
|
||||
import * as wasm from "./rln_wasm_bg.wasm";
|
||||
export * from "./rln_wasm_bg.js";
|
||||
@ -1,611 +0,0 @@
|
||||
import * as wasm from './rln_wasm_bg.wasm';
|
||||
|
||||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
||||
|
||||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
|
||||
cachedTextDecoder.decode();
|
||||
|
||||
let cachedUint8Memory0 = new Uint8Array();
|
||||
|
||||
function getUint8Memory0() {
|
||||
if (cachedUint8Memory0.byteLength === 0) {
|
||||
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint8Memory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
const heap = new Array(32).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;
|
||||
}
|
||||
|
||||
function getObject(idx) { return heap[idx]; }
|
||||
|
||||
function dropObject(idx) {
|
||||
if (idx < 36) 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 lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
||||
|
||||
let cachedTextEncoder = new lTextEncoder('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);
|
||||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let len = arg.length;
|
||||
let ptr = malloc(len);
|
||||
|
||||
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);
|
||||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = encodeString(arg, view);
|
||||
|
||||
offset += ret.written;
|
||||
}
|
||||
|
||||
WASM_VECTOR_LEN = offset;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function isLikeNone(x) {
|
||||
return x === undefined || x === null;
|
||||
}
|
||||
|
||||
let cachedInt32Memory0 = new Int32Array();
|
||||
|
||||
function getInt32Memory0() {
|
||||
if (cachedInt32Memory0.byteLength === 0) {
|
||||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedInt32Memory0;
|
||||
}
|
||||
|
||||
function debugString(val) {
|
||||
// primitive types
|
||||
const type = typeof val;
|
||||
if (type == 'number' || type == 'boolean' || val == null) {
|
||||
return `${val}`;
|
||||
}
|
||||
if (type == 'string') {
|
||||
return `"${val}"`;
|
||||
}
|
||||
if (type == 'symbol') {
|
||||
const description = val.description;
|
||||
if (description == null) {
|
||||
return 'Symbol';
|
||||
} else {
|
||||
return `Symbol(${description})`;
|
||||
}
|
||||
}
|
||||
if (type == 'function') {
|
||||
const name = val.name;
|
||||
if (typeof name == 'string' && name.length > 0) {
|
||||
return `Function(${name})`;
|
||||
} else {
|
||||
return 'Function';
|
||||
}
|
||||
}
|
||||
// objects
|
||||
if (Array.isArray(val)) {
|
||||
const length = val.length;
|
||||
let debug = '[';
|
||||
if (length > 0) {
|
||||
debug += debugString(val[0]);
|
||||
}
|
||||
for(let i = 1; i < length; i++) {
|
||||
debug += ', ' + debugString(val[i]);
|
||||
}
|
||||
debug += ']';
|
||||
return debug;
|
||||
}
|
||||
// Test for built-in
|
||||
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
||||
let className;
|
||||
if (builtInMatches.length > 1) {
|
||||
className = builtInMatches[1];
|
||||
} else {
|
||||
// Failed to match the standard '[object ClassName]'
|
||||
return toString.call(val);
|
||||
}
|
||||
if (className == 'Object') {
|
||||
// we're a user defined class or Object
|
||||
// JSON.stringify avoids problems with cycles, and is generally much
|
||||
// easier than looping through ownProperties of `val`.
|
||||
try {
|
||||
return 'Object(' + JSON.stringify(val) + ')';
|
||||
} catch (_) {
|
||||
return 'Object';
|
||||
}
|
||||
}
|
||||
// errors
|
||||
if (val instanceof Error) {
|
||||
return `${val.name}: ${val.message}\n${val.stack}`;
|
||||
}
|
||||
// TODO we could test for more things here, like `Set`s and `Map`s.
|
||||
return className;
|
||||
}
|
||||
/**
|
||||
*/
|
||||
export function init_panic_hook() {
|
||||
wasm.init_panic_hook();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} tree_height
|
||||
* @param {Uint8Array} zkey
|
||||
* @param {Uint8Array} vk
|
||||
* @returns {number}
|
||||
*/
|
||||
export function newRLN(tree_height, zkey, vk) {
|
||||
const ret = wasm.newRLN(tree_height, addHeapObject(zkey), addHeapObject(vk));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} input
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function getSerializedRLNWitness(ctx, input) {
|
||||
const ret = wasm.getSerializedRLNWitness(ctx, addHeapObject(input));
|
||||
return takeObject(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} input
|
||||
*/
|
||||
export function insertMember(ctx, input) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.insertMember(retptr, ctx, addHeapObject(input));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} serialized_witness
|
||||
* @returns {object}
|
||||
*/
|
||||
export function RLNWitnessToJson(ctx, serialized_witness) {
|
||||
const ret = wasm.RLNWitnessToJson(ctx, addHeapObject(serialized_witness));
|
||||
return takeObject(ret);
|
||||
}
|
||||
|
||||
let cachedUint32Memory0 = new Uint32Array();
|
||||
|
||||
function getUint32Memory0() {
|
||||
if (cachedUint32Memory0.byteLength === 0) {
|
||||
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint32Memory0;
|
||||
}
|
||||
|
||||
function passArrayJsValueToWasm0(array, malloc) {
|
||||
const ptr = malloc(array.length * 4);
|
||||
const mem = getUint32Memory0();
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
||||
}
|
||||
WASM_VECTOR_LEN = array.length;
|
||||
return ptr;
|
||||
}
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {(bigint)[]} calculated_witness
|
||||
* @param {Uint8Array} serialized_witness
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function generate_rln_proof_with_witness(ctx, calculated_witness, serialized_witness) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
const ptr0 = passArrayJsValueToWasm0(calculated_witness, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
wasm.generate_rln_proof_with_witness(retptr, ctx, ptr0, len0, addHeapObject(serialized_witness));
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
||||
if (r2) {
|
||||
throw takeObject(r1);
|
||||
}
|
||||
return takeObject(r0);
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function generateMembershipKey(ctx) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.generateMembershipKey(retptr, ctx);
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
||||
if (r2) {
|
||||
throw takeObject(r1);
|
||||
}
|
||||
return takeObject(r0);
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} ctx
|
||||
* @param {Uint8Array} proof
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function verifyProof(ctx, proof) {
|
||||
const ret = wasm.verifyProof(ctx, addHeapObject(proof));
|
||||
return ret !== 0;
|
||||
}
|
||||
|
||||
function handleError(f, args) {
|
||||
try {
|
||||
return f.apply(this, args);
|
||||
} catch (e) {
|
||||
wasm.__wbindgen_exn_store(addHeapObject(e));
|
||||
}
|
||||
}
|
||||
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
|
||||
const u32CvtShim = new Uint32Array(2);
|
||||
|
||||
const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer);
|
||||
|
||||
const int64CvtShim = new BigInt64Array(u32CvtShim.buffer);
|
||||
/**
|
||||
*/
|
||||
export class RLN {
|
||||
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.ptr;
|
||||
this.ptr = 0;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_rln_free(ptr);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A struct representing an aborted instruction execution, with a message
|
||||
* indicating the cause.
|
||||
*/
|
||||
export class WasmerRuntimeError {
|
||||
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.ptr;
|
||||
this.ptr = 0;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_wasmerruntimeerror_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
export function __wbindgen_string_new(arg0, arg1) {
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbindgen_object_drop_ref(arg0) {
|
||||
takeObject(arg0);
|
||||
};
|
||||
|
||||
export function __wbindgen_is_string(arg0) {
|
||||
const ret = typeof(getObject(arg0)) === 'string';
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbindgen_string_get(arg0, arg1) {
|
||||
const obj = getObject(arg1);
|
||||
const ret = typeof(obj) === 'string' ? obj : undefined;
|
||||
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||
};
|
||||
|
||||
export function __wbg_BigInt_73b2c10d8e6eb5a5(arg0, arg1) {
|
||||
u32CvtShim[0] = arg0;
|
||||
u32CvtShim[1] = arg1;
|
||||
const n0 = int64CvtShim[0];
|
||||
const ret = BigInt(n0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbindgen_number_new(arg0) {
|
||||
const ret = arg0;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_BigInt_1a499fbb5f402f4c(arg0, arg1) {
|
||||
u32CvtShim[0] = arg0;
|
||||
u32CvtShim[1] = arg1;
|
||||
const n0 = uint64CvtShim[0];
|
||||
const ret = BigInt(n0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbindgen_object_clone_ref(arg0) {
|
||||
const ret = getObject(arg0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbindgen_is_undefined(arg0) {
|
||||
const ret = getObject(arg0) === undefined;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbindgen_is_object(arg0) {
|
||||
const val = getObject(arg0);
|
||||
const ret = typeof(val) === 'object' && val !== null;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_set_e93b31d47b90bff6(arg0, arg1, arg2) {
|
||||
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
||||
};
|
||||
|
||||
export function __wbg_new_693216e109162396() {
|
||||
const ret = new Error();
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_stack_0ddaca5d1abfb52f(arg0, arg1) {
|
||||
const ret = getObject(arg1).stack;
|
||||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||
};
|
||||
|
||||
export function __wbg_error_09919627ac0992f5(arg0, arg1) {
|
||||
try {
|
||||
console.error(getStringFromWasm0(arg0, arg1));
|
||||
} finally {
|
||||
wasm.__wbindgen_free(arg0, arg1);
|
||||
}
|
||||
};
|
||||
|
||||
export function __wbg_process_e56fd54cf6319b6c(arg0) {
|
||||
const ret = getObject(arg0).process;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_versions_77e21455908dad33(arg0) {
|
||||
const ret = getObject(arg0).versions;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_node_0dd25d832e4785d5(arg0) {
|
||||
const ret = getObject(arg0).node;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_static_accessor_NODE_MODULE_26b231378c1be7dd() {
|
||||
const ret = module;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_require_0db1598d9ccecb30() { return handleError(function (arg0, arg1, arg2) {
|
||||
const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_crypto_b95d7173266618a9(arg0) {
|
||||
const ret = getObject(arg0).crypto;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_msCrypto_5a86d77a66230f81(arg0) {
|
||||
const ret = getObject(arg0).msCrypto;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_getRandomValues_b14734aa289bc356() { return handleError(function (arg0, arg1) {
|
||||
getObject(arg0).getRandomValues(getObject(arg1));
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_randomFillSync_91e2b39becca6147() { return handleError(function (arg0, arg1, arg2) {
|
||||
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_new_ee1a3da85465d621() {
|
||||
const ret = new Array();
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_newnoargs_971e9a5abe185139(arg0, arg1) {
|
||||
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_new_ac586205e4424583() {
|
||||
const ret = new Map();
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_call_33d7bcddbbfa394a() { return handleError(function (arg0, arg1) {
|
||||
const ret = getObject(arg0).call(getObject(arg1));
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_new_e6a9fecc2bf26696() {
|
||||
const ret = new Object();
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_self_fd00a1ef86d1b2ed() { return handleError(function () {
|
||||
const ret = self.self;
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_window_6f6e346d8bbd61d7() { return handleError(function () {
|
||||
const ret = window.window;
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_globalThis_3348936ac49df00a() { return handleError(function () {
|
||||
const ret = globalThis.globalThis;
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_global_67175caf56f55ca9() { return handleError(function () {
|
||||
const ret = global.global;
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_set_64cc39858b2ec3f1(arg0, arg1, arg2) {
|
||||
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
||||
};
|
||||
|
||||
export function __wbg_toString_b1dd862c6b41dd95() { return handleError(function (arg0, arg1) {
|
||||
const ret = getObject(arg0).toString(arg1);
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_new_3ee7ebe9952c1fbd(arg0, arg1) {
|
||||
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_set_a55cff623a9eaa21(arg0, arg1, arg2) {
|
||||
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_fromEntries_576d8e028b09637c() { return handleError(function (arg0) {
|
||||
const ret = Object.fromEntries(getObject(arg0));
|
||||
return addHeapObject(ret);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_buffer_34f5ec9f8a838ba0(arg0) {
|
||||
const ret = getObject(arg0).buffer;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_newwithbyteoffsetandlength_88fdad741db1b182(arg0, arg1, arg2) {
|
||||
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_new_cda198d9dbc6d7ea(arg0) {
|
||||
const ret = new Uint8Array(getObject(arg0));
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_set_1a930cfcda1a8067(arg0, arg1, arg2) {
|
||||
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
||||
};
|
||||
|
||||
export function __wbg_length_51f19f73d6d9eff3(arg0) {
|
||||
const ret = getObject(arg0).length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_newwithlength_66e5530e7079ea1b(arg0) {
|
||||
const ret = new Uint8Array(arg0 >>> 0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbg_subarray_270ff8dd5582c1ac(arg0, arg1, arg2) {
|
||||
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
export function __wbindgen_debug_string(arg0, arg1) {
|
||||
const ret = debugString(getObject(arg1));
|
||||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||
};
|
||||
|
||||
export function __wbindgen_throw(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
|
||||
export function __wbindgen_memory() {
|
||||
const ret = wasm.memory;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
Binary file not shown.
24
src/zerokit/rln_wasm_bg.wasm.d.ts
vendored
24
src/zerokit/rln_wasm_bg.wasm.d.ts
vendored
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
|
||||
export const memory: WebAssembly.Memory;
|
||||
export function __wbg_rln_free(a: number): void;
|
||||
export function newRLN(a: number, b: number, c: number): number;
|
||||
export function getSerializedRLNWitness(a: number, b: number): number;
|
||||
export function insertMember(a: number, b: number, c: number): void;
|
||||
export function RLNWitnessToJson(a: number, b: number): number;
|
||||
export function generate_rln_proof_with_witness(
|
||||
a: number,
|
||||
b: number,
|
||||
c: number,
|
||||
d: number,
|
||||
e: number
|
||||
): void;
|
||||
export function generateMembershipKey(a: number, b: number): void;
|
||||
export function verifyProof(a: number, b: number): number;
|
||||
export function init_panic_hook(): void;
|
||||
export function __wbg_wasmerruntimeerror_free(a: number): void;
|
||||
export function __wbindgen_malloc(a: number): number;
|
||||
export function __wbindgen_realloc(a: number, b: number, c: number): number;
|
||||
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
||||
export function __wbindgen_free(a: number, b: number): void;
|
||||
export function __wbindgen_exn_store(a: number): void;
|
||||
Loading…
x
Reference in New Issue
Block a user