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