@crisp-e3/sdk 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/.tsbuildinfo +1 -0
- package/dist/index.d.ts +33 -16
- package/dist/index.js +2516 -159
- package/dist/index.js.map +1 -1
- package/dist/workers/generateCircuitInputs.worker.d.ts +2 -0
- package/dist/workers/generateCircuitInputs.worker.js +144 -0
- package/dist/workers/generateCircuitInputs.worker.js.map +1 -0
- package/package.json +13 -7
package/dist/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ type MerkleProof = {
|
|
|
82
82
|
/**
|
|
83
83
|
* Type representing a vote
|
|
84
84
|
*/
|
|
85
|
-
type Vote =
|
|
85
|
+
type Vote = number[];
|
|
86
86
|
type ProofData = {
|
|
87
87
|
publicInputs: string[];
|
|
88
88
|
proof: Uint8Array;
|
|
@@ -197,33 +197,50 @@ declare const getAddressFromSignature: (signature: `0x${string}`, messageHash?:
|
|
|
197
197
|
* @param numChoices Number of choices.
|
|
198
198
|
* @returns Maximum value per choice.
|
|
199
199
|
*/
|
|
200
|
-
declare const getMaxVoteValue: (numChoices: number) =>
|
|
200
|
+
declare const getMaxVoteValue: (numChoices: number) => number;
|
|
201
201
|
/**
|
|
202
202
|
* Get a zero vote with the given number of choices.
|
|
203
203
|
* @param numChoices Number of choices.
|
|
204
204
|
* @returns A zero vote with the given number of choices.
|
|
205
205
|
*/
|
|
206
|
-
declare const getZeroVote: (numChoices: number) =>
|
|
206
|
+
declare const getZeroVote: (numChoices: number) => number[];
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
209
|
+
* Vote encoding and BFV encryption for the CRISP voting protocol.
|
|
210
|
+
*
|
|
211
|
+
* Encodes vote choices (numbers per option) into polynomial coefficient arrays
|
|
212
|
+
* suitable for BFV homomorphic encryption. Each choice is represented as a
|
|
213
|
+
* segment of binary digits, padded to fit the polynomial degree. Supports
|
|
214
|
+
* encoding, encryption, decryption, and tally decoding.
|
|
213
215
|
*/
|
|
214
|
-
|
|
216
|
+
|
|
215
217
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* @param
|
|
219
|
-
* @
|
|
218
|
+
* Encrypts an encoded vote using BFV homomorphic encryption.
|
|
219
|
+
*
|
|
220
|
+
* @param vote - Vote choices to encrypt
|
|
221
|
+
* @param publicKey - BFV public key
|
|
222
|
+
* @returns Encrypted ciphertext
|
|
220
223
|
*/
|
|
221
224
|
declare const encryptVote: (vote: Vote, publicKey: Uint8Array) => Uint8Array;
|
|
222
225
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
226
|
+
* Decodes raw tally bytes (or hex string) into vote values per choice.
|
|
227
|
+
* Expects the same segment layout as used in encodeVote.
|
|
228
|
+
*
|
|
229
|
+
* @param tallyBytes - Hex string or array of decoded numbers from tally/decryption
|
|
230
|
+
* @param numChoices - Number of vote options
|
|
231
|
+
* @returns Vote array with one value per choice
|
|
232
|
+
*/
|
|
233
|
+
declare const decodeTally: (tallyBytes: string | number[], numChoices: number) => Vote;
|
|
234
|
+
/**
|
|
235
|
+
* Generates a BFV keypair for vote encryption and decryption.
|
|
236
|
+
*
|
|
237
|
+
* @returns Object with secretKey and publicKey as Uint8Arrays
|
|
225
238
|
*/
|
|
226
|
-
declare const
|
|
239
|
+
declare const generateBFVKeys: () => {
|
|
240
|
+
secretKey: Uint8Array;
|
|
241
|
+
publicKey: Uint8Array;
|
|
242
|
+
};
|
|
243
|
+
|
|
227
244
|
/**
|
|
228
245
|
* Validate a vote.
|
|
229
246
|
* @param vote - The vote to validate.
|
|
@@ -284,4 +301,4 @@ declare class CrispSDK {
|
|
|
284
301
|
generateVoteProof(voteProofInputs: VoteProofRequest): Promise<ProofData>;
|
|
285
302
|
}
|
|
286
303
|
|
|
287
|
-
export { CreditMode, 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,
|
|
304
|
+
export { CreditMode, 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, generateBFVKeys, generateMaskVoteProof, generateMerkleProof, generateMerkleTree, generateVoteProof, getAddressFromSignature, getBalanceAt, getIsSlotEmpty, getMaxVoteValue, getPreviousCiphertext, getRoundDetails, getRoundTokenDetails, getTotalSupplyAt, getTreeData, getZeroVote, hashLeaf, validateVote, verifyProof };
|