@crisp-e3/zk-inputs 0.5.11 → 0.6.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/dist/index.d.ts +6 -7
- package/dist/index.js +36 -126
- package/dist/index_base64.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export class ZKInputsGenerator {
|
|
|
8
8
|
free(): void;
|
|
9
9
|
[Symbol.dispose](): void;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Decrypt a vote from JavaScript.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
decryptVote(secret_key: Uint8Array, ciphertext: Uint8Array): BigInt64Array;
|
|
14
14
|
/**
|
|
15
15
|
* Encrypt a vote from JavaScript.
|
|
16
16
|
*/
|
|
@@ -24,9 +24,9 @@ export class ZKInputsGenerator {
|
|
|
24
24
|
*/
|
|
25
25
|
generateInputsForUpdate(prev_ciphertext: Uint8Array, public_key: Uint8Array, vote: BigInt64Array): any;
|
|
26
26
|
/**
|
|
27
|
-
* Generate a public key from JavaScript.
|
|
27
|
+
* Generate a public/secret key pair from JavaScript.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
generateKeys(): any;
|
|
30
30
|
/**
|
|
31
31
|
* Get the BFV parameters used by the generator.
|
|
32
32
|
*/
|
|
@@ -59,16 +59,15 @@ export interface InitOutput {
|
|
|
59
59
|
readonly zkinputsgenerator_withDefaults: () => [number, number, number];
|
|
60
60
|
readonly zkinputsgenerator_generateInputs: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
61
61
|
readonly zkinputsgenerator_generateInputsForUpdate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
62
|
-
readonly
|
|
63
|
-
readonly zkinputsgenerator_computeCiphertextCommitment: (a: number, b: any, c: any) => [number, number, number, number];
|
|
62
|
+
readonly zkinputsgenerator_generateKeys: (a: number) => [number, number, number];
|
|
64
63
|
readonly zkinputsgenerator_encryptVote: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
64
|
+
readonly zkinputsgenerator_decryptVote: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
65
65
|
readonly zkinputsgenerator_getBFVParams: (a: number) => [number, number, number];
|
|
66
66
|
readonly zkinputsgenerator_version: () => [number, number];
|
|
67
67
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
68
68
|
readonly __externref_table_alloc: () => number;
|
|
69
69
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
70
70
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
71
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
72
71
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
73
72
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
74
73
|
readonly __wbindgen_start: () => void;
|
package/dist/index.js
CHANGED
|
@@ -22,28 +22,23 @@ export class ZKInputsGenerator {
|
|
|
22
22
|
wasm.__wbg_zkinputsgenerator_free(ptr, 0);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @returns {
|
|
25
|
+
* Decrypt a vote from JavaScript.
|
|
26
|
+
* @param {Uint8Array} secret_key
|
|
27
|
+
* @param {Uint8Array} ciphertext
|
|
28
|
+
* @returns {BigInt64Array}
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
ptr1 = 0; len1 = 0;
|
|
39
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
40
|
-
}
|
|
41
|
-
deferred2_0 = ptr1;
|
|
42
|
-
deferred2_1 = len1;
|
|
43
|
-
return getStringFromWasm0(ptr1, len1);
|
|
44
|
-
} finally {
|
|
45
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
30
|
+
decryptVote(secret_key, ciphertext) {
|
|
31
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
32
|
+
const len0 = WASM_VECTOR_LEN;
|
|
33
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
34
|
+
const len1 = WASM_VECTOR_LEN;
|
|
35
|
+
const ret = wasm.zkinputsgenerator_decryptVote(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
36
|
+
if (ret[3]) {
|
|
37
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
46
38
|
}
|
|
39
|
+
var v3 = getArrayI64FromWasm0(ret[0], ret[1]).slice();
|
|
40
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
41
|
+
return v3;
|
|
47
42
|
}
|
|
48
43
|
/**
|
|
49
44
|
* Encrypt a vote from JavaScript.
|
|
@@ -105,17 +100,15 @@ export class ZKInputsGenerator {
|
|
|
105
100
|
return takeFromExternrefTable0(ret[0]);
|
|
106
101
|
}
|
|
107
102
|
/**
|
|
108
|
-
* Generate a public key from JavaScript.
|
|
109
|
-
* @returns {
|
|
103
|
+
* Generate a public/secret key pair from JavaScript.
|
|
104
|
+
* @returns {any}
|
|
110
105
|
*/
|
|
111
|
-
|
|
112
|
-
const ret = wasm.
|
|
113
|
-
if (ret[
|
|
114
|
-
throw takeFromExternrefTable0(ret[
|
|
106
|
+
generateKeys() {
|
|
107
|
+
const ret = wasm.zkinputsgenerator_generateKeys(this.__wbg_ptr);
|
|
108
|
+
if (ret[2]) {
|
|
109
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
118
|
-
return v1;
|
|
111
|
+
return takeFromExternrefTable0(ret[0]);
|
|
119
112
|
}
|
|
120
113
|
/**
|
|
121
114
|
* Get the BFV parameters used by the generator.
|
|
@@ -187,10 +180,6 @@ function __wbg_get_imports() {
|
|
|
187
180
|
const ret = BigInt(arg0);
|
|
188
181
|
return ret;
|
|
189
182
|
}, arguments); },
|
|
190
|
-
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
191
|
-
const ret = typeof(arg0) === 'bigint';
|
|
192
|
-
return ret;
|
|
193
|
-
},
|
|
194
183
|
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
195
184
|
const ret = typeof(arg0) === 'function';
|
|
196
185
|
return ret;
|
|
@@ -208,20 +197,6 @@ function __wbg_get_imports() {
|
|
|
208
197
|
const ret = arg0 === undefined;
|
|
209
198
|
return ret;
|
|
210
199
|
},
|
|
211
|
-
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
212
|
-
const obj = arg1;
|
|
213
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
214
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
215
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
216
|
-
},
|
|
217
|
-
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
218
|
-
const obj = arg1;
|
|
219
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
220
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
221
|
-
var len1 = WASM_VECTOR_LEN;
|
|
222
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
223
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
224
|
-
},
|
|
225
200
|
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
226
201
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
227
202
|
},
|
|
@@ -237,29 +212,13 @@ function __wbg_get_imports() {
|
|
|
237
212
|
const ret = arg0.crypto;
|
|
238
213
|
return ret;
|
|
239
214
|
},
|
|
240
|
-
__wbg_from_bddd64e7d5ff6941: function(arg0) {
|
|
241
|
-
const ret = Array.from(arg0);
|
|
242
|
-
return ret;
|
|
243
|
-
},
|
|
244
215
|
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
245
216
|
arg0.getRandomValues(arg1);
|
|
246
217
|
}, arguments); },
|
|
247
|
-
__wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
|
|
248
|
-
const ret = arg0[arg1 >>> 0];
|
|
249
|
-
return ret;
|
|
250
|
-
},
|
|
251
|
-
__wbg_isArray_d314bb98fcf08331: function(arg0) {
|
|
252
|
-
const ret = Array.isArray(arg0);
|
|
253
|
-
return ret;
|
|
254
|
-
},
|
|
255
218
|
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
256
219
|
const ret = arg0.length;
|
|
257
220
|
return ret;
|
|
258
221
|
},
|
|
259
|
-
__wbg_length_35a7bace40f36eac: function(arg0) {
|
|
260
|
-
const ret = arg0.length;
|
|
261
|
-
return ret;
|
|
262
|
-
},
|
|
263
222
|
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
264
223
|
const ret = arg0.msCrypto;
|
|
265
224
|
return ret;
|
|
@@ -334,10 +293,6 @@ function __wbg_get_imports() {
|
|
|
334
293
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
335
294
|
return ret;
|
|
336
295
|
},
|
|
337
|
-
__wbg_toString_3cadee6e7c22b39e: function() { return handleError(function (arg0, arg1) {
|
|
338
|
-
const ret = arg0.toString(arg1);
|
|
339
|
-
return ret;
|
|
340
|
-
}, arguments); },
|
|
341
296
|
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
342
297
|
const ret = arg0.versions;
|
|
343
298
|
return ret;
|
|
@@ -383,11 +338,24 @@ function addToExternrefTable0(obj) {
|
|
|
383
338
|
return idx;
|
|
384
339
|
}
|
|
385
340
|
|
|
341
|
+
function getArrayI64FromWasm0(ptr, len) {
|
|
342
|
+
ptr = ptr >>> 0;
|
|
343
|
+
return getBigInt64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
344
|
+
}
|
|
345
|
+
|
|
386
346
|
function getArrayU8FromWasm0(ptr, len) {
|
|
387
347
|
ptr = ptr >>> 0;
|
|
388
348
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
389
349
|
}
|
|
390
350
|
|
|
351
|
+
let cachedBigInt64ArrayMemory0 = null;
|
|
352
|
+
function getBigInt64ArrayMemory0() {
|
|
353
|
+
if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
|
|
354
|
+
cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
|
|
355
|
+
}
|
|
356
|
+
return cachedBigInt64ArrayMemory0;
|
|
357
|
+
}
|
|
358
|
+
|
|
391
359
|
let cachedBigUint64ArrayMemory0 = null;
|
|
392
360
|
function getBigUint64ArrayMemory0() {
|
|
393
361
|
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
@@ -396,14 +364,6 @@ function getBigUint64ArrayMemory0() {
|
|
|
396
364
|
return cachedBigUint64ArrayMemory0;
|
|
397
365
|
}
|
|
398
366
|
|
|
399
|
-
let cachedDataViewMemory0 = null;
|
|
400
|
-
function getDataViewMemory0() {
|
|
401
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
402
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
403
|
-
}
|
|
404
|
-
return cachedDataViewMemory0;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
367
|
function getStringFromWasm0(ptr, len) {
|
|
408
368
|
ptr = ptr >>> 0;
|
|
409
369
|
return decodeText(ptr, len);
|
|
@@ -444,43 +404,6 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
444
404
|
return ptr;
|
|
445
405
|
}
|
|
446
406
|
|
|
447
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
448
|
-
if (realloc === undefined) {
|
|
449
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
450
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
451
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
452
|
-
WASM_VECTOR_LEN = buf.length;
|
|
453
|
-
return ptr;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
let len = arg.length;
|
|
457
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
458
|
-
|
|
459
|
-
const mem = getUint8ArrayMemory0();
|
|
460
|
-
|
|
461
|
-
let offset = 0;
|
|
462
|
-
|
|
463
|
-
for (; offset < len; offset++) {
|
|
464
|
-
const code = arg.charCodeAt(offset);
|
|
465
|
-
if (code > 0x7F) break;
|
|
466
|
-
mem[ptr + offset] = code;
|
|
467
|
-
}
|
|
468
|
-
if (offset !== len) {
|
|
469
|
-
if (offset !== 0) {
|
|
470
|
-
arg = arg.slice(offset);
|
|
471
|
-
}
|
|
472
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
473
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
474
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
475
|
-
|
|
476
|
-
offset += ret.written;
|
|
477
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
WASM_VECTOR_LEN = offset;
|
|
481
|
-
return ptr;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
407
|
function takeFromExternrefTable0(idx) {
|
|
485
408
|
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
486
409
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -501,27 +424,14 @@ function decodeText(ptr, len) {
|
|
|
501
424
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
502
425
|
}
|
|
503
426
|
|
|
504
|
-
const cachedTextEncoder = new TextEncoder();
|
|
505
|
-
|
|
506
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
507
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
508
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
509
|
-
view.set(buf);
|
|
510
|
-
return {
|
|
511
|
-
read: arg.length,
|
|
512
|
-
written: buf.length
|
|
513
|
-
};
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
427
|
let WASM_VECTOR_LEN = 0;
|
|
518
428
|
|
|
519
429
|
let wasmModule, wasm;
|
|
520
430
|
function __wbg_finalize_init(instance, module) {
|
|
521
431
|
wasm = instance.exports;
|
|
522
432
|
wasmModule = module;
|
|
433
|
+
cachedBigInt64ArrayMemory0 = null;
|
|
523
434
|
cachedBigUint64ArrayMemory0 = null;
|
|
524
|
-
cachedDataViewMemory0 = null;
|
|
525
435
|
cachedUint8ArrayMemory0 = null;
|
|
526
436
|
wasm.__wbindgen_start();
|
|
527
437
|
return wasm;
|