@izi-noir/sdk 0.1.0 → 0.1.1
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.
- package/dist/index.cjs +1003 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +1009 -79
- package/dist/index.js.map +1 -1
- package/dist/providers/arkworks.cjs +982 -36
- package/dist/providers/arkworks.cjs.map +1 -1
- package/dist/providers/arkworks.d.cts +7 -1
- package/dist/providers/arkworks.d.ts +7 -1
- package/dist/providers/arkworks.js +989 -38
- package/dist/providers/arkworks.js.map +1 -1
- package/dist/providers/barretenberg.cjs +982 -36
- package/dist/providers/barretenberg.cjs.map +1 -1
- package/dist/providers/barretenberg.js +989 -38
- package/dist/providers/barretenberg.js.map +1 -1
- package/dist/providers/solana.cjs +2 -20
- package/dist/providers/solana.cjs.map +1 -1
- package/dist/providers/solana.js +2 -20
- package/dist/providers/solana.js.map +1 -1
- package/dist/wasm/nodejs/arkworks_groth16_wasm.js +52 -0
- package/dist/wasm/nodejs/arkworks_groth16_wasm_bg.wasm +0 -0
- package/dist/wasm/web/arkworks_groth16_wasm.js +50 -0
- package/dist/wasm/web/arkworks_groth16_wasm_bg.wasm +0 -0
- package/package.json +6 -2
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
3
9
|
var __esm = (fn, res) => function __init() {
|
|
4
10
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
11
|
};
|
|
@@ -103,6 +109,872 @@ authors = [""]
|
|
|
103
109
|
}
|
|
104
110
|
});
|
|
105
111
|
|
|
112
|
+
// src/wasm/nodejs/arkworks_groth16_wasm.js
|
|
113
|
+
var arkworks_groth16_wasm_exports = {};
|
|
114
|
+
function acir_to_r1cs_info(acir_json) {
|
|
115
|
+
const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ret = wasm.acir_to_r1cs_info(ptr0, len0);
|
|
118
|
+
if (ret[2]) {
|
|
119
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
120
|
+
}
|
|
121
|
+
return takeFromExternrefTable0(ret[0]);
|
|
122
|
+
}
|
|
123
|
+
function init_panic_hook() {
|
|
124
|
+
wasm.init_panic_hook();
|
|
125
|
+
}
|
|
126
|
+
function prove(proving_key_b64, acir_json, witness_json) {
|
|
127
|
+
const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
128
|
+
const len0 = WASM_VECTOR_LEN;
|
|
129
|
+
const ptr1 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len1 = WASM_VECTOR_LEN;
|
|
131
|
+
const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
+
const len2 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.prove(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
134
|
+
if (ret[2]) {
|
|
135
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
136
|
+
}
|
|
137
|
+
return takeFromExternrefTable0(ret[0]);
|
|
138
|
+
}
|
|
139
|
+
function prove_from_r1cs(proving_key_b64, r1cs_json, witness_json) {
|
|
140
|
+
const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
141
|
+
const len0 = WASM_VECTOR_LEN;
|
|
142
|
+
const ptr1 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
143
|
+
const len1 = WASM_VECTOR_LEN;
|
|
144
|
+
const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
145
|
+
const len2 = WASM_VECTOR_LEN;
|
|
146
|
+
const ret = wasm.prove_from_r1cs(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
147
|
+
if (ret[2]) {
|
|
148
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
149
|
+
}
|
|
150
|
+
return takeFromExternrefTable0(ret[0]);
|
|
151
|
+
}
|
|
152
|
+
function setup(acir_json) {
|
|
153
|
+
const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ret = wasm.setup(ptr0, len0);
|
|
156
|
+
if (ret[2]) {
|
|
157
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
158
|
+
}
|
|
159
|
+
return takeFromExternrefTable0(ret[0]);
|
|
160
|
+
}
|
|
161
|
+
function setup_from_r1cs(r1cs_json) {
|
|
162
|
+
const ptr0 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
163
|
+
const len0 = WASM_VECTOR_LEN;
|
|
164
|
+
const ret = wasm.setup_from_r1cs(ptr0, len0);
|
|
165
|
+
if (ret[2]) {
|
|
166
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
167
|
+
}
|
|
168
|
+
return takeFromExternrefTable0(ret[0]);
|
|
169
|
+
}
|
|
170
|
+
function verify(verifying_key_b64, proof_b64, public_inputs_json) {
|
|
171
|
+
const ptr0 = passStringToWasm0(verifying_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
172
|
+
const len0 = WASM_VECTOR_LEN;
|
|
173
|
+
const ptr1 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
174
|
+
const len1 = WASM_VECTOR_LEN;
|
|
175
|
+
const ptr2 = passStringToWasm0(public_inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
|
+
const len2 = WASM_VECTOR_LEN;
|
|
177
|
+
const ret = wasm.verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
178
|
+
if (ret[2]) {
|
|
179
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
180
|
+
}
|
|
181
|
+
return ret[0] !== 0;
|
|
182
|
+
}
|
|
183
|
+
function verify_gnark(verifying_key_gnark_b64, proof_gnark_b64, public_inputs_gnark_b64, num_public_inputs) {
|
|
184
|
+
const ptr0 = passStringToWasm0(verifying_key_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
186
|
+
const ptr1 = passStringToWasm0(proof_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
+
const len1 = WASM_VECTOR_LEN;
|
|
188
|
+
const ptr2 = passStringToWasm0(public_inputs_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
189
|
+
const len2 = WASM_VECTOR_LEN;
|
|
190
|
+
const ret = wasm.verify_gnark(ptr0, len0, ptr1, len1, ptr2, len2, num_public_inputs);
|
|
191
|
+
if (ret[2]) {
|
|
192
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
193
|
+
}
|
|
194
|
+
return ret[0] !== 0;
|
|
195
|
+
}
|
|
196
|
+
function version() {
|
|
197
|
+
let deferred1_0;
|
|
198
|
+
let deferred1_1;
|
|
199
|
+
try {
|
|
200
|
+
const ret = wasm.version();
|
|
201
|
+
deferred1_0 = ret[0];
|
|
202
|
+
deferred1_1 = ret[1];
|
|
203
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
204
|
+
} finally {
|
|
205
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function __wbg_get_imports() {
|
|
209
|
+
const import0 = {
|
|
210
|
+
__proto__: null,
|
|
211
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
212
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
213
|
+
return ret;
|
|
214
|
+
},
|
|
215
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
216
|
+
const ret = String(arg1);
|
|
217
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
218
|
+
const len1 = WASM_VECTOR_LEN;
|
|
219
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
220
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
221
|
+
},
|
|
222
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
223
|
+
const ret = typeof arg0 === "function";
|
|
224
|
+
return ret;
|
|
225
|
+
},
|
|
226
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
227
|
+
const val = arg0;
|
|
228
|
+
const ret = typeof val === "object" && val !== null;
|
|
229
|
+
return ret;
|
|
230
|
+
},
|
|
231
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
232
|
+
const ret = typeof arg0 === "string";
|
|
233
|
+
return ret;
|
|
234
|
+
},
|
|
235
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
236
|
+
const ret = arg0 === void 0;
|
|
237
|
+
return ret;
|
|
238
|
+
},
|
|
239
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
240
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
241
|
+
},
|
|
242
|
+
__wbg_call_389efe28435a9388: function() {
|
|
243
|
+
return handleError(function(arg0, arg1) {
|
|
244
|
+
const ret = arg0.call(arg1);
|
|
245
|
+
return ret;
|
|
246
|
+
}, arguments);
|
|
247
|
+
},
|
|
248
|
+
__wbg_call_4708e0c13bdc8e95: function() {
|
|
249
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
250
|
+
const ret = arg0.call(arg1, arg2);
|
|
251
|
+
return ret;
|
|
252
|
+
}, arguments);
|
|
253
|
+
},
|
|
254
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
255
|
+
const ret = arg0.crypto;
|
|
256
|
+
return ret;
|
|
257
|
+
},
|
|
258
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
259
|
+
let deferred0_0;
|
|
260
|
+
let deferred0_1;
|
|
261
|
+
try {
|
|
262
|
+
deferred0_0 = arg0;
|
|
263
|
+
deferred0_1 = arg1;
|
|
264
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
265
|
+
} finally {
|
|
266
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() {
|
|
270
|
+
return handleError(function(arg0, arg1) {
|
|
271
|
+
arg0.getRandomValues(arg1);
|
|
272
|
+
}, arguments);
|
|
273
|
+
},
|
|
274
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
275
|
+
const ret = arg0.length;
|
|
276
|
+
return ret;
|
|
277
|
+
},
|
|
278
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
279
|
+
const ret = arg0.msCrypto;
|
|
280
|
+
return ret;
|
|
281
|
+
},
|
|
282
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
283
|
+
const ret = new Object();
|
|
284
|
+
return ret;
|
|
285
|
+
},
|
|
286
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
287
|
+
const ret = new Array();
|
|
288
|
+
return ret;
|
|
289
|
+
},
|
|
290
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
291
|
+
const ret = new Error();
|
|
292
|
+
return ret;
|
|
293
|
+
},
|
|
294
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
295
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
296
|
+
return ret;
|
|
297
|
+
},
|
|
298
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
299
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
300
|
+
return ret;
|
|
301
|
+
},
|
|
302
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
303
|
+
const ret = arg0.node;
|
|
304
|
+
return ret;
|
|
305
|
+
},
|
|
306
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
307
|
+
const ret = arg0.process;
|
|
308
|
+
return ret;
|
|
309
|
+
},
|
|
310
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
311
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
312
|
+
},
|
|
313
|
+
__wbg_randomFillSync_f8c153b79f285817: function() {
|
|
314
|
+
return handleError(function(arg0, arg1) {
|
|
315
|
+
arg0.randomFillSync(arg1);
|
|
316
|
+
}, arguments);
|
|
317
|
+
},
|
|
318
|
+
__wbg_require_b74f47fc2d022fd6: function() {
|
|
319
|
+
return handleError(function() {
|
|
320
|
+
const ret = module.require;
|
|
321
|
+
return ret;
|
|
322
|
+
}, arguments);
|
|
323
|
+
},
|
|
324
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
325
|
+
arg0[arg1] = arg2;
|
|
326
|
+
},
|
|
327
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
328
|
+
arg0[arg1 >>> 0] = arg2;
|
|
329
|
+
},
|
|
330
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
331
|
+
const ret = arg1.stack;
|
|
332
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
333
|
+
const len1 = WASM_VECTOR_LEN;
|
|
334
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
335
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
336
|
+
},
|
|
337
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
338
|
+
const ret = typeof global === "undefined" ? null : global;
|
|
339
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
340
|
+
},
|
|
341
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
342
|
+
const ret = typeof globalThis === "undefined" ? null : globalThis;
|
|
343
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
344
|
+
},
|
|
345
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
346
|
+
const ret = typeof self === "undefined" ? null : self;
|
|
347
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
348
|
+
},
|
|
349
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
350
|
+
const ret = typeof window === "undefined" ? null : window;
|
|
351
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
352
|
+
},
|
|
353
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
354
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
355
|
+
return ret;
|
|
356
|
+
},
|
|
357
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
358
|
+
const ret = arg0.versions;
|
|
359
|
+
return ret;
|
|
360
|
+
},
|
|
361
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
362
|
+
const ret = arg0;
|
|
363
|
+
return ret;
|
|
364
|
+
},
|
|
365
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
366
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
367
|
+
return ret;
|
|
368
|
+
},
|
|
369
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
370
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
371
|
+
return ret;
|
|
372
|
+
},
|
|
373
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
374
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
375
|
+
return ret;
|
|
376
|
+
},
|
|
377
|
+
__wbindgen_init_externref_table: function() {
|
|
378
|
+
const table = wasm.__wbindgen_externrefs;
|
|
379
|
+
const offset = table.grow(4);
|
|
380
|
+
table.set(0, void 0);
|
|
381
|
+
table.set(offset + 0, void 0);
|
|
382
|
+
table.set(offset + 1, null);
|
|
383
|
+
table.set(offset + 2, true);
|
|
384
|
+
table.set(offset + 3, false);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
return {
|
|
388
|
+
__proto__: null,
|
|
389
|
+
"./arkworks_groth16_wasm_bg.js": import0
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function addToExternrefTable0(obj) {
|
|
393
|
+
const idx = wasm.__externref_table_alloc();
|
|
394
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
395
|
+
return idx;
|
|
396
|
+
}
|
|
397
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
398
|
+
ptr = ptr >>> 0;
|
|
399
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
400
|
+
}
|
|
401
|
+
function getDataViewMemory0() {
|
|
402
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
403
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
404
|
+
}
|
|
405
|
+
return cachedDataViewMemory0;
|
|
406
|
+
}
|
|
407
|
+
function getStringFromWasm0(ptr, len) {
|
|
408
|
+
ptr = ptr >>> 0;
|
|
409
|
+
return decodeText(ptr, len);
|
|
410
|
+
}
|
|
411
|
+
function getUint8ArrayMemory0() {
|
|
412
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
413
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
414
|
+
}
|
|
415
|
+
return cachedUint8ArrayMemory0;
|
|
416
|
+
}
|
|
417
|
+
function handleError(f, args) {
|
|
418
|
+
try {
|
|
419
|
+
return f.apply(this, args);
|
|
420
|
+
} catch (e) {
|
|
421
|
+
const idx = addToExternrefTable0(e);
|
|
422
|
+
wasm.__wbindgen_exn_store(idx);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function isLikeNone(x) {
|
|
426
|
+
return x === void 0 || x === null;
|
|
427
|
+
}
|
|
428
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
429
|
+
if (realloc === void 0) {
|
|
430
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
431
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
432
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
433
|
+
WASM_VECTOR_LEN = buf.length;
|
|
434
|
+
return ptr2;
|
|
435
|
+
}
|
|
436
|
+
let len = arg.length;
|
|
437
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
438
|
+
const mem = getUint8ArrayMemory0();
|
|
439
|
+
let offset = 0;
|
|
440
|
+
for (; offset < len; offset++) {
|
|
441
|
+
const code = arg.charCodeAt(offset);
|
|
442
|
+
if (code > 127) break;
|
|
443
|
+
mem[ptr + offset] = code;
|
|
444
|
+
}
|
|
445
|
+
if (offset !== len) {
|
|
446
|
+
if (offset !== 0) {
|
|
447
|
+
arg = arg.slice(offset);
|
|
448
|
+
}
|
|
449
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
450
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
451
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
452
|
+
offset += ret.written;
|
|
453
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
454
|
+
}
|
|
455
|
+
WASM_VECTOR_LEN = offset;
|
|
456
|
+
return ptr;
|
|
457
|
+
}
|
|
458
|
+
function takeFromExternrefTable0(idx) {
|
|
459
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
460
|
+
wasm.__externref_table_dealloc(idx);
|
|
461
|
+
return value;
|
|
462
|
+
}
|
|
463
|
+
function decodeText(ptr, len) {
|
|
464
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
465
|
+
}
|
|
466
|
+
var cachedDataViewMemory0, cachedUint8ArrayMemory0, cachedTextDecoder, cachedTextEncoder, WASM_VECTOR_LEN, wasmPath, wasmBytes, wasmModule, wasm;
|
|
467
|
+
var init_arkworks_groth16_wasm = __esm({
|
|
468
|
+
"src/wasm/nodejs/arkworks_groth16_wasm.js"() {
|
|
469
|
+
"use strict";
|
|
470
|
+
exports.acir_to_r1cs_info = acir_to_r1cs_info;
|
|
471
|
+
exports.init_panic_hook = init_panic_hook;
|
|
472
|
+
exports.prove = prove;
|
|
473
|
+
exports.prove_from_r1cs = prove_from_r1cs;
|
|
474
|
+
exports.setup = setup;
|
|
475
|
+
exports.setup_from_r1cs = setup_from_r1cs;
|
|
476
|
+
exports.verify = verify;
|
|
477
|
+
exports.verify_gnark = verify_gnark;
|
|
478
|
+
exports.version = version;
|
|
479
|
+
cachedDataViewMemory0 = null;
|
|
480
|
+
cachedUint8ArrayMemory0 = null;
|
|
481
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
482
|
+
cachedTextDecoder.decode();
|
|
483
|
+
cachedTextEncoder = new TextEncoder();
|
|
484
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
485
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
486
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
487
|
+
view.set(buf);
|
|
488
|
+
return {
|
|
489
|
+
read: arg.length,
|
|
490
|
+
written: buf.length
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
WASM_VECTOR_LEN = 0;
|
|
495
|
+
wasmPath = `${__dirname}/arkworks_groth16_wasm_bg.wasm`;
|
|
496
|
+
wasmBytes = __require("fs").readFileSync(wasmPath);
|
|
497
|
+
wasmModule = new WebAssembly.Module(wasmBytes);
|
|
498
|
+
wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
499
|
+
wasm.__wbindgen_start();
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// src/wasm/web/arkworks_groth16_wasm.js
|
|
504
|
+
var arkworks_groth16_wasm_exports2 = {};
|
|
505
|
+
__export(arkworks_groth16_wasm_exports2, {
|
|
506
|
+
acir_to_r1cs_info: () => acir_to_r1cs_info2,
|
|
507
|
+
default: () => __wbg_init,
|
|
508
|
+
initSync: () => initSync,
|
|
509
|
+
init_panic_hook: () => init_panic_hook2,
|
|
510
|
+
prove: () => prove2,
|
|
511
|
+
prove_from_r1cs: () => prove_from_r1cs2,
|
|
512
|
+
setup: () => setup2,
|
|
513
|
+
setup_from_r1cs: () => setup_from_r1cs2,
|
|
514
|
+
verify: () => verify2,
|
|
515
|
+
verify_gnark: () => verify_gnark2,
|
|
516
|
+
version: () => version2
|
|
517
|
+
});
|
|
518
|
+
function acir_to_r1cs_info2(acir_json) {
|
|
519
|
+
const ptr0 = passStringToWasm02(acir_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
520
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
521
|
+
const ret = wasm2.acir_to_r1cs_info(ptr0, len0);
|
|
522
|
+
if (ret[2]) {
|
|
523
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
524
|
+
}
|
|
525
|
+
return takeFromExternrefTable02(ret[0]);
|
|
526
|
+
}
|
|
527
|
+
function init_panic_hook2() {
|
|
528
|
+
wasm2.init_panic_hook();
|
|
529
|
+
}
|
|
530
|
+
function prove2(proving_key_b64, acir_json, witness_json) {
|
|
531
|
+
const ptr0 = passStringToWasm02(proving_key_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
532
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
533
|
+
const ptr1 = passStringToWasm02(acir_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
534
|
+
const len1 = WASM_VECTOR_LEN2;
|
|
535
|
+
const ptr2 = passStringToWasm02(witness_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
536
|
+
const len2 = WASM_VECTOR_LEN2;
|
|
537
|
+
const ret = wasm2.prove(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
538
|
+
if (ret[2]) {
|
|
539
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
540
|
+
}
|
|
541
|
+
return takeFromExternrefTable02(ret[0]);
|
|
542
|
+
}
|
|
543
|
+
function prove_from_r1cs2(proving_key_b64, r1cs_json, witness_json) {
|
|
544
|
+
const ptr0 = passStringToWasm02(proving_key_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
545
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
546
|
+
const ptr1 = passStringToWasm02(r1cs_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
547
|
+
const len1 = WASM_VECTOR_LEN2;
|
|
548
|
+
const ptr2 = passStringToWasm02(witness_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
549
|
+
const len2 = WASM_VECTOR_LEN2;
|
|
550
|
+
const ret = wasm2.prove_from_r1cs(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
551
|
+
if (ret[2]) {
|
|
552
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
553
|
+
}
|
|
554
|
+
return takeFromExternrefTable02(ret[0]);
|
|
555
|
+
}
|
|
556
|
+
function setup2(acir_json) {
|
|
557
|
+
const ptr0 = passStringToWasm02(acir_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
558
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
559
|
+
const ret = wasm2.setup(ptr0, len0);
|
|
560
|
+
if (ret[2]) {
|
|
561
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
562
|
+
}
|
|
563
|
+
return takeFromExternrefTable02(ret[0]);
|
|
564
|
+
}
|
|
565
|
+
function setup_from_r1cs2(r1cs_json) {
|
|
566
|
+
const ptr0 = passStringToWasm02(r1cs_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
567
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
568
|
+
const ret = wasm2.setup_from_r1cs(ptr0, len0);
|
|
569
|
+
if (ret[2]) {
|
|
570
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
571
|
+
}
|
|
572
|
+
return takeFromExternrefTable02(ret[0]);
|
|
573
|
+
}
|
|
574
|
+
function verify2(verifying_key_b64, proof_b64, public_inputs_json) {
|
|
575
|
+
const ptr0 = passStringToWasm02(verifying_key_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
576
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
577
|
+
const ptr1 = passStringToWasm02(proof_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
578
|
+
const len1 = WASM_VECTOR_LEN2;
|
|
579
|
+
const ptr2 = passStringToWasm02(public_inputs_json, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
580
|
+
const len2 = WASM_VECTOR_LEN2;
|
|
581
|
+
const ret = wasm2.verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
582
|
+
if (ret[2]) {
|
|
583
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
584
|
+
}
|
|
585
|
+
return ret[0] !== 0;
|
|
586
|
+
}
|
|
587
|
+
function verify_gnark2(verifying_key_gnark_b64, proof_gnark_b64, public_inputs_gnark_b64, num_public_inputs) {
|
|
588
|
+
const ptr0 = passStringToWasm02(verifying_key_gnark_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
589
|
+
const len0 = WASM_VECTOR_LEN2;
|
|
590
|
+
const ptr1 = passStringToWasm02(proof_gnark_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
591
|
+
const len1 = WASM_VECTOR_LEN2;
|
|
592
|
+
const ptr2 = passStringToWasm02(public_inputs_gnark_b64, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
593
|
+
const len2 = WASM_VECTOR_LEN2;
|
|
594
|
+
const ret = wasm2.verify_gnark(ptr0, len0, ptr1, len1, ptr2, len2, num_public_inputs);
|
|
595
|
+
if (ret[2]) {
|
|
596
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
597
|
+
}
|
|
598
|
+
return ret[0] !== 0;
|
|
599
|
+
}
|
|
600
|
+
function version2() {
|
|
601
|
+
let deferred1_0;
|
|
602
|
+
let deferred1_1;
|
|
603
|
+
try {
|
|
604
|
+
const ret = wasm2.version();
|
|
605
|
+
deferred1_0 = ret[0];
|
|
606
|
+
deferred1_1 = ret[1];
|
|
607
|
+
return getStringFromWasm02(ret[0], ret[1]);
|
|
608
|
+
} finally {
|
|
609
|
+
wasm2.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function __wbg_get_imports2() {
|
|
613
|
+
const import0 = {
|
|
614
|
+
__proto__: null,
|
|
615
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
616
|
+
const ret = Error(getStringFromWasm02(arg0, arg1));
|
|
617
|
+
return ret;
|
|
618
|
+
},
|
|
619
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
620
|
+
const ret = String(arg1);
|
|
621
|
+
const ptr1 = passStringToWasm02(ret, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
622
|
+
const len1 = WASM_VECTOR_LEN2;
|
|
623
|
+
getDataViewMemory02().setInt32(arg0 + 4 * 1, len1, true);
|
|
624
|
+
getDataViewMemory02().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
625
|
+
},
|
|
626
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
627
|
+
const ret = typeof arg0 === "function";
|
|
628
|
+
return ret;
|
|
629
|
+
},
|
|
630
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
631
|
+
const val = arg0;
|
|
632
|
+
const ret = typeof val === "object" && val !== null;
|
|
633
|
+
return ret;
|
|
634
|
+
},
|
|
635
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
636
|
+
const ret = typeof arg0 === "string";
|
|
637
|
+
return ret;
|
|
638
|
+
},
|
|
639
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
640
|
+
const ret = arg0 === void 0;
|
|
641
|
+
return ret;
|
|
642
|
+
},
|
|
643
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
644
|
+
throw new Error(getStringFromWasm02(arg0, arg1));
|
|
645
|
+
},
|
|
646
|
+
__wbg_call_389efe28435a9388: function() {
|
|
647
|
+
return handleError2(function(arg0, arg1) {
|
|
648
|
+
const ret = arg0.call(arg1);
|
|
649
|
+
return ret;
|
|
650
|
+
}, arguments);
|
|
651
|
+
},
|
|
652
|
+
__wbg_call_4708e0c13bdc8e95: function() {
|
|
653
|
+
return handleError2(function(arg0, arg1, arg2) {
|
|
654
|
+
const ret = arg0.call(arg1, arg2);
|
|
655
|
+
return ret;
|
|
656
|
+
}, arguments);
|
|
657
|
+
},
|
|
658
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
659
|
+
const ret = arg0.crypto;
|
|
660
|
+
return ret;
|
|
661
|
+
},
|
|
662
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
663
|
+
let deferred0_0;
|
|
664
|
+
let deferred0_1;
|
|
665
|
+
try {
|
|
666
|
+
deferred0_0 = arg0;
|
|
667
|
+
deferred0_1 = arg1;
|
|
668
|
+
console.error(getStringFromWasm02(arg0, arg1));
|
|
669
|
+
} finally {
|
|
670
|
+
wasm2.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() {
|
|
674
|
+
return handleError2(function(arg0, arg1) {
|
|
675
|
+
arg0.getRandomValues(arg1);
|
|
676
|
+
}, arguments);
|
|
677
|
+
},
|
|
678
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
679
|
+
const ret = arg0.length;
|
|
680
|
+
return ret;
|
|
681
|
+
},
|
|
682
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
683
|
+
const ret = arg0.msCrypto;
|
|
684
|
+
return ret;
|
|
685
|
+
},
|
|
686
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
687
|
+
const ret = new Object();
|
|
688
|
+
return ret;
|
|
689
|
+
},
|
|
690
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
691
|
+
const ret = new Array();
|
|
692
|
+
return ret;
|
|
693
|
+
},
|
|
694
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
695
|
+
const ret = new Error();
|
|
696
|
+
return ret;
|
|
697
|
+
},
|
|
698
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
699
|
+
const ret = new Function(getStringFromWasm02(arg0, arg1));
|
|
700
|
+
return ret;
|
|
701
|
+
},
|
|
702
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
703
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
704
|
+
return ret;
|
|
705
|
+
},
|
|
706
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
707
|
+
const ret = arg0.node;
|
|
708
|
+
return ret;
|
|
709
|
+
},
|
|
710
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
711
|
+
const ret = arg0.process;
|
|
712
|
+
return ret;
|
|
713
|
+
},
|
|
714
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
715
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm02(arg0, arg1), arg2);
|
|
716
|
+
},
|
|
717
|
+
__wbg_randomFillSync_f8c153b79f285817: function() {
|
|
718
|
+
return handleError2(function(arg0, arg1) {
|
|
719
|
+
arg0.randomFillSync(arg1);
|
|
720
|
+
}, arguments);
|
|
721
|
+
},
|
|
722
|
+
__wbg_require_b74f47fc2d022fd6: function() {
|
|
723
|
+
return handleError2(function() {
|
|
724
|
+
const ret = module.require;
|
|
725
|
+
return ret;
|
|
726
|
+
}, arguments);
|
|
727
|
+
},
|
|
728
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
729
|
+
arg0[arg1] = arg2;
|
|
730
|
+
},
|
|
731
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
732
|
+
arg0[arg1 >>> 0] = arg2;
|
|
733
|
+
},
|
|
734
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
735
|
+
const ret = arg1.stack;
|
|
736
|
+
const ptr1 = passStringToWasm02(ret, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
737
|
+
const len1 = WASM_VECTOR_LEN2;
|
|
738
|
+
getDataViewMemory02().setInt32(arg0 + 4 * 1, len1, true);
|
|
739
|
+
getDataViewMemory02().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
740
|
+
},
|
|
741
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
742
|
+
const ret = typeof global === "undefined" ? null : global;
|
|
743
|
+
return isLikeNone2(ret) ? 0 : addToExternrefTable02(ret);
|
|
744
|
+
},
|
|
745
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
746
|
+
const ret = typeof globalThis === "undefined" ? null : globalThis;
|
|
747
|
+
return isLikeNone2(ret) ? 0 : addToExternrefTable02(ret);
|
|
748
|
+
},
|
|
749
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
750
|
+
const ret = typeof self === "undefined" ? null : self;
|
|
751
|
+
return isLikeNone2(ret) ? 0 : addToExternrefTable02(ret);
|
|
752
|
+
},
|
|
753
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
754
|
+
const ret = typeof window === "undefined" ? null : window;
|
|
755
|
+
return isLikeNone2(ret) ? 0 : addToExternrefTable02(ret);
|
|
756
|
+
},
|
|
757
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
758
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
759
|
+
return ret;
|
|
760
|
+
},
|
|
761
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
762
|
+
const ret = arg0.versions;
|
|
763
|
+
return ret;
|
|
764
|
+
},
|
|
765
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
766
|
+
const ret = arg0;
|
|
767
|
+
return ret;
|
|
768
|
+
},
|
|
769
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
770
|
+
const ret = getArrayU8FromWasm02(arg0, arg1);
|
|
771
|
+
return ret;
|
|
772
|
+
},
|
|
773
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
774
|
+
const ret = getStringFromWasm02(arg0, arg1);
|
|
775
|
+
return ret;
|
|
776
|
+
},
|
|
777
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
778
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
779
|
+
return ret;
|
|
780
|
+
},
|
|
781
|
+
__wbindgen_init_externref_table: function() {
|
|
782
|
+
const table = wasm2.__wbindgen_externrefs;
|
|
783
|
+
const offset = table.grow(4);
|
|
784
|
+
table.set(0, void 0);
|
|
785
|
+
table.set(offset + 0, void 0);
|
|
786
|
+
table.set(offset + 1, null);
|
|
787
|
+
table.set(offset + 2, true);
|
|
788
|
+
table.set(offset + 3, false);
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
return {
|
|
792
|
+
__proto__: null,
|
|
793
|
+
"./arkworks_groth16_wasm_bg.js": import0
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function addToExternrefTable02(obj) {
|
|
797
|
+
const idx = wasm2.__externref_table_alloc();
|
|
798
|
+
wasm2.__wbindgen_externrefs.set(idx, obj);
|
|
799
|
+
return idx;
|
|
800
|
+
}
|
|
801
|
+
function getArrayU8FromWasm02(ptr, len) {
|
|
802
|
+
ptr = ptr >>> 0;
|
|
803
|
+
return getUint8ArrayMemory02().subarray(ptr / 1, ptr / 1 + len);
|
|
804
|
+
}
|
|
805
|
+
function getDataViewMemory02() {
|
|
806
|
+
if (cachedDataViewMemory02 === null || cachedDataViewMemory02.buffer.detached === true || cachedDataViewMemory02.buffer.detached === void 0 && cachedDataViewMemory02.buffer !== wasm2.memory.buffer) {
|
|
807
|
+
cachedDataViewMemory02 = new DataView(wasm2.memory.buffer);
|
|
808
|
+
}
|
|
809
|
+
return cachedDataViewMemory02;
|
|
810
|
+
}
|
|
811
|
+
function getStringFromWasm02(ptr, len) {
|
|
812
|
+
ptr = ptr >>> 0;
|
|
813
|
+
return decodeText2(ptr, len);
|
|
814
|
+
}
|
|
815
|
+
function getUint8ArrayMemory02() {
|
|
816
|
+
if (cachedUint8ArrayMemory02 === null || cachedUint8ArrayMemory02.byteLength === 0) {
|
|
817
|
+
cachedUint8ArrayMemory02 = new Uint8Array(wasm2.memory.buffer);
|
|
818
|
+
}
|
|
819
|
+
return cachedUint8ArrayMemory02;
|
|
820
|
+
}
|
|
821
|
+
function handleError2(f, args) {
|
|
822
|
+
try {
|
|
823
|
+
return f.apply(this, args);
|
|
824
|
+
} catch (e) {
|
|
825
|
+
const idx = addToExternrefTable02(e);
|
|
826
|
+
wasm2.__wbindgen_exn_store(idx);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
function isLikeNone2(x) {
|
|
830
|
+
return x === void 0 || x === null;
|
|
831
|
+
}
|
|
832
|
+
function passStringToWasm02(arg, malloc, realloc) {
|
|
833
|
+
if (realloc === void 0) {
|
|
834
|
+
const buf = cachedTextEncoder2.encode(arg);
|
|
835
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
836
|
+
getUint8ArrayMemory02().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
837
|
+
WASM_VECTOR_LEN2 = buf.length;
|
|
838
|
+
return ptr2;
|
|
839
|
+
}
|
|
840
|
+
let len = arg.length;
|
|
841
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
842
|
+
const mem = getUint8ArrayMemory02();
|
|
843
|
+
let offset = 0;
|
|
844
|
+
for (; offset < len; offset++) {
|
|
845
|
+
const code = arg.charCodeAt(offset);
|
|
846
|
+
if (code > 127) break;
|
|
847
|
+
mem[ptr + offset] = code;
|
|
848
|
+
}
|
|
849
|
+
if (offset !== len) {
|
|
850
|
+
if (offset !== 0) {
|
|
851
|
+
arg = arg.slice(offset);
|
|
852
|
+
}
|
|
853
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
854
|
+
const view = getUint8ArrayMemory02().subarray(ptr + offset, ptr + len);
|
|
855
|
+
const ret = cachedTextEncoder2.encodeInto(arg, view);
|
|
856
|
+
offset += ret.written;
|
|
857
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
858
|
+
}
|
|
859
|
+
WASM_VECTOR_LEN2 = offset;
|
|
860
|
+
return ptr;
|
|
861
|
+
}
|
|
862
|
+
function takeFromExternrefTable02(idx) {
|
|
863
|
+
const value = wasm2.__wbindgen_externrefs.get(idx);
|
|
864
|
+
wasm2.__externref_table_dealloc(idx);
|
|
865
|
+
return value;
|
|
866
|
+
}
|
|
867
|
+
function decodeText2(ptr, len) {
|
|
868
|
+
numBytesDecoded += len;
|
|
869
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
870
|
+
cachedTextDecoder2 = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
871
|
+
cachedTextDecoder2.decode();
|
|
872
|
+
numBytesDecoded = len;
|
|
873
|
+
}
|
|
874
|
+
return cachedTextDecoder2.decode(getUint8ArrayMemory02().subarray(ptr, ptr + len));
|
|
875
|
+
}
|
|
876
|
+
function __wbg_finalize_init(instance, module2) {
|
|
877
|
+
wasm2 = instance.exports;
|
|
878
|
+
wasmModule2 = module2;
|
|
879
|
+
cachedDataViewMemory02 = null;
|
|
880
|
+
cachedUint8ArrayMemory02 = null;
|
|
881
|
+
wasm2.__wbindgen_start();
|
|
882
|
+
return wasm2;
|
|
883
|
+
}
|
|
884
|
+
async function __wbg_load(module2, imports) {
|
|
885
|
+
if (typeof Response === "function" && module2 instanceof Response) {
|
|
886
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
887
|
+
try {
|
|
888
|
+
return await WebAssembly.instantiateStreaming(module2, imports);
|
|
889
|
+
} catch (e) {
|
|
890
|
+
const validResponse = module2.ok && expectedResponseType(module2.type);
|
|
891
|
+
if (validResponse && module2.headers.get("Content-Type") !== "application/wasm") {
|
|
892
|
+
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);
|
|
893
|
+
} else {
|
|
894
|
+
throw e;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
const bytes = await module2.arrayBuffer();
|
|
899
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
900
|
+
} else {
|
|
901
|
+
const instance = await WebAssembly.instantiate(module2, imports);
|
|
902
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
903
|
+
return { instance, module: module2 };
|
|
904
|
+
} else {
|
|
905
|
+
return instance;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function expectedResponseType(type) {
|
|
909
|
+
switch (type) {
|
|
910
|
+
case "basic":
|
|
911
|
+
case "cors":
|
|
912
|
+
case "default":
|
|
913
|
+
return true;
|
|
914
|
+
}
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function initSync(module2) {
|
|
919
|
+
if (wasm2 !== void 0) return wasm2;
|
|
920
|
+
if (module2 !== void 0) {
|
|
921
|
+
if (Object.getPrototypeOf(module2) === Object.prototype) {
|
|
922
|
+
({ module: module2 } = module2);
|
|
923
|
+
} else {
|
|
924
|
+
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const imports = __wbg_get_imports2();
|
|
928
|
+
if (!(module2 instanceof WebAssembly.Module)) {
|
|
929
|
+
module2 = new WebAssembly.Module(module2);
|
|
930
|
+
}
|
|
931
|
+
const instance = new WebAssembly.Instance(module2, imports);
|
|
932
|
+
return __wbg_finalize_init(instance, module2);
|
|
933
|
+
}
|
|
934
|
+
async function __wbg_init(module_or_path) {
|
|
935
|
+
if (wasm2 !== void 0) return wasm2;
|
|
936
|
+
if (module_or_path !== void 0) {
|
|
937
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
938
|
+
({ module_or_path } = module_or_path);
|
|
939
|
+
} else {
|
|
940
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (module_or_path === void 0) {
|
|
944
|
+
module_or_path = new URL("arkworks_groth16_wasm_bg.wasm", import.meta.url);
|
|
945
|
+
}
|
|
946
|
+
const imports = __wbg_get_imports2();
|
|
947
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
948
|
+
module_or_path = fetch(module_or_path);
|
|
949
|
+
}
|
|
950
|
+
const { instance, module: module2 } = await __wbg_load(await module_or_path, imports);
|
|
951
|
+
return __wbg_finalize_init(instance, module2);
|
|
952
|
+
}
|
|
953
|
+
var cachedDataViewMemory02, cachedUint8ArrayMemory02, cachedTextDecoder2, MAX_SAFARI_DECODE_BYTES, numBytesDecoded, cachedTextEncoder2, WASM_VECTOR_LEN2, wasmModule2, wasm2;
|
|
954
|
+
var init_arkworks_groth16_wasm2 = __esm({
|
|
955
|
+
"src/wasm/web/arkworks_groth16_wasm.js"() {
|
|
956
|
+
"use strict";
|
|
957
|
+
cachedDataViewMemory02 = null;
|
|
958
|
+
cachedUint8ArrayMemory02 = null;
|
|
959
|
+
cachedTextDecoder2 = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
960
|
+
cachedTextDecoder2.decode();
|
|
961
|
+
MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
962
|
+
numBytesDecoded = 0;
|
|
963
|
+
cachedTextEncoder2 = new TextEncoder();
|
|
964
|
+
if (!("encodeInto" in cachedTextEncoder2)) {
|
|
965
|
+
cachedTextEncoder2.encodeInto = function(arg, view) {
|
|
966
|
+
const buf = cachedTextEncoder2.encode(arg);
|
|
967
|
+
view.set(buf);
|
|
968
|
+
return {
|
|
969
|
+
read: arg.length,
|
|
970
|
+
written: buf.length
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
WASM_VECTOR_LEN2 = 0;
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
|
|
106
978
|
// src/infra/provingSystems/ArkworksWasm.ts
|
|
107
979
|
var ArkworksWasm_exports = {};
|
|
108
980
|
__export(ArkworksWasm_exports, {
|
|
@@ -111,6 +983,7 @@ __export(ArkworksWasm_exports, {
|
|
|
111
983
|
});
|
|
112
984
|
import { compile as compile2, createFileManager as createFileManager2 } from "@noir-lang/noir_wasm";
|
|
113
985
|
import { Noir as Noir2 } from "@noir-lang/noir_js";
|
|
986
|
+
import { decompressWitness } from "@noir-lang/acvm_js";
|
|
114
987
|
function stringToStream2(content) {
|
|
115
988
|
return new ReadableStream({
|
|
116
989
|
start(controller) {
|
|
@@ -139,8 +1012,8 @@ function isArkworksCircuit(circuit) {
|
|
|
139
1012
|
return "__arkworks" in circuit && circuit.__arkworks === true;
|
|
140
1013
|
}
|
|
141
1014
|
async function initWasm() {
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
1015
|
+
if (wasmModule3) {
|
|
1016
|
+
return wasmModule3;
|
|
144
1017
|
}
|
|
145
1018
|
if (wasmInitPromise2) {
|
|
146
1019
|
return wasmInitPromise2;
|
|
@@ -148,16 +1021,16 @@ async function initWasm() {
|
|
|
148
1021
|
wasmInitPromise2 = (async () => {
|
|
149
1022
|
try {
|
|
150
1023
|
if (isNodeJs3()) {
|
|
151
|
-
const
|
|
152
|
-
|
|
1024
|
+
const module2 = await Promise.resolve().then(() => (init_arkworks_groth16_wasm(), arkworks_groth16_wasm_exports));
|
|
1025
|
+
wasmModule3 = module2;
|
|
153
1026
|
} else {
|
|
154
|
-
const
|
|
155
|
-
if (typeof
|
|
156
|
-
await
|
|
1027
|
+
const module2 = await Promise.resolve().then(() => (init_arkworks_groth16_wasm2(), arkworks_groth16_wasm_exports2));
|
|
1028
|
+
if (typeof module2.default === "function") {
|
|
1029
|
+
await module2.default();
|
|
157
1030
|
}
|
|
158
|
-
|
|
1031
|
+
wasmModule3 = module2;
|
|
159
1032
|
}
|
|
160
|
-
return
|
|
1033
|
+
return wasmModule3;
|
|
161
1034
|
} catch (error) {
|
|
162
1035
|
wasmInitPromise2 = null;
|
|
163
1036
|
throw new Error(
|
|
@@ -201,11 +1074,11 @@ function hexToBytes(hex) {
|
|
|
201
1074
|
}
|
|
202
1075
|
return bytes;
|
|
203
1076
|
}
|
|
204
|
-
var
|
|
1077
|
+
var wasmModule3, wasmInitPromise2, ArkworksWasm;
|
|
205
1078
|
var init_ArkworksWasm = __esm({
|
|
206
1079
|
"src/infra/provingSystems/ArkworksWasm.ts"() {
|
|
207
1080
|
"use strict";
|
|
208
|
-
|
|
1081
|
+
wasmModule3 = null;
|
|
209
1082
|
wasmInitPromise2 = null;
|
|
210
1083
|
ArkworksWasm = class {
|
|
211
1084
|
config;
|
|
@@ -220,7 +1093,7 @@ var init_ArkworksWasm = __esm({
|
|
|
220
1093
|
* Compile Noir code to a circuit with ACIR for Groth16 proving
|
|
221
1094
|
*/
|
|
222
1095
|
async compile(noirCode) {
|
|
223
|
-
const
|
|
1096
|
+
const wasm3 = await initWasm();
|
|
224
1097
|
const { basePath, cleanup } = await createTempDir2();
|
|
225
1098
|
const fm = createFileManager2(basePath);
|
|
226
1099
|
const nargoToml = `[package]
|
|
@@ -243,37 +1116,74 @@ authors = [""]
|
|
|
243
1116
|
if (!compiled || !compiled.bytecode) {
|
|
244
1117
|
throw new Error("Compilation failed: no bytecode generated");
|
|
245
1118
|
}
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
1119
|
+
const parameters = compiled.abi.parameters;
|
|
1120
|
+
const publicR1csIndices = [];
|
|
1121
|
+
const privateR1csIndices = [];
|
|
1122
|
+
const witnessIndexMapping = /* @__PURE__ */ new Map();
|
|
1123
|
+
parameters.forEach((p, noirIndex) => {
|
|
1124
|
+
const r1csIndex = noirIndex + 1;
|
|
1125
|
+
witnessIndexMapping.set(noirIndex, r1csIndex);
|
|
1126
|
+
console.log(` Parameter "${p.name}" (${p.visibility}): noir[${noirIndex}] \u2192 R1CS w_${r1csIndex}`);
|
|
1127
|
+
if (p.visibility === "public") {
|
|
1128
|
+
publicR1csIndices.push(r1csIndex);
|
|
1129
|
+
} else if (p.visibility === "private") {
|
|
1130
|
+
privateR1csIndices.push(r1csIndex);
|
|
1131
|
+
}
|
|
259
1132
|
});
|
|
1133
|
+
console.log("=== COMPILE: R1CS Witness Assignment ===");
|
|
1134
|
+
console.log("Public R1CS indices:", publicR1csIndices);
|
|
1135
|
+
console.log("Private R1CS indices:", privateR1csIndices);
|
|
1136
|
+
console.log("Witness mapping:", Object.fromEntries(witnessIndexMapping));
|
|
1137
|
+
console.log("=========================================");
|
|
1138
|
+
const r1cs = {
|
|
1139
|
+
num_witnesses: parameters.length + 1,
|
|
1140
|
+
// +1 for w_0
|
|
1141
|
+
public_inputs: publicR1csIndices,
|
|
1142
|
+
private_inputs: privateR1csIndices,
|
|
1143
|
+
constraints: []
|
|
1144
|
+
};
|
|
1145
|
+
if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
1146
|
+
const privateIdx = privateR1csIndices[0];
|
|
1147
|
+
const publicIdx = publicR1csIndices[0];
|
|
1148
|
+
r1cs.constraints.push({
|
|
1149
|
+
a: [["0x1", privateIdx]],
|
|
1150
|
+
// secret
|
|
1151
|
+
b: [["0x1", privateIdx]],
|
|
1152
|
+
// secret
|
|
1153
|
+
c: [["0x1", publicIdx]]
|
|
1154
|
+
// expected
|
|
1155
|
+
});
|
|
1156
|
+
console.log(` Added constraint: w_${privateIdx} * w_${privateIdx} = w_${publicIdx}`);
|
|
1157
|
+
} else {
|
|
1158
|
+
console.warn("Complex circuit detected - R1CS constraint generation may be incomplete");
|
|
1159
|
+
}
|
|
1160
|
+
const r1csJson = JSON.stringify(r1cs);
|
|
1161
|
+
console.log("R1CS JSON:", r1csJson);
|
|
260
1162
|
let provingKey;
|
|
261
1163
|
let verifyingKey;
|
|
262
1164
|
let verifyingKeyGnark;
|
|
263
1165
|
if (this.config.cacheKeys) {
|
|
264
1166
|
try {
|
|
265
|
-
|
|
1167
|
+
console.log("Running trusted setup from R1CS...");
|
|
1168
|
+
const setupResult = wasm3.setup_from_r1cs(r1csJson);
|
|
266
1169
|
provingKey = setupResult.proving_key;
|
|
267
1170
|
verifyingKey = setupResult.verifying_key;
|
|
268
1171
|
verifyingKeyGnark = setupResult.verifying_key_gnark;
|
|
1172
|
+
console.log("Setup complete!");
|
|
269
1173
|
} catch (error) {
|
|
270
|
-
console.
|
|
1174
|
+
console.error("Setup failed:", error);
|
|
1175
|
+
throw new Error(`R1CS setup failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
271
1176
|
}
|
|
272
1177
|
}
|
|
1178
|
+
const acirJson = JSON.stringify({
|
|
1179
|
+
functions: [{ current_witness_index: parameters.length, opcodes: [], private_parameters: privateR1csIndices, public_parameters: { witnesses: publicR1csIndices }, return_values: { witnesses: [] } }]
|
|
1180
|
+
});
|
|
273
1181
|
const arkworksCircuit = {
|
|
274
1182
|
...compiled,
|
|
275
1183
|
__arkworks: true,
|
|
276
1184
|
acirJson,
|
|
1185
|
+
r1csJson,
|
|
1186
|
+
witnessIndexMapping,
|
|
277
1187
|
provingKey,
|
|
278
1188
|
verifyingKey,
|
|
279
1189
|
verifyingKeyGnark
|
|
@@ -289,28 +1199,69 @@ authors = [""]
|
|
|
289
1199
|
* Generate a Groth16 proof
|
|
290
1200
|
*/
|
|
291
1201
|
async generateProof(circuit, inputs) {
|
|
292
|
-
const
|
|
1202
|
+
const wasm3 = await initWasm();
|
|
293
1203
|
if (!isArkworksCircuit(circuit)) {
|
|
294
1204
|
throw new Error(
|
|
295
1205
|
"ArkworksWasm.generateProof requires an ArkworksCompiledCircuit. Use ArkworksWasm.compile() first."
|
|
296
1206
|
);
|
|
297
1207
|
}
|
|
298
1208
|
const noir = new Noir2(circuit);
|
|
299
|
-
const { witness } = await noir.execute(inputs);
|
|
1209
|
+
const { witness: compressedWitness } = await noir.execute(inputs);
|
|
1210
|
+
const witnessMapNoir = decompressWitness(compressedWitness);
|
|
1211
|
+
console.log("=== ARKWORKS WASM DEBUG ===");
|
|
1212
|
+
console.log("Circuit ABI parameters:", circuit.abi.parameters);
|
|
1213
|
+
console.log("Inputs provided:", JSON.stringify(inputs));
|
|
1214
|
+
console.log("Compressed witness size:", compressedWitness.length, "bytes");
|
|
1215
|
+
console.log("Decompressed witness entries:", witnessMapNoir.size);
|
|
1216
|
+
console.log("Witness map entries (first 10):");
|
|
1217
|
+
const sortedWitness = Array.from(witnessMapNoir.entries()).sort(([a], [b]) => a - b);
|
|
1218
|
+
for (const [index, value] of sortedWitness.slice(0, 10)) {
|
|
1219
|
+
const strVal = String(value);
|
|
1220
|
+
console.log(` witness[${index}] = "${strVal.slice(0, 66)}${strVal.length > 66 ? "..." : ""}"`);
|
|
1221
|
+
if (strVal.startsWith("0x")) {
|
|
1222
|
+
try {
|
|
1223
|
+
const decVal = BigInt(strVal).toString(10);
|
|
1224
|
+
console.log(` \u2192 decimal: ${decVal}`);
|
|
1225
|
+
} catch {
|
|
1226
|
+
console.log(` \u2192 failed to parse as BigInt`);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
300
1230
|
const witnessMap = {};
|
|
301
|
-
|
|
302
|
-
|
|
1231
|
+
const witnessMapping = circuit.witnessIndexMapping;
|
|
1232
|
+
console.log("Converting noir witness to R1CS witness:");
|
|
1233
|
+
for (const [noirIndex, value] of witnessMapNoir.entries()) {
|
|
1234
|
+
const r1csIndex = witnessMapping.get(noirIndex) ?? noirIndex + 1;
|
|
1235
|
+
const strVal = String(value);
|
|
1236
|
+
witnessMap[r1csIndex.toString()] = strVal;
|
|
1237
|
+
console.log(` noir[${noirIndex}] \u2192 R1CS w_${r1csIndex} = ${strVal.slice(0, 20)}...`);
|
|
303
1238
|
}
|
|
304
1239
|
const witnessJson = JSON.stringify(witnessMap);
|
|
1240
|
+
console.log("Witness JSON for prove:", witnessJson.slice(0, 200) + "...");
|
|
1241
|
+
const r1csParsed = JSON.parse(circuit.r1csJson);
|
|
1242
|
+
console.log("R1CS public_inputs:", r1csParsed.public_inputs);
|
|
1243
|
+
console.log("R1CS private_inputs:", r1csParsed.private_inputs);
|
|
1244
|
+
console.log("R1CS num_witnesses:", r1csParsed.num_witnesses);
|
|
1245
|
+
console.log("R1CS constraints:", r1csParsed.constraints.length);
|
|
305
1246
|
let provingKey = circuit.provingKey;
|
|
306
1247
|
if (!provingKey) {
|
|
307
|
-
|
|
1248
|
+
console.log("Running setup_from_r1cs...");
|
|
1249
|
+
const setupResult = wasm3.setup_from_r1cs(circuit.r1csJson);
|
|
308
1250
|
provingKey = setupResult.proving_key;
|
|
309
1251
|
circuit.provingKey = provingKey;
|
|
310
1252
|
circuit.verifyingKey = setupResult.verifying_key;
|
|
311
1253
|
circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;
|
|
312
1254
|
}
|
|
313
|
-
|
|
1255
|
+
console.log("Generating proof from R1CS...");
|
|
1256
|
+
const proofResult = wasm3.prove_from_r1cs(provingKey, circuit.r1csJson, witnessJson);
|
|
1257
|
+
console.log("=== PROOF RESULT DEBUG ===");
|
|
1258
|
+
console.log("Proof public inputs from arkworks:", proofResult.public_inputs);
|
|
1259
|
+
proofResult.public_inputs.forEach((input, i) => {
|
|
1260
|
+
const hexValue = input.startsWith("0x") ? input : `0x${input}`;
|
|
1261
|
+
const decValue = BigInt(hexValue).toString(10);
|
|
1262
|
+
console.log(` Public input ${i}: ${input} (dec: ${decValue})`);
|
|
1263
|
+
});
|
|
1264
|
+
console.log("===========================");
|
|
314
1265
|
const proofBytes = base64ToUint8Array(proofResult.proof_gnark);
|
|
315
1266
|
return {
|
|
316
1267
|
proof: proofBytes,
|
|
@@ -321,7 +1272,7 @@ authors = [""]
|
|
|
321
1272
|
* Verify a Groth16 proof
|
|
322
1273
|
*/
|
|
323
1274
|
async verifyProof(circuit, proof, publicInputs) {
|
|
324
|
-
const
|
|
1275
|
+
const wasm3 = await initWasm();
|
|
325
1276
|
if (!isArkworksCircuit(circuit)) {
|
|
326
1277
|
throw new Error(
|
|
327
1278
|
"ArkworksWasm.verifyProof requires an ArkworksCompiledCircuit. Use ArkworksWasm.compile() first."
|
|
@@ -329,7 +1280,7 @@ authors = [""]
|
|
|
329
1280
|
}
|
|
330
1281
|
let verifyingKeyGnark = circuit.verifyingKeyGnark;
|
|
331
1282
|
if (!verifyingKeyGnark) {
|
|
332
|
-
const setupResult =
|
|
1283
|
+
const setupResult = wasm3.setup_from_r1cs(circuit.r1csJson);
|
|
333
1284
|
circuit.provingKey = setupResult.proving_key;
|
|
334
1285
|
circuit.verifyingKey = setupResult.verifying_key;
|
|
335
1286
|
verifyingKeyGnark = setupResult.verifying_key_gnark;
|
|
@@ -337,7 +1288,7 @@ authors = [""]
|
|
|
337
1288
|
}
|
|
338
1289
|
const proofB64 = uint8ArrayToBase64(proof);
|
|
339
1290
|
const publicInputsGnarkB64 = publicInputsToGnarkBase64(publicInputs);
|
|
340
|
-
return
|
|
1291
|
+
return wasm3.verify_gnark(
|
|
341
1292
|
verifyingKeyGnark,
|
|
342
1293
|
proofB64,
|
|
343
1294
|
publicInputsGnarkB64,
|
|
@@ -348,12 +1299,12 @@ authors = [""]
|
|
|
348
1299
|
* Get the verifying key in gnark format for on-chain deployment
|
|
349
1300
|
*/
|
|
350
1301
|
async getVerifyingKeyGnark(circuit) {
|
|
351
|
-
const
|
|
1302
|
+
const wasm3 = await initWasm();
|
|
352
1303
|
if (!isArkworksCircuit(circuit)) {
|
|
353
1304
|
throw new Error("getVerifyingKeyGnark requires an ArkworksCompiledCircuit");
|
|
354
1305
|
}
|
|
355
1306
|
if (!circuit.verifyingKeyGnark) {
|
|
356
|
-
const setupResult =
|
|
1307
|
+
const setupResult = wasm3.setup_from_r1cs(circuit.r1csJson);
|
|
357
1308
|
circuit.provingKey = setupResult.proving_key;
|
|
358
1309
|
circuit.verifyingKey = setupResult.verifying_key;
|
|
359
1310
|
circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;
|