@crisp-e3/sdk 0.2.2-test → 0.3.0-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 +92 -123
- package/dist/index.d.ts +13 -19
- package/dist/index.js +31 -26
- package/dist/index.js.map +1 -1
- package/package.json +8 -12
- package/dist/index.cjs +0 -1325
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -367
package/LICENSE.md
CHANGED
|
@@ -1,102 +1,83 @@
|
|
|
1
|
-
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
-
Version 3, 29 June 2007
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007
|
|
3
2
|
|
|
4
|
-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
-
|
|
6
|
-
of this license document, but changing it is not allowed.
|
|
3
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy
|
|
4
|
+
and distribute verbatim copies of this license document, but changing it is not allowed.
|
|
7
5
|
|
|
6
|
+
This version of the GNU Lesser General Public License incorporates the terms and conditions of
|
|
7
|
+
version 3 of the GNU General Public License, supplemented by the additional permissions listed
|
|
8
|
+
below.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
-
License, supplemented by the additional permissions listed below.
|
|
10
|
+
0. Additional Definitions.
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the
|
|
13
|
+
"GNU GPL" refers to version 3 of the GNU General Public License.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
General Public License.
|
|
15
|
+
"The Library" refers to a covered work governed by this License, other than an Application or a
|
|
16
|
+
Combined Work as defined below.
|
|
18
17
|
|
|
19
|
-
"
|
|
20
|
-
|
|
18
|
+
An "Application" is any work that makes use of an interface provided by the Library, but which is
|
|
19
|
+
not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed
|
|
20
|
+
a mode of using an interface provided by the Library.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
22
|
+
A "Combined Work" is a work produced by combining or linking an Application with the Library. The
|
|
23
|
+
particular version of the Library with which the Combined Work was made is also called the "Linked
|
|
30
24
|
Version".
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
based on the Application, and not on the Linked Version.
|
|
26
|
+
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the
|
|
27
|
+
Combined Work, excluding any source code for portions of the Combined Work that, considered in
|
|
28
|
+
isolation, are based on the Application, and not on the Linked Version.
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
|
30
|
+
The "Corresponding Application Code" for a Combined Work means the object code and/or source code
|
|
31
|
+
for the Application, including any data and utility programs needed for reproducing the Combined
|
|
32
|
+
Work from the Application, but excluding the System Libraries of the Combined Work.
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
You may convey a covered work under sections 3 and 4 of this License without being bound by section
|
|
37
|
+
3 of the GNU GPL.
|
|
46
38
|
|
|
47
|
-
|
|
39
|
+
2. Conveying Modified Versions.
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
|
53
|
-
version:
|
|
41
|
+
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or
|
|
42
|
+
data to be supplied by an Application that uses the facility (other than as an argument passed when
|
|
43
|
+
the facility is invoked), then you may convey a copy of the modified version:
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
whatever part of its purpose remains meaningful, or
|
|
45
|
+
a) under this License, provided that you make a good faith effort to ensure that, in the event an
|
|
46
|
+
Application does not supply the function or data, the facility still operates, and performs whatever
|
|
47
|
+
part of its purpose remains meaningful, or
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
b) under the GNU GPL, with none of the additional permissions of this License applicable to that
|
|
50
|
+
copy.
|
|
62
51
|
|
|
63
|
-
|
|
52
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
|
54
|
+
The object code form of an Application may incorporate material from a header file that is part of
|
|
55
|
+
the Library. You may convey such object code under terms of your choice, provided that, if the
|
|
56
|
+
incorporated material is not limited to numerical parameters, data structure layouts and accessors,
|
|
57
|
+
or small macros, inline functions and templates (ten or fewer lines in length), you do both of the
|
|
58
|
+
following:
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
covered by this License.
|
|
60
|
+
a) Give prominent notice with each copy of the object code that the Library is used in it and that
|
|
61
|
+
the Library and its use are covered by this License.
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
document.
|
|
63
|
+
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
|
78
64
|
|
|
79
|
-
|
|
65
|
+
4. Combined Works.
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
|
85
|
-
the following:
|
|
67
|
+
You may convey a Combined Work under terms of your choice that, taken together, effectively do not
|
|
68
|
+
restrict modification of the portions of the Library contained in the Combined Work and reverse
|
|
69
|
+
engineering for debugging such modifications, if you also do each of the following:
|
|
86
70
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
covered by this License.
|
|
71
|
+
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that
|
|
72
|
+
the Library and its use are covered by this License.
|
|
90
73
|
|
|
91
|
-
|
|
92
|
-
document.
|
|
74
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
|
93
75
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
copies of the GNU GPL and this license document.
|
|
76
|
+
c) For a Combined Work that displays copyright notices during execution, include the copyright
|
|
77
|
+
notice for the Library among these notices, as well as a reference directing the user to the copies
|
|
78
|
+
of the GNU GPL and this license document.
|
|
98
79
|
|
|
99
|
-
|
|
80
|
+
d) Do one of the following:
|
|
100
81
|
|
|
101
82
|
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
83
|
License, and the Corresponding Application Code in a form
|
|
@@ -113,53 +94,41 @@ the following:
|
|
|
113
94
|
of the Library that is interface-compatible with the Linked
|
|
114
95
|
Version.
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
of the GNU Lesser General Public License
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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.
|
|
97
|
+
e) Provide Installation Information, but only if you would otherwise be required to provide such
|
|
98
|
+
information under section 6 of the GNU GPL, and only to the extent that such information is
|
|
99
|
+
necessary to install and execute a modified version of the Combined Work produced by recombining or
|
|
100
|
+
relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the
|
|
101
|
+
Installation Information must accompany the Minimal Corresponding Source and Corresponding
|
|
102
|
+
Application Code. If you use option 4d1, you must provide the Installation Information in the manner
|
|
103
|
+
specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
|
104
|
+
|
|
105
|
+
5. Combined Libraries.
|
|
106
|
+
|
|
107
|
+
You may place library facilities that are a work based on the Library side by side in a single
|
|
108
|
+
library together with other library facilities that are not Applications and are not covered by this
|
|
109
|
+
License, and convey such a combined library under terms of your choice, if you do both of the
|
|
110
|
+
following:
|
|
111
|
+
|
|
112
|
+
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with
|
|
113
|
+
any other library facilities, conveyed under the terms of this License.
|
|
114
|
+
|
|
115
|
+
b) Give prominent notice with the combined library that part of it is a work based on the Library,
|
|
116
|
+
and explaining where to find the accompanying uncombined form of the same work.
|
|
117
|
+
|
|
118
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
119
|
+
|
|
120
|
+
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General
|
|
121
|
+
Public License from time to time. Such new versions will be similar in spirit to the present
|
|
122
|
+
version, but may differ in detail to address new problems or concerns.
|
|
123
|
+
|
|
124
|
+
Each version is given a distinguishing version number. If the Library as you received it specifies
|
|
125
|
+
that a certain numbered version of the GNU Lesser General Public License "or any later version"
|
|
126
|
+
applies to it, you have the option of following the terms and conditions either of that published
|
|
127
|
+
version or of any later version published by the Free Software Foundation. If the Library as you
|
|
128
|
+
received it does not specify a version number of the GNU Lesser General Public License, you may
|
|
129
|
+
choose any version of the GNU Lesser General Public License ever published by the Free Software
|
|
130
|
+
Foundation.
|
|
131
|
+
|
|
132
|
+
If the Library as you received it specifies that a proxy can decide whether future versions of the
|
|
133
|
+
GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any
|
|
134
|
+
version is permanent authorization for you to choose that version for the Library.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LeanIMTMerkleProof, LeanIMT } from '@zk-kit/lean-imt';
|
|
2
2
|
import { ProofData } from '@aztec/bb.js';
|
|
3
|
+
import { Hex } from 'viem';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Get the merkle tree data from the CRISP server
|
|
@@ -174,14 +175,6 @@ interface CRISPCircuitInputs {
|
|
|
174
175
|
balance: string;
|
|
175
176
|
is_first_vote: boolean;
|
|
176
177
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Interface representing the BFV parameters
|
|
179
|
-
*/
|
|
180
|
-
interface BFVParams {
|
|
181
|
-
degree: number;
|
|
182
|
-
plaintextModulus: bigint;
|
|
183
|
-
moduli: BigInt64Array;
|
|
184
|
-
}
|
|
185
178
|
/**
|
|
186
179
|
* Interface representing the inputs for Noir signature verification
|
|
187
180
|
*/
|
|
@@ -214,7 +207,6 @@ interface EncryptVoteAndGenerateCRISPInputsParams {
|
|
|
214
207
|
message: string;
|
|
215
208
|
merkleData: IMerkleProof;
|
|
216
209
|
balance: bigint;
|
|
217
|
-
bfvParams?: BFVParams;
|
|
218
210
|
slotAddress: string;
|
|
219
211
|
isFirstVote: boolean;
|
|
220
212
|
}
|
|
@@ -244,11 +236,6 @@ declare const HALF_LARGEST_MINIMUM_DEGREE = 28;
|
|
|
244
236
|
* The minimum degree that BFV should use is 56 (to accommodate both Yes and No votes)
|
|
245
237
|
*/
|
|
246
238
|
declare const MAXIMUM_VOTE_VALUE: bigint;
|
|
247
|
-
/**
|
|
248
|
-
* Default BFV parameters for the CRISP ZK inputs generator.
|
|
249
|
-
* These are the parameters used for the default testing purposes only.
|
|
250
|
-
*/
|
|
251
|
-
declare const DEFAULT_BFV_PARAMS: BFVParams;
|
|
252
239
|
/**
|
|
253
240
|
* Mock message for masking signature
|
|
254
241
|
*/
|
|
@@ -303,7 +290,7 @@ declare const calculateValidIndicesForPlaintext: (totalVotingPower: bigint, degr
|
|
|
303
290
|
* @param bfvParams The BFV parameters to use for encoding
|
|
304
291
|
* @returns The encoded vote as a string
|
|
305
292
|
*/
|
|
306
|
-
declare const encodeVote: (vote: IVote, votingMode: VotingMode, votingPower: bigint
|
|
293
|
+
declare const encodeVote: (vote: IVote, votingMode: VotingMode, votingPower: bigint) => string[];
|
|
307
294
|
/**
|
|
308
295
|
* Given an encoded tally, decode it into its decimal representation
|
|
309
296
|
* @param tally The encoded tally to decode
|
|
@@ -318,6 +305,7 @@ declare const decodeTally: (tally: string[], votingMode: VotingMode) => IVote;
|
|
|
318
305
|
*/
|
|
319
306
|
declare const validateVote: (votingMode: VotingMode, vote: IVote, votingPower: bigint) => void;
|
|
320
307
|
declare const encryptVote: (encodedVote: string[], publicKey: Uint8Array) => Promise<Uint8Array>;
|
|
308
|
+
declare const generatePublicKey: () => Promise<Uint8Array>;
|
|
321
309
|
/**
|
|
322
310
|
* This is a wrapper around enclave-e3/sdk encryption functions as CRISP circuit will require some more
|
|
323
311
|
* input values which generic Greco do not need.
|
|
@@ -333,19 +321,18 @@ declare const encryptVote: (encodedVote: string[], publicKey: Uint8Array) => Pro
|
|
|
333
321
|
* @param isFirstVote Whether this is the first vote for this slot
|
|
334
322
|
* @returns The CRISP circuit inputs
|
|
335
323
|
*/
|
|
336
|
-
declare const encryptVoteAndGenerateCRISPInputs: ({ encodedVote, publicKey, previousCiphertext,
|
|
324
|
+
declare const encryptVoteAndGenerateCRISPInputs: ({ encodedVote, publicKey, previousCiphertext, merkleData, message, signature, balance, slotAddress, isFirstVote, }: EncryptVoteAndGenerateCRISPInputsParams) => Promise<CRISPCircuitInputs>;
|
|
337
325
|
/**
|
|
338
326
|
* A function to generate the data required to mask a vote
|
|
339
327
|
* @param voter The voter's address
|
|
340
328
|
* @param publicKey The voter's public key
|
|
341
329
|
* @param previousCiphertext The previous ciphertext
|
|
342
|
-
* @param bfvParams The BFV parameters
|
|
343
330
|
* @param merkleRoot The merkle root of the census tree
|
|
344
331
|
* @param slotAddress The voter's slot address
|
|
345
332
|
* @param isFirstVote Whether this is the first vote for this slot
|
|
346
333
|
* @returns The CRISP circuit inputs for a mask vote
|
|
347
334
|
*/
|
|
348
|
-
declare const generateMaskVote: (publicKey: Uint8Array, previousCiphertext: Uint8Array,
|
|
335
|
+
declare const generateMaskVote: (publicKey: Uint8Array, previousCiphertext: Uint8Array, merkleRoot: bigint, slotAddress: string, isFirstVote: boolean) => Promise<CRISPCircuitInputs>;
|
|
349
336
|
declare const generateProof: (crispInputs: CRISPCircuitInputs) => Promise<ProofData>;
|
|
350
337
|
declare const generateProofWithReturnValue: (crispInputs: CRISPCircuitInputs) => Promise<{
|
|
351
338
|
returnValue: unknown;
|
|
@@ -355,6 +342,13 @@ declare const getCircuitOutputValue: (crispInputs: CRISPCircuitInputs) => Promis
|
|
|
355
342
|
returnValue: unknown;
|
|
356
343
|
}>;
|
|
357
344
|
declare const verifyProof: (proof: ProofData) => Promise<boolean>;
|
|
345
|
+
/**
|
|
346
|
+
* Encode the proof data into a format that can be used by the CRISP program in Solidity
|
|
347
|
+
* to validate the proof.
|
|
348
|
+
* @param proof The proof data.
|
|
349
|
+
* @returns The encoded proof data as a hex string.
|
|
350
|
+
*/
|
|
351
|
+
declare const encodeSolidityProof: (proof: ProofData) => Hex;
|
|
358
352
|
|
|
359
353
|
/**
|
|
360
354
|
* Given a message and its signed version, extract the signature components
|
|
@@ -364,4 +358,4 @@ declare const verifyProof: (proof: ProofData) => Promise<boolean>;
|
|
|
364
358
|
*/
|
|
365
359
|
declare const extractSignature: (message: string, signedMessage: `0x${string}`) => Promise<NoirSignatureInputs>;
|
|
366
360
|
|
|
367
|
-
export { type CRISPCircuitInputs, CRISP_SERVER_STATE_LITE_ENDPOINT, CRISP_SERVER_TOKEN_TREE_ENDPOINT,
|
|
361
|
+
export { type CRISPCircuitInputs, CRISP_SERVER_STATE_LITE_ENDPOINT, CRISP_SERVER_TOKEN_TREE_ENDPOINT, HALF_LARGEST_MINIMUM_DEGREE, type IMerkleProof, type IRoundDetails, type IRoundDetailsResponse, type ITokenDetails, type IVote, MAXIMUM_VOTE_VALUE, MERKLE_TREE_MAX_DEPTH, MESSAGE, type NoirSignatureInputs, VotingMode, calculateValidIndicesForPlaintext, decodeTally, encodeSolidityProof, encodeVote, encryptVote, encryptVoteAndGenerateCRISPInputs, extractSignature, generateMaskVote, generateMerkleProof, generateMerkleTree, generateProof, generateProofWithReturnValue, generatePublicKey, getBalanceAt, getCircuitOutputValue, getRoundDetails, getRoundTokenDetails, getTotalSupplyAt, getTreeData, hashLeaf, toBinary, validateVote, verifyProof };
|