@crisp-e3/sdk 0.5.8 → 0.5.9
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 +28 -21
- package/dist/index.js +97 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -80,18 +80,9 @@ type MerkleProof = {
|
|
|
80
80
|
indices: number[];
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
* Type representing a vote
|
|
83
|
+
* Type representing a vote
|
|
84
84
|
*/
|
|
85
|
-
type Vote =
|
|
86
|
-
/**
|
|
87
|
-
* The voting power for 'yes' votes
|
|
88
|
-
*/
|
|
89
|
-
yes: bigint;
|
|
90
|
-
/**
|
|
91
|
-
* The voting power for 'no' votes
|
|
92
|
-
*/
|
|
93
|
-
no: bigint;
|
|
94
|
-
};
|
|
85
|
+
type Vote = bigint[];
|
|
95
86
|
type ProofData = {
|
|
96
87
|
publicInputs: string[];
|
|
97
88
|
proof: Uint8Array;
|
|
@@ -103,6 +94,7 @@ type MaskVoteProofInputs = {
|
|
|
103
94
|
slotAddress: string;
|
|
104
95
|
merkleLeaves: string[] | bigint[];
|
|
105
96
|
previousCiphertext?: Uint8Array;
|
|
97
|
+
numOptions: number;
|
|
106
98
|
};
|
|
107
99
|
type MaskVoteProofRequest = {
|
|
108
100
|
e3Id: number;
|
|
@@ -110,6 +102,7 @@ type MaskVoteProofRequest = {
|
|
|
110
102
|
balance: bigint;
|
|
111
103
|
slotAddress: string;
|
|
112
104
|
merkleLeaves: string[] | bigint[];
|
|
105
|
+
numOptions: number;
|
|
113
106
|
};
|
|
114
107
|
type VoteProofInputs = {
|
|
115
108
|
merkleLeaves: string[] | bigint[];
|
|
@@ -161,11 +154,6 @@ declare const getPreviousCiphertext: (serverUrl: string, e3Id: number, address:
|
|
|
161
154
|
declare const getIsSlotEmpty: (serverUrl: string, e3Id: number, address: string) => Promise<boolean>;
|
|
162
155
|
|
|
163
156
|
declare const MERKLE_TREE_MAX_DEPTH = 20;
|
|
164
|
-
/**
|
|
165
|
-
* This is the maximum value for a vote (Yes or No). This is 2^50 - 1
|
|
166
|
-
* The minimum degree that BFV should use is 100 (to accommodate both Yes and No votes)
|
|
167
|
-
*/
|
|
168
|
-
declare const MAXIMUM_VOTE_VALUE: number;
|
|
169
157
|
/**
|
|
170
158
|
* Message used by users to prove ownership of their Ethereum account
|
|
171
159
|
* This message is signed by the user's private key to authenticate their identity
|
|
@@ -195,13 +183,26 @@ declare const generateMerkleTree: (leaves: bigint[]) => LeanIMT;
|
|
|
195
183
|
*/
|
|
196
184
|
declare const generateMerkleProof: (balance: bigint, address: string, leaves: bigint[] | string[]) => MerkleProof;
|
|
197
185
|
declare const getAddressFromSignature: (signature: `0x${string}`, messageHash?: `0x${string}`) => Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Get the maximum vote value for a given number of choices.
|
|
188
|
+
* @param numChoices Number of choices.
|
|
189
|
+
* @returns Maximum value per choice.
|
|
190
|
+
*/
|
|
191
|
+
declare const getMaxVoteValue: (numChoices: number) => bigint;
|
|
192
|
+
/**
|
|
193
|
+
* Get a zero vote with the given number of choices.
|
|
194
|
+
* @param numChoices Number of choices.
|
|
195
|
+
* @returns A zero vote with the given number of choices.
|
|
196
|
+
*/
|
|
197
|
+
declare const getZeroVote: (numChoices: number) => bigint[];
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
|
-
* Decode an encoded tally into
|
|
201
|
-
* @param tallyBytes The encoded tally as a hex string
|
|
202
|
-
* @
|
|
200
|
+
* Decode an encoded tally into vote counts for n choices.
|
|
201
|
+
* @param tallyBytes The encoded tally as a hex string.
|
|
202
|
+
* @param numChoices Number of choices.
|
|
203
|
+
* @returns Array of vote counts per choice.
|
|
203
204
|
*/
|
|
204
|
-
declare const decodeTally: (tallyBytes: string) => Vote;
|
|
205
|
+
declare const decodeTally: (tallyBytes: string, numChoices: number) => Vote;
|
|
205
206
|
/**
|
|
206
207
|
* Encrypt the vote using the public key.
|
|
207
208
|
* @param vote - The vote to encrypt.
|
|
@@ -214,6 +215,12 @@ declare const encryptVote: (vote: Vote, publicKey: Uint8Array) => Uint8Array;
|
|
|
214
215
|
* @returns The generated public key as a Uint8Array.
|
|
215
216
|
*/
|
|
216
217
|
declare const generatePublicKey: () => Uint8Array;
|
|
218
|
+
/**
|
|
219
|
+
* Validate a vote.
|
|
220
|
+
* @param vote - The vote to validate.
|
|
221
|
+
* @param balance - The balance of the voter.
|
|
222
|
+
*/
|
|
223
|
+
declare const validateVote: (vote: Vote, balance: bigint) => void;
|
|
217
224
|
/**
|
|
218
225
|
* Generate a vote proof for the CRISP circuit given the vote proof inputs.
|
|
219
226
|
* @param voteProofInputs - The vote proof inputs.
|
|
@@ -268,4 +275,4 @@ declare class CrispSDK {
|
|
|
268
275
|
generateVoteProof(voteProofInputs: VoteProofRequest): Promise<ProofData>;
|
|
269
276
|
}
|
|
270
277
|
|
|
271
|
-
export { CrispSDK,
|
|
278
|
+
export { CrispSDK, MERKLE_TREE_MAX_DEPTH, type MaskVoteProofInputs, type RoundDetails, type RoundDetailsResponse, SIGNATURE_MESSAGE, SIGNATURE_MESSAGE_HASH, type TokenDetails, type Vote, type VoteProofInputs, decodeTally, encodeSolidityProof, encryptVote, generateMaskVoteProof, generateMerkleProof, generateMerkleTree, generatePublicKey, generateVoteProof, getAddressFromSignature, getBalanceAt, getIsSlotEmpty, getMaxVoteValue, getPreviousCiphertext, getRoundDetails, getRoundTokenDetails, getTotalSupplyAt, getTreeData, getZeroVote, hashLeaf, validateVote, verifyProof };
|