@devtion/actions 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 +83 -0
- package/dist/index.mjs +2608 -0
- package/dist/index.node.js +2714 -0
- package/dist/types/hardhat.config.d.ts +6 -0
- package/dist/types/hardhat.config.d.ts.map +1 -0
- package/dist/types/src/helpers/authentication.d.ts +21 -0
- package/dist/types/src/helpers/authentication.d.ts.map +1 -0
- package/dist/types/src/helpers/constants.d.ts +194 -0
- package/dist/types/src/helpers/constants.d.ts.map +1 -0
- package/dist/types/src/helpers/contracts.d.ts +57 -0
- package/dist/types/src/helpers/contracts.d.ts.map +1 -0
- package/dist/types/src/helpers/crypto.d.ts +27 -0
- package/dist/types/src/helpers/crypto.d.ts.map +1 -0
- package/dist/types/src/helpers/database.d.ts +105 -0
- package/dist/types/src/helpers/database.d.ts.map +1 -0
- package/dist/types/src/helpers/functions.d.ts +145 -0
- package/dist/types/src/helpers/functions.d.ts.map +1 -0
- package/dist/types/src/helpers/security.d.ts +10 -0
- package/dist/types/src/helpers/security.d.ts.map +1 -0
- package/dist/types/src/helpers/services.d.ts +38 -0
- package/dist/types/src/helpers/services.d.ts.map +1 -0
- package/dist/types/src/helpers/storage.d.ts +121 -0
- package/dist/types/src/helpers/storage.d.ts.map +1 -0
- package/dist/types/src/helpers/tasks.d.ts +2 -0
- package/dist/types/src/helpers/tasks.d.ts.map +1 -0
- package/dist/types/src/helpers/utils.d.ts +139 -0
- package/dist/types/src/helpers/utils.d.ts.map +1 -0
- package/dist/types/src/helpers/verification.d.ts +95 -0
- package/dist/types/src/helpers/verification.d.ts.map +1 -0
- package/dist/types/src/helpers/vm.d.ts +112 -0
- package/dist/types/src/helpers/vm.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +15 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/types/enums.d.ts +133 -0
- package/dist/types/src/types/enums.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +603 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/package.json +87 -0
- package/src/helpers/authentication.ts +37 -0
- package/src/helpers/constants.ts +312 -0
- package/src/helpers/contracts.ts +268 -0
- package/src/helpers/crypto.ts +55 -0
- package/src/helpers/database.ts +221 -0
- package/src/helpers/functions.ts +438 -0
- package/src/helpers/security.ts +86 -0
- package/src/helpers/services.ts +83 -0
- package/src/helpers/storage.ts +329 -0
- package/src/helpers/tasks.ts +56 -0
- package/src/helpers/utils.ts +743 -0
- package/src/helpers/verification.ts +354 -0
- package/src/helpers/vm.ts +392 -0
- package/src/index.ts +162 -0
- package/src/types/enums.ts +141 -0
- package/src/types/index.ts +650 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/helpers/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAiB,MAAM,cAAc,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAgB,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAgB,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YAAa,eAAe,KAAG,WAAqC,CAAA;AAEtG;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAS,WAAW,KAAG,SAA8B,CAAA;AAEtF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAS,WAAW,KAAG,SAA8C,CAAA;AAEtG;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,YAmBlC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,WAC/B,MAAM,cACF,MAAM,aACP,MAAM,qBACE,MAAM,SAClB,MAAM,KACd,QAAQ,gBAAgB,CAgB1B,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Functions } from "firebase/functions";
|
|
2
|
+
import { ETagWithPartNumber, ChunkWithUrl, TemporaryParticipantContributionData } from "../types/index";
|
|
3
|
+
/**
|
|
4
|
+
* Return the bucket name based on ceremony prefix.
|
|
5
|
+
* @param ceremonyPrefix <string> - the ceremony prefix.
|
|
6
|
+
* @param ceremonyPostfix <string> - the ceremony postfix.
|
|
7
|
+
* @returns <string>
|
|
8
|
+
*/
|
|
9
|
+
export declare const getBucketName: (ceremonyPrefix: string, ceremonyPostfix: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Get chunks and signed urls related to an object that must be uploaded using a multi-part upload.
|
|
12
|
+
* @param cloudFunctions <Functions> - the Firebase Cloud Functions service instance.
|
|
13
|
+
* @param bucketName <string> - the name of the ceremony artifacts bucket (AWS S3).
|
|
14
|
+
* @param objectKey <string> - the unique key to identify the object inside the given AWS S3 bucket.
|
|
15
|
+
* @param localFilePath <string> - the local path where the artifact will be downloaded.
|
|
16
|
+
* @param uploadId <string> - the unique identifier of the multi-part upload.
|
|
17
|
+
* @param configStreamChunkSize <number> - size of each chunk into which the artifact is going to be splitted (nb. will be converted in MB).
|
|
18
|
+
* @param [ceremonyId] <string> - the unique identifier of the ceremony.
|
|
19
|
+
* @returns Promise<Array<ChunkWithUrl>> - the chunks with related pre-signed url.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getChunksAndPreSignedUrls: (cloudFunctions: Functions, bucketName: string, objectKey: string, localFilePath: string, uploadId: string, configStreamChunkSize: number, ceremonyId?: string) => Promise<Array<ChunkWithUrl>>;
|
|
22
|
+
/**
|
|
23
|
+
* Forward the request to upload each single chunk of the related ceremony artifact.
|
|
24
|
+
* @param chunksWithUrls <Array<ChunkWithUrl>> - the array containing each chunk mapped with the corresponding pre-signed urls.
|
|
25
|
+
* @param contentType <string | false> - the content type of the ceremony artifact.
|
|
26
|
+
* @param cloudFunctions <Functions> - the Firebase Cloud Functions service instance.
|
|
27
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
28
|
+
* @param alreadyUploadedChunks Array<ETagWithPartNumber> - the temporary information about the already uploaded chunks.
|
|
29
|
+
* @returns <Promise<Array<ETagWithPartNumber>>> - the completed (uploaded) chunks information.
|
|
30
|
+
*/
|
|
31
|
+
export declare const uploadParts: (chunksWithUrls: Array<ChunkWithUrl>, contentType: string | false, cloudFunctions?: Functions, ceremonyId?: string, alreadyUploadedChunks?: Array<ETagWithPartNumber>) => Promise<Array<ETagWithPartNumber>>;
|
|
32
|
+
/**
|
|
33
|
+
* Upload a ceremony artifact to the corresponding bucket.
|
|
34
|
+
* @notice this method implements the multi-part upload using pre-signed urls, optimal for large files.
|
|
35
|
+
* Steps:
|
|
36
|
+
* 0) Check if current contributor could resume a multi-part upload.
|
|
37
|
+
* 0.A) If yes, continue from last uploaded chunk using the already opened multi-part upload.
|
|
38
|
+
* 0.B) Otherwise, start creating a new multi-part upload.
|
|
39
|
+
* 1) Generate a pre-signed url for each (remaining) chunk of the ceremony artifact.
|
|
40
|
+
* 2) Consume the pre-signed urls to upload chunks.
|
|
41
|
+
* 3) Complete the multi-part upload.
|
|
42
|
+
* @param cloudFunctions <Functions> - the Firebase Cloud Functions service instance.
|
|
43
|
+
* @param bucketName <string> - the name of the ceremony artifacts bucket (AWS S3).
|
|
44
|
+
* @param objectKey <string> - the unique key to identify the object inside the given AWS S3 bucket.
|
|
45
|
+
* @param localPath <string> - the local path where the artifact will be downloaded.
|
|
46
|
+
* @param configStreamChunkSize <number> - size of each chunk into which the artifact is going to be splitted (nb. will be converted in MB).
|
|
47
|
+
* @param [ceremonyId] <string> - the unique identifier of the ceremony (used as a double-edge sword - as identifier and as a check if current contributor is the coordinator finalizing the ceremony).
|
|
48
|
+
* @param [temporaryDataToResumeMultiPartUpload] <TemporaryParticipantContributionData> - the temporary information necessary to resume an already started multi-part upload.
|
|
49
|
+
*/
|
|
50
|
+
export declare const multiPartUpload: (cloudFunctions: Functions, bucketName: string, objectKey: string, localFilePath: string, configStreamChunkSize: number, ceremonyId?: string, temporaryDataToResumeMultiPartUpload?: TemporaryParticipantContributionData) => Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Download an artifact from S3 (only for authorized users)
|
|
53
|
+
* @param cloudFunctions <Functions> Firebase cloud functions instance.
|
|
54
|
+
* @param bucketName <string> Name of the bucket where the artifact is stored.
|
|
55
|
+
* @param storagePath <string> Path to the artifact in the bucket.
|
|
56
|
+
* @param localPath <string> Path to the local file where the artifact will be saved.
|
|
57
|
+
*/
|
|
58
|
+
export declare const downloadCeremonyArtifact: (cloudFunctions: Functions, bucketName: string, storagePath: string, localPath: string) => Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Get R1CS file path tied to a particular circuit of a ceremony in the storage.
|
|
61
|
+
* @notice each R1CS file in the storage must be stored in the following path: `circuits/<circuitPrefix>/<completeR1csFilename>`.
|
|
62
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
63
|
+
* @param circuitPrefix <string> - the prefix of the circuit.
|
|
64
|
+
* @param completeR1csFilename <string> - the complete R1CS filename (name + ext).
|
|
65
|
+
* @returns <string> - the storage path of the R1CS file.
|
|
66
|
+
*/
|
|
67
|
+
export declare const getR1csStorageFilePath: (circuitPrefix: string, completeR1csFilename: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Get WASM file path tied to a particular circuit of a ceremony in the storage.
|
|
70
|
+
* @notice each WASM file in the storage must be stored in the following path: `circuits/<circuitPrefix>/<completeWasmFilename>`.
|
|
71
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
72
|
+
* @param circuitPrefix <string> - the prefix of the circuit.
|
|
73
|
+
* @param completeWasmFilename <string> - the complete WASM filename (name + ext).
|
|
74
|
+
* @returns <string> - the storage path of the WASM file.
|
|
75
|
+
*/
|
|
76
|
+
export declare const getWasmStorageFilePath: (circuitPrefix: string, completeWasmFilename: string) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Get PoT file path in the storage.
|
|
79
|
+
* @notice each PoT file in the storage must be stored in the following path: `pot/<completePotFilename>`.
|
|
80
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
81
|
+
* @param completePotFilename <string> - the complete PoT filename (name + ext).
|
|
82
|
+
* @returns <string> - the storage path of the PoT file.
|
|
83
|
+
*/
|
|
84
|
+
export declare const getPotStorageFilePath: (completePotFilename: string) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Get zKey file path tied to a particular circuit of a ceremony in the storage.
|
|
87
|
+
* @notice each zKey file in the storage must be stored in the following path: `circuits/<circuitPrefix>/contributions/<completeZkeyFilename>`.
|
|
88
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
89
|
+
* @param circuitPrefix <string> - the prefix of the circuit.
|
|
90
|
+
* @param completeZkeyFilename <string> - the complete zKey filename (name + ext).
|
|
91
|
+
* @returns <string> - the storage path of the zKey file.
|
|
92
|
+
*/
|
|
93
|
+
export declare const getZkeyStorageFilePath: (circuitPrefix: string, completeZkeyFilename: string) => string;
|
|
94
|
+
/**
|
|
95
|
+
* Get verification key file path tied to a particular circuit of a ceremony in the storage.
|
|
96
|
+
* @notice each verification key file in the storage must be stored in the following path: `circuits/<circuitPrefix>/<completeVerificationKeyFilename>`.
|
|
97
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
98
|
+
* @param circuitPrefix <string> - the prefix of the circuit.
|
|
99
|
+
* @param completeVerificationKeyFilename <string> - the complete verification key filename (name + ext).
|
|
100
|
+
* @returns <string> - the storage path of the verification key file.
|
|
101
|
+
*/
|
|
102
|
+
export declare const getVerificationKeyStorageFilePath: (circuitPrefix: string, completeVerificationKeyFilename: string) => string;
|
|
103
|
+
/**
|
|
104
|
+
* Get verifier contract file path tied to a particular circuit of a ceremony in the storage.
|
|
105
|
+
* @notice each verifier contract file in the storage must be stored in the following path: `circuits/<circuitPrefix>/<completeVerificationKeyFilename>`.
|
|
106
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
107
|
+
* @param circuitPrefix <string> - the prefix of the circuit.
|
|
108
|
+
* @param completeVerifierContractFilename <string> - the complete verifier contract filename (name + ext).
|
|
109
|
+
* @returns <string> - the storage path of the verifier contract file.
|
|
110
|
+
*/
|
|
111
|
+
export declare const getVerifierContractStorageFilePath: (circuitPrefix: string, completeVerifierContractFilename: string) => string;
|
|
112
|
+
/**
|
|
113
|
+
* Get transcript file path tied to a particular circuit of a ceremony in the storage.
|
|
114
|
+
* @notice each R1CS file in the storage must be stored in the following path: `circuits/<circuitPrefix>/<completeTranscriptFilename>`.
|
|
115
|
+
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
|
|
116
|
+
* @param circuitPrefix <string> - the prefix of the circuit.
|
|
117
|
+
* @param completeTranscriptFilename <string> - the complete transcript filename (name + ext).
|
|
118
|
+
* @returns <string> - the storage path of the transcript file.
|
|
119
|
+
*/
|
|
120
|
+
export declare const getTranscriptStorageFilePath: (circuitPrefix: string, completeTranscriptFilename: string) => string;
|
|
121
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../src/helpers/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAK9C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAA;AAWvG;;;;;GAKG;AACH,eAAO,MAAM,aAAa,mBAAoB,MAAM,mBAAmB,MAAM,KAAG,MACvC,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,mBAClB,SAAS,cACb,MAAM,aACP,MAAM,iBACF,MAAM,YACX,MAAM,yBACO,MAAM,eAChB,MAAM,KACpB,QAAQ,MAAM,YAAY,CAAC,CA6B7B,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,mBACJ,MAAM,YAAY,CAAC,eACtB,MAAM,GAAG,KAAK,mBACV,SAAS,eACb,MAAM,0BACK,MAAM,kBAAkB,CAAC,KAClD,QAAQ,MAAM,kBAAkB,CAAC,CA2CnC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,mBACR,SAAS,cACb,MAAM,aACP,MAAM,iBACF,MAAM,yBACE,MAAM,eAChB,MAAM,yCACoB,oCAAoC,kBAoD9E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,mBACjB,SAAS,cACb,MAAM,eACL,MAAM,aACR,MAAM,kBAuBpB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,kBAAmB,MAAM,wBAAwB,MAAM,KAAG,MACN,CAAA;AAEvF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,kBAAmB,MAAM,wBAAwB,MAAM,KAAG,MACN,CAAA;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,wBAAyB,MAAM,KAAG,MACA,CAAA;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,kBAAmB,MAAM,wBAAwB,MAAM,KAAG,MACwC,CAAA;AAErI;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,kBAC3B,MAAM,mCACY,MAAM,KACxC,MAAwG,CAAA;AAE3G;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,kBAC5B,MAAM,oCACa,MAAM,KACzC,MAAyG,CAAA;AAE5G;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,kBAAmB,MAAM,8BAA8B,MAAM,KAAG,MACoC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../../src/helpers/tasks.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Firestore } from "firebase/firestore";
|
|
3
|
+
import { ReadPosition } from "fs";
|
|
4
|
+
import winston, { Logger } from "winston";
|
|
5
|
+
import { CircuitMetadata, Contribution, ContributionValidity, FirebaseDocumentInfo, SetupCeremonyData } from "../types/index";
|
|
6
|
+
/**
|
|
7
|
+
* Parse and validate that the ceremony configuration is correct
|
|
8
|
+
* @notice this does not upload any files to storage
|
|
9
|
+
* @param path <string> - the path to the configuration file
|
|
10
|
+
* @param cleanup <boolean> - whether to delete the r1cs file after parsing
|
|
11
|
+
* @returns any - the data to pass to the cloud function for setup and the circuit artifacts
|
|
12
|
+
*/
|
|
13
|
+
export declare const parseCeremonyFile: (path: string, cleanup?: boolean) => Promise<SetupCeremonyData>;
|
|
14
|
+
/**
|
|
15
|
+
* Extract data from a R1CS metadata file generated with a custom file-based logger.
|
|
16
|
+
* @notice useful for extracting metadata circuits contained in the generated file using a logger
|
|
17
|
+
* on the `r1cs.info()` method of snarkjs.
|
|
18
|
+
* @param fullFilePath <string> - the full path of the file.
|
|
19
|
+
* @param keyRgx <RegExp> - the regular expression linked to the key from which you want to extract the value.
|
|
20
|
+
* @returns <string> - the stringified extracted value.
|
|
21
|
+
*/
|
|
22
|
+
export declare const extractR1CSInfoValueForGivenKey: (fullFilePath: string, keyRgx: RegExp) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the smallest amount of Powers of Tau needed for a circuit with a constraint size.
|
|
25
|
+
* @param constraints <number> - the number of circuit constraints (extracted from metadata).
|
|
26
|
+
* @param outputs <number> - the number of circuit outputs (extracted from metadata)
|
|
27
|
+
* @returns <number> - the smallest amount of Powers of Tau for the given constraint size.
|
|
28
|
+
*/
|
|
29
|
+
export declare const computeSmallestPowersOfTauForCircuit: (constraints: number, outputs: number) => number;
|
|
30
|
+
/**
|
|
31
|
+
* Transform a number in a zKey index format.
|
|
32
|
+
* @dev this method is aligned with the number of characters of the genesis zKey index (which is a constant).
|
|
33
|
+
* @param progress <number> - the progression in zKey index.
|
|
34
|
+
* @returns <string> - the progression in a zKey index format (`XYZAB`).
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatZkeyIndex: (progress: number) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Extract the amount of powers from Powers of Tau file name.
|
|
39
|
+
* @dev the PoT files must follow these convention (i_am_a_pot_file_09.ptau) where the numbers before '.ptau' are the powers.
|
|
40
|
+
* @param potCompleteFilename <string> - the complete filename of the Powers of Tau file.
|
|
41
|
+
* @returns <number> - the amount of powers.
|
|
42
|
+
*/
|
|
43
|
+
export declare const extractPoTFromFilename: (potCompleteFilename: string) => number;
|
|
44
|
+
/**
|
|
45
|
+
* Extract a prefix consisting of alphanumeric and underscore characters from a string with arbitrary characters.
|
|
46
|
+
* @dev replaces all special symbols and whitespaces with an underscore char ('_'). Convert all uppercase chars to lowercase.
|
|
47
|
+
* @notice example: str = 'Multiplier-2!2.4.zkey'; output prefix = 'multiplier_2_2_4.zkey'.
|
|
48
|
+
* NB. Prefix extraction is a key process that conditions the name of the ceremony artifacts, download/upload from/to storage, collections paths.
|
|
49
|
+
* @param str <string> - the arbitrary string from which to extract the prefix.
|
|
50
|
+
* @returns <string> - the resulting prefix.
|
|
51
|
+
*/
|
|
52
|
+
export declare const extractPrefix: (str: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Automate the generation of an entropy for a contribution.
|
|
55
|
+
* @dev Took inspiration from here https://github.com/glamperd/setup-mpc-ui/blob/master/client/src/state/Compute.tsx#L112.
|
|
56
|
+
* @todo we need to improve the entropy generation (too naive).
|
|
57
|
+
* @returns <string> - the auto-generated entropy.
|
|
58
|
+
*/
|
|
59
|
+
export declare const autoGenerateEntropy: () => string;
|
|
60
|
+
/**
|
|
61
|
+
* Check and return the circuit document based on its sequence position among a set of circuits (if any).
|
|
62
|
+
* @dev there should be only one circuit with a provided sequence position. This method checks and return an
|
|
63
|
+
* error if none is found.
|
|
64
|
+
* @param circuits <Array<FirebaseDocumentInfo>> - the set of ceremony circuits documents.
|
|
65
|
+
* @param sequencePosition <number> - the sequence position (index) of the circuit to be found and returned.
|
|
66
|
+
* @returns <FirebaseDocumentInfo> - the document of the circuit in the set of circuits that has the provided sequence position.
|
|
67
|
+
*/
|
|
68
|
+
export declare const getCircuitBySequencePosition: (circuits: Array<FirebaseDocumentInfo>, sequencePosition: number) => FirebaseDocumentInfo;
|
|
69
|
+
/**
|
|
70
|
+
* Convert bytes or chilobytes into gigabytes with customizable precision.
|
|
71
|
+
* @param bytesOrKb <number> - the amount of bytes or chilobytes to be converted.
|
|
72
|
+
* @param isBytes <boolean> - true when the amount to be converted is in bytes; otherwise false (= Chilobytes).
|
|
73
|
+
* @returns <number> - the converted amount in GBs.
|
|
74
|
+
*/
|
|
75
|
+
export declare const convertBytesOrKbToGb: (bytesOrKb: number, isBytes: boolean) => number;
|
|
76
|
+
/**
|
|
77
|
+
* Get the validity of contributors' contributions for each circuit of the given ceremony (if any).
|
|
78
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
79
|
+
* @param circuits <Array<FirebaseDocumentInfo>> - the array of ceremony circuits documents.
|
|
80
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
81
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
82
|
+
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
|
|
83
|
+
* @returns <Promise<Array<ContributionValidity>>> - a list of contributor contributions together with contribution validity (based on coordinator verification).
|
|
84
|
+
*/
|
|
85
|
+
export declare const getContributionsValidityForContributor: (firestoreDatabase: Firestore, circuits: Array<FirebaseDocumentInfo>, ceremonyId: string, participantId: string, isFinalizing: boolean) => Promise<Array<ContributionValidity>>;
|
|
86
|
+
/**
|
|
87
|
+
* Return the public attestation preamble for given contributor.
|
|
88
|
+
* @param contributorIdentifier <string> - the identifier of the contributor (handle, name, uid).
|
|
89
|
+
* @param ceremonyName <string> - the name of the ceremony.
|
|
90
|
+
* @param isFinalizing <boolean> - true when the coordinator is finalizing the ceremony, otherwise false.
|
|
91
|
+
* @returns <string> - the public attestation preamble.
|
|
92
|
+
*/
|
|
93
|
+
export declare const getPublicAttestationPreambleForContributor: (contributorIdentifier: string, ceremonyName: string, isFinalizing: boolean) => string;
|
|
94
|
+
/**
|
|
95
|
+
* Check and prepare public attestation for the contributor made only of its valid contributions.
|
|
96
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
97
|
+
* @param circuits <Array<FirebaseDocumentInfo>> - the array of ceremony circuits documents.
|
|
98
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
99
|
+
* @param participantId <string> - the unique identifier of the contributor.
|
|
100
|
+
* @param participantContributions <Array<Co> - the document data of the participant.
|
|
101
|
+
* @param contributorIdentifier <string> - the identifier of the contributor (handle, name, uid).
|
|
102
|
+
* @param ceremonyName <string> - the name of the ceremony.
|
|
103
|
+
* @param isFinalizing <boolean> - true when the coordinator is finalizing the ceremony, otherwise false.
|
|
104
|
+
* @returns <Promise<string>> - the public attestation for the contributor.
|
|
105
|
+
*/
|
|
106
|
+
export declare const generateValidContributionsAttestation: (firestoreDatabase: Firestore, circuits: Array<FirebaseDocumentInfo>, ceremonyId: string, participantId: string, participantContributions: Array<Contribution>, contributorIdentifier: string, ceremonyName: string, isFinalizing: boolean) => Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Create a custom logger to write logs on a local file.
|
|
109
|
+
* @param filename <string> - the name of the output file (where the logs are going to be written).
|
|
110
|
+
* @param level <winston.LoggerOptions["level"]> - the option for the logger level (e.g., info, error).
|
|
111
|
+
* @returns <Logger> - a customized winston logger for files.
|
|
112
|
+
*/
|
|
113
|
+
export declare const createCustomLoggerForFile: (filename: string, level?: winston.LoggerOptions["level"]) => Logger;
|
|
114
|
+
/**
|
|
115
|
+
* Return an amount of bytes read from a file to a particular location in the form of a buffer.
|
|
116
|
+
* @param localFilePath <string> - the local path where the artifact will be downloaded.
|
|
117
|
+
* @param offset <number> - the index of the line to be read (0 from the start).
|
|
118
|
+
* @param length <number> - the length of the line to be read.
|
|
119
|
+
* @param position <ReadPosition> - the position inside the file.
|
|
120
|
+
* @returns <Buffer> - the buffer w/ the read bytes.
|
|
121
|
+
*/
|
|
122
|
+
export declare const readBytesFromFile: (localFilePath: string, offset: number, length: number, position: ReadPosition) => Buffer;
|
|
123
|
+
/**
|
|
124
|
+
* Return the info about the R1CS file.ù
|
|
125
|
+
* @dev this method was built taking inspiration from
|
|
126
|
+
* https://github.com/weijiekoh/circom-helper/blob/master/ts/read_num_inputs.ts#L5.
|
|
127
|
+
* You can find the specs of R1CS file here
|
|
128
|
+
* https://github.com/iden3/r1csfile/blob/master/doc/r1cs_bin_format.md
|
|
129
|
+
* @param localR1CSFilePath <string> - the local path to the R1CS file.
|
|
130
|
+
* @returns <CircuitMetadata> - the info about the R1CS file.
|
|
131
|
+
*/
|
|
132
|
+
export declare const getR1CSInfo: (localR1CSFilePath: string) => CircuitMetadata;
|
|
133
|
+
/**
|
|
134
|
+
* Return a string with double digits if the provided input is one digit only.
|
|
135
|
+
* @param in <number> - the input number to be converted.
|
|
136
|
+
* @returns <string> - the two digits stringified number derived from the conversion.
|
|
137
|
+
*/
|
|
138
|
+
export declare const convertToDoubleDigits: (amount: number) => string;
|
|
139
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/helpers/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAW,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAErC,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EACH,eAAe,EACf,YAAY,EAGZ,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EAGpB,MAAM,gBAAgB,CAAA;AAmBvB;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAgB,MAAM,YAAW,OAAO,KAAW,QAAQ,iBA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A;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,kBACX,MAAM,UACb,MAAM,UACN,MAAM,YACJ,YAAY,KACvB,MAYF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,sBAAuB,MAAM,KAAG,eA0IvD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAY,MAAM,KAAG,MAA0D,CAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Firestore } from "firebase/firestore";
|
|
2
|
+
import { Functions } from "firebase/functions";
|
|
3
|
+
import { CeremonyArtifacts } from "../types/index";
|
|
4
|
+
/**
|
|
5
|
+
* Verify that a zKey is valid
|
|
6
|
+
* @param r1csLocalFilePath <string> path to the r1cs file
|
|
7
|
+
* @param zkeyLocalPath <string> path to the zKey file
|
|
8
|
+
* @param potLocalFilePath <string> path to the PoT file
|
|
9
|
+
* @param logger <any> logger instance
|
|
10
|
+
* @returns <boolean> true if the zKey is valid, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare const verifyZKey: (r1csLocalFilePath: string, zkeyLocalPath: string, potLocalFilePath: string, logger?: any) => Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a GROTH16 proof
|
|
15
|
+
* @param circuitInput <object> Input to the circuit
|
|
16
|
+
* @param zkeyFilePath <string> Path to the proving key
|
|
17
|
+
* @param wasmFilePath <string> Path to the compiled circuit
|
|
18
|
+
* @param logger <any> Optional logger
|
|
19
|
+
* @returns <Promise<object>> The proof
|
|
20
|
+
*/
|
|
21
|
+
export declare const generateGROTH16Proof: (circuitInput: object, zkeyFilePath: string, wasmFilePath: string, logger?: any) => Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Verifies a GROTH16 proof
|
|
24
|
+
* @param verificationKeyPath <string> Path to the verification key
|
|
25
|
+
* @param publicSignals <object> Public signals
|
|
26
|
+
* @param proof <object> Proof
|
|
27
|
+
* @returns <Promise<boolean>> Whether the proof is valid or not
|
|
28
|
+
*/
|
|
29
|
+
export declare const verifyGROTH16Proof: (verificationKeyPath: string, publicSignals: object, proof: object) => Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Helper method to extract the Solidity verifier
|
|
32
|
+
* from a final zKey file and save it to a local file.
|
|
33
|
+
* @param finalZkeyPath <string> The path to the zKey file.
|
|
34
|
+
* @return <any> The Solidity verifier code.
|
|
35
|
+
*/
|
|
36
|
+
export declare const exportVerifierContract: (finalZkeyPath: string, templatePath: string) => Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Helpers method to extract the vKey from a final zKey file
|
|
39
|
+
* @param finalZkeyPath <string> The path to the zKey file.
|
|
40
|
+
* @return <any> The vKey.
|
|
41
|
+
*/
|
|
42
|
+
export declare const exportVkey: (finalZkeyPath: string) => Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Helper method to extract the Solidity verifier and the Verification key
|
|
45
|
+
* from a final zKey file and save them to local files.
|
|
46
|
+
* @param finalZkeyPath <string> The path to the zKey file.
|
|
47
|
+
* @param verifierLocalPath <string> The path to the local file where the verifier will be saved.
|
|
48
|
+
* @param vKeyLocalPath <string> The path to the local file where the vKey will be saved.
|
|
49
|
+
* @param templatePath <string> The path to the template file.
|
|
50
|
+
*/
|
|
51
|
+
export declare const exportVerifierAndVKey: (finalZkeyPath: string, verifierLocalPath: string, vKeyLocalPath: string, templatePath: string) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Generate a zKey from scratch (useful to compute either the genesis or final zKey)
|
|
54
|
+
* @param isFinalizing <boolean> Whether the ceremony is finalizing or not
|
|
55
|
+
* @param r1csLocalPath <string> The path to the local r1cs file
|
|
56
|
+
* @param potLocalPath <string> The path to the local pot file
|
|
57
|
+
* @param zkeyLocalPath <string> The path to save the generated zKey
|
|
58
|
+
* @param logger <any> The logger instance
|
|
59
|
+
* @param finalContributionZKeyLocalPath <string> The path to the local zkey file of the final contribution (only for final zKey)
|
|
60
|
+
* @param coordinatorIdentifier <string> The identifier of the coordinator (only for final zKey)
|
|
61
|
+
* @param beacon <string> The beacon value for the last contribution (only for final zKey)
|
|
62
|
+
*/
|
|
63
|
+
export declare const generateZkeyFromScratch: (isFinalizing: boolean, r1csLocalPath: string, potLocalPath: string, zkeyLocalPath: string, logger: any, finalContributionZKeyLocalPath?: string, coordinatorIdentifier?: string, beacon?: string) => Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Helper function used to compare two ceremony artifacts
|
|
66
|
+
* @param firebaseFunctions <Functions> Firebase functions object
|
|
67
|
+
* @param localPath1 <string> Local path to store the first artifact
|
|
68
|
+
* @param localPath2 <string> Local path to store the second artifact
|
|
69
|
+
* @param storagePath1 <string> Storage path to the first artifact
|
|
70
|
+
* @param storagePath2 <string> Storage path to the second artifact
|
|
71
|
+
* @param bucketName1 <string> Bucket name of the first artifact
|
|
72
|
+
* @param bucketName2 <string> Bucket name of the second artifact
|
|
73
|
+
* @param cleanup <boolean> Whether to delete the downloaded files or not
|
|
74
|
+
* @returns <Promise<boolean>> true if the hashes match, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
export declare const compareCeremonyArtifacts: (firebaseFunctions: Functions, localPath1: string, localPath2: string, storagePath1: string, storagePath2: string, bucketName1: string, bucketName2: string, cleanup: boolean) => Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Given a ceremony prefix, download all the ceremony artifacts
|
|
79
|
+
* @param functions <Functions> firebase functions instance
|
|
80
|
+
* @param firestore <Firestore> firebase firestore instance
|
|
81
|
+
* @param ceremonyPrefix <string> ceremony prefix
|
|
82
|
+
* @param outputDirectory <string> output directory where to
|
|
83
|
+
* @returns <Promise<CeremonyArtifacts[]>> array of ceremony artifacts
|
|
84
|
+
*/
|
|
85
|
+
export declare const downloadAllCeremonyArtifacts: (functions: Functions, firestore: Firestore, ceremonyPrefix: string, outputDirectory: string) => Promise<CeremonyArtifacts[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch the final contribution beacon from Firestore
|
|
88
|
+
* @param firestore <Firestore> firebase firestore instance
|
|
89
|
+
* @param ceremonyId <string> ceremony id
|
|
90
|
+
* @param circuitId <string> circuit id
|
|
91
|
+
* @param participantId <string> participant id
|
|
92
|
+
* @returns <Promise<string>> final contribution beacon
|
|
93
|
+
*/
|
|
94
|
+
export declare const getFinalContributionBeacon: (firestore: Firestore, ceremonyId: string, circuitId: string, participantId: string) => Promise<string>;
|
|
95
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../../src/helpers/verification.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAS,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAyB9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,sBACA,MAAM,iBACV,MAAM,oBACH,MAAM,WACf,GAAG,KACb,QAAQ,OAAO,CASjB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,iBACf,MAAM,gBACN,MAAM,gBACN,MAAM,WACX,GAAG,KACb,QAAQ,GAAG,CAYb,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,wBACN,MAAM,iBACZ,MAAM,SACd,MAAM,KACd,QAAQ,OAAO,CAIjB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,kBAAyB,MAAM,gBAAgB,MAAM,iBAcvF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,kBAAyB,MAAM,iBAGrD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,kBACf,MAAM,qBACF,MAAM,iBACV,MAAM,gBACP,MAAM,kBAMvB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,iBAClB,OAAO,iBACN,MAAM,gBACP,MAAM,iBACL,MAAM,UACb,GAAG,mCACsB,MAAM,0BACf,MAAM,WACrB,MAAM,kBAqBlB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,sBACd,SAAS,cAChB,MAAM,cACN,MAAM,gBACJ,MAAM,gBACN,MAAM,eACP,MAAM,eACN,MAAM,WACV,OAAO,KACjB,QAAQ,OAAO,CAajB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,cAC1B,SAAS,aACT,SAAS,kBACJ,MAAM,mBACL,MAAM,KACxB,QAAQ,iBAAiB,EAAE,CAqF7B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,cACxB,SAAS,cACR,MAAM,aACP,MAAM,iBACF,MAAM,KACtB,QAAQ,MAAM,CAYhB,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { EC2Client } from "@aws-sdk/client-ec2";
|
|
2
|
+
import { SSMClient } from "@aws-sdk/client-ssm";
|
|
3
|
+
import { DiskTypeForVM } from "src";
|
|
4
|
+
import { EC2Instance } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Create a new AWS EC2 client.
|
|
7
|
+
* @returns <Promise<EC2Client>> - the EC2 client instance.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createEC2Client: () => Promise<EC2Client>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new AWS SSM client.
|
|
12
|
+
* @returns <Promise<SSMClient>> - the SSM client instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createSSMClient: () => Promise<SSMClient>;
|
|
15
|
+
/**
|
|
16
|
+
* Return the list of bootstrap commands to be executed.
|
|
17
|
+
* @dev the startup commands must be suitable for a shell script.
|
|
18
|
+
* @param bucketName <string> - the name of the AWS S3 bucket.
|
|
19
|
+
* @returns <Array<string>> - the list of startup commands to be executed.
|
|
20
|
+
*/
|
|
21
|
+
export declare const vmBootstrapCommand: (bucketName: string) => Array<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Return the list of Node environment (and packages) installation plus artifact caching for contribution verification.
|
|
24
|
+
* @param zKeyPath <string> - the path to zKey artifact inside AWS S3 bucket.
|
|
25
|
+
* @param potPath <string> - the path to ptau artifact inside AWS S3 bucket.
|
|
26
|
+
* @param snsTopic <string> - the SNS topic ARN.
|
|
27
|
+
* @param region <string> - the AWS region.
|
|
28
|
+
* @returns <Array<string>> - the array of commands to be run by the EC2 instance.
|
|
29
|
+
*/
|
|
30
|
+
export declare const vmDependenciesAndCacheArtifactsCommand: (zKeyPath: string, potPath: string, snsTopic: string, region: string) => Array<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Return the list of commands for contribution verification.
|
|
33
|
+
* @dev this method generates the verification transcript as well.
|
|
34
|
+
* @param bucketName <string> - the name of the AWS S3 bucket.
|
|
35
|
+
* @param lastZkeyStoragePath <string> - the last zKey storage path.
|
|
36
|
+
* @param verificationTranscriptStoragePathAndFilename <string> - the verification transcript storage path.
|
|
37
|
+
* @returns Array<string> - the list of commands for contribution verification.
|
|
38
|
+
*/
|
|
39
|
+
export declare const vmContributionVerificationCommand: (bucketName: string, lastZkeyStoragePath: string, verificationTranscriptStoragePathAndFilename: string) => Array<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Compute the VM disk size.
|
|
42
|
+
* @dev the disk size is computed using the zKey size in bytes taking into consideration
|
|
43
|
+
* the verification task (2 * zKeySize) + ptauSize + OS/VM (~8GB).
|
|
44
|
+
* @param zKeySizeInBytes <number> the size of the zKey in bytes.
|
|
45
|
+
* @param pot <number> the amount of powers needed for the circuit (index of the PPoT file).
|
|
46
|
+
* @return <number> the configuration of the VM disk size in GB.
|
|
47
|
+
*/
|
|
48
|
+
export declare const computeDiskSizeForVM: (zKeySizeInBytes: number, pot: number) => number;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new EC2 instance
|
|
51
|
+
* @param ec2 <EC2Client> - the instance of the EC2 client.
|
|
52
|
+
* @param commands <Array<string>> - the list of commands to be run on the EC2 instance.
|
|
53
|
+
* @param instanceType <string> - the type of the EC2 VM instance.
|
|
54
|
+
* @param diskSize <number> - the size of the disk (volume) of the VM.
|
|
55
|
+
* @param diskType <DiskTypeForVM> - the type of the disk (volume) of the VM.
|
|
56
|
+
* @returns <Promise<P0tionEC2Instance>> the instance that was created
|
|
57
|
+
*/
|
|
58
|
+
export declare const createEC2Instance: (ec2: EC2Client, commands: string[], instanceType: string, volumeSize: number, diskType: DiskTypeForVM) => Promise<EC2Instance>;
|
|
59
|
+
/**
|
|
60
|
+
* Check if the current VM EC2 instance is running by querying the status.
|
|
61
|
+
* @param ec2 <EC2Client> - the instance of the EC2 client.
|
|
62
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
63
|
+
* @returns <Promise<boolean>> - true if the current status of the EC2 VM instance is 'running'; otherwise false.
|
|
64
|
+
*/
|
|
65
|
+
export declare const checkIfRunning: (ec2Client: EC2Client, instanceId: string) => Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Start an EC2 VM instance.
|
|
68
|
+
* @dev the instance must have been created previously.
|
|
69
|
+
* @param ec2 <EC2Client> - the instance of the EC2 client.
|
|
70
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
71
|
+
*/
|
|
72
|
+
export declare const startEC2Instance: (ec2: EC2Client, instanceId: string) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Stop an EC2 VM instance.
|
|
75
|
+
* @dev the instance must have been in a running status.
|
|
76
|
+
* @param ec2 <EC2Client> - the instance of the EC2 client.
|
|
77
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
78
|
+
*/
|
|
79
|
+
export declare const stopEC2Instance: (ec2: EC2Client, instanceId: string) => Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Terminate an EC2 VM instance.
|
|
82
|
+
* @param ec2 <EC2Client> - the instance of the EC2 client.
|
|
83
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
84
|
+
*/
|
|
85
|
+
export declare const terminateEC2Instance: (ec2: EC2Client, instanceId: string) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Run a command on an EC2 VM instance by using SSM.
|
|
88
|
+
* @dev this method returns the command identifier for checking the status and retrieve
|
|
89
|
+
* the output of the command execution later on.
|
|
90
|
+
* @param ssm <SSMClient> - the instance of the sSM client.
|
|
91
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
92
|
+
* @param commands <Array<string>> - the list of commands.
|
|
93
|
+
* @return <Promise<string>> - the unique identifier of the command.
|
|
94
|
+
*/
|
|
95
|
+
export declare const runCommandUsingSSM: (ssm: SSMClient, instanceId: string, commands: Array<string>) => Promise<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the output of an SSM command executed on an EC2 VM instance.
|
|
98
|
+
* @param ssm <SSMClient> - the instance of the sSM client.
|
|
99
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
100
|
+
* @param commandId <string> - the unique identifier of the command.
|
|
101
|
+
* @return <Promise<string>> - the command output.
|
|
102
|
+
*/
|
|
103
|
+
export declare const retrieveCommandOutput: (ssm: SSMClient, instanceId: string, commandId: string) => Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Get the status of an SSM command executed on an EC2 VM instance.
|
|
106
|
+
* @param ssm <SSMClient> - the instance of the sSM client.
|
|
107
|
+
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
|
|
108
|
+
* @param commandId <string> - the unique identifier of the command.
|
|
109
|
+
* @return <Promise<string>> - the command status.
|
|
110
|
+
*/
|
|
111
|
+
export declare const retrieveCommandStatus: (ssm: SSMClient, instanceId: string, commandId: string) => Promise<string>;
|
|
112
|
+
//# sourceMappingURL=vm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../../../../src/helpers/vm.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,SAAS,EAEZ,MAA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B,SAAS,cACF,MAAM,YACR,MAAM,MAAM,CAAC,KACxB,QAAQ,MAAM,CAwBhB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAe,SAAS,cAAc,MAAM,aAAa,MAAM,KAAG,QAAQ,MAAM,CAiBjH,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAe,SAAS,cAAc,MAAM,aAAa,MAAM,KAAG,QAAQ,MAAM,CAgBjH,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { downloadCeremonyArtifact, getBucketName, multiPartUpload, getR1csStorageFilePath, getPotStorageFilePath, getZkeyStorageFilePath, getVerificationKeyStorageFilePath, getVerifierContractStorageFilePath, getTranscriptStorageFilePath, getWasmStorageFilePath } from "./helpers/storage";
|
|
2
|
+
export { queryCollection, fromQueryToFirebaseDocumentInfo, getAllCollectionDocs, getCircuitContributionsFromContributor, getDocumentById, getCurrentActiveParticipantTimeout, getClosedCeremonies, getParticipantsCollectionPath, getCircuitsCollectionPath, getContributionsCollectionPath, getTimeoutsCollectionPath, getOpenedCeremonies, getCeremonyCircuits } from "./helpers/database";
|
|
3
|
+
export { compareCeremonyArtifacts, downloadAllCeremonyArtifacts, exportVerifierAndVKey, exportVerifierContract, exportVkey, generateGROTH16Proof, generateZkeyFromScratch, verifyGROTH16Proof, verifyZKey } from "./helpers/verification";
|
|
4
|
+
export { initializeFirebaseCoreServices } from "./helpers/services";
|
|
5
|
+
export { signInToFirebaseWithCredentials, getCurrentFirebaseAuthUser, isCoordinator } from "./helpers/authentication";
|
|
6
|
+
export { commonTerms, potFileDownloadMainUrl, potFilenameTemplate, genesisZkeyIndex, numExpIterations, solidityVersion, finalContributionIndex, verificationKeyAcronym, verifierSmartContractAcronym, ec2InstanceTag, vmConfigurationTypes, vmBootstrapScriptFilename, powersOfTauFiles } from "./helpers/constants";
|
|
7
|
+
export { extractPrefix, extractPoTFromFilename, extractR1CSInfoValueForGivenKey, formatZkeyIndex, autoGenerateEntropy, getCircuitBySequencePosition, convertBytesOrKbToGb, getPublicAttestationPreambleForContributor, getContributionsValidityForContributor, generateValidContributionsAttestation, createCustomLoggerForFile, getR1CSInfo, computeSmallestPowersOfTauForCircuit, convertToDoubleDigits, parseCeremonyFile } from "./helpers/utils";
|
|
8
|
+
export { setupCeremony, checkParticipantForCeremony, progressToNextCircuitForContribution, resumeContributionAfterTimeoutExpiration, createS3Bucket, generateGetObjectPreSignedUrl, progressToNextContributionStep, permanentlyStoreCurrentContributionTimeAndHash, temporaryStoreCurrentContributionMultiPartUploadId, temporaryStoreCurrentContributionUploadedChunkData, generatePreSignedUrlsParts, completeMultiPartUpload, checkIfObjectExist, verifyContribution, checkAndPrepareCoordinatorForFinalization, finalizeCircuit, finalizeCeremony } from "./helpers/functions";
|
|
9
|
+
export { toHex, blake512FromPath, computeSHA256ToHex, compareHashes } from "./helpers/crypto";
|
|
10
|
+
export { compileContract, verifyCeremony, p256, verifyGROTH16ProofOnChain, formatSolidityCalldata } from "./helpers/contracts";
|
|
11
|
+
export { githubReputation } from "./helpers/security";
|
|
12
|
+
export { CeremonyState, CeremonyType, CeremonyTimeoutType, ParticipantStatus, ParticipantContributionStep, TimeoutType, RequestType, TestingEnvironment, CircuitContributionVerificationMechanism, DiskTypeForVM } from "./types/enums";
|
|
13
|
+
export { FirebaseDocumentInfo, ChunkWithUrl, ETagWithPartNumber, ContributionValidity, UserDocument, CeremonyInputData, CircomCompilerData, SourceTemplateData, CompilationArtifacts, CircuitInputData, CeremonyDocument, Contribution, TemporaryParticipantContributionData, ParticipantDocument, CircuitMetadata, CircuitArtifacts, CircuitTimings, CircuitWaitingQueue, CircuitDocument, ContributionFiles, ContributionVerificationSoftware, BeaconInfo, ContributionDocument, CircuitDocumentReferenceAndData, UserDocumentReferenceAndData, CeremonyDocumentReferenceAndData, ParticipantDocumentReferenceAndData, CeremonyArtifacts, ContributionDocumentReferenceAndData, FirebaseServices, VMConfigurationType, AWSVariables } from "./types/index";
|
|
14
|
+
export { createEC2Instance, terminateEC2Instance, stopEC2Instance, startEC2Instance, checkIfRunning, vmBootstrapCommand, vmDependenciesAndCacheArtifactsCommand, retrieveCommandOutput, computeDiskSizeForVM, createSSMClient, runCommandUsingSSM, createEC2Client, vmContributionVerificationCommand, retrieveCommandStatus } from "./helpers/vm";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,EACjC,kCAAkC,EAClC,4BAA4B,EAC5B,sBAAsB,EACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,eAAe,EACf,+BAA+B,EAC/B,oBAAoB,EACpB,sCAAsC,EACtC,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,6BAA6B,EAC7B,yBAAyB,EACzB,8BAA8B,EAC9B,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,UAAU,EACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACrH,OAAO,EACH,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EACnB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