@midnightntwrk/zkir-v2 2.1.0

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.
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./midnight_zkir_wasm_bg.wasm";
2
+ export * from "./midnight_zkir_wasm_bg.js";
3
+ import { __wbg_set_wasm } from "./midnight_zkir_wasm_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
@@ -0,0 +1,818 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
+
18
+ cachedTextDecoder.decode();
19
+
20
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
+ let numBytesDecoded = 0;
22
+ function decodeText(ptr, len) {
23
+ numBytesDecoded += len;
24
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+ cachedTextDecoder.decode();
27
+ numBytesDecoded = len;
28
+ }
29
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ }
31
+
32
+ function getStringFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ return decodeText(ptr, len);
35
+ }
36
+
37
+ function isLikeNone(x) {
38
+ return x === undefined || x === null;
39
+ }
40
+
41
+ function addToExternrefTable0(obj) {
42
+ const idx = wasm.__externref_table_alloc();
43
+ wasm.__wbindgen_export_1.set(idx, obj);
44
+ return idx;
45
+ }
46
+
47
+ function handleError(f, args) {
48
+ try {
49
+ return f.apply(this, args);
50
+ } catch (e) {
51
+ const idx = addToExternrefTable0(e);
52
+ wasm.__wbindgen_exn_store(idx);
53
+ }
54
+ }
55
+
56
+ function getArrayU8FromWasm0(ptr, len) {
57
+ ptr = ptr >>> 0;
58
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
59
+ }
60
+
61
+ let WASM_VECTOR_LEN = 0;
62
+
63
+ const cachedTextEncoder = new TextEncoder();
64
+
65
+ if (!('encodeInto' in cachedTextEncoder)) {
66
+ cachedTextEncoder.encodeInto = function (arg, view) {
67
+ const buf = cachedTextEncoder.encode(arg);
68
+ view.set(buf);
69
+ return {
70
+ read: arg.length,
71
+ written: buf.length
72
+ };
73
+ }
74
+ }
75
+
76
+ function passStringToWasm0(arg, malloc, realloc) {
77
+
78
+ if (realloc === undefined) {
79
+ const buf = cachedTextEncoder.encode(arg);
80
+ const ptr = malloc(buf.length, 1) >>> 0;
81
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
82
+ WASM_VECTOR_LEN = buf.length;
83
+ return ptr;
84
+ }
85
+
86
+ let len = arg.length;
87
+ let ptr = malloc(len, 1) >>> 0;
88
+
89
+ const mem = getUint8ArrayMemory0();
90
+
91
+ let offset = 0;
92
+
93
+ for (; offset < len; offset++) {
94
+ const code = arg.charCodeAt(offset);
95
+ if (code > 0x7F) break;
96
+ mem[ptr + offset] = code;
97
+ }
98
+
99
+ if (offset !== len) {
100
+ if (offset !== 0) {
101
+ arg = arg.slice(offset);
102
+ }
103
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
104
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
105
+ const ret = cachedTextEncoder.encodeInto(arg, view);
106
+
107
+ offset += ret.written;
108
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
109
+ }
110
+
111
+ WASM_VECTOR_LEN = offset;
112
+ return ptr;
113
+ }
114
+
115
+ let cachedDataViewMemory0 = null;
116
+
117
+ function getDataViewMemory0() {
118
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
119
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
120
+ }
121
+ return cachedDataViewMemory0;
122
+ }
123
+
124
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
125
+ ? { register: () => {}, unregister: () => {} }
126
+ : new FinalizationRegistry(
127
+ state => {
128
+ wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b);
129
+ }
130
+ );
131
+
132
+ function makeMutClosure(arg0, arg1, dtor, f) {
133
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
134
+ const real = (...args) => {
135
+
136
+ // First up with a closure we increment the internal reference
137
+ // count. This ensures that the Rust closure environment won't
138
+ // be deallocated while we're invoking it.
139
+ state.cnt++;
140
+ const a = state.a;
141
+ state.a = 0;
142
+ try {
143
+ return f(a, state.b, ...args);
144
+ } finally {
145
+ if (--state.cnt === 0) {
146
+ wasm.__wbindgen_export_5.get(state.dtor)(a, state.b);
147
+ CLOSURE_DTORS.unregister(state);
148
+ } else {
149
+ state.a = a;
150
+ }
151
+ }
152
+ };
153
+ real.original = state;
154
+ CLOSURE_DTORS.register(real, state, state);
155
+ return real;
156
+ }
157
+
158
+ function getArrayJsValueFromWasm0(ptr, len) {
159
+ ptr = ptr >>> 0;
160
+ const mem = getDataViewMemory0();
161
+ const result = [];
162
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
163
+ result.push(wasm.__wbindgen_export_1.get(mem.getUint32(i, true)));
164
+ }
165
+ wasm.__externref_drop_slice(ptr, len);
166
+ return result;
167
+ }
168
+ /**
169
+ * @param {Uint8Array} ser_preimage
170
+ * @param {any} provider
171
+ * @returns {Promise<any[]>}
172
+ */
173
+ export function check(ser_preimage, provider) {
174
+ const ret = wasm.check(ser_preimage, provider);
175
+ return ret;
176
+ }
177
+
178
+ /**
179
+ * @param {any} km_provider
180
+ * @returns {WrappedProvingProvider}
181
+ */
182
+ export function provingProvider(km_provider) {
183
+ const ret = wasm.provingProvider(km_provider);
184
+ return WrappedProvingProvider.__wrap(ret);
185
+ }
186
+
187
+ /**
188
+ * @param {Uint8Array} ser_preimage
189
+ * @param {any} provider
190
+ * @param {bigint | null} [overwrite_binding_input]
191
+ * @returns {Promise<Uint8Array>}
192
+ */
193
+ export function prove(ser_preimage, provider, overwrite_binding_input) {
194
+ const ret = wasm.prove(ser_preimage, provider, isLikeNone(overwrite_binding_input) ? 0 : addToExternrefTable0(overwrite_binding_input));
195
+ return ret;
196
+ }
197
+
198
+ function takeFromExternrefTable0(idx) {
199
+ const value = wasm.__wbindgen_export_1.get(idx);
200
+ wasm.__externref_table_dealloc(idx);
201
+ return value;
202
+ }
203
+ /**
204
+ * @param {string} json
205
+ * @returns {Uint8Array}
206
+ */
207
+ export function jsonIrToBinary(json) {
208
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
209
+ const len0 = WASM_VECTOR_LEN;
210
+ const ret = wasm.jsonIrToBinary(ptr0, len0);
211
+ if (ret[2]) {
212
+ throw takeFromExternrefTable0(ret[1]);
213
+ }
214
+ return takeFromExternrefTable0(ret[0]);
215
+ }
216
+
217
+ function __wbg_adapter_12(arg0, arg1, arg2) {
218
+ wasm.closure1572_externref_shim(arg0, arg1, arg2);
219
+ }
220
+
221
+ function __wbg_adapter_104(arg0, arg1, arg2, arg3) {
222
+ wasm.closure1634_externref_shim(arg0, arg1, arg2, arg3);
223
+ }
224
+
225
+ const __wbindgen_enum_ReadableStreamType = ["bytes"];
226
+
227
+ const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined')
228
+ ? { register: () => {}, unregister: () => {} }
229
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1));
230
+
231
+ export class IntoUnderlyingByteSource {
232
+
233
+ __destroy_into_raw() {
234
+ const ptr = this.__wbg_ptr;
235
+ this.__wbg_ptr = 0;
236
+ IntoUnderlyingByteSourceFinalization.unregister(this);
237
+ return ptr;
238
+ }
239
+
240
+ free() {
241
+ const ptr = this.__destroy_into_raw();
242
+ wasm.__wbg_intounderlyingbytesource_free(ptr, 0);
243
+ }
244
+ /**
245
+ * @returns {number}
246
+ */
247
+ get autoAllocateChunkSize() {
248
+ const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr);
249
+ return ret >>> 0;
250
+ }
251
+ /**
252
+ * @param {ReadableByteStreamController} controller
253
+ * @returns {Promise<any>}
254
+ */
255
+ pull(controller) {
256
+ const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, controller);
257
+ return ret;
258
+ }
259
+ /**
260
+ * @param {ReadableByteStreamController} controller
261
+ */
262
+ start(controller) {
263
+ wasm.intounderlyingbytesource_start(this.__wbg_ptr, controller);
264
+ }
265
+ /**
266
+ * @returns {ReadableStreamType}
267
+ */
268
+ get type() {
269
+ const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr);
270
+ return __wbindgen_enum_ReadableStreamType[ret];
271
+ }
272
+ cancel() {
273
+ const ptr = this.__destroy_into_raw();
274
+ wasm.intounderlyingbytesource_cancel(ptr);
275
+ }
276
+ }
277
+ if (Symbol.dispose) IntoUnderlyingByteSource.prototype[Symbol.dispose] = IntoUnderlyingByteSource.prototype.free;
278
+
279
+ const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined')
280
+ ? { register: () => {}, unregister: () => {} }
281
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1));
282
+
283
+ export class IntoUnderlyingSink {
284
+
285
+ __destroy_into_raw() {
286
+ const ptr = this.__wbg_ptr;
287
+ this.__wbg_ptr = 0;
288
+ IntoUnderlyingSinkFinalization.unregister(this);
289
+ return ptr;
290
+ }
291
+
292
+ free() {
293
+ const ptr = this.__destroy_into_raw();
294
+ wasm.__wbg_intounderlyingsink_free(ptr, 0);
295
+ }
296
+ /**
297
+ * @param {any} reason
298
+ * @returns {Promise<any>}
299
+ */
300
+ abort(reason) {
301
+ const ptr = this.__destroy_into_raw();
302
+ const ret = wasm.intounderlyingsink_abort(ptr, reason);
303
+ return ret;
304
+ }
305
+ /**
306
+ * @returns {Promise<any>}
307
+ */
308
+ close() {
309
+ const ptr = this.__destroy_into_raw();
310
+ const ret = wasm.intounderlyingsink_close(ptr);
311
+ return ret;
312
+ }
313
+ /**
314
+ * @param {any} chunk
315
+ * @returns {Promise<any>}
316
+ */
317
+ write(chunk) {
318
+ const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk);
319
+ return ret;
320
+ }
321
+ }
322
+ if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free;
323
+
324
+ const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
325
+ ? { register: () => {}, unregister: () => {} }
326
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
327
+
328
+ export class IntoUnderlyingSource {
329
+
330
+ __destroy_into_raw() {
331
+ const ptr = this.__wbg_ptr;
332
+ this.__wbg_ptr = 0;
333
+ IntoUnderlyingSourceFinalization.unregister(this);
334
+ return ptr;
335
+ }
336
+
337
+ free() {
338
+ const ptr = this.__destroy_into_raw();
339
+ wasm.__wbg_intounderlyingsource_free(ptr, 0);
340
+ }
341
+ /**
342
+ * @param {ReadableStreamDefaultController} controller
343
+ * @returns {Promise<any>}
344
+ */
345
+ pull(controller) {
346
+ const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller);
347
+ return ret;
348
+ }
349
+ cancel() {
350
+ const ptr = this.__destroy_into_raw();
351
+ wasm.intounderlyingsource_cancel(ptr);
352
+ }
353
+ }
354
+ if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
355
+
356
+ const WrappedProvingProviderFinalization = (typeof FinalizationRegistry === 'undefined')
357
+ ? { register: () => {}, unregister: () => {} }
358
+ : new FinalizationRegistry(ptr => wasm.__wbg_wrappedprovingprovider_free(ptr >>> 0, 1));
359
+
360
+ export class WrappedProvingProvider {
361
+
362
+ static __wrap(ptr) {
363
+ ptr = ptr >>> 0;
364
+ const obj = Object.create(WrappedProvingProvider.prototype);
365
+ obj.__wbg_ptr = ptr;
366
+ WrappedProvingProviderFinalization.register(obj, obj.__wbg_ptr, obj);
367
+ return obj;
368
+ }
369
+
370
+ __destroy_into_raw() {
371
+ const ptr = this.__wbg_ptr;
372
+ this.__wbg_ptr = 0;
373
+ WrappedProvingProviderFinalization.unregister(this);
374
+ return ptr;
375
+ }
376
+
377
+ free() {
378
+ const ptr = this.__destroy_into_raw();
379
+ wasm.__wbg_wrappedprovingprovider_free(ptr, 0);
380
+ }
381
+ /**
382
+ * @param {Uint8Array} ser_preimage
383
+ * @param {string} _key_location
384
+ * @returns {Promise<any[]>}
385
+ */
386
+ check(ser_preimage, _key_location) {
387
+ const ptr0 = passStringToWasm0(_key_location, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
388
+ const len0 = WASM_VECTOR_LEN;
389
+ const ret = wasm.wrappedprovingprovider_check(this.__wbg_ptr, ser_preimage, ptr0, len0);
390
+ return ret;
391
+ }
392
+ /**
393
+ * @param {Uint8Array} ser_preimage
394
+ * @param {string} _key_location
395
+ * @param {bigint | null} [overwrite_binding_input]
396
+ * @returns {Promise<Uint8Array>}
397
+ */
398
+ prove(ser_preimage, _key_location, overwrite_binding_input) {
399
+ const ptr0 = passStringToWasm0(_key_location, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
400
+ const len0 = WASM_VECTOR_LEN;
401
+ const ret = wasm.wrappedprovingprovider_prove(this.__wbg_ptr, ser_preimage, ptr0, len0, isLikeNone(overwrite_binding_input) ? 0 : addToExternrefTable0(overwrite_binding_input));
402
+ return ret;
403
+ }
404
+ }
405
+ if (Symbol.dispose) WrappedProvingProvider.prototype[Symbol.dispose] = WrappedProvingProvider.prototype.free;
406
+
407
+ const ZkirFinalization = (typeof FinalizationRegistry === 'undefined')
408
+ ? { register: () => {}, unregister: () => {} }
409
+ : new FinalizationRegistry(ptr => wasm.__wbg_zkir_free(ptr >>> 0, 1));
410
+
411
+ export class Zkir {
412
+
413
+ static __wrap(ptr) {
414
+ ptr = ptr >>> 0;
415
+ const obj = Object.create(Zkir.prototype);
416
+ obj.__wbg_ptr = ptr;
417
+ ZkirFinalization.register(obj, obj.__wbg_ptr, obj);
418
+ return obj;
419
+ }
420
+
421
+ __destroy_into_raw() {
422
+ const ptr = this.__wbg_ptr;
423
+ this.__wbg_ptr = 0;
424
+ ZkirFinalization.unregister(this);
425
+ return ptr;
426
+ }
427
+
428
+ free() {
429
+ const ptr = this.__destroy_into_raw();
430
+ wasm.__wbg_zkir_free(ptr, 0);
431
+ }
432
+ /**
433
+ * @param {Uint8Array} bytes
434
+ * @returns {Zkir}
435
+ */
436
+ static deserialize(bytes) {
437
+ const ret = wasm.zkir_deserialize(bytes);
438
+ if (ret[2]) {
439
+ throw takeFromExternrefTable0(ret[1]);
440
+ }
441
+ return Zkir.__wrap(ret[0]);
442
+ }
443
+ constructor() {
444
+ const ret = wasm.zkir_new();
445
+ if (ret[2]) {
446
+ throw takeFromExternrefTable0(ret[1]);
447
+ }
448
+ this.__wbg_ptr = ret[0] >>> 0;
449
+ ZkirFinalization.register(this, this.__wbg_ptr, this);
450
+ return this;
451
+ }
452
+ /**
453
+ * @returns {number}
454
+ */
455
+ getK() {
456
+ const ret = wasm.zkir_getK(this.__wbg_ptr);
457
+ return ret;
458
+ }
459
+ /**
460
+ * @param {string} json
461
+ * @returns {Zkir}
462
+ */
463
+ static fromJson(json) {
464
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
465
+ const len0 = WASM_VECTOR_LEN;
466
+ const ret = wasm.zkir_fromJson(ptr0, len0);
467
+ if (ret[2]) {
468
+ throw takeFromExternrefTable0(ret[1]);
469
+ }
470
+ return Zkir.__wrap(ret[0]);
471
+ }
472
+ /**
473
+ * @returns {Uint8Array}
474
+ */
475
+ serialize() {
476
+ const ret = wasm.zkir_serialize(this.__wbg_ptr);
477
+ if (ret[2]) {
478
+ throw takeFromExternrefTable0(ret[1]);
479
+ }
480
+ return takeFromExternrefTable0(ret[0]);
481
+ }
482
+ }
483
+ if (Symbol.dispose) Zkir.prototype[Symbol.dispose] = Zkir.prototype.free;
484
+
485
+ export function __wbg_BigInt_6adbfd8eb0f7ec07(arg0) {
486
+ const ret = BigInt(arg0);
487
+ return ret;
488
+ };
489
+
490
+ export function __wbg_Error_e17e777aac105295(arg0, arg1) {
491
+ const ret = Error(getStringFromWasm0(arg0, arg1));
492
+ return ret;
493
+ };
494
+
495
+ export function __wbg_buffer_8d40b1d762fb3c66(arg0) {
496
+ const ret = arg0.buffer;
497
+ return ret;
498
+ };
499
+
500
+ export function __wbg_byobRequest_2c036bceca1e6037(arg0) {
501
+ const ret = arg0.byobRequest;
502
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
503
+ };
504
+
505
+ export function __wbg_byteLength_331a6b5545834024(arg0) {
506
+ const ret = arg0.byteLength;
507
+ return ret;
508
+ };
509
+
510
+ export function __wbg_byteOffset_49a5b5608000358b(arg0) {
511
+ const ret = arg0.byteOffset;
512
+ return ret;
513
+ };
514
+
515
+ export function __wbg_call_13410aac570ffff7() { return handleError(function (arg0, arg1) {
516
+ const ret = arg0.call(arg1);
517
+ return ret;
518
+ }, arguments) };
519
+
520
+ export function __wbg_call_a5400b25a865cfd8() { return handleError(function (arg0, arg1, arg2) {
521
+ const ret = arg0.call(arg1, arg2);
522
+ return ret;
523
+ }, arguments) };
524
+
525
+ export function __wbg_close_cccada6053ee3a65() { return handleError(function (arg0) {
526
+ arg0.close();
527
+ }, arguments) };
528
+
529
+ export function __wbg_close_d71a78219dc23e91() { return handleError(function (arg0) {
530
+ arg0.close();
531
+ }, arguments) };
532
+
533
+ export function __wbg_crypto_86f2631e91b51511(arg0) {
534
+ const ret = arg0.crypto;
535
+ return ret;
536
+ };
537
+
538
+ export function __wbg_enqueue_452bc2343d1c2ff9() { return handleError(function (arg0, arg1) {
539
+ arg0.enqueue(arg1);
540
+ }, arguments) };
541
+
542
+ export function __wbg_getRandomValues_b3f15fcbfabb0f8b() { return handleError(function (arg0, arg1) {
543
+ arg0.getRandomValues(arg1);
544
+ }, arguments) };
545
+
546
+ export function __wbg_get_458e874b43b18b25() { return handleError(function (arg0, arg1) {
547
+ const ret = Reflect.get(arg0, arg1);
548
+ return ret;
549
+ }, arguments) };
550
+
551
+ export function __wbg_instanceof_Promise_3ec9e849bf41bdb6(arg0) {
552
+ let result;
553
+ try {
554
+ result = arg0 instanceof Promise;
555
+ } catch (_) {
556
+ result = false;
557
+ }
558
+ const ret = result;
559
+ return ret;
560
+ };
561
+
562
+ export function __wbg_instanceof_Uint8Array_9a8378d955933db7(arg0) {
563
+ let result;
564
+ try {
565
+ result = arg0 instanceof Uint8Array;
566
+ } catch (_) {
567
+ result = false;
568
+ }
569
+ const ret = result;
570
+ return ret;
571
+ };
572
+
573
+ export function __wbg_length_6bb7e81f9d7713e4(arg0) {
574
+ const ret = arg0.length;
575
+ return ret;
576
+ };
577
+
578
+ export function __wbg_msCrypto_d562bbe83e0d4b91(arg0) {
579
+ const ret = arg0.msCrypto;
580
+ return ret;
581
+ };
582
+
583
+ export function __wbg_new_2e3c58a15f39f5f9(arg0, arg1) {
584
+ try {
585
+ var state0 = {a: arg0, b: arg1};
586
+ var cb0 = (arg0, arg1) => {
587
+ const a = state0.a;
588
+ state0.a = 0;
589
+ try {
590
+ return __wbg_adapter_104(a, state0.b, arg0, arg1);
591
+ } finally {
592
+ state0.a = a;
593
+ }
594
+ };
595
+ const ret = new Promise(cb0);
596
+ return ret;
597
+ } finally {
598
+ state0.a = state0.b = 0;
599
+ }
600
+ };
601
+
602
+ export function __wbg_new_da9dc54c5db29dfa(arg0, arg1) {
603
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
604
+ return ret;
605
+ };
606
+
607
+ export function __wbg_newfromslice_074c56947bd43469(arg0, arg1) {
608
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
609
+ return ret;
610
+ };
611
+
612
+ export function __wbg_newnoargs_254190557c45b4ec(arg0, arg1) {
613
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
614
+ return ret;
615
+ };
616
+
617
+ export function __wbg_newwithbyteoffsetandlength_e8f53910b4d42b45(arg0, arg1, arg2) {
618
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
619
+ return ret;
620
+ };
621
+
622
+ export function __wbg_newwithlength_a167dcc7aaa3ba77(arg0) {
623
+ const ret = new Uint8Array(arg0 >>> 0);
624
+ return ret;
625
+ };
626
+
627
+ export function __wbg_node_e1f24f89a7336c2e(arg0) {
628
+ const ret = arg0.node;
629
+ return ret;
630
+ };
631
+
632
+ export function __wbg_process_3975fd6c72f520aa(arg0) {
633
+ const ret = arg0.process;
634
+ return ret;
635
+ };
636
+
637
+ export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
638
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
639
+ };
640
+
641
+ export function __wbg_queueMicrotask_25d0739ac89e8c88(arg0) {
642
+ queueMicrotask(arg0);
643
+ };
644
+
645
+ export function __wbg_queueMicrotask_4488407636f5bf24(arg0) {
646
+ const ret = arg0.queueMicrotask;
647
+ return ret;
648
+ };
649
+
650
+ export function __wbg_randomFillSync_f8c153b79f285817() { return handleError(function (arg0, arg1) {
651
+ arg0.randomFillSync(arg1);
652
+ }, arguments) };
653
+
654
+ export function __wbg_require_b74f47fc2d022fd6() { return handleError(function () {
655
+ const ret = module.require;
656
+ return ret;
657
+ }, arguments) };
658
+
659
+ export function __wbg_resolve_4055c623acdd6a1b(arg0) {
660
+ const ret = Promise.resolve(arg0);
661
+ return ret;
662
+ };
663
+
664
+ export function __wbg_respond_6c2c4e20ef85138e() { return handleError(function (arg0, arg1) {
665
+ arg0.respond(arg1 >>> 0);
666
+ }, arguments) };
667
+
668
+ export function __wbg_set_1353b2a5e96bc48c(arg0, arg1, arg2) {
669
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
670
+ };
671
+
672
+ export function __wbg_static_accessor_GLOBAL_8921f820c2ce3f12() {
673
+ const ret = typeof global === 'undefined' ? null : global;
674
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
675
+ };
676
+
677
+ export function __wbg_static_accessor_GLOBAL_THIS_f0a4409105898184() {
678
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
679
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
680
+ };
681
+
682
+ export function __wbg_static_accessor_SELF_995b214ae681ff99() {
683
+ const ret = typeof self === 'undefined' ? null : self;
684
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
685
+ };
686
+
687
+ export function __wbg_static_accessor_WINDOW_cde3890479c675ea() {
688
+ const ret = typeof window === 'undefined' ? null : window;
689
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
690
+ };
691
+
692
+ export function __wbg_subarray_70fd07feefe14294(arg0, arg1, arg2) {
693
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
694
+ return ret;
695
+ };
696
+
697
+ export function __wbg_then_b33a773d723afa3e(arg0, arg1, arg2) {
698
+ const ret = arg0.then(arg1, arg2);
699
+ return ret;
700
+ };
701
+
702
+ export function __wbg_then_e22500defe16819f(arg0, arg1) {
703
+ const ret = arg0.then(arg1);
704
+ return ret;
705
+ };
706
+
707
+ export function __wbg_toString_7268338f40012a03() { return handleError(function (arg0, arg1) {
708
+ const ret = arg0.toString(arg1);
709
+ return ret;
710
+ }, arguments) };
711
+
712
+ export function __wbg_toString_d8f537919ef401d6(arg0) {
713
+ const ret = arg0.toString();
714
+ return ret;
715
+ };
716
+
717
+ export function __wbg_versions_4e31226f5e8dc909(arg0) {
718
+ const ret = arg0.versions;
719
+ return ret;
720
+ };
721
+
722
+ export function __wbg_view_91cc97d57ab30530(arg0) {
723
+ const ret = arg0.view;
724
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
725
+ };
726
+
727
+ export function __wbg_wbindgencbdrop_eb10308566512b88(arg0) {
728
+ const obj = arg0.original;
729
+ if (obj.cnt-- == 1) {
730
+ obj.a = 0;
731
+ return true;
732
+ }
733
+ const ret = false;
734
+ return ret;
735
+ };
736
+
737
+ export function __wbg_wbindgenisfunction_8cee7dce3725ae74(arg0) {
738
+ const ret = typeof(arg0) === 'function';
739
+ return ret;
740
+ };
741
+
742
+ export function __wbg_wbindgenisnull_f3037694abe4d97a(arg0) {
743
+ const ret = arg0 === null;
744
+ return ret;
745
+ };
746
+
747
+ export function __wbg_wbindgenisobject_307a53c6bd97fbf8(arg0) {
748
+ const val = arg0;
749
+ const ret = typeof(val) === 'object' && val !== null;
750
+ return ret;
751
+ };
752
+
753
+ export function __wbg_wbindgenisstring_d4fa939789f003b0(arg0) {
754
+ const ret = typeof(arg0) === 'string';
755
+ return ret;
756
+ };
757
+
758
+ export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
759
+ const ret = arg0 === undefined;
760
+ return ret;
761
+ };
762
+
763
+ export function __wbg_wbindgenstringget_0f16a6ddddef376f(arg0, arg1) {
764
+ const obj = arg1;
765
+ const ret = typeof(obj) === 'string' ? obj : undefined;
766
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
767
+ var len1 = WASM_VECTOR_LEN;
768
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
769
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
770
+ };
771
+
772
+ export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
773
+ throw new Error(getStringFromWasm0(arg0, arg1));
774
+ };
775
+
776
+ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
777
+ // Cast intrinsic for `Ref(String) -> Externref`.
778
+ const ret = getStringFromWasm0(arg0, arg1);
779
+ return ret;
780
+ };
781
+
782
+ export function __wbindgen_cast_64046a632493e65c(arg0, arg1) {
783
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1571, function: Function { arguments: [Externref], shim_idx: 1572, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
784
+ const ret = makeMutClosure(arg0, arg1, 1571, __wbg_adapter_12);
785
+ return ret;
786
+ };
787
+
788
+ export function __wbindgen_cast_cb9088102bce6b30(arg0, arg1) {
789
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
790
+ const ret = getArrayU8FromWasm0(arg0, arg1);
791
+ return ret;
792
+ };
793
+
794
+ export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
795
+ // Cast intrinsic for `F64 -> Externref`.
796
+ const ret = arg0;
797
+ return ret;
798
+ };
799
+
800
+ export function __wbindgen_cast_e481686c74984159(arg0, arg1) {
801
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
802
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
803
+ // Cast intrinsic for `Vector(Externref) -> Externref`.
804
+ const ret = v0;
805
+ return ret;
806
+ };
807
+
808
+ export function __wbindgen_init_externref_table() {
809
+ const table = wasm.__wbindgen_export_1;
810
+ const offset = table.grow(4);
811
+ table.set(0, undefined);
812
+ table.set(offset + 0, undefined);
813
+ table.set(offset + 1, null);
814
+ table.set(offset + 2, true);
815
+ table.set(offset + 3, false);
816
+ ;
817
+ };
818
+
Binary file
@@ -0,0 +1,22 @@
1
+ export * from "./midnight_zkir_wasm_bg.js";
2
+ import * as exports from "./midnight_zkir_wasm_bg.js";
3
+ import { __wbg_set_wasm } from "./midnight_zkir_wasm_bg.js";
4
+ import { readFileSync } from 'fs';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ let imports = {};
9
+ imports['./midnight_zkir_wasm_bg.js'] = exports;
10
+
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+ const wasmPath = join(__dirname, 'midnight_zkir_wasm_bg.wasm');
15
+ const bytes = readFileSync(wasmPath);
16
+
17
+ const wasmModule = new WebAssembly.Module(bytes);
18
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
19
+ const wasm = wasmInstance.exports;
20
+
21
+ __wbg_set_wasm(wasm);
22
+ wasm.__wbindgen_start();
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@midnightntwrk/zkir-v2",
3
+ "version": "2.1.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "@midnightntwrk/zkir-v2",
9
+ "version": "2.1.0"
10
+ }
11
+ }
12
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@midnightntwrk/zkir-v2",
3
+ "version": "2.1.0",
4
+ "type": "module",
5
+ "files": [
6
+ "midnight_zkir_wasm.js",
7
+ "midnight_zkir_wasm_fs.js",
8
+ "midnight_zkir_wasm_bg.js",
9
+ "midnight_zkir_wasm_bg.wasm",
10
+ "zkir-v2.d.ts",
11
+ "snippets"
12
+ ],
13
+ "sideEffects": [
14
+ "./midnight_zkir_wasm.js",
15
+ "./midnight_zkir_wasm_fs.js",
16
+ "./snippets/*"
17
+ ],
18
+ "imports": {
19
+ "#self": {
20
+ "browser": "./midnight_zkir_wasm.js",
21
+ "node": "./midnight_zkir_wasm_fs.js"
22
+ }
23
+ },
24
+ "types": "./zkir-v2.d.ts",
25
+ "exports": {
26
+ "types": "./zkir-v2.d.ts",
27
+ "browser": "./midnight_zkir_wasm.js",
28
+ "node": "./midnight_zkir_wasm_fs.js"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/midnightntwrk/midnight-ledger.git"
33
+ }
34
+ }
package/zkir-v2.d.ts ADDED
@@ -0,0 +1,47 @@
1
+
2
+ export type ProvingProvider = {
3
+ check(
4
+ serializedPreimage: Uint8Array,
5
+ keyLocation: string,
6
+ ): Promise<(bigint | undefined)[]>;
7
+ prove(
8
+ serializedPreimage: Uint8Array,
9
+ keyLocation: string,
10
+ overwriteBindingInput?: bigint,
11
+ ): Promise<Uint8Array>;
12
+ };
13
+
14
+ export type ProvingKeyMaterial = {
15
+ proverKey: Uint8Array,
16
+ verifierKey: Uint8Array,
17
+ ir: Uint8Array,
18
+ };
19
+
20
+ export type KeyMaterialProvider = {
21
+ lookupKey(keyLocation: string): Promise<ProvingKeyMaterial | undefined>;
22
+ getParams(k: number): Promise<Uint8Array>;
23
+ }
24
+
25
+ export function prove(
26
+ serializedPreimage: Uint8Array,
27
+ provider: KeyMaterialProvider,
28
+ overwriteBindingInput?: bigint,
29
+ ): Promise<Uint8Array>;
30
+
31
+ export function check(
32
+ serializedPreimage: Uint8Array,
33
+ provider: KeyMaterialProvider,
34
+ ): Promise<(bigint | undefined)[]>;
35
+
36
+ export function provingProvider(kmProvider: KeyMaterialProvider): ProvingProvider;
37
+
38
+ export function jsonIrToBinary(json: String): Uint8Array;
39
+
40
+ export class Zkir {
41
+ static fromJson(json: string): Zkir;
42
+ static deserialize(bytes: Uint8Array): Zkir;
43
+
44
+ private constructor();
45
+ getK(): number;
46
+ serialize(): Uint8Array;
47
+ }