@noir-lang/noir_wasm 0.2.0 → 0.4.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.
- package/noir_wasm.d.ts +10 -0
- package/noir_wasm.js +232 -54
- package/noir_wasm_bg.wasm +0 -0
- package/noir_wasm_bg.wasm.d.ts +5 -2
- package/package.json +1 -1
package/noir_wasm.d.ts
CHANGED
|
@@ -5,3 +5,13 @@
|
|
|
5
5
|
* @returns {any}
|
|
6
6
|
*/
|
|
7
7
|
export function compile(src: string): any;
|
|
8
|
+
/**
|
|
9
|
+
* @param {Uint8Array} bytes
|
|
10
|
+
* @returns {any}
|
|
11
|
+
*/
|
|
12
|
+
export function acir_from_bytes(bytes: Uint8Array): any;
|
|
13
|
+
/**
|
|
14
|
+
* @param {any} acir
|
|
15
|
+
* @returns {Uint8Array}
|
|
16
|
+
*/
|
|
17
|
+
export function acir_to_bytes(acir: any): Uint8Array;
|
package/noir_wasm.js
CHANGED
|
@@ -2,54 +2,24 @@ let imports = {};
|
|
|
2
2
|
imports['__wbindgen_placeholder__'] = module.exports;
|
|
3
3
|
let wasm;
|
|
4
4
|
const { read_file } = require(String.raw`./snippets/fm-cffb18dcbd478425/file_reader.js`);
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
8
|
-
|
|
9
|
-
cachedTextDecoder.decode();
|
|
10
|
-
|
|
11
|
-
let cachedUint8Memory0;
|
|
12
|
-
function getUint8Memory0() {
|
|
13
|
-
if (cachedUint8Memory0.byteLength === 0) {
|
|
14
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
15
|
-
}
|
|
16
|
-
return cachedUint8Memory0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getStringFromWasm0(ptr, len) {
|
|
20
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
21
|
-
}
|
|
5
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
22
6
|
|
|
23
7
|
const heap = new Array(32).fill(undefined);
|
|
24
8
|
|
|
25
9
|
heap.push(undefined, null, true, false);
|
|
26
10
|
|
|
27
|
-
let heap_next = heap.length;
|
|
28
|
-
|
|
29
|
-
function addHeapObject(obj) {
|
|
30
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
31
|
-
const idx = heap_next;
|
|
32
|
-
heap_next = heap[idx];
|
|
33
|
-
|
|
34
|
-
heap[idx] = obj;
|
|
35
|
-
return idx;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
11
|
function getObject(idx) { return heap[idx]; }
|
|
39
12
|
|
|
40
|
-
|
|
41
|
-
if (idx < 36) return;
|
|
42
|
-
heap[idx] = heap_next;
|
|
43
|
-
heap_next = idx;
|
|
44
|
-
}
|
|
13
|
+
let WASM_VECTOR_LEN = 0;
|
|
45
14
|
|
|
46
|
-
|
|
47
|
-
const ret = getObject(idx);
|
|
48
|
-
dropObject(idx);
|
|
49
|
-
return ret;
|
|
50
|
-
}
|
|
15
|
+
let cachedUint8Memory0 = new Uint8Array();
|
|
51
16
|
|
|
52
|
-
|
|
17
|
+
function getUint8Memory0() {
|
|
18
|
+
if (cachedUint8Memory0.byteLength === 0) {
|
|
19
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
20
|
+
}
|
|
21
|
+
return cachedUint8Memory0;
|
|
22
|
+
}
|
|
53
23
|
|
|
54
24
|
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
55
25
|
|
|
@@ -103,6 +73,46 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
103
73
|
WASM_VECTOR_LEN = offset;
|
|
104
74
|
return ptr;
|
|
105
75
|
}
|
|
76
|
+
|
|
77
|
+
let cachedInt32Memory0 = new Int32Array();
|
|
78
|
+
|
|
79
|
+
function getInt32Memory0() {
|
|
80
|
+
if (cachedInt32Memory0.byteLength === 0) {
|
|
81
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
82
|
+
}
|
|
83
|
+
return cachedInt32Memory0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let heap_next = heap.length;
|
|
87
|
+
|
|
88
|
+
function dropObject(idx) {
|
|
89
|
+
if (idx < 36) return;
|
|
90
|
+
heap[idx] = heap_next;
|
|
91
|
+
heap_next = idx;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function takeObject(idx) {
|
|
95
|
+
const ret = getObject(idx);
|
|
96
|
+
dropObject(idx);
|
|
97
|
+
return ret;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
101
|
+
|
|
102
|
+
cachedTextDecoder.decode();
|
|
103
|
+
|
|
104
|
+
function getStringFromWasm0(ptr, len) {
|
|
105
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function addHeapObject(obj) {
|
|
109
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
110
|
+
const idx = heap_next;
|
|
111
|
+
heap_next = heap[idx];
|
|
112
|
+
|
|
113
|
+
heap[idx] = obj;
|
|
114
|
+
return idx;
|
|
115
|
+
}
|
|
106
116
|
/**
|
|
107
117
|
* @param {string} src
|
|
108
118
|
* @returns {any}
|
|
@@ -114,22 +124,65 @@ module.exports.compile = function(src) {
|
|
|
114
124
|
return takeObject(ret);
|
|
115
125
|
};
|
|
116
126
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return cachedInt32Memory0;
|
|
127
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
128
|
+
const ptr = malloc(arg.length * 1);
|
|
129
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
130
|
+
WASM_VECTOR_LEN = arg.length;
|
|
131
|
+
return ptr;
|
|
123
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* @param {Uint8Array} bytes
|
|
135
|
+
* @returns {any}
|
|
136
|
+
*/
|
|
137
|
+
module.exports.acir_from_bytes = function(bytes) {
|
|
138
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
139
|
+
const len0 = WASM_VECTOR_LEN;
|
|
140
|
+
const ret = wasm.acir_from_bytes(ptr0, len0);
|
|
141
|
+
return takeObject(ret);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
145
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @param {any} acir
|
|
149
|
+
* @returns {Uint8Array}
|
|
150
|
+
*/
|
|
151
|
+
module.exports.acir_to_bytes = function(acir) {
|
|
152
|
+
try {
|
|
153
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
154
|
+
wasm.acir_to_bytes(retptr, addHeapObject(acir));
|
|
155
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
156
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
157
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
158
|
+
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
159
|
+
return v0;
|
|
160
|
+
} finally {
|
|
161
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
124
164
|
|
|
125
165
|
function handleError(f, args) {
|
|
126
166
|
try {
|
|
127
167
|
return f.apply(this, args);
|
|
128
168
|
} catch (e) {
|
|
129
|
-
wasm.
|
|
169
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
130
170
|
}
|
|
131
171
|
}
|
|
132
172
|
|
|
173
|
+
module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
174
|
+
const obj = getObject(arg1);
|
|
175
|
+
const ret = JSON.stringify(obj === undefined ? null : obj);
|
|
176
|
+
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
179
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
183
|
+
takeObject(arg0);
|
|
184
|
+
};
|
|
185
|
+
|
|
133
186
|
module.exports.__wbindgen_json_parse = function(arg0, arg1) {
|
|
134
187
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
135
188
|
return addHeapObject(ret);
|
|
@@ -143,10 +196,6 @@ module.exports.__wbg_readfile_381ecedf0ec0c1aa = function() { return handleError
|
|
|
143
196
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
144
197
|
}, arguments) };
|
|
145
198
|
|
|
146
|
-
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
147
|
-
takeObject(arg0);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
199
|
module.exports.__wbg_new_693216e109162396 = function() {
|
|
151
200
|
const ret = new Error();
|
|
152
201
|
return addHeapObject(ret);
|
|
@@ -164,10 +213,142 @@ module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
|
|
|
164
213
|
try {
|
|
165
214
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
166
215
|
} finally {
|
|
167
|
-
wasm.
|
|
216
|
+
wasm.__wbindgen_export_2(arg0, arg1);
|
|
168
217
|
}
|
|
169
218
|
};
|
|
170
219
|
|
|
220
|
+
module.exports.__wbg_randomFillSync_91e2b39becca6147 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
221
|
+
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
|
222
|
+
}, arguments) };
|
|
223
|
+
|
|
224
|
+
module.exports.__wbg_getRandomValues_b14734aa289bc356 = function() { return handleError(function (arg0, arg1) {
|
|
225
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
226
|
+
}, arguments) };
|
|
227
|
+
|
|
228
|
+
module.exports.__wbg_process_e56fd54cf6319b6c = function(arg0) {
|
|
229
|
+
const ret = getObject(arg0).process;
|
|
230
|
+
return addHeapObject(ret);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
module.exports.__wbindgen_is_object = function(arg0) {
|
|
234
|
+
const val = getObject(arg0);
|
|
235
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
236
|
+
return ret;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
module.exports.__wbg_versions_77e21455908dad33 = function(arg0) {
|
|
240
|
+
const ret = getObject(arg0).versions;
|
|
241
|
+
return addHeapObject(ret);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
module.exports.__wbg_node_0dd25d832e4785d5 = function(arg0) {
|
|
245
|
+
const ret = getObject(arg0).node;
|
|
246
|
+
return addHeapObject(ret);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
module.exports.__wbindgen_is_string = function(arg0) {
|
|
250
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
251
|
+
return ret;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
module.exports.__wbg_crypto_b95d7173266618a9 = function(arg0) {
|
|
255
|
+
const ret = getObject(arg0).crypto;
|
|
256
|
+
return addHeapObject(ret);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
module.exports.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) {
|
|
260
|
+
const ret = getObject(arg0).msCrypto;
|
|
261
|
+
return addHeapObject(ret);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
module.exports.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() {
|
|
265
|
+
const ret = module;
|
|
266
|
+
return addHeapObject(ret);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
module.exports.__wbg_require_0db1598d9ccecb30 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
270
|
+
const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
|
|
271
|
+
return addHeapObject(ret);
|
|
272
|
+
}, arguments) };
|
|
273
|
+
|
|
274
|
+
module.exports.__wbg_newnoargs_971e9a5abe185139 = function(arg0, arg1) {
|
|
275
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
276
|
+
return addHeapObject(ret);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
module.exports.__wbg_call_33d7bcddbbfa394a = function() { return handleError(function (arg0, arg1) {
|
|
280
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
281
|
+
return addHeapObject(ret);
|
|
282
|
+
}, arguments) };
|
|
283
|
+
|
|
284
|
+
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
285
|
+
const ret = getObject(arg0);
|
|
286
|
+
return addHeapObject(ret);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
module.exports.__wbg_self_fd00a1ef86d1b2ed = function() { return handleError(function () {
|
|
290
|
+
const ret = self.self;
|
|
291
|
+
return addHeapObject(ret);
|
|
292
|
+
}, arguments) };
|
|
293
|
+
|
|
294
|
+
module.exports.__wbg_window_6f6e346d8bbd61d7 = function() { return handleError(function () {
|
|
295
|
+
const ret = window.window;
|
|
296
|
+
return addHeapObject(ret);
|
|
297
|
+
}, arguments) };
|
|
298
|
+
|
|
299
|
+
module.exports.__wbg_globalThis_3348936ac49df00a = function() { return handleError(function () {
|
|
300
|
+
const ret = globalThis.globalThis;
|
|
301
|
+
return addHeapObject(ret);
|
|
302
|
+
}, arguments) };
|
|
303
|
+
|
|
304
|
+
module.exports.__wbg_global_67175caf56f55ca9 = function() { return handleError(function () {
|
|
305
|
+
const ret = global.global;
|
|
306
|
+
return addHeapObject(ret);
|
|
307
|
+
}, arguments) };
|
|
308
|
+
|
|
309
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
310
|
+
const ret = getObject(arg0) === undefined;
|
|
311
|
+
return ret;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
module.exports.__wbg_buffer_34f5ec9f8a838ba0 = function(arg0) {
|
|
315
|
+
const ret = getObject(arg0).buffer;
|
|
316
|
+
return addHeapObject(ret);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
module.exports.__wbg_new_cda198d9dbc6d7ea = function(arg0) {
|
|
320
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
321
|
+
return addHeapObject(ret);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
module.exports.__wbg_set_1a930cfcda1a8067 = function(arg0, arg1, arg2) {
|
|
325
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
module.exports.__wbg_length_51f19f73d6d9eff3 = function(arg0) {
|
|
329
|
+
const ret = getObject(arg0).length;
|
|
330
|
+
return ret;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
module.exports.__wbg_newwithlength_66e5530e7079ea1b = function(arg0) {
|
|
334
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
335
|
+
return addHeapObject(ret);
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
module.exports.__wbg_subarray_270ff8dd5582c1ac = function(arg0, arg1, arg2) {
|
|
339
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
340
|
+
return addHeapObject(ret);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
344
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
module.exports.__wbindgen_memory = function() {
|
|
348
|
+
const ret = wasm.memory;
|
|
349
|
+
return addHeapObject(ret);
|
|
350
|
+
};
|
|
351
|
+
|
|
171
352
|
const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
|
|
172
353
|
const bytes = require('fs').readFileSync(path);
|
|
173
354
|
|
|
@@ -176,6 +357,3 @@ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
|
176
357
|
wasm = wasmInstance.exports;
|
|
177
358
|
module.exports.__wasm = wasm;
|
|
178
359
|
|
|
179
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
180
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
181
|
-
|
package/noir_wasm_bg.wasm
CHANGED
|
Binary file
|
package/noir_wasm_bg.wasm.d.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export function compile(a: number, b: number): number;
|
|
5
|
+
export function acir_from_bytes(a: number, b: number): number;
|
|
6
|
+
export function acir_to_bytes(a: number, b: number): void;
|
|
5
7
|
export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
|
|
6
8
|
export function rust_psm_stack_direction(): number;
|
|
7
9
|
export function rust_psm_stack_pointer(): number;
|
|
8
10
|
export function rust_psm_replace_stack(a: number, b: number, c: number): void;
|
|
9
11
|
export function __wbindgen_export_0(a: number): number;
|
|
10
12
|
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
11
|
-
export function
|
|
12
|
-
export function
|
|
13
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
14
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
15
|
+
export function __wbindgen_export_3(a: number): void;
|