@succinctlabs/sp1-wasm-verifier 5.0.2 → 5.0.4

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,12 +1,12 @@
1
1
  {
2
2
  "name": "@succinctlabs/sp1-wasm-verifier",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "A rust verifier for BN254 curve",
5
5
  "main": "./sp1_wasm_verifier.js",
6
6
  "module": "./sp1_wasm_verifier.js",
7
7
  "types": "./sp1_wasm_verifier.d.ts",
8
8
  "type": "module",
9
- "react-native": "./sp1_wasm_verifier.rn.js",
9
+ "react-native": "./sp1_wasm_verifier_rn.js",
10
10
  "sideEffects": false,
11
11
  "author": "Bhargav Annem, Yuwen Zhang",
12
12
  "license": "MIT OR Apache-2.0",
@@ -31,6 +31,8 @@
31
31
  ],
32
32
  "files": [
33
33
  "sp1_wasm_verifier.js",
34
+ "sp1_wasm_verifier_rn.js",
35
+ "sp1_wasm_verifier_bg.js",
34
36
  "sp1_wasm_verifier_bg.wasm",
35
37
  "sp1_wasm_verifier.d.ts"
36
38
  ]
@@ -0,0 +1,162 @@
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
+ };
Binary file