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