@devtion/devcli 0.0.0-7e983e3
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 +21 -0
- package/README.md +118 -0
- package/dist/.env +41 -0
- package/dist/index.js +3206 -0
- package/dist/types/commands/auth.d.ts +25 -0
- package/dist/types/commands/clean.d.ts +6 -0
- package/dist/types/commands/contribute.d.ts +139 -0
- package/dist/types/commands/finalize.d.ts +51 -0
- package/dist/types/commands/index.d.ts +9 -0
- package/dist/types/commands/listCeremonies.d.ts +5 -0
- package/dist/types/commands/logout.d.ts +6 -0
- package/dist/types/commands/observe.d.ts +22 -0
- package/dist/types/commands/setup.d.ts +86 -0
- package/dist/types/commands/validate.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lib/errors.d.ts +60 -0
- package/dist/types/lib/files.d.ts +64 -0
- package/dist/types/lib/localConfigs.d.ts +110 -0
- package/dist/types/lib/prompts.d.ts +104 -0
- package/dist/types/lib/services.d.ts +31 -0
- package/dist/types/lib/theme.d.ts +42 -0
- package/dist/types/lib/utils.d.ts +158 -0
- package/dist/types/types/index.d.ts +65 -0
- package/package.json +100 -0
- package/src/commands/auth.ts +194 -0
- package/src/commands/clean.ts +49 -0
- package/src/commands/contribute.ts +1090 -0
- package/src/commands/finalize.ts +382 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/listCeremonies.ts +32 -0
- package/src/commands/logout.ts +67 -0
- package/src/commands/observe.ts +193 -0
- package/src/commands/setup.ts +901 -0
- package/src/commands/validate.ts +29 -0
- package/src/index.ts +66 -0
- package/src/lib/errors.ts +77 -0
- package/src/lib/files.ts +102 -0
- package/src/lib/localConfigs.ts +186 -0
- package/src/lib/prompts.ts +748 -0
- package/src/lib/services.ts +191 -0
- package/src/lib/theme.ts +45 -0
- package/src/lib/utils.ts +778 -0
- package/src/types/conf.d.ts +16 -0
- package/src/types/index.ts +70 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Verification } from "@octokit/auth-oauth-device/dist-types/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Custom countdown which throws an error when expires.
|
|
5
|
+
* @param expirationInSeconds <number> - the expiration time in seconds.
|
|
6
|
+
*/
|
|
7
|
+
export declare const expirationCountdownForGithubOAuth: (expirationInSeconds: number) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Callback to manage the data requested for Github OAuth2.0 device flow.
|
|
10
|
+
* @param verification <Verification> - the data from Github OAuth2.0 device flow.
|
|
11
|
+
*/
|
|
12
|
+
export declare const onVerification: (verification: Verification) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Return the Github OAuth 2.0 token using manual Device Flow authentication process.
|
|
15
|
+
* @param clientId <string> - the client id for the CLI OAuth app.
|
|
16
|
+
* @returns <string> the Github OAuth 2.0 token.
|
|
17
|
+
*/
|
|
18
|
+
export declare const executeGithubDeviceFlow: (clientId: string) => Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Auth command.
|
|
21
|
+
* @notice The auth command allows a user to make the association of their Github account with the CLI by leveraging OAuth 2.0 as an authentication mechanism.
|
|
22
|
+
* @dev Under the hood, the command handles a manual Device Flow following the guidelines in the Github documentation.
|
|
23
|
+
*/
|
|
24
|
+
declare const auth: () => Promise<void>;
|
|
25
|
+
export default auth;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Contribution, ContributionValidity, FirebaseDocumentInfo } from "@p0tion/actions";
|
|
3
|
+
import { DocumentSnapshot, DocumentData, Firestore } from "firebase/firestore";
|
|
4
|
+
import { Functions } from "firebase/functions";
|
|
5
|
+
/**
|
|
6
|
+
* Return the verification result for latest contribution.
|
|
7
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
8
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
9
|
+
* @param circuitId <string> - the unique identifier of the circuit.
|
|
10
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getLatestVerificationResult: (firestoreDatabase: Firestore, ceremonyId: string, circuitId: string, participantId: string) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a ready-to-share tweet on public attestation.
|
|
15
|
+
* @param ceremonyTitle <string> - the title of the ceremony.
|
|
16
|
+
* @param gistUrl <string> - the Github public attestation gist url.
|
|
17
|
+
*/
|
|
18
|
+
export declare const handleTweetGeneration: (ceremonyTitle: string, gistUrl: string) => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Display if a set of contributions computed for a circuit is valid/invalid.
|
|
21
|
+
* @param contributionsWithValidity <Array<ContributionValidity>> - list of contributor contributions together with contribution validity.
|
|
22
|
+
*/
|
|
23
|
+
export declare const displayContributionValidity: (contributionsWithValidity: Array<ContributionValidity>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Display and manage data necessary when participant has already made the contribution for all circuits of a ceremony.
|
|
26
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
27
|
+
* @param circuits <Array<FirebaseDocumentInfo>> - the array of ceremony circuits documents.
|
|
28
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
29
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
30
|
+
*/
|
|
31
|
+
export declare const handleContributionValidity: (firestoreDatabase: Firestore, circuits: Array<FirebaseDocumentInfo>, ceremonyId: string, participantId: string) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Display and manage data necessary when participant would like to contribute but there is still an on-going timeout.
|
|
34
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
35
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
36
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
37
|
+
* @param participantContributionProgress <number> - the progress in the contribution of the various circuits of the ceremony.
|
|
38
|
+
* @param wasContributing <boolean> - flag to discriminate between participant currently contributing (true) or not (false).
|
|
39
|
+
*/
|
|
40
|
+
export declare const handleTimedoutMessageForContributor: (firestoreDatabase: Firestore, participantId: string, ceremonyId: string, participantContributionProgress: number, wasContributing: boolean) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Check if the participant has enough disk space available before joining the waiting queue
|
|
43
|
+
* for the computing the next circuit contribution.
|
|
44
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
45
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
46
|
+
* @param circuitSequencePosition <number> - the position of the circuit in the sequence for contribution.
|
|
47
|
+
* @param circuitZkeySizeInBytes <number> - the size in bytes of the circuit zKey.
|
|
48
|
+
* @param isResumingAfterTimeout <boolean> - flag to discriminate between resuming after a timeout expiration (true) or progressing to next contribution (false).
|
|
49
|
+
* @param providerUserId <string> - the external third-party provider user identifier.
|
|
50
|
+
* @return <Promise<boolean>> - true when the contributor would like to generate the attestation and do not provide any further contribution to the ceremony; otherwise false.
|
|
51
|
+
*/
|
|
52
|
+
export declare const handleDiskSpaceRequirementForNextContribution: (cloudFunctions: Functions, ceremonyId: string, circuitSequencePosition: number, circuitZkeySizeInBytes: number, isResumingAfterTimeout: boolean, providerUserId: string) => Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Generate the public attestation for the contributor.
|
|
55
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
56
|
+
* @param circuits <Array<FirebaseDocumentInfo>> - the array of ceremony circuits documents.
|
|
57
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
58
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
59
|
+
* @param participantContributions <Array<Co> - the document data of the participant.
|
|
60
|
+
* @param contributorIdentifier <string> - the identifier of the contributor (handle, name, uid).
|
|
61
|
+
* @param ceremonyName <string> - the name of the ceremony.
|
|
62
|
+
* @returns <Promise<string>> - the public attestation.
|
|
63
|
+
*/
|
|
64
|
+
export declare const generatePublicAttestation: (firestoreDatabase: Firestore, circuits: Array<FirebaseDocumentInfo>, ceremonyId: string, participantId: string, participantContributions: Array<Contribution>, contributorIdentifier: string, ceremonyName: string) => Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Generate a public attestation for a contributor, publish the attestation as gist, and prepare a new ready-to-share tweet about ceremony participation.
|
|
67
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
68
|
+
* @param circuits <Array<FirebaseDocumentInfo>> - the array of ceremony circuits documents.
|
|
69
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
70
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
71
|
+
* @param participantContributions <Array<Co> - the document data of the participant.
|
|
72
|
+
* @param contributorIdentifier <string> - the identifier of the contributor (handle, name, uid).
|
|
73
|
+
* @param ceremonyName <string> - the name of the ceremony.
|
|
74
|
+
* @param ceremonyPrefix <string> - the prefix of the ceremony.
|
|
75
|
+
* @param participantAccessToken <string> - the access token of the participant.
|
|
76
|
+
*/
|
|
77
|
+
export declare const handlePublicAttestation: (firestoreDatabase: Firestore, circuits: Array<FirebaseDocumentInfo>, ceremonyId: string, participantId: string, participantContributions: Array<Contribution>, contributorIdentifier: string, ceremonyName: string, ceremonyPrefix: string, participantAccessToken: string) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Listen to circuit document changes.
|
|
80
|
+
* @notice the circuit is the one for which the participant wants to contribute.
|
|
81
|
+
* @dev display custom messages in order to make the participant able to follow what's going while waiting in the queue.
|
|
82
|
+
* Also, this listener use another listener for the current circuit contributor in order to inform the waiting participant about the current contributor's progress.
|
|
83
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
84
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
85
|
+
* @param participantId <string> - the unique identifier of the participant.
|
|
86
|
+
* @param circuit <FirebaseDocumentInfo> - the Firestore document info about the circuit.
|
|
87
|
+
*/
|
|
88
|
+
export declare const listenToCeremonyCircuitDocumentChanges: (firestoreDatabase: Firestore, ceremonyId: string, participantId: string, circuit: FirebaseDocumentInfo) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Listen to current authenticated participant document changes.
|
|
91
|
+
* @dev this is the core business logic related to the execution of the contribute command.
|
|
92
|
+
* Basically, the command follows the updates of circuit waiting queue, participant status and contribution steps,
|
|
93
|
+
* while covering aspects regarding memory requirements, contribution completion or resumability, interaction w/ cloud functions, and so on.
|
|
94
|
+
* @notice in order to compute a contribute for each circuit, this method follows several steps:
|
|
95
|
+
* 1) Checking participant memory availability on root disk before joining for the first contribution (circuit having circuitPosition = 1).
|
|
96
|
+
* 2) Check if the participant has not completed the contributions for every circuit or has just finished contributing.
|
|
97
|
+
* 3) If (2) is true:
|
|
98
|
+
* 3.A) Check if the participant switched to `WAITING` as contribution status.
|
|
99
|
+
* 3.A.1) if true; display circuit waiting queue updates to the participant (listener to circuit document changes).
|
|
100
|
+
* 3.A.2) otherwise; do nothing and continue with other checks.
|
|
101
|
+
* 3.B) Check if the participant switched to `CONTRIBUTING` status. The participant must be the current contributor for the circuit w/ a resumable contribution step.
|
|
102
|
+
* 3.B.1) if true; start or resume the contribution from last contribution step.
|
|
103
|
+
* 3.B.2) otherwise; do nothing and continue with other checks.
|
|
104
|
+
* 3.C) Check if the current contributor is resuming from the "VERIFYING" contribution step.
|
|
105
|
+
* 3.C.1) if true; display previous completed steps and wait for verification results.
|
|
106
|
+
* 3.C.2) otherwise; do nothing and continue with other checks.
|
|
107
|
+
* 3.D) Check if the 'verifycontribution' cloud function has successfully completed the execution.
|
|
108
|
+
* 3.D.1) if true; get and display contribution verification results.
|
|
109
|
+
* 3.D.2) otherwise; do nothing and continue with other checks.
|
|
110
|
+
* 3.E) Check if the participant experiences a timeout while contributing.
|
|
111
|
+
* 3.E.1) if true; display timeout message and gracefully terminate.
|
|
112
|
+
* 3.E.2) otherwise; do nothing and continue with other checks.
|
|
113
|
+
* 3.F) Check if the participant has completed the contribution or is trying to resume the contribution after timeout expiration.
|
|
114
|
+
* 3.F.1) if true; check the memory requirement for next/current (completed/resuming) contribution while
|
|
115
|
+
* handling early interruption of contributions resulting in a final public attestation generation.
|
|
116
|
+
* (this allows a user to stop their contributions to a certain circuit X if their cannot provide/do not own
|
|
117
|
+
* an adequate amount of memory for satisfying the memory requirements of the next/current contribution).
|
|
118
|
+
* 3.F.2) otherwise; do nothing and continue with other checks.
|
|
119
|
+
* 3.G) Check if the participant has already contributed to every circuit when running the command.
|
|
120
|
+
* 3.G.1) if true; generate public final attestation and gracefully exit.
|
|
121
|
+
* 3.G.2) otherwise; do nothing
|
|
122
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
123
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
124
|
+
* @param participant <DocumentSnapshot<DocumentData>> - the Firestore document of the participant.
|
|
125
|
+
* @param ceremony <FirebaseDocumentInfo> - the Firestore document info about the selected ceremony.
|
|
126
|
+
* @param entropy <string> - the random value (aka toxic waste) entered by the participant for the contribution.
|
|
127
|
+
* @param providerUserId <string> - the unique provider user identifier associated to the authenticated account.
|
|
128
|
+
* @param accessToken <string> - the Github token generated through the Device Flow process.
|
|
129
|
+
*/
|
|
130
|
+
export declare const listenToParticipantDocumentChanges: (firestoreDatabase: Firestore, cloudFunctions: Functions, participant: DocumentSnapshot<DocumentData>, ceremony: FirebaseDocumentInfo, entropy: string, providerUserId: string, accessToken: string) => Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Contribute command.
|
|
133
|
+
* @notice The contribute command allows an authenticated user to become a participant (contributor) to the selected ceremony by providing the
|
|
134
|
+
* entropy (toxic waste) for the contribution.
|
|
135
|
+
* @dev For proper execution, the command requires the user to be authenticated with Github account (run auth command first) in order to
|
|
136
|
+
* handle sybil-resistance and connect to Github APIs to publish the gist containing the public attestation.
|
|
137
|
+
*/
|
|
138
|
+
declare const contribute: (opt: any) => Promise<void>;
|
|
139
|
+
export default contribute;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { FirebaseDocumentInfo } from "@p0tion/actions";
|
|
3
|
+
import { Functions } from "firebase/functions";
|
|
4
|
+
import { Firestore } from "firebase/firestore";
|
|
5
|
+
/**
|
|
6
|
+
* Export and store on the ceremony bucket the verification key for the given final contribution.
|
|
7
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
8
|
+
* @param bucketName <string> - the name of the ceremony bucket.
|
|
9
|
+
* @param finalZkeyLocalFilePath <string> - the local file path of the final zKey.
|
|
10
|
+
* @param verificationKeyLocalFilePath <string> - the local file path of the verification key.
|
|
11
|
+
* @param verificationKeyStorageFilePath <string> - the storage file path of the verification key.
|
|
12
|
+
*/
|
|
13
|
+
export declare const handleVerificationKey: (cloudFunctions: Functions, bucketName: string, finalZkeyLocalFilePath: string, verificationKeyLocalFilePath: string, verificationKeyStorageFilePath: string) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Derive and store on the ceremony bucket the Solidity Verifier smart contract for the given final contribution.
|
|
16
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
17
|
+
* @param bucketName <string> - the name of the ceremony bucket.
|
|
18
|
+
* @param finalZkeyLocalFilePath <string> - the local file path of the final zKey.
|
|
19
|
+
* @param verifierContractLocalFilePath <string> - the local file path of the verifier smart contract.
|
|
20
|
+
* @param verifierContractStorageFilePath <string> - the storage file path of the verifier smart contract.
|
|
21
|
+
*/
|
|
22
|
+
export declare const handleVerifierSmartContract: (cloudFunctions: Functions, bucketName: string, finalZkeyLocalFilePath: string, verifierContractLocalFilePath: string, verifierContractStorageFilePath: string) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Handle the process of finalizing a ceremony circuit.
|
|
25
|
+
* @dev this process results in the extraction of the final ceremony artifacts for the calculation and verification of proofs.
|
|
26
|
+
* @notice this method must enforce the order among these steps:
|
|
27
|
+
* 1) Compute the final contribution (zKey).
|
|
28
|
+
* 2) Extract the verification key (vKey).
|
|
29
|
+
* 3) Extract the Verifier smart contract (.sol).
|
|
30
|
+
* 4) Upload the artifacts in the AWS S3 storage.
|
|
31
|
+
* 5) Complete the final contribution data w/ artifacts references and hashes (cloud function).
|
|
32
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
33
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
34
|
+
* @param ceremony <FirebaseDocumentInfo> - the Firestore document of the ceremony.
|
|
35
|
+
* @param circuit <FirebaseDocumentInfo> - the Firestore document of the ceremony circuit.
|
|
36
|
+
* @param participant <FirebaseDocumentInfo> - the Firestore document of the participant (coordinator).
|
|
37
|
+
* @param beacon <string> - the value used to compute the final contribution while finalizing the ceremony.
|
|
38
|
+
* @param coordinatorIdentifier <string> - the identifier of the coordinator.
|
|
39
|
+
*/
|
|
40
|
+
export declare const handleCircuitFinalization: (cloudFunctions: Functions, firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, beacon: string, coordinatorIdentifier: string) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Finalize command.
|
|
43
|
+
* @notice The finalize command allows a coordinator to finalize a Trusted Setup Phase 2 ceremony by providing the final beacon,
|
|
44
|
+
* computing the final zKeys and extracting the Verifier Smart Contract + Verification Keys per each ceremony circuit.
|
|
45
|
+
* anyone could use the final zKey to create a proof and everyone else could verify the correctness using the
|
|
46
|
+
* related verification key (off-chain) or Verifier smart contract (on-chain).
|
|
47
|
+
* @dev For proper execution, the command requires the coordinator to be authenticated with a GitHub account (run auth command first) in order to
|
|
48
|
+
* handle sybil-resistance and connect to GitHub APIs to publish the gist containing the final public attestation.
|
|
49
|
+
*/
|
|
50
|
+
declare const finalize: () => Promise<void>;
|
|
51
|
+
export default finalize;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as setup } from "./setup.js";
|
|
2
|
+
export { default as auth } from "./auth.js";
|
|
3
|
+
export { default as contribute } from "./contribute.js";
|
|
4
|
+
export { default as observe } from "./observe.js";
|
|
5
|
+
export { default as finalize } from "./finalize.js";
|
|
6
|
+
export { default as clean } from "./clean.js";
|
|
7
|
+
export { default as logout } from "./logout.js";
|
|
8
|
+
export { default as validate } from "./validate.js";
|
|
9
|
+
export { default as listCeremonies } from "./listCeremonies.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { FirebaseDocumentInfo } from "@p0tion/actions";
|
|
3
|
+
import { Firestore } from "firebase/firestore";
|
|
4
|
+
/**
|
|
5
|
+
* Clean cursor lines from current position back to root (default: zero).
|
|
6
|
+
* @param currentCursorPos - the current position of the cursor.
|
|
7
|
+
* @returns <number>
|
|
8
|
+
*/
|
|
9
|
+
export declare const cleanCursorPosBackToRoot: (currentCursorPos: number) => number;
|
|
10
|
+
/**
|
|
11
|
+
* Show the latest updates for the given circuit.
|
|
12
|
+
* @param firestoreDatabase <Firestore> - the Firestore database to query from.
|
|
13
|
+
* @param ceremony <FirebaseDocumentInfo> - the Firebase document containing info about the ceremony.
|
|
14
|
+
* @param circuit <FirebaseDocumentInfo> - the Firebase document containing info about the circuit.
|
|
15
|
+
* @returns Promise<number> return the current position of the cursor (i.e., number of lines displayed).
|
|
16
|
+
*/
|
|
17
|
+
export declare const displayLatestCircuitUpdates: (firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo) => Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Observe command.
|
|
20
|
+
*/
|
|
21
|
+
declare const observe: () => Promise<void>;
|
|
22
|
+
export default observe;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Functions } from "firebase/functions";
|
|
3
|
+
import { CeremonyTimeoutType, CircomCompilerData, CircuitInputData, CeremonyInputData, CircuitDocument } from "@p0tion/actions";
|
|
4
|
+
/**
|
|
5
|
+
* Handle whatever is needed to obtain the input data for a circuit that the coordinator would like to add to the ceremony.
|
|
6
|
+
* @param choosenCircuitFilename <string> - the name of the circuit to add.
|
|
7
|
+
* @param matchingWasmFilename <string> - the name of the circuit wasm file.
|
|
8
|
+
* @param ceremonyTimeoutMechanismType <CeremonyTimeoutType> - the type of ceremony timeout mechanism.
|
|
9
|
+
* @param sameCircomCompiler <boolean> - true, if this circuit shares with the others the <CircomCompilerData>; otherwise false.
|
|
10
|
+
* @param circuitSequencePosition <number> - the position of the circuit in the contribution queue.
|
|
11
|
+
* @param sharedCircomCompilerData <string> - version and commit hash of the Circom compiler used to compile the ceremony circuits.
|
|
12
|
+
* @returns <Promise<CircuitInputData>> - the input data of the circuit to add to the ceremony.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getInputDataToAddCircuitToCeremony: (choosenCircuitFilename: string, matchingWasmFilename: string, ceremonyTimeoutMechanismType: CeremonyTimeoutType, sameCircomCompiler: boolean, circuitSequencePosition: number, sharedCircomCompilerData: CircomCompilerData) => Promise<CircuitInputData>;
|
|
15
|
+
/**
|
|
16
|
+
* Handle the addition of one or more circuits to the ceremony.
|
|
17
|
+
* @param options <Array<string>> - list of possible circuits that can be added to the ceremony.
|
|
18
|
+
* @param ceremonyTimeoutMechanismType <CeremonyTimeoutType> - the type of ceremony timeout mechanism.
|
|
19
|
+
* @returns <Promise<Array<CircuitInputData>>> - the input data for each circuit that has been added to the ceremony.
|
|
20
|
+
*/
|
|
21
|
+
export declare const handleAdditionOfCircuitsToCeremony: (r1csOptions: Array<string>, wasmOptions: Array<string>, ceremonyTimeoutMechanismType: CeremonyTimeoutType) => Promise<Array<CircuitInputData>>;
|
|
22
|
+
/**
|
|
23
|
+
* Print ceremony and related circuits information.
|
|
24
|
+
* @param ceremonyInputData <CeremonyInputData> - the input data of the ceremony.
|
|
25
|
+
* @param circuits <Array<CircuitDocument>> - the circuit documents associated to the circuits of the ceremony.
|
|
26
|
+
*/
|
|
27
|
+
export declare const displayCeremonySummary: (ceremonyInputData: CeremonyInputData, circuits: Array<CircuitDocument>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the smallest Powers of Tau has already been downloaded/stored in the correspondent local path
|
|
30
|
+
* @dev we are downloading the Powers of Tau file from Hermez Cryptography Phase 1 Trusted Setup.
|
|
31
|
+
* @param powers <string> - the smallest amount of powers needed for the given circuit (should be in a 'XY' stringified form).
|
|
32
|
+
* @param ptauCompleteFilename <string> - the complete file name of the powers of tau file to be downloaded.
|
|
33
|
+
* @returns <Promise<void>>
|
|
34
|
+
*/
|
|
35
|
+
export declare const checkAndDownloadSmallestPowersOfTau: (powers: string, ptauCompleteFilename: string) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Handle the needs in terms of Powers of Tau for the selected pre-computed zKey.
|
|
38
|
+
* @notice in case there are no Powers of Tau file suitable for the pre-computed zKey (i.e., having a
|
|
39
|
+
* number of powers greater than or equal to the powers needed by the zKey), the coordinator will be asked
|
|
40
|
+
* to provide a number of powers manually, ranging from the smallest possible to the largest.
|
|
41
|
+
* @param neededPowers <number> - the smallest amount of powers needed by the zKey.
|
|
42
|
+
* @returns Promise<string, string> - the information about the choosen Powers of Tau file for the pre-computed zKey
|
|
43
|
+
* along with related powers.
|
|
44
|
+
*/
|
|
45
|
+
export declare const handlePreComputedZkeyPowersOfTauSelection: (neededPowers: number) => Promise<{
|
|
46
|
+
doubleDigitsPowers: string;
|
|
47
|
+
potCompleteFilename: string;
|
|
48
|
+
usePreDownloadedPoT: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Generate a brand new zKey from scratch.
|
|
52
|
+
* @param r1csLocalPathAndFileName <string> - the local complete path of the R1CS selected file.
|
|
53
|
+
* @param potLocalPathAndFileName <string> - the local complete path of the PoT selected file.
|
|
54
|
+
* @param zkeyLocalPathAndFileName <string> - the local complete path of the pre-computed zKey selected file.
|
|
55
|
+
*/
|
|
56
|
+
export declare const handleNewZkeyGeneration: (r1csLocalPathAndFileName: string, potLocalPathAndFileName: string, zkeyLocalPathAndFileName: string) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Manage the creation of a ceremony file storage bucket.
|
|
59
|
+
* @param firebaseFunctions <Functions> - the Firebase Cloud Functions instance connected to the current application.
|
|
60
|
+
* @param ceremonyPrefix <string> - the prefix of the ceremony.
|
|
61
|
+
* @returns <Promise<string>> - the ceremony bucket name.
|
|
62
|
+
*/
|
|
63
|
+
export declare const handleCeremonyBucketCreation: (firebaseFunctions: Functions, ceremonyPrefix: string) => Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Upload a circuit artifact (r1cs, WASM, ptau) to the ceremony storage.
|
|
66
|
+
* @dev this method uses a multi part upload to upload the file in chunks.
|
|
67
|
+
* @param firebaseFunctions <Functions> - the Firebase Cloud Functions instance connected to the current application.
|
|
68
|
+
* @param bucketName <string> - the ceremony bucket name.
|
|
69
|
+
* @param storageFilePath <string> - the storage (bucket) path where the file should be uploaded.
|
|
70
|
+
* @param localPathAndFileName <string> - the local file path where is located.
|
|
71
|
+
* @param completeFilename <string> - the complete filename.
|
|
72
|
+
*/
|
|
73
|
+
export declare const handleCircuitArtifactUploadToStorage: (firebaseFunctions: Functions, bucketName: string, storageFilePath: string, localPathAndFileName: string, completeFilename: string) => Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Setup command.
|
|
76
|
+
* @notice The setup command allows the coordinator of the ceremony to prepare the next ceremony by interacting with the CLI.
|
|
77
|
+
* @dev For proper execution, the command must be run in a folder containing the R1CS files related to the circuits
|
|
78
|
+
* for which the coordinator wants to create the ceremony. The command will download the necessary Tau powers
|
|
79
|
+
* from Hermez's ceremony Phase 1 Reliable Setup Ceremony.
|
|
80
|
+
* @param cmd? <any> - the path to the ceremony setup file.
|
|
81
|
+
*/
|
|
82
|
+
declare const setup: (cmd: {
|
|
83
|
+
template?: string;
|
|
84
|
+
auth?: string;
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
export default setup;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Services */
|
|
2
|
+
export declare const CORE_SERVICES_ERRORS: {
|
|
3
|
+
FIREBASE_DEFAULT_APP_DOUBLE_CONFIG: string;
|
|
4
|
+
FIREBASE_TOKEN_EXPIRED_REMOVED_PERMISSIONS: string;
|
|
5
|
+
FIREBASE_USER_DISABLED: string;
|
|
6
|
+
FIREBASE_FAILED_CREDENTIALS_VERIFICATION: string;
|
|
7
|
+
FIREBASE_NETWORK_ERROR: string;
|
|
8
|
+
FIREBASE_CEREMONY_NOT_OPENED: string;
|
|
9
|
+
FIREBASE_CEREMONY_NOT_CLOSED: string;
|
|
10
|
+
AWS_CEREMONY_BUCKET_CREATION: string;
|
|
11
|
+
AWS_CEREMONY_BUCKET_CANNOT_DOWNLOAD_GET_PRESIGNED_URL: string;
|
|
12
|
+
};
|
|
13
|
+
/** Github */
|
|
14
|
+
export declare const THIRD_PARTY_SERVICES_ERRORS: {
|
|
15
|
+
GITHUB_ACCOUNT_ASSOCIATION_REJECTED: string;
|
|
16
|
+
GITHUB_SERVER_TIMEDOUT: string;
|
|
17
|
+
GITHUB_GET_GITHUB_ACCOUNT_INFO: string;
|
|
18
|
+
GITHUB_NOT_AUTHENTICATED: string;
|
|
19
|
+
GITHUB_GIST_PUBLICATION_FAILED: string;
|
|
20
|
+
};
|
|
21
|
+
/** Command */
|
|
22
|
+
export declare const COMMAND_ERRORS: {
|
|
23
|
+
COMMAND_NOT_COORDINATOR: string;
|
|
24
|
+
COMMAND_ABORT_PROMPT: string;
|
|
25
|
+
COMMAND_ABORT_SELECTION: string;
|
|
26
|
+
COMMAND_SETUP_NO_R1CS: string;
|
|
27
|
+
COMMAND_SETUP_NO_WASM: string;
|
|
28
|
+
COMMAND_SETUP_MISMATCH_R1CS_WASM: string;
|
|
29
|
+
COMMAND_SETUP_DOWNLOAD_PTAU: string;
|
|
30
|
+
COMMAND_SETUP_ABORT: string;
|
|
31
|
+
COMMAND_CONTRIBUTE_NO_OPENED_CEREMONIES: string;
|
|
32
|
+
COMMAND_CONTRIBUTE_NO_PARTICIPANT_DATA: string;
|
|
33
|
+
COMMAND_CONTRIBUTE_WRONG_OPTION_CEREMONY: string;
|
|
34
|
+
COMMAND_CONTRIBUTE_NO_CURRENT_CONTRIBUTOR_DATA: string;
|
|
35
|
+
COMMAND_CONTRIBUTE_NO_CURRENT_CONTRIBUTOR_CONTRIBUTION: string;
|
|
36
|
+
COMMAND_CONTRIBUTE_WRONG_CURRENT_CONTRIBUTOR_CONTRIBUTION_STEP: string;
|
|
37
|
+
COMMAND_CONTRIBUTE_NO_CIRCUIT_DATA: string;
|
|
38
|
+
COMMAND_CONTRIBUTE_NO_ACTIVE_TIMEOUT_DATA: string;
|
|
39
|
+
COMMAND_CONTRIBUTE_NO_UNIQUE_ACTIVE_TIMEOUTS: string;
|
|
40
|
+
COMMAND_CONTRIBUTE_FINALIZE_NO_TRANSCRIPT_CONTRIBUTION_HASH_MATCH: string;
|
|
41
|
+
COMMAND_FINALIZED_NO_CLOSED_CEREMONIES: string;
|
|
42
|
+
COMMAND_FINALIZED_NOT_READY_FOR_FINALIZATION: string;
|
|
43
|
+
};
|
|
44
|
+
/** Config */
|
|
45
|
+
export declare const CONFIG_ERRORS: {
|
|
46
|
+
CONFIG_GITHUB_ERROR: string;
|
|
47
|
+
CONFIG_FIREBASE_ERROR: string;
|
|
48
|
+
CONFIG_OTHER_ERROR: string;
|
|
49
|
+
};
|
|
50
|
+
/** Generic */
|
|
51
|
+
export declare const GENERIC_ERRORS: {
|
|
52
|
+
GENERIC_ERROR_RETRIEVING_DATA: string;
|
|
53
|
+
GENERIC_COUNTDOWN_EXPIRATION: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Print an error string and gracefully terminate the process.
|
|
57
|
+
* @param err <string> - the error string to be shown.
|
|
58
|
+
* @param doExit <boolean> - when true the function terminate the process; otherwise not.
|
|
59
|
+
*/
|
|
60
|
+
export declare const showError: (err: string, doExit: boolean) => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Dirent, Stats } from "fs";
|
|
3
|
+
/**
|
|
4
|
+
* Check a directory path.
|
|
5
|
+
* @param directoryPath <string> - the local path of the directory.
|
|
6
|
+
* @returns <boolean> true if the directory at given path exists, otherwise false.
|
|
7
|
+
*/
|
|
8
|
+
export declare const directoryExists: (directoryPath: string) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Write a new file locally.
|
|
11
|
+
* @param localFilePath <string> - the local path of the file.
|
|
12
|
+
* @param data <Buffer> - the content to be written inside the file.
|
|
13
|
+
*/
|
|
14
|
+
export declare const writeFile: (localFilePath: string, data: Buffer) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Read a new file from local folder.
|
|
17
|
+
* @param localFilePath <string> - the local path of the file.
|
|
18
|
+
*/
|
|
19
|
+
export declare const readFile: (localFilePath: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Get back the statistics of the provided file.
|
|
22
|
+
* @param localFilePath <string> - the local path of the file.
|
|
23
|
+
* @returns <Stats> - the metadata of the file.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getFileStats: (localFilePath: string) => Stats;
|
|
26
|
+
/**
|
|
27
|
+
* Return the sub-paths for each file stored in the given directory.
|
|
28
|
+
* @param directoryLocalPath <string> - the local path of the directory.
|
|
29
|
+
* @returns <Promise<Array<Dirent>>> - the list of sub-paths of the files contained inside the directory.
|
|
30
|
+
*/
|
|
31
|
+
export declare const getDirFilesSubPaths: (directoryLocalPath: string) => Promise<Array<Dirent>>;
|
|
32
|
+
/**
|
|
33
|
+
* Filter all files in a directory by returning only those that match the given extension.
|
|
34
|
+
* @param directoryLocalPath <string> - the local path of the directory.
|
|
35
|
+
* @param fileExtension <string> - the file extension.
|
|
36
|
+
* @returns <Promise<Array<Dirent>>> - return the filenames of the file that match the given extension, if any
|
|
37
|
+
*/
|
|
38
|
+
export declare const filterDirectoryFilesByExtension: (directoryLocalPath: string, fileExtension: string) => Promise<Array<Dirent>>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete a directory specified at a given path.
|
|
41
|
+
* @param directoryLocalPath <string> - the local path of the directory.
|
|
42
|
+
*/
|
|
43
|
+
export declare const deleteDir: (directoryLocalPath: string) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Clean a directory specified at a given path.
|
|
46
|
+
* @param directoryLocalPath <string> - the local path of the directory.
|
|
47
|
+
*/
|
|
48
|
+
export declare const cleanDir: (directoryLocalPath: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new directory in a specified path if not exist in that path.
|
|
51
|
+
* @param directoryLocalPath <string> - the local path of the directory.
|
|
52
|
+
*/
|
|
53
|
+
export declare const checkAndMakeNewDirectoryIfNonexistent: (directoryLocalPath: string) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Write data a local JSON file at a given path.
|
|
56
|
+
* @param localFilePath <string> - the local path of the file.
|
|
57
|
+
* @param data <JSON> - the JSON content to be written inside the file.
|
|
58
|
+
*/
|
|
59
|
+
export declare const writeLocalJsonFile: (filePath: string, data: JSON) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Return the local current project directory name.
|
|
62
|
+
* @returns <string> - the local project (e.g., dist/) directory name.
|
|
63
|
+
*/
|
|
64
|
+
export declare const getLocalDirname: () => string;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export declare const localPaths: {
|
|
2
|
+
output: string;
|
|
3
|
+
setup: string;
|
|
4
|
+
contribute: string;
|
|
5
|
+
finalize: string;
|
|
6
|
+
pot: string;
|
|
7
|
+
zkeys: string;
|
|
8
|
+
wasm: string;
|
|
9
|
+
contributions: string;
|
|
10
|
+
transcripts: string;
|
|
11
|
+
attestations: string;
|
|
12
|
+
finalZkeys: string;
|
|
13
|
+
finalPot: string;
|
|
14
|
+
finalTranscripts: string;
|
|
15
|
+
finalAttestations: string;
|
|
16
|
+
verificationKeys: string;
|
|
17
|
+
verifierContracts: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Return the access token, if present.
|
|
21
|
+
* @returns <string | undefined> - the access token if present, otherwise undefined.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getLocalAccessToken: () => string | unknown;
|
|
24
|
+
/**
|
|
25
|
+
* Check if the access token exists in the local storage.
|
|
26
|
+
* @returns <boolean>
|
|
27
|
+
*/
|
|
28
|
+
export declare const checkLocalAccessToken: () => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Set the access token.
|
|
31
|
+
* @param token <string> - the access token to be stored.
|
|
32
|
+
*/
|
|
33
|
+
export declare const setLocalAccessToken: (token: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Delete the stored access token.
|
|
36
|
+
*/
|
|
37
|
+
export declare const deleteLocalAccessToken: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the complete local file path.
|
|
40
|
+
* @param cwd <string> - the current working directory path.
|
|
41
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
42
|
+
* @returns <string> - the complete local path to the file.
|
|
43
|
+
*/
|
|
44
|
+
export declare const getCWDFilePath: (cwd: string, completeFilename: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Get the complete PoT file path.
|
|
47
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
48
|
+
* @returns <string> - the complete PoT path to the file.
|
|
49
|
+
*/
|
|
50
|
+
export declare const getPotLocalFilePath: (completeFilename: string) => string;
|
|
51
|
+
/**
|
|
52
|
+
* Get the complete zKey file path.
|
|
53
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
54
|
+
* @returns <string> - the complete zKey path to the file.
|
|
55
|
+
*/
|
|
56
|
+
export declare const getZkeyLocalFilePath: (completeFilename: string) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the complete contribution file path.
|
|
59
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
60
|
+
* @returns <string> - the complete contribution path to the file.
|
|
61
|
+
*/
|
|
62
|
+
export declare const getContributionLocalFilePath: (completeFilename: string) => string;
|
|
63
|
+
/**
|
|
64
|
+
* Get the contribution attestation file path.
|
|
65
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
66
|
+
* @returns <string> - the the contribution attestation path to the file.
|
|
67
|
+
*/
|
|
68
|
+
export declare const getAttestationLocalFilePath: (completeFilename: string) => string;
|
|
69
|
+
/**
|
|
70
|
+
* Get the transcript file path.
|
|
71
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
72
|
+
* @returns <string> - the the transcript path to the file.
|
|
73
|
+
*/
|
|
74
|
+
export declare const getTranscriptLocalFilePath: (completeFilename: string) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Get the complete final zKey file path.
|
|
77
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
78
|
+
* @returns <string> - the complete final zKey path to the file.
|
|
79
|
+
*/
|
|
80
|
+
export declare const getFinalZkeyLocalFilePath: (completeFilename: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Get the complete final PoT file path.
|
|
83
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
84
|
+
* @returns <string> - the complete final PoT path to the file.
|
|
85
|
+
*/
|
|
86
|
+
export declare const getFinalPotLocalFilePath: (completeFilename: string) => string;
|
|
87
|
+
/**
|
|
88
|
+
* Get the complete verification key file path.
|
|
89
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
90
|
+
* @returns <string> - the complete final verification key path to the file.
|
|
91
|
+
*/
|
|
92
|
+
export declare const getVerificationKeyLocalFilePath: (completeFilename: string) => string;
|
|
93
|
+
/**
|
|
94
|
+
* Get the complete verifier contract file path.
|
|
95
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
96
|
+
* @returns <string> - the complete final verifier contract path to the file.
|
|
97
|
+
*/
|
|
98
|
+
export declare const getVerifierContractLocalFilePath: (completeFilename: string) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Get the complete final attestation file path.
|
|
101
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
102
|
+
* @returns <string> - the complete final final attestation path to the file.
|
|
103
|
+
*/
|
|
104
|
+
export declare const getFinalAttestationLocalFilePath: (completeFilename: string) => string;
|
|
105
|
+
/**
|
|
106
|
+
* Get the final transcript file path.
|
|
107
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
108
|
+
* @returns <string> - the the final transcript path to the file.
|
|
109
|
+
*/
|
|
110
|
+
export declare const getFinalTranscriptLocalFilePath: (completeFilename: string) => string;
|