@matterlabs/ethproofs-airbender-verifier 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterlabs/ethproofs-airbender-verifier",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Airbender ZK Proof Verifier for EthProofs",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proof_verifier_wasm",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "files": [
7
7
  "proof_verifier_wasm_bg.wasm",
@@ -2,17 +2,17 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  export class ProofHandle {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
8
  }
9
9
 
10
10
  export class VerifyResult {
11
- private constructor();
12
- free(): void;
13
- [Symbol.dispose](): void;
14
- error(): any | undefined;
15
- readonly success: boolean;
11
+ private constructor();
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ error(): any | undefined;
15
+ readonly success: boolean;
16
16
  }
17
17
 
18
18
  export function deserialize_proof_bytes(proof_bytes: Uint8Array): ProofHandle;
@@ -26,41 +26,41 @@ export function verify_proof(handle: ProofHandle): VerifyResult;
26
26
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
27
27
 
28
28
  export interface InitOutput {
29
- readonly memory: WebAssembly.Memory;
30
- readonly __wbg_proofhandle_free: (a: number, b: number) => void;
31
- readonly __wbg_verifyresult_free: (a: number, b: number) => void;
32
- readonly deserialize_proof_bytes: (a: number, b: number) => [number, number, number];
33
- readonly init_defaults: () => [number, number];
34
- readonly init_with: (a: number, b: number, c: number, d: number) => [number, number];
35
- readonly verify_proof: (a: number) => number;
36
- readonly verifyresult_error: (a: number) => any;
37
- readonly verifyresult_success: (a: number) => number;
38
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
39
- readonly __wbindgen_malloc: (a: number, b: number) => number;
40
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
41
- readonly __wbindgen_externrefs: WebAssembly.Table;
42
- readonly __externref_table_dealloc: (a: number) => void;
43
- readonly __wbindgen_start: () => void;
29
+ readonly memory: WebAssembly.Memory;
30
+ readonly __wbg_proofhandle_free: (a: number, b: number) => void;
31
+ readonly __wbg_verifyresult_free: (a: number, b: number) => void;
32
+ readonly deserialize_proof_bytes: (a: number, b: number) => [number, number, number];
33
+ readonly init_defaults: () => [number, number];
34
+ readonly init_with: (a: number, b: number, c: number, d: number) => [number, number];
35
+ readonly verify_proof: (a: number) => number;
36
+ readonly verifyresult_error: (a: number) => any;
37
+ readonly verifyresult_success: (a: number) => number;
38
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
39
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
40
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
41
+ readonly __wbindgen_externrefs: WebAssembly.Table;
42
+ readonly __externref_table_dealloc: (a: number) => void;
43
+ readonly __wbindgen_start: () => void;
44
44
  }
45
45
 
46
46
  export type SyncInitInput = BufferSource | WebAssembly.Module;
47
47
 
48
48
  /**
49
- * Instantiates the given `module`, which can either be bytes or
50
- * a precompiled `WebAssembly.Module`.
51
- *
52
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
53
- *
54
- * @returns {InitOutput}
55
- */
49
+ * Instantiates the given `module`, which can either be bytes or
50
+ * a precompiled `WebAssembly.Module`.
51
+ *
52
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
53
+ *
54
+ * @returns {InitOutput}
55
+ */
56
56
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
57
57
 
58
58
  /**
59
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
60
- * for everything else, calls `WebAssembly.instantiate` directly.
61
- *
62
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
63
- *
64
- * @returns {Promise<InitOutput>}
65
- */
59
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
60
+ * for everything else, calls `WebAssembly.instantiate` directly.
61
+ *
62
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
63
+ *
64
+ * @returns {Promise<InitOutput>}
65
+ */
66
66
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -1,4 +1,162 @@
1
- let wasm;
1
+ /* @ts-self-types="./proof_verifier_wasm.d.ts" */
2
+
3
+ export class ProofHandle {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(ProofHandle.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ ProofHandleFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ ProofHandleFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_proofhandle_free(ptr, 0);
20
+ }
21
+ }
22
+ if (Symbol.dispose) ProofHandle.prototype[Symbol.dispose] = ProofHandle.prototype.free;
23
+
24
+ export class VerifyResult {
25
+ static __wrap(ptr) {
26
+ ptr = ptr >>> 0;
27
+ const obj = Object.create(VerifyResult.prototype);
28
+ obj.__wbg_ptr = ptr;
29
+ VerifyResultFinalization.register(obj, obj.__wbg_ptr, obj);
30
+ return obj;
31
+ }
32
+ __destroy_into_raw() {
33
+ const ptr = this.__wbg_ptr;
34
+ this.__wbg_ptr = 0;
35
+ VerifyResultFinalization.unregister(this);
36
+ return ptr;
37
+ }
38
+ free() {
39
+ const ptr = this.__destroy_into_raw();
40
+ wasm.__wbg_verifyresult_free(ptr, 0);
41
+ }
42
+ /**
43
+ * @returns {any | undefined}
44
+ */
45
+ error() {
46
+ const ret = wasm.verifyresult_error(this.__wbg_ptr);
47
+ return ret;
48
+ }
49
+ /**
50
+ * @returns {boolean}
51
+ */
52
+ get success() {
53
+ const ret = wasm.verifyresult_success(this.__wbg_ptr);
54
+ return ret !== 0;
55
+ }
56
+ }
57
+ if (Symbol.dispose) VerifyResult.prototype[Symbol.dispose] = VerifyResult.prototype.free;
58
+
59
+ /**
60
+ * @param {Uint8Array} proof_bytes
61
+ * @returns {ProofHandle}
62
+ */
63
+ export function deserialize_proof_bytes(proof_bytes) {
64
+ const ptr0 = passArray8ToWasm0(proof_bytes, wasm.__wbindgen_malloc);
65
+ const len0 = WASM_VECTOR_LEN;
66
+ const ret = wasm.deserialize_proof_bytes(ptr0, len0);
67
+ if (ret[2]) {
68
+ throw takeFromExternrefTable0(ret[1]);
69
+ }
70
+ return ProofHandle.__wrap(ret[0]);
71
+ }
72
+
73
+ export function init_defaults() {
74
+ const ret = wasm.init_defaults();
75
+ if (ret[1]) {
76
+ throw takeFromExternrefTable0(ret[0]);
77
+ }
78
+ }
79
+
80
+ /**
81
+ * @param {Uint8Array} setup_bin
82
+ * @param {Uint8Array} layout_bin
83
+ */
84
+ export function init_with(setup_bin, layout_bin) {
85
+ const ptr0 = passArray8ToWasm0(setup_bin, wasm.__wbindgen_malloc);
86
+ const len0 = WASM_VECTOR_LEN;
87
+ const ptr1 = passArray8ToWasm0(layout_bin, wasm.__wbindgen_malloc);
88
+ const len1 = WASM_VECTOR_LEN;
89
+ const ret = wasm.init_with(ptr0, len0, ptr1, len1);
90
+ if (ret[1]) {
91
+ throw takeFromExternrefTable0(ret[0]);
92
+ }
93
+ }
94
+
95
+ /**
96
+ * @param {ProofHandle} handle
97
+ * @returns {VerifyResult}
98
+ */
99
+ export function verify_proof(handle) {
100
+ _assertClass(handle, ProofHandle);
101
+ const ret = wasm.verify_proof(handle.__wbg_ptr);
102
+ return VerifyResult.__wrap(ret);
103
+ }
104
+
105
+ function __wbg_get_imports() {
106
+ const import0 = {
107
+ __proto__: null,
108
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
109
+ throw new Error(getStringFromWasm0(arg0, arg1));
110
+ },
111
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
112
+ let deferred0_0;
113
+ let deferred0_1;
114
+ try {
115
+ deferred0_0 = arg0;
116
+ deferred0_1 = arg1;
117
+ console.error(getStringFromWasm0(arg0, arg1));
118
+ } finally {
119
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
120
+ }
121
+ },
122
+ __wbg_new_8a6f238a6ece86ea: function() {
123
+ const ret = new Error();
124
+ return ret;
125
+ },
126
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
127
+ const ret = arg1.stack;
128
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
129
+ const len1 = WASM_VECTOR_LEN;
130
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
131
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
132
+ },
133
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
134
+ // Cast intrinsic for `Ref(String) -> Externref`.
135
+ const ret = getStringFromWasm0(arg0, arg1);
136
+ return ret;
137
+ },
138
+ __wbindgen_init_externref_table: function() {
139
+ const table = wasm.__wbindgen_externrefs;
140
+ const offset = table.grow(4);
141
+ table.set(0, undefined);
142
+ table.set(offset + 0, undefined);
143
+ table.set(offset + 1, null);
144
+ table.set(offset + 2, true);
145
+ table.set(offset + 3, false);
146
+ },
147
+ };
148
+ return {
149
+ __proto__: null,
150
+ "./proof_verifier_wasm_bg.js": import0,
151
+ };
152
+ }
153
+
154
+ const ProofHandleFinalization = (typeof FinalizationRegistry === 'undefined')
155
+ ? { register: () => {}, unregister: () => {} }
156
+ : new FinalizationRegistry(ptr => wasm.__wbg_proofhandle_free(ptr >>> 0, 1));
157
+ const VerifyResultFinalization = (typeof FinalizationRegistry === 'undefined')
158
+ ? { register: () => {}, unregister: () => {} }
159
+ : new FinalizationRegistry(ptr => wasm.__wbg_verifyresult_free(ptr >>> 0, 1));
2
160
 
3
161
  function _assertClass(instance, klass) {
4
162
  if (!(instance instanceof klass)) {
@@ -101,137 +259,33 @@ if (!('encodeInto' in cachedTextEncoder)) {
101
259
  read: arg.length,
102
260
  written: buf.length
103
261
  };
104
- }
262
+ };
105
263
  }
106
264
 
107
265
  let WASM_VECTOR_LEN = 0;
108
266
 
109
- const ProofHandleFinalization = (typeof FinalizationRegistry === 'undefined')
110
- ? { register: () => {}, unregister: () => {} }
111
- : new FinalizationRegistry(ptr => wasm.__wbg_proofhandle_free(ptr >>> 0, 1));
112
-
113
- const VerifyResultFinalization = (typeof FinalizationRegistry === 'undefined')
114
- ? { register: () => {}, unregister: () => {} }
115
- : new FinalizationRegistry(ptr => wasm.__wbg_verifyresult_free(ptr >>> 0, 1));
116
-
117
- export class ProofHandle {
118
- static __wrap(ptr) {
119
- ptr = ptr >>> 0;
120
- const obj = Object.create(ProofHandle.prototype);
121
- obj.__wbg_ptr = ptr;
122
- ProofHandleFinalization.register(obj, obj.__wbg_ptr, obj);
123
- return obj;
124
- }
125
- __destroy_into_raw() {
126
- const ptr = this.__wbg_ptr;
127
- this.__wbg_ptr = 0;
128
- ProofHandleFinalization.unregister(this);
129
- return ptr;
130
- }
131
- free() {
132
- const ptr = this.__destroy_into_raw();
133
- wasm.__wbg_proofhandle_free(ptr, 0);
134
- }
135
- }
136
- if (Symbol.dispose) ProofHandle.prototype[Symbol.dispose] = ProofHandle.prototype.free;
137
-
138
- export class VerifyResult {
139
- static __wrap(ptr) {
140
- ptr = ptr >>> 0;
141
- const obj = Object.create(VerifyResult.prototype);
142
- obj.__wbg_ptr = ptr;
143
- VerifyResultFinalization.register(obj, obj.__wbg_ptr, obj);
144
- return obj;
145
- }
146
- __destroy_into_raw() {
147
- const ptr = this.__wbg_ptr;
148
- this.__wbg_ptr = 0;
149
- VerifyResultFinalization.unregister(this);
150
- return ptr;
151
- }
152
- free() {
153
- const ptr = this.__destroy_into_raw();
154
- wasm.__wbg_verifyresult_free(ptr, 0);
155
- }
156
- /**
157
- * @returns {any | undefined}
158
- */
159
- error() {
160
- const ret = wasm.verifyresult_error(this.__wbg_ptr);
161
- return ret;
162
- }
163
- /**
164
- * @returns {boolean}
165
- */
166
- get success() {
167
- const ret = wasm.verifyresult_success(this.__wbg_ptr);
168
- return ret !== 0;
169
- }
170
- }
171
- if (Symbol.dispose) VerifyResult.prototype[Symbol.dispose] = VerifyResult.prototype.free;
172
-
173
- /**
174
- * @param {Uint8Array} proof_bytes
175
- * @returns {ProofHandle}
176
- */
177
- export function deserialize_proof_bytes(proof_bytes) {
178
- const ptr0 = passArray8ToWasm0(proof_bytes, wasm.__wbindgen_malloc);
179
- const len0 = WASM_VECTOR_LEN;
180
- const ret = wasm.deserialize_proof_bytes(ptr0, len0);
181
- if (ret[2]) {
182
- throw takeFromExternrefTable0(ret[1]);
183
- }
184
- return ProofHandle.__wrap(ret[0]);
185
- }
186
-
187
- export function init_defaults() {
188
- const ret = wasm.init_defaults();
189
- if (ret[1]) {
190
- throw takeFromExternrefTable0(ret[0]);
191
- }
192
- }
193
-
194
- /**
195
- * @param {Uint8Array} setup_bin
196
- * @param {Uint8Array} layout_bin
197
- */
198
- export function init_with(setup_bin, layout_bin) {
199
- const ptr0 = passArray8ToWasm0(setup_bin, wasm.__wbindgen_malloc);
200
- const len0 = WASM_VECTOR_LEN;
201
- const ptr1 = passArray8ToWasm0(layout_bin, wasm.__wbindgen_malloc);
202
- const len1 = WASM_VECTOR_LEN;
203
- const ret = wasm.init_with(ptr0, len0, ptr1, len1);
204
- if (ret[1]) {
205
- throw takeFromExternrefTable0(ret[0]);
206
- }
207
- }
208
-
209
- /**
210
- * @param {ProofHandle} handle
211
- * @returns {VerifyResult}
212
- */
213
- export function verify_proof(handle) {
214
- _assertClass(handle, ProofHandle);
215
- const ret = wasm.verify_proof(handle.__wbg_ptr);
216
- return VerifyResult.__wrap(ret);
267
+ let wasmModule, wasm;
268
+ function __wbg_finalize_init(instance, module) {
269
+ wasm = instance.exports;
270
+ wasmModule = module;
271
+ cachedDataViewMemory0 = null;
272
+ cachedUint8ArrayMemory0 = null;
273
+ wasm.__wbindgen_start();
274
+ return wasm;
217
275
  }
218
276
 
219
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
220
-
221
277
  async function __wbg_load(module, imports) {
222
278
  if (typeof Response === 'function' && module instanceof Response) {
223
279
  if (typeof WebAssembly.instantiateStreaming === 'function') {
224
280
  try {
225
281
  return await WebAssembly.instantiateStreaming(module, imports);
226
282
  } catch (e) {
227
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
283
+ const validResponse = module.ok && expectedResponseType(module.type);
228
284
 
229
285
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
230
286
  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);
231
287
 
232
- } else {
233
- throw e;
234
- }
288
+ } else { throw e; }
235
289
  }
236
290
  }
237
291
 
@@ -246,70 +300,20 @@ async function __wbg_load(module, imports) {
246
300
  return instance;
247
301
  }
248
302
  }
249
- }
250
303
 
251
- function __wbg_get_imports() {
252
- const imports = {};
253
- imports.wbg = {};
254
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
255
- throw new Error(getStringFromWasm0(arg0, arg1));
256
- };
257
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
258
- let deferred0_0;
259
- let deferred0_1;
260
- try {
261
- deferred0_0 = arg0;
262
- deferred0_1 = arg1;
263
- console.error(getStringFromWasm0(arg0, arg1));
264
- } finally {
265
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
304
+ function expectedResponseType(type) {
305
+ switch (type) {
306
+ case 'basic': case 'cors': case 'default': return true;
266
307
  }
267
- };
268
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
269
- const ret = new Error();
270
- return ret;
271
- };
272
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
273
- const ret = arg1.stack;
274
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
275
- const len1 = WASM_VECTOR_LEN;
276
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
277
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
278
- };
279
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
280
- // Cast intrinsic for `Ref(String) -> Externref`.
281
- const ret = getStringFromWasm0(arg0, arg1);
282
- return ret;
283
- };
284
- imports.wbg.__wbindgen_init_externref_table = function() {
285
- const table = wasm.__wbindgen_externrefs;
286
- const offset = table.grow(4);
287
- table.set(0, undefined);
288
- table.set(offset + 0, undefined);
289
- table.set(offset + 1, null);
290
- table.set(offset + 2, true);
291
- table.set(offset + 3, false);
292
- };
293
-
294
- return imports;
295
- }
296
-
297
- function __wbg_finalize_init(instance, module) {
298
- wasm = instance.exports;
299
- __wbg_init.__wbindgen_wasm_module = module;
300
- cachedDataViewMemory0 = null;
301
- cachedUint8ArrayMemory0 = null;
302
-
303
-
304
- wasm.__wbindgen_start();
305
- return wasm;
308
+ return false;
309
+ }
306
310
  }
307
311
 
308
312
  function initSync(module) {
309
313
  if (wasm !== undefined) return wasm;
310
314
 
311
315
 
312
- if (typeof module !== 'undefined') {
316
+ if (module !== undefined) {
313
317
  if (Object.getPrototypeOf(module) === Object.prototype) {
314
318
  ({module} = module)
315
319
  } else {
@@ -329,7 +333,7 @@ async function __wbg_init(module_or_path) {
329
333
  if (wasm !== undefined) return wasm;
330
334
 
331
335
 
332
- if (typeof module_or_path !== 'undefined') {
336
+ if (module_or_path !== undefined) {
333
337
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
334
338
  ({module_or_path} = module_or_path)
335
339
  } else {
@@ -337,7 +341,7 @@ async function __wbg_init(module_or_path) {
337
341
  }
338
342
  }
339
343
 
340
- if (typeof module_or_path === 'undefined') {
344
+ if (module_or_path === undefined) {
341
345
  module_or_path = new URL('proof_verifier_wasm_bg.wasm', import.meta.url);
342
346
  }
343
347
  const imports = __wbg_get_imports();
@@ -351,5 +355,4 @@ async function __wbg_init(module_or_path) {
351
355
  return __wbg_finalize_init(instance, module);
352
356
  }
353
357
 
354
- export { initSync };
355
- export default __wbg_init;
358
+ export { initSync, __wbg_init as default };