@quilibrium/quilibrium-js-verenc-sdk 2.1.0-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Quilibrium Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ declare function VerencNewProof(data: ArrayBuffer): {
2
+ proof: Buffer;
3
+ encryptionKey: Buffer;
4
+ };
5
+ declare function VerencNewProofEncryptOnly(data: ArrayBuffer, encryptionKey: ArrayBuffer): Buffer;
6
+ declare function VerencVerify(proof: ArrayBuffer): {
7
+ data: Buffer;
8
+ blindingPubkey: Buffer;
9
+ };
10
+ declare function VerencCompress(proof: ArrayBuffer): {
11
+ proof: Buffer;
12
+ recovery: Buffer;
13
+ };
14
+ declare function VerencRecover(recovery: ArrayBuffer): Buffer;
15
+ declare function VerencChunkDataForVerenc(data: ArrayBuffer): Buffer[];
16
+ declare function VerencCombineChunkedData(chunks: ArrayBuffer[]): Buffer;
17
+ declare function VerencVerifyStatement(input: ArrayBuffer, blindingPubkey: ArrayBuffer, statement: ArrayBuffer): boolean;
18
+
19
+ declare const verenc_VerencChunkDataForVerenc: typeof VerencChunkDataForVerenc;
20
+ declare const verenc_VerencCombineChunkedData: typeof VerencCombineChunkedData;
21
+ declare const verenc_VerencCompress: typeof VerencCompress;
22
+ declare const verenc_VerencNewProof: typeof VerencNewProof;
23
+ declare const verenc_VerencNewProofEncryptOnly: typeof VerencNewProofEncryptOnly;
24
+ declare const verenc_VerencRecover: typeof VerencRecover;
25
+ declare const verenc_VerencVerify: typeof VerencVerify;
26
+ declare const verenc_VerencVerifyStatement: typeof VerencVerifyStatement;
27
+ declare namespace verenc {
28
+ export {
29
+ verenc_VerencChunkDataForVerenc as VerencChunkDataForVerenc,
30
+ verenc_VerencCombineChunkedData as VerencCombineChunkedData,
31
+ verenc_VerencCompress as VerencCompress,
32
+ verenc_VerencNewProof as VerencNewProof,
33
+ verenc_VerencNewProofEncryptOnly as VerencNewProofEncryptOnly,
34
+ verenc_VerencRecover as VerencRecover,
35
+ verenc_VerencVerify as VerencVerify,
36
+ verenc_VerencVerifyStatement as VerencVerifyStatement,
37
+ };
38
+ }
39
+
40
+ export { verenc };
@@ -0,0 +1,383 @@
1
+ import { Buffer as Buffer$1 } from 'buffer';
2
+
3
+ let wasm;
4
+
5
+ const heap = new Array(128).fill(undefined);
6
+
7
+ heap.push(undefined, null, true, false);
8
+
9
+ heap.length;
10
+
11
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
12
+
13
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
14
+ let cachedUint8Memory0 = null;
15
+
16
+ function getUint8Memory0() {
17
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
18
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
19
+ }
20
+ return cachedUint8Memory0;
21
+ }
22
+
23
+ function getStringFromWasm0(ptr, len) {
24
+ ptr = ptr >>> 0;
25
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ let WASM_VECTOR_LEN = 0;
29
+
30
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
31
+
32
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
33
+ ? function (arg, view) {
34
+ return cachedTextEncoder.encodeInto(arg, view);
35
+ }
36
+ : function (arg, view) {
37
+ const buf = cachedTextEncoder.encode(arg);
38
+ view.set(buf);
39
+ return {
40
+ read: arg.length,
41
+ written: buf.length
42
+ };
43
+ });
44
+
45
+ function passStringToWasm0(arg, malloc, realloc) {
46
+
47
+ if (realloc === undefined) {
48
+ const buf = cachedTextEncoder.encode(arg);
49
+ const ptr = malloc(buf.length, 1) >>> 0;
50
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
51
+ WASM_VECTOR_LEN = buf.length;
52
+ return ptr;
53
+ }
54
+
55
+ let len = arg.length;
56
+ let ptr = malloc(len, 1) >>> 0;
57
+
58
+ const mem = getUint8Memory0();
59
+
60
+ let offset = 0;
61
+
62
+ for (; offset < len; offset++) {
63
+ const code = arg.charCodeAt(offset);
64
+ if (code > 0x7F) break;
65
+ mem[ptr + offset] = code;
66
+ }
67
+
68
+ if (offset !== len) {
69
+ if (offset !== 0) {
70
+ arg = arg.slice(offset);
71
+ }
72
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
73
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
74
+ const ret = encodeString(arg, view);
75
+
76
+ offset += ret.written;
77
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
78
+ }
79
+
80
+ WASM_VECTOR_LEN = offset;
81
+ return ptr;
82
+ }
83
+
84
+ let cachedInt32Memory0 = null;
85
+
86
+ function getInt32Memory0() {
87
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
88
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
89
+ }
90
+ return cachedInt32Memory0;
91
+ }
92
+ /**
93
+ * @param {string} data
94
+ * @returns {string}
95
+ */
96
+ function js_new_verenc_proof(data) {
97
+ let deferred2_0;
98
+ let deferred2_1;
99
+ try {
100
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
101
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
102
+ const len0 = WASM_VECTOR_LEN;
103
+ wasm.js_new_verenc_proof(retptr, ptr0, len0);
104
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
105
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
106
+ deferred2_0 = r0;
107
+ deferred2_1 = r1;
108
+ return getStringFromWasm0(r0, r1);
109
+ } finally {
110
+ wasm.__wbindgen_add_to_stack_pointer(16);
111
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
112
+ }
113
+ }
114
+
115
+ /**
116
+ * @param {string} data
117
+ * @param {string} encryption_key
118
+ * @returns {string}
119
+ */
120
+ function js_new_verenc_proof_encrypt_only(data, encryption_key) {
121
+ let deferred3_0;
122
+ let deferred3_1;
123
+ try {
124
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
125
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ const ptr1 = passStringToWasm0(encryption_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
128
+ const len1 = WASM_VECTOR_LEN;
129
+ wasm.js_new_verenc_proof_encrypt_only(retptr, ptr0, len0, ptr1, len1);
130
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
131
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
132
+ deferred3_0 = r0;
133
+ deferred3_1 = r1;
134
+ return getStringFromWasm0(r0, r1);
135
+ } finally {
136
+ wasm.__wbindgen_add_to_stack_pointer(16);
137
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * @param {string} proof
143
+ * @returns {string}
144
+ */
145
+ function js_verenc_verify(proof) {
146
+ let deferred2_0;
147
+ let deferred2_1;
148
+ try {
149
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
150
+ const ptr0 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
151
+ const len0 = WASM_VECTOR_LEN;
152
+ wasm.js_verenc_verify(retptr, ptr0, len0);
153
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
154
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
155
+ deferred2_0 = r0;
156
+ deferred2_1 = r1;
157
+ return getStringFromWasm0(r0, r1);
158
+ } finally {
159
+ wasm.__wbindgen_add_to_stack_pointer(16);
160
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * @param {string} proof
166
+ * @returns {string}
167
+ */
168
+ function js_verenc_compress(proof) {
169
+ let deferred2_0;
170
+ let deferred2_1;
171
+ try {
172
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
173
+ const ptr0 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
174
+ const len0 = WASM_VECTOR_LEN;
175
+ wasm.js_verenc_compress(retptr, ptr0, len0);
176
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
177
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
178
+ deferred2_0 = r0;
179
+ deferred2_1 = r1;
180
+ return getStringFromWasm0(r0, r1);
181
+ } finally {
182
+ wasm.__wbindgen_add_to_stack_pointer(16);
183
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
184
+ }
185
+ }
186
+
187
+ /**
188
+ * @param {string} recovery
189
+ * @returns {string}
190
+ */
191
+ function js_verenc_recover(recovery) {
192
+ let deferred2_0;
193
+ let deferred2_1;
194
+ try {
195
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
196
+ const ptr0 = passStringToWasm0(recovery, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
197
+ const len0 = WASM_VECTOR_LEN;
198
+ wasm.js_verenc_recover(retptr, ptr0, len0);
199
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
200
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
201
+ deferred2_0 = r0;
202
+ deferred2_1 = r1;
203
+ return getStringFromWasm0(r0, r1);
204
+ } finally {
205
+ wasm.__wbindgen_add_to_stack_pointer(16);
206
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
207
+ }
208
+ }
209
+
210
+ /**
211
+ * @param {string} data
212
+ * @returns {string}
213
+ */
214
+ function js_chunk_data_for_verenc(data) {
215
+ let deferred2_0;
216
+ let deferred2_1;
217
+ try {
218
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
219
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ wasm.js_chunk_data_for_verenc(retptr, ptr0, len0);
222
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
223
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
224
+ deferred2_0 = r0;
225
+ deferred2_1 = r1;
226
+ return getStringFromWasm0(r0, r1);
227
+ } finally {
228
+ wasm.__wbindgen_add_to_stack_pointer(16);
229
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
230
+ }
231
+ }
232
+
233
+ /**
234
+ * @param {string} chunks
235
+ * @returns {string}
236
+ */
237
+ function js_combine_chunked_data(chunks) {
238
+ let deferred2_0;
239
+ let deferred2_1;
240
+ try {
241
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
242
+ const ptr0 = passStringToWasm0(chunks, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
243
+ const len0 = WASM_VECTOR_LEN;
244
+ wasm.js_combine_chunked_data(retptr, ptr0, len0);
245
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
246
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
247
+ deferred2_0 = r0;
248
+ deferred2_1 = r1;
249
+ return getStringFromWasm0(r0, r1);
250
+ } finally {
251
+ wasm.__wbindgen_add_to_stack_pointer(16);
252
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * @param {string} input
258
+ * @param {string} blinding_pubkey
259
+ * @param {string} statement
260
+ * @returns {string}
261
+ */
262
+ function js_verenc_verify_statement(input, blinding_pubkey, statement) {
263
+ let deferred4_0;
264
+ let deferred4_1;
265
+ try {
266
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
267
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
268
+ const len0 = WASM_VECTOR_LEN;
269
+ const ptr1 = passStringToWasm0(blinding_pubkey, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
270
+ const len1 = WASM_VECTOR_LEN;
271
+ const ptr2 = passStringToWasm0(statement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
272
+ const len2 = WASM_VECTOR_LEN;
273
+ wasm.js_verenc_verify_statement(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
274
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
275
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
276
+ deferred4_0 = r0;
277
+ deferred4_1 = r1;
278
+ return getStringFromWasm0(r0, r1);
279
+ } finally {
280
+ wasm.__wbindgen_add_to_stack_pointer(16);
281
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
282
+ }
283
+ }
284
+
285
+ class VerencError extends Error {
286
+ }
287
+ function VerencNewProof(data) {
288
+ const result = JSON.parse(js_new_verenc_proof(Buffer.from(data).toString('hex')));
289
+ if (typeof (result) == 'object') {
290
+ if (result.proof && result.encryption_key) {
291
+ return {
292
+ proof: Buffer.from(result.proof, 'hex'),
293
+ encryptionKey: Buffer.from(result.encryption_key, 'hex'),
294
+ };
295
+ }
296
+ }
297
+ throw new VerencError(result.error || "unknown response");
298
+ }
299
+ function VerencNewProofEncryptOnly(data, encryptionKey) {
300
+ const result = JSON.parse(js_new_verenc_proof_encrypt_only(Buffer.from(data).toString('hex'), Buffer.from(encryptionKey).toString('hex')));
301
+ if (typeof (result) == 'string') {
302
+ return Buffer.from(result, 'hex');
303
+ }
304
+ else {
305
+ throw new VerencError(result.error);
306
+ }
307
+ }
308
+ function VerencVerify(proof) {
309
+ const result = JSON.parse(js_verenc_verify(Buffer.from(proof).toString('hex')));
310
+ if (typeof (result) == 'object') {
311
+ if (result.data && result.blinding_pubkey) {
312
+ return {
313
+ data: Buffer.from(result.data, 'hex'),
314
+ blindingPubkey: Buffer.from(result.blinding_pubkey, 'hex'),
315
+ };
316
+ }
317
+ }
318
+ throw new VerencError(result.error || "unknown response");
319
+ }
320
+ function VerencCompress(proof) {
321
+ const result = JSON.parse(js_verenc_compress(Buffer.from(proof).toString('hex')));
322
+ if (typeof (result) == 'object') {
323
+ if (result.proof && result.recovery) {
324
+ return {
325
+ proof: Buffer.from(result.proof, 'hex'),
326
+ recovery: Buffer.from(result.recovery, 'hex'),
327
+ };
328
+ }
329
+ }
330
+ throw new VerencError(result.error || "unknown response");
331
+ }
332
+ function VerencRecover(recovery) {
333
+ const result = JSON.parse(js_verenc_recover(Buffer.from(recovery).toString('hex')));
334
+ if (typeof (result) == 'string') {
335
+ return Buffer.from(result, 'hex');
336
+ }
337
+ else {
338
+ throw new VerencError(result.error);
339
+ }
340
+ }
341
+ function VerencChunkDataForVerenc(data) {
342
+ const result = JSON.parse(js_chunk_data_for_verenc(Buffer.from(data).toString('hex')));
343
+ if (Array.isArray(result)) {
344
+ return result.map(chunk => Buffer.from(chunk, 'hex'));
345
+ }
346
+ else {
347
+ throw new VerencError(result.error);
348
+ }
349
+ }
350
+ function VerencCombineChunkedData(chunks) {
351
+ const result = JSON.parse(js_combine_chunked_data(JSON.stringify(chunks.map(c => Buffer.from(c).toString('hex')))));
352
+ if (typeof (result) == 'string') {
353
+ return Buffer.from(result, 'hex');
354
+ }
355
+ else {
356
+ throw new VerencError(result.error);
357
+ }
358
+ }
359
+ function VerencVerifyStatement(input, blindingPubkey, statement) {
360
+ const result = JSON.parse(js_verenc_verify_statement(Buffer.from(input).toString('hex'), Buffer.from(blindingPubkey).toString('hex'), Buffer.from(statement).toString('hex')));
361
+ if (typeof (result) == 'boolean') {
362
+ return result;
363
+ }
364
+ else {
365
+ throw new VerencError(result.error);
366
+ }
367
+ }
368
+
369
+ var verenc = /*#__PURE__*/Object.freeze({
370
+ __proto__: null,
371
+ VerencChunkDataForVerenc: VerencChunkDataForVerenc,
372
+ VerencCombineChunkedData: VerencCombineChunkedData,
373
+ VerencCompress: VerencCompress,
374
+ VerencNewProof: VerencNewProof,
375
+ VerencNewProofEncryptOnly: VerencNewProofEncryptOnly,
376
+ VerencRecover: VerencRecover,
377
+ VerencVerify: VerencVerify,
378
+ VerencVerifyStatement: VerencVerifyStatement
379
+ });
380
+
381
+ window.Buffer = Buffer$1;
382
+
383
+ export { verenc };
package/dist/index.js ADDED
@@ -0,0 +1,385 @@
1
+ 'use strict';
2
+
3
+ var buffer = require('buffer');
4
+
5
+ let wasm;
6
+
7
+ const heap = new Array(128).fill(undefined);
8
+
9
+ heap.push(undefined, null, true, false);
10
+
11
+ heap.length;
12
+
13
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
14
+
15
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
16
+ let cachedUint8Memory0 = null;
17
+
18
+ function getUint8Memory0() {
19
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
20
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
21
+ }
22
+ return cachedUint8Memory0;
23
+ }
24
+
25
+ function getStringFromWasm0(ptr, len) {
26
+ ptr = ptr >>> 0;
27
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
28
+ }
29
+
30
+ let WASM_VECTOR_LEN = 0;
31
+
32
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
33
+
34
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
35
+ ? function (arg, view) {
36
+ return cachedTextEncoder.encodeInto(arg, view);
37
+ }
38
+ : function (arg, view) {
39
+ const buf = cachedTextEncoder.encode(arg);
40
+ view.set(buf);
41
+ return {
42
+ read: arg.length,
43
+ written: buf.length
44
+ };
45
+ });
46
+
47
+ function passStringToWasm0(arg, malloc, realloc) {
48
+
49
+ if (realloc === undefined) {
50
+ const buf = cachedTextEncoder.encode(arg);
51
+ const ptr = malloc(buf.length, 1) >>> 0;
52
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
53
+ WASM_VECTOR_LEN = buf.length;
54
+ return ptr;
55
+ }
56
+
57
+ let len = arg.length;
58
+ let ptr = malloc(len, 1) >>> 0;
59
+
60
+ const mem = getUint8Memory0();
61
+
62
+ let offset = 0;
63
+
64
+ for (; offset < len; offset++) {
65
+ const code = arg.charCodeAt(offset);
66
+ if (code > 0x7F) break;
67
+ mem[ptr + offset] = code;
68
+ }
69
+
70
+ if (offset !== len) {
71
+ if (offset !== 0) {
72
+ arg = arg.slice(offset);
73
+ }
74
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
75
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
76
+ const ret = encodeString(arg, view);
77
+
78
+ offset += ret.written;
79
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
80
+ }
81
+
82
+ WASM_VECTOR_LEN = offset;
83
+ return ptr;
84
+ }
85
+
86
+ let cachedInt32Memory0 = null;
87
+
88
+ function getInt32Memory0() {
89
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
90
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
91
+ }
92
+ return cachedInt32Memory0;
93
+ }
94
+ /**
95
+ * @param {string} data
96
+ * @returns {string}
97
+ */
98
+ function js_new_verenc_proof(data) {
99
+ let deferred2_0;
100
+ let deferred2_1;
101
+ try {
102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
103
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ wasm.js_new_verenc_proof(retptr, ptr0, len0);
106
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
107
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
108
+ deferred2_0 = r0;
109
+ deferred2_1 = r1;
110
+ return getStringFromWasm0(r0, r1);
111
+ } finally {
112
+ wasm.__wbindgen_add_to_stack_pointer(16);
113
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * @param {string} data
119
+ * @param {string} encryption_key
120
+ * @returns {string}
121
+ */
122
+ function js_new_verenc_proof_encrypt_only(data, encryption_key) {
123
+ let deferred3_0;
124
+ let deferred3_1;
125
+ try {
126
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
127
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
128
+ const len0 = WASM_VECTOR_LEN;
129
+ const ptr1 = passStringToWasm0(encryption_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
130
+ const len1 = WASM_VECTOR_LEN;
131
+ wasm.js_new_verenc_proof_encrypt_only(retptr, ptr0, len0, ptr1, len1);
132
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
133
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
134
+ deferred3_0 = r0;
135
+ deferred3_1 = r1;
136
+ return getStringFromWasm0(r0, r1);
137
+ } finally {
138
+ wasm.__wbindgen_add_to_stack_pointer(16);
139
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * @param {string} proof
145
+ * @returns {string}
146
+ */
147
+ function js_verenc_verify(proof) {
148
+ let deferred2_0;
149
+ let deferred2_1;
150
+ try {
151
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
152
+ const ptr0 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ wasm.js_verenc_verify(retptr, ptr0, len0);
155
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
156
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
157
+ deferred2_0 = r0;
158
+ deferred2_1 = r1;
159
+ return getStringFromWasm0(r0, r1);
160
+ } finally {
161
+ wasm.__wbindgen_add_to_stack_pointer(16);
162
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
163
+ }
164
+ }
165
+
166
+ /**
167
+ * @param {string} proof
168
+ * @returns {string}
169
+ */
170
+ function js_verenc_compress(proof) {
171
+ let deferred2_0;
172
+ let deferred2_1;
173
+ try {
174
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
175
+ const ptr0 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
176
+ const len0 = WASM_VECTOR_LEN;
177
+ wasm.js_verenc_compress(retptr, ptr0, len0);
178
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
179
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
180
+ deferred2_0 = r0;
181
+ deferred2_1 = r1;
182
+ return getStringFromWasm0(r0, r1);
183
+ } finally {
184
+ wasm.__wbindgen_add_to_stack_pointer(16);
185
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
186
+ }
187
+ }
188
+
189
+ /**
190
+ * @param {string} recovery
191
+ * @returns {string}
192
+ */
193
+ function js_verenc_recover(recovery) {
194
+ let deferred2_0;
195
+ let deferred2_1;
196
+ try {
197
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
198
+ const ptr0 = passStringToWasm0(recovery, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
199
+ const len0 = WASM_VECTOR_LEN;
200
+ wasm.js_verenc_recover(retptr, ptr0, len0);
201
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
202
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
203
+ deferred2_0 = r0;
204
+ deferred2_1 = r1;
205
+ return getStringFromWasm0(r0, r1);
206
+ } finally {
207
+ wasm.__wbindgen_add_to_stack_pointer(16);
208
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
209
+ }
210
+ }
211
+
212
+ /**
213
+ * @param {string} data
214
+ * @returns {string}
215
+ */
216
+ function js_chunk_data_for_verenc(data) {
217
+ let deferred2_0;
218
+ let deferred2_1;
219
+ try {
220
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
221
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
+ const len0 = WASM_VECTOR_LEN;
223
+ wasm.js_chunk_data_for_verenc(retptr, ptr0, len0);
224
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
225
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
226
+ deferred2_0 = r0;
227
+ deferred2_1 = r1;
228
+ return getStringFromWasm0(r0, r1);
229
+ } finally {
230
+ wasm.__wbindgen_add_to_stack_pointer(16);
231
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
232
+ }
233
+ }
234
+
235
+ /**
236
+ * @param {string} chunks
237
+ * @returns {string}
238
+ */
239
+ function js_combine_chunked_data(chunks) {
240
+ let deferred2_0;
241
+ let deferred2_1;
242
+ try {
243
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
244
+ const ptr0 = passStringToWasm0(chunks, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
245
+ const len0 = WASM_VECTOR_LEN;
246
+ wasm.js_combine_chunked_data(retptr, ptr0, len0);
247
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
248
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
249
+ deferred2_0 = r0;
250
+ deferred2_1 = r1;
251
+ return getStringFromWasm0(r0, r1);
252
+ } finally {
253
+ wasm.__wbindgen_add_to_stack_pointer(16);
254
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
255
+ }
256
+ }
257
+
258
+ /**
259
+ * @param {string} input
260
+ * @param {string} blinding_pubkey
261
+ * @param {string} statement
262
+ * @returns {string}
263
+ */
264
+ function js_verenc_verify_statement(input, blinding_pubkey, statement) {
265
+ let deferred4_0;
266
+ let deferred4_1;
267
+ try {
268
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
269
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ptr1 = passStringToWasm0(blinding_pubkey, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
272
+ const len1 = WASM_VECTOR_LEN;
273
+ const ptr2 = passStringToWasm0(statement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
274
+ const len2 = WASM_VECTOR_LEN;
275
+ wasm.js_verenc_verify_statement(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
276
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
277
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
278
+ deferred4_0 = r0;
279
+ deferred4_1 = r1;
280
+ return getStringFromWasm0(r0, r1);
281
+ } finally {
282
+ wasm.__wbindgen_add_to_stack_pointer(16);
283
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
284
+ }
285
+ }
286
+
287
+ class VerencError extends Error {
288
+ }
289
+ function VerencNewProof(data) {
290
+ const result = JSON.parse(js_new_verenc_proof(Buffer.from(data).toString('hex')));
291
+ if (typeof (result) == 'object') {
292
+ if (result.proof && result.encryption_key) {
293
+ return {
294
+ proof: Buffer.from(result.proof, 'hex'),
295
+ encryptionKey: Buffer.from(result.encryption_key, 'hex'),
296
+ };
297
+ }
298
+ }
299
+ throw new VerencError(result.error || "unknown response");
300
+ }
301
+ function VerencNewProofEncryptOnly(data, encryptionKey) {
302
+ const result = JSON.parse(js_new_verenc_proof_encrypt_only(Buffer.from(data).toString('hex'), Buffer.from(encryptionKey).toString('hex')));
303
+ if (typeof (result) == 'string') {
304
+ return Buffer.from(result, 'hex');
305
+ }
306
+ else {
307
+ throw new VerencError(result.error);
308
+ }
309
+ }
310
+ function VerencVerify(proof) {
311
+ const result = JSON.parse(js_verenc_verify(Buffer.from(proof).toString('hex')));
312
+ if (typeof (result) == 'object') {
313
+ if (result.data && result.blinding_pubkey) {
314
+ return {
315
+ data: Buffer.from(result.data, 'hex'),
316
+ blindingPubkey: Buffer.from(result.blinding_pubkey, 'hex'),
317
+ };
318
+ }
319
+ }
320
+ throw new VerencError(result.error || "unknown response");
321
+ }
322
+ function VerencCompress(proof) {
323
+ const result = JSON.parse(js_verenc_compress(Buffer.from(proof).toString('hex')));
324
+ if (typeof (result) == 'object') {
325
+ if (result.proof && result.recovery) {
326
+ return {
327
+ proof: Buffer.from(result.proof, 'hex'),
328
+ recovery: Buffer.from(result.recovery, 'hex'),
329
+ };
330
+ }
331
+ }
332
+ throw new VerencError(result.error || "unknown response");
333
+ }
334
+ function VerencRecover(recovery) {
335
+ const result = JSON.parse(js_verenc_recover(Buffer.from(recovery).toString('hex')));
336
+ if (typeof (result) == 'string') {
337
+ return Buffer.from(result, 'hex');
338
+ }
339
+ else {
340
+ throw new VerencError(result.error);
341
+ }
342
+ }
343
+ function VerencChunkDataForVerenc(data) {
344
+ const result = JSON.parse(js_chunk_data_for_verenc(Buffer.from(data).toString('hex')));
345
+ if (Array.isArray(result)) {
346
+ return result.map(chunk => Buffer.from(chunk, 'hex'));
347
+ }
348
+ else {
349
+ throw new VerencError(result.error);
350
+ }
351
+ }
352
+ function VerencCombineChunkedData(chunks) {
353
+ const result = JSON.parse(js_combine_chunked_data(JSON.stringify(chunks.map(c => Buffer.from(c).toString('hex')))));
354
+ if (typeof (result) == 'string') {
355
+ return Buffer.from(result, 'hex');
356
+ }
357
+ else {
358
+ throw new VerencError(result.error);
359
+ }
360
+ }
361
+ function VerencVerifyStatement(input, blindingPubkey, statement) {
362
+ const result = JSON.parse(js_verenc_verify_statement(Buffer.from(input).toString('hex'), Buffer.from(blindingPubkey).toString('hex'), Buffer.from(statement).toString('hex')));
363
+ if (typeof (result) == 'boolean') {
364
+ return result;
365
+ }
366
+ else {
367
+ throw new VerencError(result.error);
368
+ }
369
+ }
370
+
371
+ var verenc = /*#__PURE__*/Object.freeze({
372
+ __proto__: null,
373
+ VerencChunkDataForVerenc: VerencChunkDataForVerenc,
374
+ VerencCombineChunkedData: VerencCombineChunkedData,
375
+ VerencCompress: VerencCompress,
376
+ VerencNewProof: VerencNewProof,
377
+ VerencNewProofEncryptOnly: VerencNewProofEncryptOnly,
378
+ VerencRecover: VerencRecover,
379
+ VerencVerify: VerencVerify,
380
+ VerencVerifyStatement: VerencVerifyStatement
381
+ });
382
+
383
+ window.Buffer = buffer.Buffer;
384
+
385
+ exports.verenc = verenc;
@@ -0,0 +1,17 @@
1
+ export declare function VerencNewProof(data: ArrayBuffer): {
2
+ proof: Buffer;
3
+ encryptionKey: Buffer;
4
+ };
5
+ export declare function VerencNewProofEncryptOnly(data: ArrayBuffer, encryptionKey: ArrayBuffer): Buffer;
6
+ export declare function VerencVerify(proof: ArrayBuffer): {
7
+ data: Buffer;
8
+ blindingPubkey: Buffer;
9
+ };
10
+ export declare function VerencCompress(proof: ArrayBuffer): {
11
+ proof: Buffer;
12
+ recovery: Buffer;
13
+ };
14
+ export declare function VerencRecover(recovery: ArrayBuffer): Buffer;
15
+ export declare function VerencChunkDataForVerenc(data: ArrayBuffer): Buffer[];
16
+ export declare function VerencCombineChunkedData(chunks: ArrayBuffer[]): Buffer;
17
+ export declare function VerencVerifyStatement(input: ArrayBuffer, blindingPubkey: ArrayBuffer, statement: ArrayBuffer): boolean;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@quilibrium/quilibrium-js-verenc-sdk",
3
+ "version": "2.1.0-0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "scripts": {
13
+ "build": "rollup -c",
14
+ "dev": "rollup -c -w",
15
+ "clean": "rimraf dist"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.esm.js",
24
+ "require": "./dist/index.js"
25
+ }
26
+ },
27
+ "dependencies": {
28
+ "base58-js": "^2.0.0",
29
+ "buffer": "^6.0.3",
30
+ "multiformats": "^13.3.1",
31
+ "react": "^18.0.0",
32
+ "react-dom": "^18.0.0",
33
+ "react-dropzone": "^14.3.5"
34
+ },
35
+ "devDependencies": {
36
+ "@rollup/plugin-commonjs": "^28.0.2",
37
+ "@rollup/plugin-node-resolve": "^16.0.0",
38
+ "@rollup/plugin-typescript": "^12.1.2",
39
+ "@rollup/plugin-wasm": "^6.2.2",
40
+ "@types/react": "^19.0.7",
41
+ "@types/react-dom": "^19.0.3",
42
+ "rollup": "^4.30.1",
43
+ "rollup-plugin-dts": "^6.1.1",
44
+ "tailwindcss": "^3.4.17",
45
+ "typescript": "^5.7.3"
46
+ }
47
+ }