@crisp-e3/sdk 0.27.0-insecure.0 → 0.27.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/README.md +23 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +38 -4
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/presets/insecure-64.js +2 -2
- package/dist/presets/secure-8192.d.ts +7 -0
- package/dist/presets/secure-8192.js +20 -6
- package/dist/workers/generateCircuitInputs.worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,35 @@ type ProofData = {
|
|
|
105
105
|
*/
|
|
106
106
|
parentIndexPlusOne: number;
|
|
107
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* One proof in the ballot pipeline, in the order {@link finishBallotProof} produces them.
|
|
110
|
+
*
|
|
111
|
+
* - `encryption_ct0` (`user_data_encryption_ct0`) - `ct0 = pk0·u + e0 + k0·k1` with every term
|
|
112
|
+
* bounded: the half of the ciphertext that carries the ballot plaintext `k1` is well formed.
|
|
113
|
+
* - `encryption_ct1` (`user_data_encryption_ct1`) - `ct1 = pk1·u + e1`: the other half is well
|
|
114
|
+
* formed. It does not compare `u` with ct0's.
|
|
115
|
+
* - `ballot` (`crisp` / `crisp_onchain`) - the ballot rules. A vote is signed over the digest by the
|
|
116
|
+
* slot owner and is within the voting power; a mask is zero everywhere. Either way the new slot
|
|
117
|
+
* ciphertext is the ballot ciphertext plus the addend (the slot's current ciphertext for a mask,
|
|
118
|
+
* zero otherwise).
|
|
119
|
+
* - `encryption` (`user_data_encryption`) - verifies both halves and asserts they share the same
|
|
120
|
+
* randomness `u`, then commits to the key and the ciphertext.
|
|
121
|
+
* - `fold` (`fold` / `fold_onchain`) - verifies the encryption and ballot proofs, asserts they cover
|
|
122
|
+
* the same ciphertext and plaintext, and outputs the key commitment, which the contract checks
|
|
123
|
+
* against the round's committee key.
|
|
124
|
+
*/
|
|
125
|
+
type ProofStage = 'encryption_ct0' | 'encryption_ct1' | 'ballot' | 'encryption' | 'fold';
|
|
126
|
+
/** Reported when a proof stage starts. The proof is complete when the promise resolves. */
|
|
127
|
+
type ProofProgress = {
|
|
128
|
+
stage: ProofStage;
|
|
129
|
+
/** Zero-based position of `stage` in {@link PROOF_STAGES}. */
|
|
130
|
+
index: number;
|
|
131
|
+
total: number;
|
|
132
|
+
};
|
|
133
|
+
type ProofOptions = {
|
|
134
|
+
/** Called as each stage starts. Proving takes tens of seconds, so a client can show where it is. */
|
|
135
|
+
onProgress?: (progress: ProofProgress) => void;
|
|
136
|
+
};
|
|
108
137
|
/**
|
|
109
138
|
* Which circuit a ballot is built for.
|
|
110
139
|
*
|
|
@@ -679,6 +708,8 @@ declare const getBlockAtTimestamp: (serverUrl: string, timestamp: bigint) => Pro
|
|
|
679
708
|
*/
|
|
680
709
|
declare const chainRpcUrl: (serverUrl: string) => string;
|
|
681
710
|
|
|
711
|
+
/** The proofs `finishBallotProof` produces, in order. See {@link ProofStage}. */
|
|
712
|
+
declare const PROOF_STAGES: readonly ProofStage[];
|
|
682
713
|
declare const MERKLE_TREE_MAX_DEPTH = 20;
|
|
683
714
|
declare const MAX_MSG_NON_ZERO_COEFFS = 50;
|
|
684
715
|
declare const MAX_VOTE_OPTIONS = 10;
|
|
@@ -824,9 +855,10 @@ declare const prepareBallot: (inputs: PrepareBallotInputs) => Promise<PreparedBa
|
|
|
824
855
|
* @param prepared The output of `prepareBallot`.
|
|
825
856
|
* @param digest The ballot digest.
|
|
826
857
|
* @param signature The voter signature over that digest.
|
|
858
|
+
* @param options `onProgress` reports each proof stage as it starts.
|
|
827
859
|
* @returns The proof.
|
|
828
860
|
*/
|
|
829
|
-
declare const finishBallotProof: (prepared: PreparedBallot, digest: `0x${string}`, signature: `0x${string}
|
|
861
|
+
declare const finishBallotProof: (prepared: PreparedBallot, digest: `0x${string}`, signature: `0x${string}`, options?: ProofOptions) => Promise<ProofData>;
|
|
830
862
|
/**
|
|
831
863
|
* Phase two for a mask.
|
|
832
864
|
*
|
|
@@ -837,9 +869,10 @@ declare const finishBallotProof: (prepared: PreparedBallot, digest: `0x${string}
|
|
|
837
869
|
*
|
|
838
870
|
* @param prepared The output of `prepareBallot` with `isMaskVote: true`.
|
|
839
871
|
* @param digest The ballot digest, from the same contract call a real vote would use.
|
|
872
|
+
* @param options `onProgress` reports each proof stage as it starts.
|
|
840
873
|
* @returns The proof.
|
|
841
874
|
*/
|
|
842
|
-
declare const finishMaskProof: (prepared: PreparedBallot, digest: `0x${string}
|
|
875
|
+
declare const finishMaskProof: (prepared: PreparedBallot, digest: `0x${string}`, options?: ProofOptions) => Promise<ProofData>;
|
|
843
876
|
/**
|
|
844
877
|
* Locally verify a Noir proof.
|
|
845
878
|
* @param proof - The proof to verify.
|
|
@@ -945,9 +978,10 @@ declare class CrispSDK {
|
|
|
945
978
|
* @param prepared - The output of {@link prepareBallot}.
|
|
946
979
|
* @param digest - The digest read from `CRISPProgram.ballotDigest`.
|
|
947
980
|
* @param signature - The voter signature, omitted for a mask.
|
|
981
|
+
* @param options - `onProgress` reports each proof stage as it starts.
|
|
948
982
|
* @returns A promise that resolves to the generated proof data.
|
|
949
983
|
*/
|
|
950
|
-
finishBallot(prepared: PreparedBallot, digest: `0x${string}`, signature?: `0x${string}
|
|
984
|
+
finishBallot(prepared: PreparedBallot, digest: `0x${string}`, signature?: `0x${string}`, options?: ProofOptions): Promise<ProofData>;
|
|
951
985
|
/**
|
|
952
986
|
* Get the current (most recent) round, optionally filtered by requester addresses.
|
|
953
987
|
* @param requesters - Optional list of requester addresses to filter by
|
|
@@ -1104,4 +1138,4 @@ declare class CrispSDK {
|
|
|
1104
1138
|
getPreviousCiphertext(e3Id: bigint, address: string): Promise<SlotHead | undefined>;
|
|
1105
1139
|
}
|
|
1106
1140
|
|
|
1107
|
-
export { type BroadcastVoteRequest, type BroadcastVoteResponse, type CensusVariant, type ChainHead, type ContractRead, type ContractReadResult, CreditMode, CrispSDK, type CurrentRoundResponse, type E3StateLiteResponse, type IndexedLog, type InputExclusionReason, type InputIdentity, type InputSelectionResponse, type InputSelectionStatus, type JsonResponse, type LogQuery, MAX_MSG_NON_ZERO_COEFFS, MAX_VOTE_OPTIONS, MERKLE_TREE_MAX_DEPTH, type NewRoundRequest, type OnChainRoundData, type PrepareBallotInputs, type PrepareBallotRequest, type PreparedBallot, type ProofData, type RoundDetails, SERVER_RPC, SIGNATURE_MESSAGE, SIGNATURE_MESSAGE_HASH, type SlotHead, type SubmissionStage, type SubmissionStageInputs, type SubmissionStatus, type TallyResult, type TokenDetails, type TokenHolder, type Vote, type VoteResponseStatus, type VoteStatusResponse, type WebResultResponse, broadcastVote, chainRpcUrl, decodeInputIdentity, decodeTally, decryptVote, destroyBBApi, encodeSolidityProof, encodeVote, encryptVote, finishBallotProof, finishMaskProof, generateBFVKeys, generateMerkleProof, generateMerkleTree, getAddressFromSignature, getAllRoundResults, getBalanceAt, getBlockAtTimestamp, getChainHead, getCurrentRound, getEligibleAddresses, getIndexedLogs, getInputSelection, getOnChainRoundData, getOnchainVotingPower, getPreviousCiphertext, getRoundCiphertext, getRoundDetails, getRoundPublicKey, getRoundResult, getRoundStateLite, getRoundTokenDetails, getSubmissionStage, getTokenHolderHashes, getTotalSupplyAt, getTreeData, getVoteAvailability, getVoteStatus, getZeroVote, hashLeaf, prepareBallot, prepareCircuitInputs, readContracts, requestNewRound, splitDigest, validateVote, verifyProof };
|
|
1141
|
+
export { type BroadcastVoteRequest, type BroadcastVoteResponse, type CensusVariant, type ChainHead, type ContractRead, type ContractReadResult, CreditMode, CrispSDK, type CurrentRoundResponse, type E3StateLiteResponse, type IndexedLog, type InputExclusionReason, type InputIdentity, type InputSelectionResponse, type InputSelectionStatus, type JsonResponse, type LogQuery, MAX_MSG_NON_ZERO_COEFFS, MAX_VOTE_OPTIONS, MERKLE_TREE_MAX_DEPTH, type NewRoundRequest, type OnChainRoundData, PROOF_STAGES, type PrepareBallotInputs, type PrepareBallotRequest, type PreparedBallot, type ProofData, type ProofOptions, type ProofProgress, type ProofStage, type RoundDetails, SERVER_RPC, SIGNATURE_MESSAGE, SIGNATURE_MESSAGE_HASH, type SlotHead, type SubmissionStage, type SubmissionStageInputs, type SubmissionStatus, type TallyResult, type TokenDetails, type TokenHolder, type Vote, type VoteResponseStatus, type VoteStatusResponse, type WebResultResponse, broadcastVote, chainRpcUrl, decodeInputIdentity, decodeTally, decryptVote, destroyBBApi, encodeSolidityProof, encodeVote, encryptVote, finishBallotProof, finishMaskProof, generateBFVKeys, generateMerkleProof, generateMerkleTree, getAddressFromSignature, getAllRoundResults, getBalanceAt, getBlockAtTimestamp, getChainHead, getCurrentRound, getEligibleAddresses, getIndexedLogs, getInputSelection, getOnChainRoundData, getOnchainVotingPower, getPreviousCiphertext, getRoundCiphertext, getRoundDetails, getRoundPublicKey, getRoundResult, getRoundStateLite, getRoundTokenDetails, getSubmissionStage, getTokenHolderHashes, getTotalSupplyAt, getTreeData, getVoteAvailability, getVoteStatus, getZeroVote, hashLeaf, prepareBallot, prepareCircuitInputs, readContracts, requestNewRound, splitDigest, validateVote, verifyProof };
|