@crisp-e3/zk-inputs 0.5.7 → 0.5.8
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 -0
- package/dist/index.js +111 -0
- package/dist/index_base64.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export class ZKInputsGenerator {
|
|
|
29
29
|
* Generate a public key from JavaScript.
|
|
30
30
|
*/
|
|
31
31
|
generatePublicKey(): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* Compute the commitment to a set of ciphertext polynomials from JavaScript.
|
|
34
|
+
*/
|
|
35
|
+
computeCommitment(ct0is: any, ct1is: any): string;
|
|
32
36
|
/**
|
|
33
37
|
* Encrypt a vote from JavaScript.
|
|
34
38
|
*/
|
|
@@ -53,6 +57,7 @@ export interface InitOutput {
|
|
|
53
57
|
readonly zkinputsgenerator_generateInputs: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
54
58
|
readonly zkinputsgenerator_generateInputsForUpdate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
55
59
|
readonly zkinputsgenerator_generatePublicKey: (a: number) => [number, number, number, number];
|
|
60
|
+
readonly zkinputsgenerator_computeCommitment: (a: number, b: any, c: any) => [number, number, number, number];
|
|
56
61
|
readonly zkinputsgenerator_encryptVote: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
57
62
|
readonly zkinputsgenerator_getBFVParams: (a: number) => [number, number, number];
|
|
58
63
|
readonly zkinputsgenerator_version: () => [number, number];
|
|
@@ -60,6 +65,7 @@ export interface InitOutput {
|
|
|
60
65
|
readonly __externref_table_alloc: () => number;
|
|
61
66
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
62
67
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
68
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
63
69
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
64
70
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
65
71
|
readonly __wbindgen_start: () => void;
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,14 @@ function getBigUint64ArrayMemory0() {
|
|
|
19
19
|
return cachedBigUint64ArrayMemory0;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
let cachedDataViewMemory0 = null;
|
|
23
|
+
function getDataViewMemory0() {
|
|
24
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
25
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
26
|
+
}
|
|
27
|
+
return cachedDataViewMemory0;
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
function getStringFromWasm0(ptr, len) {
|
|
23
31
|
ptr = ptr >>> 0;
|
|
24
32
|
return decodeText(ptr, len);
|
|
@@ -59,6 +67,43 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
59
67
|
return ptr;
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
71
|
+
if (realloc === undefined) {
|
|
72
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
73
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
74
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
75
|
+
WASM_VECTOR_LEN = buf.length;
|
|
76
|
+
return ptr;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let len = arg.length;
|
|
80
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
81
|
+
|
|
82
|
+
const mem = getUint8ArrayMemory0();
|
|
83
|
+
|
|
84
|
+
let offset = 0;
|
|
85
|
+
|
|
86
|
+
for (; offset < len; offset++) {
|
|
87
|
+
const code = arg.charCodeAt(offset);
|
|
88
|
+
if (code > 0x7F) break;
|
|
89
|
+
mem[ptr + offset] = code;
|
|
90
|
+
}
|
|
91
|
+
if (offset !== len) {
|
|
92
|
+
if (offset !== 0) {
|
|
93
|
+
arg = arg.slice(offset);
|
|
94
|
+
}
|
|
95
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
96
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
97
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
98
|
+
|
|
99
|
+
offset += ret.written;
|
|
100
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
WASM_VECTOR_LEN = offset;
|
|
104
|
+
return ptr;
|
|
105
|
+
}
|
|
106
|
+
|
|
62
107
|
function takeFromExternrefTable0(idx) {
|
|
63
108
|
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
64
109
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -79,6 +124,19 @@ function decodeText(ptr, len) {
|
|
|
79
124
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
80
125
|
}
|
|
81
126
|
|
|
127
|
+
const cachedTextEncoder = new TextEncoder();
|
|
128
|
+
|
|
129
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
130
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
131
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
132
|
+
view.set(buf);
|
|
133
|
+
return {
|
|
134
|
+
read: arg.length,
|
|
135
|
+
written: buf.length
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
82
140
|
let WASM_VECTOR_LEN = 0;
|
|
83
141
|
|
|
84
142
|
const ZKInputsGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -192,6 +250,30 @@ export class ZKInputsGenerator {
|
|
|
192
250
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
193
251
|
return v1;
|
|
194
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Compute the commitment to a set of ciphertext polynomials from JavaScript.
|
|
255
|
+
* @param {any} ct0is
|
|
256
|
+
* @param {any} ct1is
|
|
257
|
+
* @returns {string}
|
|
258
|
+
*/
|
|
259
|
+
computeCommitment(ct0is, ct1is) {
|
|
260
|
+
let deferred2_0;
|
|
261
|
+
let deferred2_1;
|
|
262
|
+
try {
|
|
263
|
+
const ret = wasm.zkinputsgenerator_computeCommitment(this.__wbg_ptr, ct0is, ct1is);
|
|
264
|
+
var ptr1 = ret[0];
|
|
265
|
+
var len1 = ret[1];
|
|
266
|
+
if (ret[3]) {
|
|
267
|
+
ptr1 = 0; len1 = 0;
|
|
268
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
269
|
+
}
|
|
270
|
+
deferred2_0 = ptr1;
|
|
271
|
+
deferred2_1 = len1;
|
|
272
|
+
return getStringFromWasm0(ptr1, len1);
|
|
273
|
+
} finally {
|
|
274
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
195
277
|
/**
|
|
196
278
|
* Encrypt a vote from JavaScript.
|
|
197
279
|
* @param {Uint8Array} public_key
|
|
@@ -297,6 +379,14 @@ function __wbg_get_imports() {
|
|
|
297
379
|
const ret = arg0 === undefined;
|
|
298
380
|
return ret;
|
|
299
381
|
};
|
|
382
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
383
|
+
const obj = arg1;
|
|
384
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
385
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
+
var len1 = WASM_VECTOR_LEN;
|
|
387
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
388
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
389
|
+
};
|
|
300
390
|
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
301
391
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
302
392
|
};
|
|
@@ -312,13 +402,29 @@ function __wbg_get_imports() {
|
|
|
312
402
|
const ret = arg0.crypto;
|
|
313
403
|
return ret;
|
|
314
404
|
};
|
|
405
|
+
imports.wbg.__wbg_from_29a8414a7a7cd19d = function(arg0) {
|
|
406
|
+
const ret = Array.from(arg0);
|
|
407
|
+
return ret;
|
|
408
|
+
};
|
|
315
409
|
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
316
410
|
arg0.getRandomValues(arg1);
|
|
317
411
|
}, arguments) };
|
|
412
|
+
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
413
|
+
const ret = arg0[arg1 >>> 0];
|
|
414
|
+
return ret;
|
|
415
|
+
};
|
|
416
|
+
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
417
|
+
const ret = Array.isArray(arg0);
|
|
418
|
+
return ret;
|
|
419
|
+
};
|
|
318
420
|
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
319
421
|
const ret = arg0.length;
|
|
320
422
|
return ret;
|
|
321
423
|
};
|
|
424
|
+
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
425
|
+
const ret = arg0.length;
|
|
426
|
+
return ret;
|
|
427
|
+
};
|
|
322
428
|
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
323
429
|
const ret = arg0.msCrypto;
|
|
324
430
|
return ret;
|
|
@@ -331,6 +437,10 @@ function __wbg_get_imports() {
|
|
|
331
437
|
const ret = new Array();
|
|
332
438
|
return ret;
|
|
333
439
|
};
|
|
440
|
+
imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
|
|
441
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
442
|
+
return ret;
|
|
443
|
+
};
|
|
334
444
|
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
335
445
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
336
446
|
return ret;
|
|
@@ -425,6 +535,7 @@ function __wbg_finalize_init(instance, module) {
|
|
|
425
535
|
wasm = instance.exports;
|
|
426
536
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
427
537
|
cachedBigUint64ArrayMemory0 = null;
|
|
538
|
+
cachedDataViewMemory0 = null;
|
|
428
539
|
cachedUint8ArrayMemory0 = null;
|
|
429
540
|
|
|
430
541
|
|