@succinctlabs/sp1-wasm-verifier 5.0.4 → 5.0.6

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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # SP1 Wasm verification
2
+
3
+ This repo wraps the [`sp1-verifier`](https://github.com/succinctlabs/sp1) crate in Wasm bindings, and invoke it from JavaScript (Node.js).
4
+
5
+ ## Usage
6
+
7
+ Install the node module with the following command:
8
+
9
+ ```bash
10
+ npm install sp1-wasm-verifier
11
+ ```
12
+
13
+ `sp1-wasm-verifier` declare the following functions:
14
+
15
+ ```js
16
+ function verify_groth16(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: string): boolean;
17
+ function verify_plonk(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: string): boolean
18
+ function verify_compressed(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: Uint8Array): boolean;
19
+ ```
package/package.json CHANGED
@@ -1,39 +1,31 @@
1
1
  {
2
- "name": "@succinctlabs/sp1-wasm-verifier",
3
- "version": "5.0.4",
4
- "description": "A rust verifier for BN254 curve",
5
- "main": "./sp1_wasm_verifier.js",
6
- "module": "./sp1_wasm_verifier.js",
7
- "types": "./sp1_wasm_verifier.d.ts",
8
- "type": "module",
9
- "react-native": "./sp1_wasm_verifier_rn.js",
10
- "sideEffects": false,
11
- "author": "Bhargav Annem, Yuwen Zhang",
12
- "license": "MIT OR Apache-2.0",
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/succinctlabs/example-sp1-wasm-verifier"
16
- },
17
- "bugs": {
18
- "url": "https://github.com/succinctlabs/example-sp1-wasm-verifier/issues"
19
- },
20
- "homepage": "https://github.com/succinctlabs/example-sp1-wasm-verifier#readme",
21
- "readme": "README.md",
22
- "keywords": [
23
- "zero-knowledge",
24
- "cryptography",
25
- "zkSNARK",
26
- "SNARK",
27
- "gnark",
28
- "bn254",
29
- "verifier",
30
- "wasm"
31
- ],
32
- "files": [
33
- "sp1_wasm_verifier.js",
34
- "sp1_wasm_verifier_rn.js",
35
- "sp1_wasm_verifier_bg.js",
36
- "sp1_wasm_verifier_bg.wasm",
37
- "sp1_wasm_verifier.d.ts"
38
- ]
2
+ "name": "@succinctlabs/sp1-wasm-verifier",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Bhargav Annem, Yuwen Zhang"
6
+ ],
7
+ "description": "A rust verifier for BN254 curve",
8
+ "version": "5.0.6",
9
+ "license": "MIT/Apache-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/succinctlabs/example-sp1-wasm-verifier"
13
+ },
14
+ "files": [
15
+ "sp1_wasm_verifier_bg.wasm",
16
+ "sp1_wasm_verifier.js",
17
+ "sp1_wasm_verifier.d.ts"
18
+ ],
19
+ "main": "sp1_wasm_verifier.js",
20
+ "types": "sp1_wasm_verifier.d.ts",
21
+ "sideEffects": [
22
+ "./snippets/*"
23
+ ],
24
+ "keywords": [
25
+ "zero-knowledge",
26
+ "cryptography",
27
+ "zkSNARK",
28
+ "SNARK",
29
+ "gnark"
30
+ ]
39
31
  }
@@ -1,23 +1,54 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
-
4
- /**
5
- * Wrapper around [`sp1_verifier::CompressedVerifier::verify_sp1_proof`].
6
- *
7
- * We hardcode the Plonk VK bytes to only verify SP1 proofs.
8
- */
9
- export function verify_compressed(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: Uint8Array): boolean;
10
-
11
3
  /**
12
4
  * Wrapper around [`sp1_verifier::Groth16Verifier::verify`].
13
5
  *
14
6
  * We hardcode the Groth16 VK bytes to only verify SP1 proofs.
15
7
  */
16
8
  export function verify_groth16(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: string): boolean;
17
-
18
9
  /**
19
10
  * Wrapper around [`sp1_verifier::PlonkVerifier::verify`].
20
11
  *
21
12
  * We hardcode the Plonk VK bytes to only verify SP1 proofs.
22
13
  */
23
14
  export function verify_plonk(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: string): boolean;
15
+ /**
16
+ * Wrapper around [`sp1_verifier::CompressedVerifier::verify_sp1_proof`].
17
+ *
18
+ * We hardcode the Plonk VK bytes to only verify SP1 proofs.
19
+ */
20
+ export function verify_compressed(proof: Uint8Array, public_inputs: Uint8Array, sp1_vk_hash: Uint8Array): boolean;
21
+
22
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
23
+
24
+ export interface InitOutput {
25
+ readonly memory: WebAssembly.Memory;
26
+ readonly verify_compressed: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
27
+ readonly verify_groth16: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
28
+ readonly verify_plonk: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
29
+ readonly __wbindgen_export_0: WebAssembly.Table;
30
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
31
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
32
+ readonly __wbindgen_start: () => void;
33
+ }
34
+
35
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
36
+ /**
37
+ * Instantiates the given `module`, which can either be bytes or
38
+ * a precompiled `WebAssembly.Module`.
39
+ *
40
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
41
+ *
42
+ * @returns {InitOutput}
43
+ */
44
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
45
+
46
+ /**
47
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
48
+ * for everything else, calls `WebAssembly.instantiate` directly.
49
+ *
50
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
51
+ *
52
+ * @returns {Promise<InitOutput>}
53
+ */
54
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -1,16 +1,281 @@
1
+ let wasm;
1
2
 
2
- let imports = {};
3
- import * as import0 from './sp1_wasm_verifier_bg.js';
4
- imports['./sp1_wasm_verifier_bg.js'] = import0;
3
+ let cachedUint8ArrayMemory0 = null;
5
4
 
6
- import { readFileSync } from 'node:fs';
5
+ function getUint8ArrayMemory0() {
6
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
+ }
9
+ return cachedUint8ArrayMemory0;
10
+ }
7
11
 
8
- const wasmUrl = new URL('sp1_wasm_verifier_bg.wasm', import.meta.url);
9
- const wasmBytes = readFileSync(wasmUrl);
10
- const wasmModule = new WebAssembly.Module(wasmBytes);
11
- const wasm = new WebAssembly.Instance(wasmModule, imports).exports;
12
- export { wasm as __wasm };
13
- imports["./sp1_wasm_verifier_bg.js"].__wbg_set_wasm(wasm, wasmModule);
14
- wasm.__wbindgen_start();
12
+ let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
15
13
 
16
- export * from "./sp1_wasm_verifier_bg.js";
14
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let WASM_VECTOR_LEN = 0;
34
+
35
+ function passArray8ToWasm0(arg, malloc) {
36
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
37
+ getUint8ArrayMemory0().set(arg, ptr / 1);
38
+ WASM_VECTOR_LEN = arg.length;
39
+ return ptr;
40
+ }
41
+
42
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
43
+
44
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
45
+ ? function (arg, view) {
46
+ return cachedTextEncoder.encodeInto(arg, view);
47
+ }
48
+ : function (arg, view) {
49
+ const buf = cachedTextEncoder.encode(arg);
50
+ view.set(buf);
51
+ return {
52
+ read: arg.length,
53
+ written: buf.length
54
+ };
55
+ });
56
+
57
+ function passStringToWasm0(arg, malloc, realloc) {
58
+
59
+ if (realloc === undefined) {
60
+ const buf = cachedTextEncoder.encode(arg);
61
+ const ptr = malloc(buf.length, 1) >>> 0;
62
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
63
+ WASM_VECTOR_LEN = buf.length;
64
+ return ptr;
65
+ }
66
+
67
+ let len = arg.length;
68
+ let ptr = malloc(len, 1) >>> 0;
69
+
70
+ const mem = getUint8ArrayMemory0();
71
+
72
+ let offset = 0;
73
+
74
+ for (; offset < len; offset++) {
75
+ const code = arg.charCodeAt(offset);
76
+ if (code > 0x7F) break;
77
+ mem[ptr + offset] = code;
78
+ }
79
+
80
+ if (offset !== len) {
81
+ if (offset !== 0) {
82
+ arg = arg.slice(offset);
83
+ }
84
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
85
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
86
+ const ret = encodeString(arg, view);
87
+
88
+ offset += ret.written;
89
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
90
+ }
91
+
92
+ WASM_VECTOR_LEN = offset;
93
+ return ptr;
94
+ }
95
+ /**
96
+ * Wrapper around [`sp1_verifier::Groth16Verifier::verify`].
97
+ *
98
+ * We hardcode the Groth16 VK bytes to only verify SP1 proofs.
99
+ * @param {Uint8Array} proof
100
+ * @param {Uint8Array} public_inputs
101
+ * @param {string} sp1_vk_hash
102
+ * @returns {boolean}
103
+ */
104
+ export function verify_groth16(proof, public_inputs, sp1_vk_hash) {
105
+ const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
106
+ const len0 = WASM_VECTOR_LEN;
107
+ const ptr1 = passArray8ToWasm0(public_inputs, wasm.__wbindgen_malloc);
108
+ const len1 = WASM_VECTOR_LEN;
109
+ const ptr2 = passStringToWasm0(sp1_vk_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ const len2 = WASM_VECTOR_LEN;
111
+ const ret = wasm.verify_groth16(ptr0, len0, ptr1, len1, ptr2, len2);
112
+ return ret !== 0;
113
+ }
114
+
115
+ /**
116
+ * Wrapper around [`sp1_verifier::PlonkVerifier::verify`].
117
+ *
118
+ * We hardcode the Plonk VK bytes to only verify SP1 proofs.
119
+ * @param {Uint8Array} proof
120
+ * @param {Uint8Array} public_inputs
121
+ * @param {string} sp1_vk_hash
122
+ * @returns {boolean}
123
+ */
124
+ export function verify_plonk(proof, public_inputs, sp1_vk_hash) {
125
+ const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ const ptr1 = passArray8ToWasm0(public_inputs, wasm.__wbindgen_malloc);
128
+ const len1 = WASM_VECTOR_LEN;
129
+ const ptr2 = passStringToWasm0(sp1_vk_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
130
+ const len2 = WASM_VECTOR_LEN;
131
+ const ret = wasm.verify_plonk(ptr0, len0, ptr1, len1, ptr2, len2);
132
+ return ret !== 0;
133
+ }
134
+
135
+ /**
136
+ * Wrapper around [`sp1_verifier::CompressedVerifier::verify_sp1_proof`].
137
+ *
138
+ * We hardcode the Plonk VK bytes to only verify SP1 proofs.
139
+ * @param {Uint8Array} proof
140
+ * @param {Uint8Array} public_inputs
141
+ * @param {Uint8Array} sp1_vk_hash
142
+ * @returns {boolean}
143
+ */
144
+ export function verify_compressed(proof, public_inputs, sp1_vk_hash) {
145
+ const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
146
+ const len0 = WASM_VECTOR_LEN;
147
+ const ptr1 = passArray8ToWasm0(public_inputs, wasm.__wbindgen_malloc);
148
+ const len1 = WASM_VECTOR_LEN;
149
+ const ptr2 = passArray8ToWasm0(sp1_vk_hash, wasm.__wbindgen_malloc);
150
+ const len2 = WASM_VECTOR_LEN;
151
+ const ret = wasm.verify_compressed(ptr0, len0, ptr1, len1, ptr2, len2);
152
+ return ret !== 0;
153
+ }
154
+
155
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
156
+
157
+ async function __wbg_load(module, imports) {
158
+ if (typeof Response === 'function' && module instanceof Response) {
159
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
160
+ try {
161
+ return await WebAssembly.instantiateStreaming(module, imports);
162
+
163
+ } catch (e) {
164
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
165
+
166
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
167
+ 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);
168
+
169
+ } else {
170
+ throw e;
171
+ }
172
+ }
173
+ }
174
+
175
+ const bytes = await module.arrayBuffer();
176
+ return await WebAssembly.instantiate(bytes, imports);
177
+
178
+ } else {
179
+ const instance = await WebAssembly.instantiate(module, imports);
180
+
181
+ if (instance instanceof WebAssembly.Instance) {
182
+ return { instance, module };
183
+
184
+ } else {
185
+ return instance;
186
+ }
187
+ }
188
+ }
189
+
190
+ function __wbg_get_imports() {
191
+ const imports = {};
192
+ imports.wbg = {};
193
+ imports.wbg.__wbg_error_4375b917961b0e7a = function(arg0, arg1) {
194
+ console.error(getStringFromWasm0(arg0, arg1));
195
+ };
196
+ imports.wbg.__wbindgen_init_externref_table = function() {
197
+ const table = wasm.__wbindgen_export_0;
198
+ const offset = table.grow(4);
199
+ table.set(0, undefined);
200
+ table.set(offset + 0, undefined);
201
+ table.set(offset + 1, null);
202
+ table.set(offset + 2, true);
203
+ table.set(offset + 3, false);
204
+ ;
205
+ };
206
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
207
+ throw new Error(getStringFromWasm0(arg0, arg1));
208
+ };
209
+
210
+ return imports;
211
+ }
212
+
213
+ function __wbg_init_memory(imports, memory) {
214
+
215
+ }
216
+
217
+ function __wbg_finalize_init(instance, module) {
218
+ wasm = instance.exports;
219
+ __wbg_init.__wbindgen_wasm_module = module;
220
+ cachedUint8ArrayMemory0 = null;
221
+
222
+
223
+ wasm.__wbindgen_start();
224
+ return wasm;
225
+ }
226
+
227
+ function initSync(module) {
228
+ if (wasm !== undefined) return wasm;
229
+
230
+
231
+ if (typeof module !== 'undefined') {
232
+ if (Object.getPrototypeOf(module) === Object.prototype) {
233
+ ({module} = module)
234
+ } else {
235
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
236
+ }
237
+ }
238
+
239
+ const imports = __wbg_get_imports();
240
+
241
+ __wbg_init_memory(imports);
242
+
243
+ if (!(module instanceof WebAssembly.Module)) {
244
+ module = new WebAssembly.Module(module);
245
+ }
246
+
247
+ const instance = new WebAssembly.Instance(module, imports);
248
+
249
+ return __wbg_finalize_init(instance, module);
250
+ }
251
+
252
+ async function __wbg_init(module_or_path) {
253
+ if (wasm !== undefined) return wasm;
254
+
255
+
256
+ if (typeof module_or_path !== 'undefined') {
257
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
258
+ ({module_or_path} = module_or_path)
259
+ } else {
260
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
261
+ }
262
+ }
263
+
264
+ if (typeof module_or_path === 'undefined') {
265
+ module_or_path = new URL('sp1_wasm_verifier_bg.wasm', import.meta.url);
266
+ }
267
+ const imports = __wbg_get_imports();
268
+
269
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
270
+ module_or_path = fetch(module_or_path);
271
+ }
272
+
273
+ __wbg_init_memory(imports);
274
+
275
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
276
+
277
+ return __wbg_finalize_init(instance, module);
278
+ }
279
+
280
+ export { initSync };
281
+ export default __wbg_init;
Binary file
@@ -1,162 +0,0 @@
1
- let wasm;
2
- let wasmModule;
3
- export function __wbg_set_wasm(exports, module) {
4
- wasm = exports;
5
- wasmModule = module;
6
- }
7
-
8
- function getStringFromWasm0(ptr, len) {
9
- ptr = ptr >>> 0;
10
- return decodeText(ptr, len);
11
- }
12
-
13
- let cachedUint8ArrayMemory0 = null;
14
- function getUint8ArrayMemory0() {
15
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
16
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
17
- }
18
- return cachedUint8ArrayMemory0;
19
- }
20
-
21
- function passArray8ToWasm0(arg, malloc) {
22
- const ptr = malloc(arg.length * 1, 1) >>> 0;
23
- getUint8ArrayMemory0().set(arg, ptr / 1);
24
- WASM_VECTOR_LEN = arg.length;
25
- return ptr;
26
- }
27
-
28
- function passStringToWasm0(arg, malloc, realloc) {
29
- if (realloc === undefined) {
30
- const buf = cachedTextEncoder.encode(arg);
31
- const ptr = malloc(buf.length, 1) >>> 0;
32
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
33
- WASM_VECTOR_LEN = buf.length;
34
- return ptr;
35
- }
36
-
37
- let len = arg.length;
38
- let ptr = malloc(len, 1) >>> 0;
39
-
40
- const mem = getUint8ArrayMemory0();
41
-
42
- let offset = 0;
43
-
44
- for (; offset < len; offset++) {
45
- const code = arg.charCodeAt(offset);
46
- if (code > 0x7F) break;
47
- mem[ptr + offset] = code;
48
- }
49
- if (offset !== len) {
50
- if (offset !== 0) {
51
- arg = arg.slice(offset);
52
- }
53
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
54
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
55
- const ret = cachedTextEncoder.encodeInto(arg, view);
56
-
57
- offset += ret.written;
58
- ptr = realloc(ptr, len, offset, 1) >>> 0;
59
- }
60
-
61
- WASM_VECTOR_LEN = offset;
62
- return ptr;
63
- }
64
-
65
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
66
- cachedTextDecoder.decode();
67
- function decodeText(ptr, len) {
68
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
69
- }
70
-
71
- const cachedTextEncoder = new TextEncoder();
72
-
73
- if (!('encodeInto' in cachedTextEncoder)) {
74
- cachedTextEncoder.encodeInto = function (arg, view) {
75
- const buf = cachedTextEncoder.encode(arg);
76
- view.set(buf);
77
- return {
78
- read: arg.length,
79
- written: buf.length
80
- };
81
- }
82
- }
83
-
84
- let WASM_VECTOR_LEN = 0;
85
-
86
- /**
87
- * Wrapper around [`sp1_verifier::CompressedVerifier::verify_sp1_proof`].
88
- *
89
- * We hardcode the Plonk VK bytes to only verify SP1 proofs.
90
- * @param {Uint8Array} proof
91
- * @param {Uint8Array} public_inputs
92
- * @param {Uint8Array} sp1_vk_hash
93
- * @returns {boolean}
94
- */
95
- export function verify_compressed(proof, public_inputs, sp1_vk_hash) {
96
- const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
97
- const len0 = WASM_VECTOR_LEN;
98
- const ptr1 = passArray8ToWasm0(public_inputs, wasm.__wbindgen_malloc);
99
- const len1 = WASM_VECTOR_LEN;
100
- const ptr2 = passArray8ToWasm0(sp1_vk_hash, wasm.__wbindgen_malloc);
101
- const len2 = WASM_VECTOR_LEN;
102
- const ret = wasm.verify_compressed(ptr0, len0, ptr1, len1, ptr2, len2);
103
- return ret !== 0;
104
- }
105
-
106
- /**
107
- * Wrapper around [`sp1_verifier::Groth16Verifier::verify`].
108
- *
109
- * We hardcode the Groth16 VK bytes to only verify SP1 proofs.
110
- * @param {Uint8Array} proof
111
- * @param {Uint8Array} public_inputs
112
- * @param {string} sp1_vk_hash
113
- * @returns {boolean}
114
- */
115
- export function verify_groth16(proof, public_inputs, sp1_vk_hash) {
116
- const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
117
- const len0 = WASM_VECTOR_LEN;
118
- const ptr1 = passArray8ToWasm0(public_inputs, wasm.__wbindgen_malloc);
119
- const len1 = WASM_VECTOR_LEN;
120
- const ptr2 = passStringToWasm0(sp1_vk_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
121
- const len2 = WASM_VECTOR_LEN;
122
- const ret = wasm.verify_groth16(ptr0, len0, ptr1, len1, ptr2, len2);
123
- return ret !== 0;
124
- }
125
-
126
- /**
127
- * Wrapper around [`sp1_verifier::PlonkVerifier::verify`].
128
- *
129
- * We hardcode the Plonk VK bytes to only verify SP1 proofs.
130
- * @param {Uint8Array} proof
131
- * @param {Uint8Array} public_inputs
132
- * @param {string} sp1_vk_hash
133
- * @returns {boolean}
134
- */
135
- export function verify_plonk(proof, public_inputs, sp1_vk_hash) {
136
- const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc);
137
- const len0 = WASM_VECTOR_LEN;
138
- const ptr1 = passArray8ToWasm0(public_inputs, wasm.__wbindgen_malloc);
139
- const len1 = WASM_VECTOR_LEN;
140
- const ptr2 = passStringToWasm0(sp1_vk_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
141
- const len2 = WASM_VECTOR_LEN;
142
- const ret = wasm.verify_plonk(ptr0, len0, ptr1, len1, ptr2, len2);
143
- return ret !== 0;
144
- }
145
-
146
- export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
147
- throw new Error(getStringFromWasm0(arg0, arg1));
148
- };
149
-
150
- export function __wbg_error_2e0b9dae3eefa9fd(arg0, arg1) {
151
- console.error(getStringFromWasm0(arg0, arg1));
152
- };
153
-
154
- export function __wbindgen_init_externref_table() {
155
- const table = wasm.__wbindgen_externrefs;
156
- const offset = table.grow(4);
157
- table.set(0, undefined);
158
- table.set(offset + 0, undefined);
159
- table.set(offset + 1, null);
160
- table.set(offset + 2, true);
161
- table.set(offset + 3, false);
162
- };