@quilibrium/quilibrium-js-bls48581-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,19 @@
1
+ export declare function BLS48581CommitRaw(data: ArrayBuffer, poly_size: number): Buffer;
2
+ export declare function BLS48581ProveRaw(data: ArrayBuffer, index: number, poly_size: number): Buffer;
3
+ export declare function BLS48581VerifyRaw(data: ArrayBuffer, commit: ArrayBuffer, index: number, proof: ArrayBuffer, poly_size: number): Buffer;
4
+ export declare function BLS48581Keygen(): {
5
+ secretKey: Buffer;
6
+ publicKey: Buffer;
7
+ proofOfPossessionSig: Buffer;
8
+ };
9
+ export declare function BLS48581Sign(secretKey: ArrayBuffer, msg: ArrayBuffer, domain: ArrayBuffer): Buffer;
10
+ export declare function BLS48581Verify(publicKey: ArrayBuffer, signature: ArrayBuffer, msg: ArrayBuffer, domain: ArrayBuffer): boolean;
11
+ export declare function BLS48581Aggregate(publicKeys: ArrayBuffer[], signatures: ArrayBuffer[]): {
12
+ aggregatePublicKey: Buffer;
13
+ aggregateSignature: Buffer;
14
+ };
15
+ export declare function BLS48581ProveMultiple(commitments: ArrayBuffer[], polys: ArrayBuffer[], indices: number[], poly_size: number): {
16
+ d: Buffer;
17
+ proof: Buffer;
18
+ };
19
+ export declare function BLS48581VerifyMultiple(commitments: ArrayBuffer[], evaluations: ArrayBuffer[], indices: number[], poly_size: number, d: ArrayBuffer, proof: ArrayBuffer): boolean;
@@ -0,0 +1,44 @@
1
+ declare function BLS48581CommitRaw(data: ArrayBuffer, poly_size: number): Buffer;
2
+ declare function BLS48581ProveRaw(data: ArrayBuffer, index: number, poly_size: number): Buffer;
3
+ declare function BLS48581VerifyRaw(data: ArrayBuffer, commit: ArrayBuffer, index: number, proof: ArrayBuffer, poly_size: number): Buffer;
4
+ declare function BLS48581Keygen(): {
5
+ secretKey: Buffer;
6
+ publicKey: Buffer;
7
+ proofOfPossessionSig: Buffer;
8
+ };
9
+ declare function BLS48581Sign(secretKey: ArrayBuffer, msg: ArrayBuffer, domain: ArrayBuffer): Buffer;
10
+ declare function BLS48581Verify(publicKey: ArrayBuffer, signature: ArrayBuffer, msg: ArrayBuffer, domain: ArrayBuffer): boolean;
11
+ declare function BLS48581Aggregate(publicKeys: ArrayBuffer[], signatures: ArrayBuffer[]): {
12
+ aggregatePublicKey: Buffer;
13
+ aggregateSignature: Buffer;
14
+ };
15
+ declare function BLS48581ProveMultiple(commitments: ArrayBuffer[], polys: ArrayBuffer[], indices: number[], poly_size: number): {
16
+ d: Buffer;
17
+ proof: Buffer;
18
+ };
19
+ declare function BLS48581VerifyMultiple(commitments: ArrayBuffer[], evaluations: ArrayBuffer[], indices: number[], poly_size: number, d: ArrayBuffer, proof: ArrayBuffer): boolean;
20
+
21
+ declare const bls48581_BLS48581Aggregate: typeof BLS48581Aggregate;
22
+ declare const bls48581_BLS48581CommitRaw: typeof BLS48581CommitRaw;
23
+ declare const bls48581_BLS48581Keygen: typeof BLS48581Keygen;
24
+ declare const bls48581_BLS48581ProveMultiple: typeof BLS48581ProveMultiple;
25
+ declare const bls48581_BLS48581ProveRaw: typeof BLS48581ProveRaw;
26
+ declare const bls48581_BLS48581Sign: typeof BLS48581Sign;
27
+ declare const bls48581_BLS48581Verify: typeof BLS48581Verify;
28
+ declare const bls48581_BLS48581VerifyMultiple: typeof BLS48581VerifyMultiple;
29
+ declare const bls48581_BLS48581VerifyRaw: typeof BLS48581VerifyRaw;
30
+ declare namespace bls48581 {
31
+ export {
32
+ bls48581_BLS48581Aggregate as BLS48581Aggregate,
33
+ bls48581_BLS48581CommitRaw as BLS48581CommitRaw,
34
+ bls48581_BLS48581Keygen as BLS48581Keygen,
35
+ bls48581_BLS48581ProveMultiple as BLS48581ProveMultiple,
36
+ bls48581_BLS48581ProveRaw as BLS48581ProveRaw,
37
+ bls48581_BLS48581Sign as BLS48581Sign,
38
+ bls48581_BLS48581Verify as BLS48581Verify,
39
+ bls48581_BLS48581VerifyMultiple as BLS48581VerifyMultiple,
40
+ bls48581_BLS48581VerifyRaw as BLS48581VerifyRaw,
41
+ };
42
+ }
43
+
44
+ export { bls48581 as verenc };
@@ -0,0 +1,454 @@
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
+ * @param {bigint} poly_size
95
+ * @returns {string}
96
+ */
97
+ function js_commit_raw(data, poly_size) {
98
+ let deferred2_0;
99
+ let deferred2_1;
100
+ try {
101
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
102
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ wasm.js_commit_raw(retptr, ptr0, len0, poly_size);
105
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
106
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
107
+ deferred2_0 = r0;
108
+ deferred2_1 = r1;
109
+ return getStringFromWasm0(r0, r1);
110
+ } finally {
111
+ wasm.__wbindgen_add_to_stack_pointer(16);
112
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
113
+ }
114
+ }
115
+
116
+ /**
117
+ * @param {string} data
118
+ * @param {bigint} index
119
+ * @param {bigint} poly_size
120
+ * @returns {string}
121
+ */
122
+ function js_prove_raw(data, index, poly_size) {
123
+ let deferred2_0;
124
+ let deferred2_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
+ wasm.js_prove_raw(retptr, ptr0, len0, index, poly_size);
130
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
131
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
132
+ deferred2_0 = r0;
133
+ deferred2_1 = r1;
134
+ return getStringFromWasm0(r0, r1);
135
+ } finally {
136
+ wasm.__wbindgen_add_to_stack_pointer(16);
137
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * @param {string} data
143
+ * @param {string} commit
144
+ * @param {bigint} index
145
+ * @param {string} proof
146
+ * @param {bigint} poly_size
147
+ * @returns {string}
148
+ */
149
+ function js_verify_raw(data, commit, index, proof, poly_size) {
150
+ let deferred4_0;
151
+ let deferred4_1;
152
+ try {
153
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
154
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
155
+ const len0 = WASM_VECTOR_LEN;
156
+ const ptr1 = passStringToWasm0(commit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len1 = WASM_VECTOR_LEN;
158
+ const ptr2 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len2 = WASM_VECTOR_LEN;
160
+ wasm.js_verify_raw(retptr, ptr0, len0, ptr1, len1, index, ptr2, len2, poly_size);
161
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
162
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
163
+ deferred4_0 = r0;
164
+ deferred4_1 = r1;
165
+ return getStringFromWasm0(r0, r1);
166
+ } finally {
167
+ wasm.__wbindgen_add_to_stack_pointer(16);
168
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
169
+ }
170
+ }
171
+
172
+ /**
173
+ * @returns {string}
174
+ */
175
+ function js_bls_keygen() {
176
+ let deferred1_0;
177
+ let deferred1_1;
178
+ try {
179
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
180
+ wasm.js_bls_keygen(retptr);
181
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
182
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
183
+ deferred1_0 = r0;
184
+ deferred1_1 = r1;
185
+ return getStringFromWasm0(r0, r1);
186
+ } finally {
187
+ wasm.__wbindgen_add_to_stack_pointer(16);
188
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
189
+ }
190
+ }
191
+
192
+ /**
193
+ * @param {string} sk
194
+ * @param {string} msg
195
+ * @param {string} domain
196
+ * @returns {string}
197
+ */
198
+ function js_bls_sign(sk, msg, domain) {
199
+ let deferred4_0;
200
+ let deferred4_1;
201
+ try {
202
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
203
+ const ptr0 = passStringToWasm0(sk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
204
+ const len0 = WASM_VECTOR_LEN;
205
+ const ptr1 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
+ const len1 = WASM_VECTOR_LEN;
207
+ const ptr2 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
+ const len2 = WASM_VECTOR_LEN;
209
+ wasm.js_bls_sign(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
210
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
211
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
212
+ deferred4_0 = r0;
213
+ deferred4_1 = r1;
214
+ return getStringFromWasm0(r0, r1);
215
+ } finally {
216
+ wasm.__wbindgen_add_to_stack_pointer(16);
217
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * @param {string} pk
223
+ * @param {string} sig
224
+ * @param {string} msg
225
+ * @param {string} domain
226
+ * @returns {string}
227
+ */
228
+ function js_bls_verify(pk, sig, msg, domain) {
229
+ let deferred5_0;
230
+ let deferred5_1;
231
+ try {
232
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
233
+ const ptr0 = passStringToWasm0(pk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
234
+ const len0 = WASM_VECTOR_LEN;
235
+ const ptr1 = passStringToWasm0(sig, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
236
+ const len1 = WASM_VECTOR_LEN;
237
+ const ptr2 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
238
+ const len2 = WASM_VECTOR_LEN;
239
+ const ptr3 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
+ const len3 = WASM_VECTOR_LEN;
241
+ wasm.js_bls_verify(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
242
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
243
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
244
+ deferred5_0 = r0;
245
+ deferred5_1 = r1;
246
+ return getStringFromWasm0(r0, r1);
247
+ } finally {
248
+ wasm.__wbindgen_add_to_stack_pointer(16);
249
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
250
+ }
251
+ }
252
+
253
+ /**
254
+ * @param {string} pks
255
+ * @param {string} sigs
256
+ * @returns {string}
257
+ */
258
+ function js_bls_aggregate(pks, sigs) {
259
+ let deferred3_0;
260
+ let deferred3_1;
261
+ try {
262
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
263
+ const ptr0 = passStringToWasm0(pks, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
264
+ const len0 = WASM_VECTOR_LEN;
265
+ const ptr1 = passStringToWasm0(sigs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
266
+ const len1 = WASM_VECTOR_LEN;
267
+ wasm.js_bls_aggregate(retptr, ptr0, len0, ptr1, len1);
268
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
269
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
270
+ deferred3_0 = r0;
271
+ deferred3_1 = r1;
272
+ return getStringFromWasm0(r0, r1);
273
+ } finally {
274
+ wasm.__wbindgen_add_to_stack_pointer(16);
275
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * @param {string} commitments
281
+ * @param {string} polys
282
+ * @param {string} indices
283
+ * @param {bigint} poly_size
284
+ * @returns {string}
285
+ */
286
+ function js_prove_multiple(commitments, polys, indices, poly_size) {
287
+ let deferred4_0;
288
+ let deferred4_1;
289
+ try {
290
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
291
+ const ptr0 = passStringToWasm0(commitments, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ptr1 = passStringToWasm0(polys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
294
+ const len1 = WASM_VECTOR_LEN;
295
+ const ptr2 = passStringToWasm0(indices, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
296
+ const len2 = WASM_VECTOR_LEN;
297
+ wasm.js_prove_multiple(retptr, ptr0, len0, ptr1, len1, ptr2, len2, poly_size);
298
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
299
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
300
+ deferred4_0 = r0;
301
+ deferred4_1 = r1;
302
+ return getStringFromWasm0(r0, r1);
303
+ } finally {
304
+ wasm.__wbindgen_add_to_stack_pointer(16);
305
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
306
+ }
307
+ }
308
+
309
+ /**
310
+ * @param {string} commits
311
+ * @param {string} y_bytes
312
+ * @param {string} indices
313
+ * @param {bigint} poly_size
314
+ * @param {string} c_q_bytes
315
+ * @param {string} proof_bytes
316
+ * @returns {string}
317
+ */
318
+ function js_verify_multiple(commits, y_bytes, indices, poly_size, c_q_bytes, proof_bytes) {
319
+ let deferred6_0;
320
+ let deferred6_1;
321
+ try {
322
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
323
+ const ptr0 = passStringToWasm0(commits, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
324
+ const len0 = WASM_VECTOR_LEN;
325
+ const ptr1 = passStringToWasm0(y_bytes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
326
+ const len1 = WASM_VECTOR_LEN;
327
+ const ptr2 = passStringToWasm0(indices, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
328
+ const len2 = WASM_VECTOR_LEN;
329
+ const ptr3 = passStringToWasm0(c_q_bytes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len3 = WASM_VECTOR_LEN;
331
+ const ptr4 = passStringToWasm0(proof_bytes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ const len4 = WASM_VECTOR_LEN;
333
+ wasm.js_verify_multiple(retptr, ptr0, len0, ptr1, len1, ptr2, len2, poly_size, ptr3, len3, ptr4, len4);
334
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
335
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
336
+ deferred6_0 = r0;
337
+ deferred6_1 = r1;
338
+ return getStringFromWasm0(r0, r1);
339
+ } finally {
340
+ wasm.__wbindgen_add_to_stack_pointer(16);
341
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
342
+ }
343
+ }
344
+
345
+ class BLS48581Error extends Error {
346
+ }
347
+ function BLS48581CommitRaw(data, poly_size) {
348
+ const result = JSON.parse(js_commit_raw(Buffer.from(data).toString('hex'), BigInt(poly_size)));
349
+ if (typeof (result) == 'string') {
350
+ return Buffer.from(result, 'hex');
351
+ }
352
+ else {
353
+ throw new BLS48581Error(result.error);
354
+ }
355
+ }
356
+ function BLS48581ProveRaw(data, index, poly_size) {
357
+ const result = JSON.parse(js_prove_raw(Buffer.from(data).toString('hex'), BigInt(index), BigInt(poly_size)));
358
+ if (typeof (result) == 'string') {
359
+ return Buffer.from(result, 'hex');
360
+ }
361
+ else {
362
+ throw new BLS48581Error(result.error);
363
+ }
364
+ }
365
+ function BLS48581VerifyRaw(data, commit, index, proof, poly_size) {
366
+ const result = JSON.parse(js_verify_raw(Buffer.from(data).toString('hex'), Buffer.from(commit).toString('hex'), BigInt(index), Buffer.from(proof).toString('hex'), BigInt(poly_size)));
367
+ if (typeof (result) == 'string') {
368
+ return Buffer.from(result, 'hex');
369
+ }
370
+ else {
371
+ throw new BLS48581Error(result.error);
372
+ }
373
+ }
374
+ function BLS48581Keygen() {
375
+ const result = JSON.parse(js_bls_keygen());
376
+ if (typeof (result) == 'object') {
377
+ if (result.secret_key && result.public_key && result.proof_of_possession_sig) {
378
+ return {
379
+ secretKey: Buffer.from(result.secret_key, 'hex'),
380
+ publicKey: Buffer.from(result.public_key, 'hex'),
381
+ proofOfPossessionSig: Buffer.from(result.proof_of_possession_sig, 'hex'),
382
+ };
383
+ }
384
+ }
385
+ throw new BLS48581Error("unknown response");
386
+ }
387
+ function BLS48581Sign(secretKey, msg, domain) {
388
+ const result = JSON.parse(js_bls_sign(Buffer.from(secretKey).toString('hex'), Buffer.from(msg).toString('hex'), Buffer.from(domain).toString('hex')));
389
+ if (typeof (result) == 'string') {
390
+ return Buffer.from(result, 'hex');
391
+ }
392
+ else {
393
+ throw new BLS48581Error(result.error);
394
+ }
395
+ }
396
+ function BLS48581Verify(publicKey, signature, msg, domain) {
397
+ const result = JSON.parse(js_bls_verify(Buffer.from(publicKey).toString('hex'), Buffer.from(signature).toString('hex'), Buffer.from(msg).toString('hex'), Buffer.from(domain).toString('hex')));
398
+ if (typeof (result) == 'boolean') {
399
+ return result;
400
+ }
401
+ else {
402
+ throw new BLS48581Error(result.error);
403
+ }
404
+ }
405
+ function BLS48581Aggregate(publicKeys, signatures) {
406
+ const result = JSON.parse(js_bls_aggregate(JSON.stringify(publicKeys.map(p => Buffer.from(p).toString('hex'))), JSON.stringify(signatures.map(s => Buffer.from(s).toString('hex')))));
407
+ if (typeof (result) == 'object') {
408
+ if (result.aggregate_public_key && result.aggregate_signature) {
409
+ return {
410
+ aggregatePublicKey: Buffer.from(result.aggregate_public_key, 'hex'),
411
+ aggregateSignature: Buffer.from(result.aggregate_signature, 'hex'),
412
+ };
413
+ }
414
+ }
415
+ throw new BLS48581Error("unknown response");
416
+ }
417
+ function BLS48581ProveMultiple(commitments, polys, indices, poly_size) {
418
+ const result = JSON.parse(js_prove_multiple(JSON.stringify(commitments.map(c => Buffer.from(c).toString('hex'))), JSON.stringify(polys.map(p => Buffer.from(p).toString('hex'))), JSON.stringify(indices), BigInt(poly_size)));
419
+ if (typeof (result) == 'object') {
420
+ if (result.d && result.proof) {
421
+ return {
422
+ d: Buffer.from(result.d, 'hex'),
423
+ proof: Buffer.from(result.proof, 'hex'),
424
+ };
425
+ }
426
+ }
427
+ throw new BLS48581Error("unknown response");
428
+ }
429
+ function BLS48581VerifyMultiple(commitments, evaluations, indices, poly_size, d, proof) {
430
+ const result = JSON.parse(js_verify_multiple(JSON.stringify(commitments.map(c => Buffer.from(c).toString('hex'))), JSON.stringify(evaluations.map(e => Buffer.from(e).toString('hex'))), JSON.stringify(indices), BigInt(poly_size), Buffer.from(d).toString('hex'), Buffer.from(proof).toString('hex')));
431
+ if (typeof (result) == 'boolean') {
432
+ return result;
433
+ }
434
+ else {
435
+ throw new BLS48581Error(result.error);
436
+ }
437
+ }
438
+
439
+ var bls48581 = /*#__PURE__*/Object.freeze({
440
+ __proto__: null,
441
+ BLS48581Aggregate: BLS48581Aggregate,
442
+ BLS48581CommitRaw: BLS48581CommitRaw,
443
+ BLS48581Keygen: BLS48581Keygen,
444
+ BLS48581ProveMultiple: BLS48581ProveMultiple,
445
+ BLS48581ProveRaw: BLS48581ProveRaw,
446
+ BLS48581Sign: BLS48581Sign,
447
+ BLS48581Verify: BLS48581Verify,
448
+ BLS48581VerifyMultiple: BLS48581VerifyMultiple,
449
+ BLS48581VerifyRaw: BLS48581VerifyRaw
450
+ });
451
+
452
+ window.Buffer = Buffer$1;
453
+
454
+ export { bls48581 as verenc };
package/dist/index.js ADDED
@@ -0,0 +1,456 @@
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
+ * @param {bigint} poly_size
97
+ * @returns {string}
98
+ */
99
+ function js_commit_raw(data, poly_size) {
100
+ let deferred2_0;
101
+ let deferred2_1;
102
+ try {
103
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
105
+ const len0 = WASM_VECTOR_LEN;
106
+ wasm.js_commit_raw(retptr, ptr0, len0, poly_size);
107
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
108
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
109
+ deferred2_0 = r0;
110
+ deferred2_1 = r1;
111
+ return getStringFromWasm0(r0, r1);
112
+ } finally {
113
+ wasm.__wbindgen_add_to_stack_pointer(16);
114
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
115
+ }
116
+ }
117
+
118
+ /**
119
+ * @param {string} data
120
+ * @param {bigint} index
121
+ * @param {bigint} poly_size
122
+ * @returns {string}
123
+ */
124
+ function js_prove_raw(data, index, poly_size) {
125
+ let deferred2_0;
126
+ let deferred2_1;
127
+ try {
128
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
129
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
130
+ const len0 = WASM_VECTOR_LEN;
131
+ wasm.js_prove_raw(retptr, ptr0, len0, index, poly_size);
132
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
133
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
134
+ deferred2_0 = r0;
135
+ deferred2_1 = r1;
136
+ return getStringFromWasm0(r0, r1);
137
+ } finally {
138
+ wasm.__wbindgen_add_to_stack_pointer(16);
139
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * @param {string} data
145
+ * @param {string} commit
146
+ * @param {bigint} index
147
+ * @param {string} proof
148
+ * @param {bigint} poly_size
149
+ * @returns {string}
150
+ */
151
+ function js_verify_raw(data, commit, index, proof, poly_size) {
152
+ let deferred4_0;
153
+ let deferred4_1;
154
+ try {
155
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len0 = WASM_VECTOR_LEN;
158
+ const ptr1 = passStringToWasm0(commit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len1 = WASM_VECTOR_LEN;
160
+ const ptr2 = passStringToWasm0(proof, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len2 = WASM_VECTOR_LEN;
162
+ wasm.js_verify_raw(retptr, ptr0, len0, ptr1, len1, index, ptr2, len2, poly_size);
163
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
164
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
165
+ deferred4_0 = r0;
166
+ deferred4_1 = r1;
167
+ return getStringFromWasm0(r0, r1);
168
+ } finally {
169
+ wasm.__wbindgen_add_to_stack_pointer(16);
170
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * @returns {string}
176
+ */
177
+ function js_bls_keygen() {
178
+ let deferred1_0;
179
+ let deferred1_1;
180
+ try {
181
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
182
+ wasm.js_bls_keygen(retptr);
183
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
184
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
185
+ deferred1_0 = r0;
186
+ deferred1_1 = r1;
187
+ return getStringFromWasm0(r0, r1);
188
+ } finally {
189
+ wasm.__wbindgen_add_to_stack_pointer(16);
190
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * @param {string} sk
196
+ * @param {string} msg
197
+ * @param {string} domain
198
+ * @returns {string}
199
+ */
200
+ function js_bls_sign(sk, msg, domain) {
201
+ let deferred4_0;
202
+ let deferred4_1;
203
+ try {
204
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
205
+ const ptr0 = passStringToWasm0(sk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
+ const len0 = WASM_VECTOR_LEN;
207
+ const ptr1 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
+ const len1 = WASM_VECTOR_LEN;
209
+ const ptr2 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
210
+ const len2 = WASM_VECTOR_LEN;
211
+ wasm.js_bls_sign(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
212
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
213
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
214
+ deferred4_0 = r0;
215
+ deferred4_1 = r1;
216
+ return getStringFromWasm0(r0, r1);
217
+ } finally {
218
+ wasm.__wbindgen_add_to_stack_pointer(16);
219
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
220
+ }
221
+ }
222
+
223
+ /**
224
+ * @param {string} pk
225
+ * @param {string} sig
226
+ * @param {string} msg
227
+ * @param {string} domain
228
+ * @returns {string}
229
+ */
230
+ function js_bls_verify(pk, sig, msg, domain) {
231
+ let deferred5_0;
232
+ let deferred5_1;
233
+ try {
234
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
235
+ const ptr0 = passStringToWasm0(pk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
236
+ const len0 = WASM_VECTOR_LEN;
237
+ const ptr1 = passStringToWasm0(sig, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
238
+ const len1 = WASM_VECTOR_LEN;
239
+ const ptr2 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
+ const len2 = WASM_VECTOR_LEN;
241
+ const ptr3 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
242
+ const len3 = WASM_VECTOR_LEN;
243
+ wasm.js_bls_verify(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
244
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
245
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
246
+ deferred5_0 = r0;
247
+ deferred5_1 = r1;
248
+ return getStringFromWasm0(r0, r1);
249
+ } finally {
250
+ wasm.__wbindgen_add_to_stack_pointer(16);
251
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
252
+ }
253
+ }
254
+
255
+ /**
256
+ * @param {string} pks
257
+ * @param {string} sigs
258
+ * @returns {string}
259
+ */
260
+ function js_bls_aggregate(pks, sigs) {
261
+ let deferred3_0;
262
+ let deferred3_1;
263
+ try {
264
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
265
+ const ptr0 = passStringToWasm0(pks, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
266
+ const len0 = WASM_VECTOR_LEN;
267
+ const ptr1 = passStringToWasm0(sigs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
268
+ const len1 = WASM_VECTOR_LEN;
269
+ wasm.js_bls_aggregate(retptr, ptr0, len0, ptr1, len1);
270
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
271
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
272
+ deferred3_0 = r0;
273
+ deferred3_1 = r1;
274
+ return getStringFromWasm0(r0, r1);
275
+ } finally {
276
+ wasm.__wbindgen_add_to_stack_pointer(16);
277
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
278
+ }
279
+ }
280
+
281
+ /**
282
+ * @param {string} commitments
283
+ * @param {string} polys
284
+ * @param {string} indices
285
+ * @param {bigint} poly_size
286
+ * @returns {string}
287
+ */
288
+ function js_prove_multiple(commitments, polys, indices, poly_size) {
289
+ let deferred4_0;
290
+ let deferred4_1;
291
+ try {
292
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
293
+ const ptr0 = passStringToWasm0(commitments, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
294
+ const len0 = WASM_VECTOR_LEN;
295
+ const ptr1 = passStringToWasm0(polys, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
296
+ const len1 = WASM_VECTOR_LEN;
297
+ const ptr2 = passStringToWasm0(indices, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
298
+ const len2 = WASM_VECTOR_LEN;
299
+ wasm.js_prove_multiple(retptr, ptr0, len0, ptr1, len1, ptr2, len2, poly_size);
300
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
301
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
302
+ deferred4_0 = r0;
303
+ deferred4_1 = r1;
304
+ return getStringFromWasm0(r0, r1);
305
+ } finally {
306
+ wasm.__wbindgen_add_to_stack_pointer(16);
307
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
308
+ }
309
+ }
310
+
311
+ /**
312
+ * @param {string} commits
313
+ * @param {string} y_bytes
314
+ * @param {string} indices
315
+ * @param {bigint} poly_size
316
+ * @param {string} c_q_bytes
317
+ * @param {string} proof_bytes
318
+ * @returns {string}
319
+ */
320
+ function js_verify_multiple(commits, y_bytes, indices, poly_size, c_q_bytes, proof_bytes) {
321
+ let deferred6_0;
322
+ let deferred6_1;
323
+ try {
324
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
325
+ const ptr0 = passStringToWasm0(commits, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
326
+ const len0 = WASM_VECTOR_LEN;
327
+ const ptr1 = passStringToWasm0(y_bytes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
328
+ const len1 = WASM_VECTOR_LEN;
329
+ const ptr2 = passStringToWasm0(indices, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len2 = WASM_VECTOR_LEN;
331
+ const ptr3 = passStringToWasm0(c_q_bytes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ const len3 = WASM_VECTOR_LEN;
333
+ const ptr4 = passStringToWasm0(proof_bytes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ const len4 = WASM_VECTOR_LEN;
335
+ wasm.js_verify_multiple(retptr, ptr0, len0, ptr1, len1, ptr2, len2, poly_size, ptr3, len3, ptr4, len4);
336
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
337
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
338
+ deferred6_0 = r0;
339
+ deferred6_1 = r1;
340
+ return getStringFromWasm0(r0, r1);
341
+ } finally {
342
+ wasm.__wbindgen_add_to_stack_pointer(16);
343
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
344
+ }
345
+ }
346
+
347
+ class BLS48581Error extends Error {
348
+ }
349
+ function BLS48581CommitRaw(data, poly_size) {
350
+ const result = JSON.parse(js_commit_raw(Buffer.from(data).toString('hex'), BigInt(poly_size)));
351
+ if (typeof (result) == 'string') {
352
+ return Buffer.from(result, 'hex');
353
+ }
354
+ else {
355
+ throw new BLS48581Error(result.error);
356
+ }
357
+ }
358
+ function BLS48581ProveRaw(data, index, poly_size) {
359
+ const result = JSON.parse(js_prove_raw(Buffer.from(data).toString('hex'), BigInt(index), BigInt(poly_size)));
360
+ if (typeof (result) == 'string') {
361
+ return Buffer.from(result, 'hex');
362
+ }
363
+ else {
364
+ throw new BLS48581Error(result.error);
365
+ }
366
+ }
367
+ function BLS48581VerifyRaw(data, commit, index, proof, poly_size) {
368
+ const result = JSON.parse(js_verify_raw(Buffer.from(data).toString('hex'), Buffer.from(commit).toString('hex'), BigInt(index), Buffer.from(proof).toString('hex'), BigInt(poly_size)));
369
+ if (typeof (result) == 'string') {
370
+ return Buffer.from(result, 'hex');
371
+ }
372
+ else {
373
+ throw new BLS48581Error(result.error);
374
+ }
375
+ }
376
+ function BLS48581Keygen() {
377
+ const result = JSON.parse(js_bls_keygen());
378
+ if (typeof (result) == 'object') {
379
+ if (result.secret_key && result.public_key && result.proof_of_possession_sig) {
380
+ return {
381
+ secretKey: Buffer.from(result.secret_key, 'hex'),
382
+ publicKey: Buffer.from(result.public_key, 'hex'),
383
+ proofOfPossessionSig: Buffer.from(result.proof_of_possession_sig, 'hex'),
384
+ };
385
+ }
386
+ }
387
+ throw new BLS48581Error("unknown response");
388
+ }
389
+ function BLS48581Sign(secretKey, msg, domain) {
390
+ const result = JSON.parse(js_bls_sign(Buffer.from(secretKey).toString('hex'), Buffer.from(msg).toString('hex'), Buffer.from(domain).toString('hex')));
391
+ if (typeof (result) == 'string') {
392
+ return Buffer.from(result, 'hex');
393
+ }
394
+ else {
395
+ throw new BLS48581Error(result.error);
396
+ }
397
+ }
398
+ function BLS48581Verify(publicKey, signature, msg, domain) {
399
+ const result = JSON.parse(js_bls_verify(Buffer.from(publicKey).toString('hex'), Buffer.from(signature).toString('hex'), Buffer.from(msg).toString('hex'), Buffer.from(domain).toString('hex')));
400
+ if (typeof (result) == 'boolean') {
401
+ return result;
402
+ }
403
+ else {
404
+ throw new BLS48581Error(result.error);
405
+ }
406
+ }
407
+ function BLS48581Aggregate(publicKeys, signatures) {
408
+ const result = JSON.parse(js_bls_aggregate(JSON.stringify(publicKeys.map(p => Buffer.from(p).toString('hex'))), JSON.stringify(signatures.map(s => Buffer.from(s).toString('hex')))));
409
+ if (typeof (result) == 'object') {
410
+ if (result.aggregate_public_key && result.aggregate_signature) {
411
+ return {
412
+ aggregatePublicKey: Buffer.from(result.aggregate_public_key, 'hex'),
413
+ aggregateSignature: Buffer.from(result.aggregate_signature, 'hex'),
414
+ };
415
+ }
416
+ }
417
+ throw new BLS48581Error("unknown response");
418
+ }
419
+ function BLS48581ProveMultiple(commitments, polys, indices, poly_size) {
420
+ const result = JSON.parse(js_prove_multiple(JSON.stringify(commitments.map(c => Buffer.from(c).toString('hex'))), JSON.stringify(polys.map(p => Buffer.from(p).toString('hex'))), JSON.stringify(indices), BigInt(poly_size)));
421
+ if (typeof (result) == 'object') {
422
+ if (result.d && result.proof) {
423
+ return {
424
+ d: Buffer.from(result.d, 'hex'),
425
+ proof: Buffer.from(result.proof, 'hex'),
426
+ };
427
+ }
428
+ }
429
+ throw new BLS48581Error("unknown response");
430
+ }
431
+ function BLS48581VerifyMultiple(commitments, evaluations, indices, poly_size, d, proof) {
432
+ const result = JSON.parse(js_verify_multiple(JSON.stringify(commitments.map(c => Buffer.from(c).toString('hex'))), JSON.stringify(evaluations.map(e => Buffer.from(e).toString('hex'))), JSON.stringify(indices), BigInt(poly_size), Buffer.from(d).toString('hex'), Buffer.from(proof).toString('hex')));
433
+ if (typeof (result) == 'boolean') {
434
+ return result;
435
+ }
436
+ else {
437
+ throw new BLS48581Error(result.error);
438
+ }
439
+ }
440
+
441
+ var bls48581 = /*#__PURE__*/Object.freeze({
442
+ __proto__: null,
443
+ BLS48581Aggregate: BLS48581Aggregate,
444
+ BLS48581CommitRaw: BLS48581CommitRaw,
445
+ BLS48581Keygen: BLS48581Keygen,
446
+ BLS48581ProveMultiple: BLS48581ProveMultiple,
447
+ BLS48581ProveRaw: BLS48581ProveRaw,
448
+ BLS48581Sign: BLS48581Sign,
449
+ BLS48581Verify: BLS48581Verify,
450
+ BLS48581VerifyMultiple: BLS48581VerifyMultiple,
451
+ BLS48581VerifyRaw: BLS48581VerifyRaw
452
+ });
453
+
454
+ window.Buffer = buffer.Buffer;
455
+
456
+ exports.verenc = bls48581;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@quilibrium/quilibrium-js-bls48581-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
+ }