@orbinum/proof-generator 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @orbinum/proof-generator might be problematic. Click here for more details.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbinum/proof-generator",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "High-performance ZK-SNARK proof generator for Orbinum privacy protocol. Hybrid TypeScript/Rust/WASM library combining snarkjs (witness calculation) with arkworks (proof generation) to produce 128-byte compressed Groth16 proofs compatible with Substrate runtime.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"postinstall": "tsx scripts/download-artifacts.ts || true",
|
|
28
28
|
"build": "npm run build:rust && npm run build:wasm && npm run build:ts",
|
|
29
29
|
"build:rust": "cd rust && cargo build --release",
|
|
30
|
-
"build:wasm": "cd rust && wasm-pack build --target web --out-dir ../pkg --features wasm",
|
|
30
|
+
"build:wasm": "cd rust && wasm-pack build --target web --out-dir ../pkg --features wasm && rm -f ../pkg/.gitignore",
|
|
31
31
|
"build:ts": "tsc",
|
|
32
32
|
"test": "jest",
|
|
33
33
|
"test:watch": "jest --watch",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
40
40
|
"lint": "tsc --noEmit",
|
|
41
41
|
"prepare": "husky",
|
|
42
|
-
"prepublishOnly": "npm run build
|
|
42
|
+
"prepublishOnly": "npm run build && npm run lint && npm test",
|
|
43
43
|
"clean": "rm -rf dist pkg circuits node_modules && cd rust && cargo clean",
|
|
44
44
|
"release": "npm version patch && git push --follow-tags",
|
|
45
45
|
"release:minor": "npm version minor && git push --follow-tags",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generate a Groth16 proof from witness (WASM interface)
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `circuit_type` - "unshield", "transfer", or "disclosure"
|
|
9
|
+
* * `witness_json` - JSON array of witness values as strings
|
|
10
|
+
* * `proving_key_bytes` - Serialized proving key (arkworks format)
|
|
11
|
+
*
|
|
12
|
+
* # Returns
|
|
13
|
+
* JSON string with format: `{"proof": "0x...", "publicSignals": ["...", "..."]}`
|
|
14
|
+
*/
|
|
15
|
+
export function generate_proof_wasm(circuit_type: string, witness_json: string, proving_key_bytes: Uint8Array): string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize panic hook for better error messages in browser.
|
|
19
|
+
* Only call this when running in actual WASM environment, not tests.
|
|
20
|
+
*/
|
|
21
|
+
export function init_panic_hook(): void;
|
|
22
|
+
|
|
23
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
24
|
+
|
|
25
|
+
export interface InitOutput {
|
|
26
|
+
readonly memory: WebAssembly.Memory;
|
|
27
|
+
readonly generate_proof_wasm: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
28
|
+
readonly init_panic_hook: () => void;
|
|
29
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
30
|
+
readonly __externref_table_alloc: () => number;
|
|
31
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
32
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
33
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
34
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
35
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
36
|
+
readonly __wbindgen_start: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
43
|
+
* a precompiled `WebAssembly.Module`.
|
|
44
|
+
*
|
|
45
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
46
|
+
*
|
|
47
|
+
* @returns {InitOutput}
|
|
48
|
+
*/
|
|
49
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
53
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
54
|
+
*
|
|
55
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
56
|
+
*
|
|
57
|
+
* @returns {Promise<InitOutput>}
|
|
58
|
+
*/
|
|
59
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/* @ts-self-types="./orbinum_proof_generator.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate a Groth16 proof from witness (WASM interface)
|
|
5
|
+
*
|
|
6
|
+
* # Arguments
|
|
7
|
+
* * `circuit_type` - "unshield", "transfer", or "disclosure"
|
|
8
|
+
* * `witness_json` - JSON array of witness values as strings
|
|
9
|
+
* * `proving_key_bytes` - Serialized proving key (arkworks format)
|
|
10
|
+
*
|
|
11
|
+
* # Returns
|
|
12
|
+
* JSON string with format: `{"proof": "0x...", "publicSignals": ["...", "..."]}`
|
|
13
|
+
* @param {string} circuit_type
|
|
14
|
+
* @param {string} witness_json
|
|
15
|
+
* @param {Uint8Array} proving_key_bytes
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function generate_proof_wasm(circuit_type, witness_json, proving_key_bytes) {
|
|
19
|
+
let deferred5_0;
|
|
20
|
+
let deferred5_1;
|
|
21
|
+
try {
|
|
22
|
+
const ptr0 = passStringToWasm0(circuit_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
23
|
+
const len0 = WASM_VECTOR_LEN;
|
|
24
|
+
const ptr1 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
25
|
+
const len1 = WASM_VECTOR_LEN;
|
|
26
|
+
const ptr2 = passArray8ToWasm0(proving_key_bytes, wasm.__wbindgen_malloc);
|
|
27
|
+
const len2 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.generate_proof_wasm(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29
|
+
var ptr4 = ret[0];
|
|
30
|
+
var len4 = ret[1];
|
|
31
|
+
if (ret[3]) {
|
|
32
|
+
ptr4 = 0; len4 = 0;
|
|
33
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
34
|
+
}
|
|
35
|
+
deferred5_0 = ptr4;
|
|
36
|
+
deferred5_1 = len4;
|
|
37
|
+
return getStringFromWasm0(ptr4, len4);
|
|
38
|
+
} finally {
|
|
39
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Initialize panic hook for better error messages in browser.
|
|
45
|
+
* Only call this when running in actual WASM environment, not tests.
|
|
46
|
+
*/
|
|
47
|
+
export function init_panic_hook() {
|
|
48
|
+
wasm.init_panic_hook();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function __wbg_get_imports() {
|
|
52
|
+
const import0 = {
|
|
53
|
+
__proto__: null,
|
|
54
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
55
|
+
const ret = typeof(arg0) === 'function';
|
|
56
|
+
return ret;
|
|
57
|
+
},
|
|
58
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
59
|
+
const val = arg0;
|
|
60
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
61
|
+
return ret;
|
|
62
|
+
},
|
|
63
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
64
|
+
const ret = typeof(arg0) === 'string';
|
|
65
|
+
return ret;
|
|
66
|
+
},
|
|
67
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
68
|
+
const ret = arg0 === undefined;
|
|
69
|
+
return ret;
|
|
70
|
+
},
|
|
71
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
72
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
73
|
+
},
|
|
74
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
75
|
+
const ret = arg0.call(arg1);
|
|
76
|
+
return ret;
|
|
77
|
+
}, arguments); },
|
|
78
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
79
|
+
const ret = arg0.call(arg1, arg2);
|
|
80
|
+
return ret;
|
|
81
|
+
}, arguments); },
|
|
82
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
83
|
+
const ret = arg0.crypto;
|
|
84
|
+
return ret;
|
|
85
|
+
},
|
|
86
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
87
|
+
let deferred0_0;
|
|
88
|
+
let deferred0_1;
|
|
89
|
+
try {
|
|
90
|
+
deferred0_0 = arg0;
|
|
91
|
+
deferred0_1 = arg1;
|
|
92
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
93
|
+
} finally {
|
|
94
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
98
|
+
arg0.getRandomValues(arg1);
|
|
99
|
+
}, arguments); },
|
|
100
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
101
|
+
const ret = arg0.length;
|
|
102
|
+
return ret;
|
|
103
|
+
},
|
|
104
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
105
|
+
const ret = arg0.msCrypto;
|
|
106
|
+
return ret;
|
|
107
|
+
},
|
|
108
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
109
|
+
const ret = new Error();
|
|
110
|
+
return ret;
|
|
111
|
+
},
|
|
112
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
113
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
114
|
+
return ret;
|
|
115
|
+
},
|
|
116
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
117
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
118
|
+
return ret;
|
|
119
|
+
},
|
|
120
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
121
|
+
const ret = arg0.node;
|
|
122
|
+
return ret;
|
|
123
|
+
},
|
|
124
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
125
|
+
const ret = arg0.process;
|
|
126
|
+
return ret;
|
|
127
|
+
},
|
|
128
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
129
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
130
|
+
},
|
|
131
|
+
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
132
|
+
arg0.randomFillSync(arg1);
|
|
133
|
+
}, arguments); },
|
|
134
|
+
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
135
|
+
const ret = module.require;
|
|
136
|
+
return ret;
|
|
137
|
+
}, arguments); },
|
|
138
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
139
|
+
const ret = arg1.stack;
|
|
140
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
141
|
+
const len1 = WASM_VECTOR_LEN;
|
|
142
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
143
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
144
|
+
},
|
|
145
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
146
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
147
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
148
|
+
},
|
|
149
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
150
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
151
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
152
|
+
},
|
|
153
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
154
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
155
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
156
|
+
},
|
|
157
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
158
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
159
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
160
|
+
},
|
|
161
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
162
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
163
|
+
return ret;
|
|
164
|
+
},
|
|
165
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
166
|
+
const ret = arg0.versions;
|
|
167
|
+
return ret;
|
|
168
|
+
},
|
|
169
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
170
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
171
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
175
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
176
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
177
|
+
return ret;
|
|
178
|
+
},
|
|
179
|
+
__wbindgen_init_externref_table: function() {
|
|
180
|
+
const table = wasm.__wbindgen_externrefs;
|
|
181
|
+
const offset = table.grow(4);
|
|
182
|
+
table.set(0, undefined);
|
|
183
|
+
table.set(offset + 0, undefined);
|
|
184
|
+
table.set(offset + 1, null);
|
|
185
|
+
table.set(offset + 2, true);
|
|
186
|
+
table.set(offset + 3, false);
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
__proto__: null,
|
|
191
|
+
"./orbinum_proof_generator_bg.js": import0,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function addToExternrefTable0(obj) {
|
|
196
|
+
const idx = wasm.__externref_table_alloc();
|
|
197
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
198
|
+
return idx;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
202
|
+
ptr = ptr >>> 0;
|
|
203
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let cachedDataViewMemory0 = null;
|
|
207
|
+
function getDataViewMemory0() {
|
|
208
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
209
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
210
|
+
}
|
|
211
|
+
return cachedDataViewMemory0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getStringFromWasm0(ptr, len) {
|
|
215
|
+
ptr = ptr >>> 0;
|
|
216
|
+
return decodeText(ptr, len);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let cachedUint8ArrayMemory0 = null;
|
|
220
|
+
function getUint8ArrayMemory0() {
|
|
221
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
222
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
223
|
+
}
|
|
224
|
+
return cachedUint8ArrayMemory0;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function handleError(f, args) {
|
|
228
|
+
try {
|
|
229
|
+
return f.apply(this, args);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
const idx = addToExternrefTable0(e);
|
|
232
|
+
wasm.__wbindgen_exn_store(idx);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function isLikeNone(x) {
|
|
237
|
+
return x === undefined || x === null;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
241
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
242
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
243
|
+
WASM_VECTOR_LEN = arg.length;
|
|
244
|
+
return ptr;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
248
|
+
if (realloc === undefined) {
|
|
249
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
250
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
251
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
252
|
+
WASM_VECTOR_LEN = buf.length;
|
|
253
|
+
return ptr;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let len = arg.length;
|
|
257
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
258
|
+
|
|
259
|
+
const mem = getUint8ArrayMemory0();
|
|
260
|
+
|
|
261
|
+
let offset = 0;
|
|
262
|
+
|
|
263
|
+
for (; offset < len; offset++) {
|
|
264
|
+
const code = arg.charCodeAt(offset);
|
|
265
|
+
if (code > 0x7F) break;
|
|
266
|
+
mem[ptr + offset] = code;
|
|
267
|
+
}
|
|
268
|
+
if (offset !== len) {
|
|
269
|
+
if (offset !== 0) {
|
|
270
|
+
arg = arg.slice(offset);
|
|
271
|
+
}
|
|
272
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
273
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
274
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
275
|
+
|
|
276
|
+
offset += ret.written;
|
|
277
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
WASM_VECTOR_LEN = offset;
|
|
281
|
+
return ptr;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function takeFromExternrefTable0(idx) {
|
|
285
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
286
|
+
wasm.__externref_table_dealloc(idx);
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
291
|
+
cachedTextDecoder.decode();
|
|
292
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
293
|
+
let numBytesDecoded = 0;
|
|
294
|
+
function decodeText(ptr, len) {
|
|
295
|
+
numBytesDecoded += len;
|
|
296
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
297
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
298
|
+
cachedTextDecoder.decode();
|
|
299
|
+
numBytesDecoded = len;
|
|
300
|
+
}
|
|
301
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const cachedTextEncoder = new TextEncoder();
|
|
305
|
+
|
|
306
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
307
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
308
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
309
|
+
view.set(buf);
|
|
310
|
+
return {
|
|
311
|
+
read: arg.length,
|
|
312
|
+
written: buf.length
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let WASM_VECTOR_LEN = 0;
|
|
318
|
+
|
|
319
|
+
let wasmModule, wasm;
|
|
320
|
+
function __wbg_finalize_init(instance, module) {
|
|
321
|
+
wasm = instance.exports;
|
|
322
|
+
wasmModule = module;
|
|
323
|
+
cachedDataViewMemory0 = null;
|
|
324
|
+
cachedUint8ArrayMemory0 = null;
|
|
325
|
+
wasm.__wbindgen_start();
|
|
326
|
+
return wasm;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async function __wbg_load(module, imports) {
|
|
330
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
331
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
332
|
+
try {
|
|
333
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
334
|
+
} catch (e) {
|
|
335
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
336
|
+
|
|
337
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
338
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
339
|
+
|
|
340
|
+
} else { throw e; }
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const bytes = await module.arrayBuffer();
|
|
345
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
346
|
+
} else {
|
|
347
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
348
|
+
|
|
349
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
350
|
+
return { instance, module };
|
|
351
|
+
} else {
|
|
352
|
+
return instance;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function expectedResponseType(type) {
|
|
357
|
+
switch (type) {
|
|
358
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
359
|
+
}
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function initSync(module) {
|
|
365
|
+
if (wasm !== undefined) return wasm;
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
if (module !== undefined) {
|
|
369
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
370
|
+
({module} = module)
|
|
371
|
+
} else {
|
|
372
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const imports = __wbg_get_imports();
|
|
377
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
378
|
+
module = new WebAssembly.Module(module);
|
|
379
|
+
}
|
|
380
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
381
|
+
return __wbg_finalize_init(instance, module);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
async function __wbg_init(module_or_path) {
|
|
385
|
+
if (wasm !== undefined) return wasm;
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
if (module_or_path !== undefined) {
|
|
389
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
390
|
+
({module_or_path} = module_or_path)
|
|
391
|
+
} else {
|
|
392
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (module_or_path === undefined) {
|
|
397
|
+
module_or_path = new URL('orbinum_proof_generator_bg.wasm', import.meta.url);
|
|
398
|
+
}
|
|
399
|
+
const imports = __wbg_get_imports();
|
|
400
|
+
|
|
401
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
402
|
+
module_or_path = fetch(module_or_path);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
406
|
+
|
|
407
|
+
return __wbg_finalize_init(instance, module);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const generate_proof_wasm: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
5
|
+
export const init_panic_hook: () => void;
|
|
6
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
7
|
+
export const __externref_table_alloc: () => number;
|
|
8
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
9
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
11
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
12
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
+
export const __wbindgen_start: () => void;
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orbinum-proof-generator",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "Apache-2.0 OR GPL-3.0-or-later",
|
|
6
|
+
"files": [
|
|
7
|
+
"orbinum_proof_generator_bg.wasm",
|
|
8
|
+
"orbinum_proof_generator.js",
|
|
9
|
+
"orbinum_proof_generator.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "orbinum_proof_generator.js",
|
|
12
|
+
"types": "orbinum_proof_generator.d.ts",
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"./snippets/*"
|
|
15
|
+
]
|
|
16
|
+
}
|