@crisp-e3/zk-inputs 0.0.1-test
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.md +165 -0
- package/package.json +26 -0
- package/pkg/index.d.ts +42 -0
- package/pkg/index.js +5 -0
- package/pkg/index_bg.js +409 -0
- package/pkg/index_bg.wasm +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crisp-e3/zk-inputs",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "Core logic to pre-compute CRISP ZK inputs (WASM/JavaScript bindings).",
|
|
5
|
+
"version": "0.0.1-test",
|
|
6
|
+
"license": "LGPL-3.0-only",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/gnosisguild/enclave"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"pkg/index_bg.wasm",
|
|
13
|
+
"pkg/index.js",
|
|
14
|
+
"pkg/index_bg.js",
|
|
15
|
+
"pkg/index.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"main": "pkg/index.js",
|
|
21
|
+
"types": "pkg/index.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./pkg/index.js",
|
|
24
|
+
"./pkg/snippets/*"
|
|
25
|
+
]
|
|
26
|
+
}
|
package/pkg/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* JavaScript-compatible CRISP ZK inputs generator.
|
|
5
|
+
*/
|
|
6
|
+
export class ZKInputsGenerator {
|
|
7
|
+
free(): void;
|
|
8
|
+
[Symbol.dispose](): void;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new JavaScript CRISP ZK inputs generator with the specified BFV parameters.
|
|
11
|
+
*
|
|
12
|
+
* # Arguments
|
|
13
|
+
* - `degree`: Polynomial degree
|
|
14
|
+
* - `plaintext_modulus`: Plaintext modulus (will be converted to u64)
|
|
15
|
+
* - `moduli`: Array of moduli (will be converted to Vec<u64>)
|
|
16
|
+
*/
|
|
17
|
+
constructor(degree: number, plaintext_modulus: bigint, moduli: BigInt64Array);
|
|
18
|
+
/**
|
|
19
|
+
* Create a new JavaScript CRISP ZK inputs generator with default BFV parameters.
|
|
20
|
+
*/
|
|
21
|
+
static withDefaults(): ZKInputsGenerator;
|
|
22
|
+
/**
|
|
23
|
+
* Generate a CRISP ZK inputs from JavaScript.
|
|
24
|
+
*/
|
|
25
|
+
generateInputs(prev_ciphertext: Uint8Array, public_key: Uint8Array, vote: BigInt64Array): any;
|
|
26
|
+
/**
|
|
27
|
+
* Generate a public key from JavaScript.
|
|
28
|
+
*/
|
|
29
|
+
generatePublicKey(): Uint8Array;
|
|
30
|
+
/**
|
|
31
|
+
* Encrypt a vote from JavaScript.
|
|
32
|
+
*/
|
|
33
|
+
encryptVote(public_key: Uint8Array, vote: BigInt64Array): Uint8Array;
|
|
34
|
+
/**
|
|
35
|
+
* Get the BFV parameters used by the generator.
|
|
36
|
+
*/
|
|
37
|
+
getBFVParams(): any;
|
|
38
|
+
/**
|
|
39
|
+
* Get the version of the library.
|
|
40
|
+
*/
|
|
41
|
+
static version(): string;
|
|
42
|
+
}
|
package/pkg/index.js
ADDED
package/pkg/index_bg.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function addToExternrefTable0(obj) {
|
|
8
|
+
const idx = wasm.__externref_table_alloc();
|
|
9
|
+
wasm.__wbindgen_export_2.set(idx, obj);
|
|
10
|
+
return idx;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function handleError(f, args) {
|
|
14
|
+
try {
|
|
15
|
+
return f.apply(this, args);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
const idx = addToExternrefTable0(e);
|
|
18
|
+
wasm.__wbindgen_exn_store(idx);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let cachedUint8ArrayMemory0 = null;
|
|
23
|
+
|
|
24
|
+
function getUint8ArrayMemory0() {
|
|
25
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
26
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
27
|
+
}
|
|
28
|
+
return cachedUint8ArrayMemory0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
32
|
+
|
|
33
|
+
cachedTextDecoder.decode();
|
|
34
|
+
|
|
35
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
36
|
+
let numBytesDecoded = 0;
|
|
37
|
+
function decodeText(ptr, len) {
|
|
38
|
+
numBytesDecoded += len;
|
|
39
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
40
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
41
|
+
cachedTextDecoder.decode();
|
|
42
|
+
numBytesDecoded = len;
|
|
43
|
+
}
|
|
44
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getStringFromWasm0(ptr, len) {
|
|
48
|
+
ptr = ptr >>> 0;
|
|
49
|
+
return decodeText(ptr, len);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
53
|
+
ptr = ptr >>> 0;
|
|
54
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isLikeNone(x) {
|
|
58
|
+
return x === undefined || x === null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
62
|
+
|
|
63
|
+
function getBigUint64ArrayMemory0() {
|
|
64
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
65
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
66
|
+
}
|
|
67
|
+
return cachedBigUint64ArrayMemory0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let WASM_VECTOR_LEN = 0;
|
|
71
|
+
|
|
72
|
+
function passArray64ToWasm0(arg, malloc) {
|
|
73
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
74
|
+
getBigUint64ArrayMemory0().set(arg, ptr / 8);
|
|
75
|
+
WASM_VECTOR_LEN = arg.length;
|
|
76
|
+
return ptr;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function takeFromExternrefTable0(idx) {
|
|
80
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
81
|
+
wasm.__externref_table_dealloc(idx);
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
86
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
87
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
88
|
+
WASM_VECTOR_LEN = arg.length;
|
|
89
|
+
return ptr;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const ZKInputsGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
93
|
+
? { register: () => {}, unregister: () => {} }
|
|
94
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zkinputsgenerator_free(ptr >>> 0, 1));
|
|
95
|
+
/**
|
|
96
|
+
* JavaScript-compatible CRISP ZK inputs generator.
|
|
97
|
+
*/
|
|
98
|
+
export class ZKInputsGenerator {
|
|
99
|
+
|
|
100
|
+
static __wrap(ptr) {
|
|
101
|
+
ptr = ptr >>> 0;
|
|
102
|
+
const obj = Object.create(ZKInputsGenerator.prototype);
|
|
103
|
+
obj.__wbg_ptr = ptr;
|
|
104
|
+
ZKInputsGeneratorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
105
|
+
return obj;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
__destroy_into_raw() {
|
|
109
|
+
const ptr = this.__wbg_ptr;
|
|
110
|
+
this.__wbg_ptr = 0;
|
|
111
|
+
ZKInputsGeneratorFinalization.unregister(this);
|
|
112
|
+
return ptr;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
free() {
|
|
116
|
+
const ptr = this.__destroy_into_raw();
|
|
117
|
+
wasm.__wbg_zkinputsgenerator_free(ptr, 0);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create a new JavaScript CRISP ZK inputs generator with the specified BFV parameters.
|
|
121
|
+
*
|
|
122
|
+
* # Arguments
|
|
123
|
+
* - `degree`: Polynomial degree
|
|
124
|
+
* - `plaintext_modulus`: Plaintext modulus (will be converted to u64)
|
|
125
|
+
* - `moduli`: Array of moduli (will be converted to Vec<u64>)
|
|
126
|
+
* @param {number} degree
|
|
127
|
+
* @param {bigint} plaintext_modulus
|
|
128
|
+
* @param {BigInt64Array} moduli
|
|
129
|
+
*/
|
|
130
|
+
constructor(degree, plaintext_modulus, moduli) {
|
|
131
|
+
const ptr0 = passArray64ToWasm0(moduli, wasm.__wbindgen_malloc);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.zkinputsgenerator_new(degree, plaintext_modulus, ptr0, len0);
|
|
134
|
+
if (ret[2]) {
|
|
135
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
136
|
+
}
|
|
137
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
138
|
+
ZKInputsGeneratorFinalization.register(this, this.__wbg_ptr, this);
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new JavaScript CRISP ZK inputs generator with default BFV parameters.
|
|
143
|
+
* @returns {ZKInputsGenerator}
|
|
144
|
+
*/
|
|
145
|
+
static withDefaults() {
|
|
146
|
+
const ret = wasm.zkinputsgenerator_withDefaults();
|
|
147
|
+
if (ret[2]) {
|
|
148
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
149
|
+
}
|
|
150
|
+
return ZKInputsGenerator.__wrap(ret[0]);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Generate a CRISP ZK inputs from JavaScript.
|
|
154
|
+
* @param {Uint8Array} prev_ciphertext
|
|
155
|
+
* @param {Uint8Array} public_key
|
|
156
|
+
* @param {BigInt64Array} vote
|
|
157
|
+
* @returns {any}
|
|
158
|
+
*/
|
|
159
|
+
generateInputs(prev_ciphertext, public_key, vote) {
|
|
160
|
+
const ptr0 = passArray8ToWasm0(prev_ciphertext, wasm.__wbindgen_malloc);
|
|
161
|
+
const len0 = WASM_VECTOR_LEN;
|
|
162
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
163
|
+
const len1 = WASM_VECTOR_LEN;
|
|
164
|
+
const ptr2 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
165
|
+
const len2 = WASM_VECTOR_LEN;
|
|
166
|
+
const ret = wasm.zkinputsgenerator_generateInputs(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
167
|
+
if (ret[2]) {
|
|
168
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
169
|
+
}
|
|
170
|
+
return takeFromExternrefTable0(ret[0]);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Generate a public key from JavaScript.
|
|
174
|
+
* @returns {Uint8Array}
|
|
175
|
+
*/
|
|
176
|
+
generatePublicKey() {
|
|
177
|
+
const ret = wasm.zkinputsgenerator_generatePublicKey(this.__wbg_ptr);
|
|
178
|
+
if (ret[3]) {
|
|
179
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
180
|
+
}
|
|
181
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
182
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
183
|
+
return v1;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Encrypt a vote from JavaScript.
|
|
187
|
+
* @param {Uint8Array} public_key
|
|
188
|
+
* @param {BigInt64Array} vote
|
|
189
|
+
* @returns {Uint8Array}
|
|
190
|
+
*/
|
|
191
|
+
encryptVote(public_key, vote) {
|
|
192
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
193
|
+
const len0 = WASM_VECTOR_LEN;
|
|
194
|
+
const ptr1 = passArray64ToWasm0(vote, wasm.__wbindgen_malloc);
|
|
195
|
+
const len1 = WASM_VECTOR_LEN;
|
|
196
|
+
const ret = wasm.zkinputsgenerator_encryptVote(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
197
|
+
if (ret[3]) {
|
|
198
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
199
|
+
}
|
|
200
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
201
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
202
|
+
return v3;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get the BFV parameters used by the generator.
|
|
206
|
+
* @returns {any}
|
|
207
|
+
*/
|
|
208
|
+
getBFVParams() {
|
|
209
|
+
const ret = wasm.zkinputsgenerator_getBFVParams(this.__wbg_ptr);
|
|
210
|
+
if (ret[2]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
212
|
+
}
|
|
213
|
+
return takeFromExternrefTable0(ret[0]);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get the version of the library.
|
|
217
|
+
* @returns {string}
|
|
218
|
+
*/
|
|
219
|
+
static version() {
|
|
220
|
+
let deferred1_0;
|
|
221
|
+
let deferred1_1;
|
|
222
|
+
try {
|
|
223
|
+
const ret = wasm.zkinputsgenerator_version();
|
|
224
|
+
deferred1_0 = ret[0];
|
|
225
|
+
deferred1_1 = ret[1];
|
|
226
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
227
|
+
} finally {
|
|
228
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (Symbol.dispose) ZKInputsGenerator.prototype[Symbol.dispose] = ZKInputsGenerator.prototype.free;
|
|
233
|
+
|
|
234
|
+
export function __wbg_BigInt_40a77d45cca49470() { return handleError(function (arg0) {
|
|
235
|
+
const ret = BigInt(arg0);
|
|
236
|
+
return ret;
|
|
237
|
+
}, arguments) };
|
|
238
|
+
|
|
239
|
+
export function __wbg_call_13410aac570ffff7() { return handleError(function (arg0, arg1) {
|
|
240
|
+
const ret = arg0.call(arg1);
|
|
241
|
+
return ret;
|
|
242
|
+
}, arguments) };
|
|
243
|
+
|
|
244
|
+
export function __wbg_call_a5400b25a865cfd8() { return handleError(function (arg0, arg1, arg2) {
|
|
245
|
+
const ret = arg0.call(arg1, arg2);
|
|
246
|
+
return ret;
|
|
247
|
+
}, arguments) };
|
|
248
|
+
|
|
249
|
+
export function __wbg_crypto_574e78ad8b13b65f(arg0) {
|
|
250
|
+
const ret = arg0.crypto;
|
|
251
|
+
return ret;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
|
|
255
|
+
arg0.getRandomValues(arg1);
|
|
256
|
+
}, arguments) };
|
|
257
|
+
|
|
258
|
+
export function __wbg_length_6bb7e81f9d7713e4(arg0) {
|
|
259
|
+
const ret = arg0.length;
|
|
260
|
+
return ret;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
|
|
264
|
+
const ret = arg0.msCrypto;
|
|
265
|
+
return ret;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export function __wbg_new_19c25a3f2fa63a02() {
|
|
269
|
+
const ret = new Object();
|
|
270
|
+
return ret;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export function __wbg_new_1f3a344cf3123716() {
|
|
274
|
+
const ret = new Array();
|
|
275
|
+
return ret;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export function __wbg_newnoargs_254190557c45b4ec(arg0, arg1) {
|
|
279
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
280
|
+
return ret;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export function __wbg_newwithlength_a167dcc7aaa3ba77(arg0) {
|
|
284
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
285
|
+
return ret;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export function __wbg_node_905d3e251edff8a2(arg0) {
|
|
289
|
+
const ret = arg0.node;
|
|
290
|
+
return ret;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export function __wbg_parse_442f5ba02e5eaf8b() { return handleError(function (arg0, arg1) {
|
|
294
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
295
|
+
return ret;
|
|
296
|
+
}, arguments) };
|
|
297
|
+
|
|
298
|
+
export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
|
|
299
|
+
const ret = arg0.process;
|
|
300
|
+
return ret;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
|
|
304
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export function __wbg_push_330b2eb93e4e1212(arg0, arg1) {
|
|
308
|
+
const ret = arg0.push(arg1);
|
|
309
|
+
return ret;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
|
|
313
|
+
arg0.randomFillSync(arg1);
|
|
314
|
+
}, arguments) };
|
|
315
|
+
|
|
316
|
+
export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
|
|
317
|
+
const ret = module.require;
|
|
318
|
+
return ret;
|
|
319
|
+
}, arguments) };
|
|
320
|
+
|
|
321
|
+
export function __wbg_set_453345bcda80b89a() { return handleError(function (arg0, arg1, arg2) {
|
|
322
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
323
|
+
return ret;
|
|
324
|
+
}, arguments) };
|
|
325
|
+
|
|
326
|
+
export function __wbg_static_accessor_GLOBAL_8921f820c2ce3f12() {
|
|
327
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
328
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export function __wbg_static_accessor_GLOBAL_THIS_f0a4409105898184() {
|
|
332
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
333
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export function __wbg_static_accessor_SELF_995b214ae681ff99() {
|
|
337
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
338
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export function __wbg_static_accessor_WINDOW_cde3890479c675ea() {
|
|
342
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
343
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export function __wbg_subarray_70fd07feefe14294(arg0, arg1, arg2) {
|
|
347
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
348
|
+
return ret;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export function __wbg_versions_c01dfd4722a88165(arg0) {
|
|
352
|
+
const ret = arg0.versions;
|
|
353
|
+
return ret;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export function __wbg_wbindgenisfunction_8cee7dce3725ae74(arg0) {
|
|
357
|
+
const ret = typeof(arg0) === 'function';
|
|
358
|
+
return ret;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export function __wbg_wbindgenisobject_307a53c6bd97fbf8(arg0) {
|
|
362
|
+
const val = arg0;
|
|
363
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
364
|
+
return ret;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
export function __wbg_wbindgenisstring_d4fa939789f003b0(arg0) {
|
|
368
|
+
const ret = typeof(arg0) === 'string';
|
|
369
|
+
return ret;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
|
|
373
|
+
const ret = arg0 === undefined;
|
|
374
|
+
return ret;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
|
|
378
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
382
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
383
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
384
|
+
return ret;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export function __wbindgen_cast_cb9088102bce6b30(arg0, arg1) {
|
|
388
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
389
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
390
|
+
return ret;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
|
|
394
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
395
|
+
const ret = arg0;
|
|
396
|
+
return ret;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
export function __wbindgen_init_externref_table() {
|
|
400
|
+
const table = wasm.__wbindgen_export_2;
|
|
401
|
+
const offset = table.grow(4);
|
|
402
|
+
table.set(0, undefined);
|
|
403
|
+
table.set(offset + 0, undefined);
|
|
404
|
+
table.set(offset + 1, null);
|
|
405
|
+
table.set(offset + 2, true);
|
|
406
|
+
table.set(offset + 3, false);
|
|
407
|
+
;
|
|
408
|
+
};
|
|
409
|
+
|
|
Binary file
|