@devtion/actions 0.0.0-4088679 → 0.0.0-477457c
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 +2 -2
- package/dist/index.mjs +376 -268
- package/dist/index.node.js +376 -266
- package/dist/types/src/helpers/authentication.d.ts.map +1 -1
- package/dist/types/src/helpers/constants.d.ts +5 -2
- package/dist/types/src/helpers/constants.d.ts.map +1 -1
- package/dist/types/src/helpers/contracts.d.ts.map +1 -1
- package/dist/types/src/helpers/crypto.d.ts.map +1 -1
- package/dist/types/src/helpers/database.d.ts +8 -0
- package/dist/types/src/helpers/database.d.ts.map +1 -1
- package/dist/types/src/helpers/functions.d.ts +2 -1
- package/dist/types/src/helpers/functions.d.ts.map +1 -1
- package/dist/types/src/helpers/security.d.ts +1 -1
- package/dist/types/src/helpers/security.d.ts.map +1 -1
- package/dist/types/src/helpers/services.d.ts.map +1 -1
- package/dist/types/src/helpers/storage.d.ts +5 -2
- package/dist/types/src/helpers/storage.d.ts.map +1 -1
- package/dist/types/src/helpers/utils.d.ts +33 -21
- package/dist/types/src/helpers/utils.d.ts.map +1 -1
- package/dist/types/src/helpers/verification.d.ts +3 -2
- package/dist/types/src/helpers/verification.d.ts.map +1 -1
- package/dist/types/src/helpers/vm.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +9 -4
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/test/data/generators.d.ts +32 -0
- package/dist/types/test/data/generators.d.ts.map +1 -0
- package/dist/types/test/data/samples.d.ts +40 -0
- package/dist/types/test/data/samples.d.ts.map +1 -0
- package/dist/types/test/utils/authentication.d.ts +72 -0
- package/dist/types/test/utils/authentication.d.ts.map +1 -0
- package/dist/types/test/utils/configs.d.ts +52 -0
- package/dist/types/test/utils/configs.d.ts.map +1 -0
- package/dist/types/test/utils/index.d.ts +4 -0
- package/dist/types/test/utils/index.d.ts.map +1 -0
- package/dist/types/test/utils/storage.d.ts +126 -0
- package/dist/types/test/utils/storage.d.ts.map +1 -0
- package/package.json +7 -8
- package/src/helpers/constants.ts +39 -31
- package/src/helpers/contracts.ts +3 -3
- package/src/helpers/crypto.ts +5 -1
- package/src/helpers/database.ts +13 -0
- package/src/helpers/functions.ts +1 -1
- package/src/helpers/security.ts +11 -8
- package/src/helpers/services.ts +3 -3
- package/src/helpers/storage.ts +15 -3
- package/src/helpers/utils.ts +335 -263
- package/src/helpers/verification.ts +6 -6
- package/src/helpers/vm.ts +28 -7
- package/src/index.ts +5 -3
- package/src/types/index.ts +32 -8
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module @
|
|
3
|
-
* @version 1.
|
|
2
|
+
* @module @p0tion/actions
|
|
3
|
+
* @version 1.2.8
|
|
4
4
|
* @file A set of actions and helpers for CLI commands
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -15,7 +15,6 @@ import { onSnapshot, query, collection, getDocs, doc, getDoc, where, Timestamp,
|
|
|
15
15
|
import { zKey, groth16 } from 'snarkjs';
|
|
16
16
|
import crypto from 'crypto';
|
|
17
17
|
import blake from 'blakejs';
|
|
18
|
-
import { utils } from 'ffjavascript';
|
|
19
18
|
import winston from 'winston';
|
|
20
19
|
import { pipeline } from 'stream';
|
|
21
20
|
import { promisify } from 'util';
|
|
@@ -27,10 +26,10 @@ import { EC2Client, RunInstancesCommand, DescribeInstanceStatusCommand, StartIns
|
|
|
27
26
|
import { SSMClient, SendCommandCommand, GetCommandInvocationCommand } from '@aws-sdk/client-ssm';
|
|
28
27
|
import dotenv from 'dotenv';
|
|
29
28
|
|
|
30
|
-
// Main part for the
|
|
31
|
-
const potFileDownloadMainUrl = `https://
|
|
32
|
-
// Main part for the
|
|
33
|
-
const potFilenameTemplate = `
|
|
29
|
+
// Main part for the PPoT Phase 1 Trusted Setup URLs to download PoT files.
|
|
30
|
+
const potFileDownloadMainUrl = `https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/`;
|
|
31
|
+
// Main part for the PPoT Phase 1 Trusted Setup PoT files to be downloaded.
|
|
32
|
+
const potFilenameTemplate = `ppot_0080_`;
|
|
34
33
|
// The genesis zKey index.
|
|
35
34
|
const genesisZkeyIndex = `00000`;
|
|
36
35
|
// The number of exponential iterations to be executed by SnarkJS when finalizing the ceremony.
|
|
@@ -47,6 +46,8 @@ const verifierSmartContractAcronym = "verifier";
|
|
|
47
46
|
const ec2InstanceTag = "p0tionec2instance";
|
|
48
47
|
// The name of the VM startup script file.
|
|
49
48
|
const vmBootstrapScriptFilename = "bootstrap.sh";
|
|
49
|
+
// Match hash output by snarkjs in transcript log
|
|
50
|
+
const contribHashRegex = /Contribution.+Hash.+\s+.+\s+.+\s+.+\s+.+\s*/;
|
|
50
51
|
/**
|
|
51
52
|
* Define the supported VM configuration types.
|
|
52
53
|
* @dev the VM configurations can be retrieved at https://aws.amazon.com/ec2/instance-types/
|
|
@@ -104,112 +105,116 @@ const vmConfigurationTypes = {
|
|
|
104
105
|
*/
|
|
105
106
|
const powersOfTauFiles = [
|
|
106
107
|
{
|
|
107
|
-
ref: "https://
|
|
108
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_01.ptau",
|
|
108
109
|
size: 0.000084
|
|
109
110
|
},
|
|
110
111
|
{
|
|
111
|
-
ref: "https://
|
|
112
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_02.ptau",
|
|
112
113
|
size: 0.000086
|
|
113
114
|
},
|
|
114
115
|
{
|
|
115
|
-
ref: "https://
|
|
116
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_03.ptau",
|
|
116
117
|
size: 0.000091
|
|
117
118
|
},
|
|
118
119
|
{
|
|
119
|
-
ref: "https://
|
|
120
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_04.ptau",
|
|
120
121
|
size: 0.0001
|
|
121
122
|
},
|
|
122
123
|
{
|
|
123
|
-
ref: "https://
|
|
124
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_05.ptau",
|
|
124
125
|
size: 0.000117
|
|
125
126
|
},
|
|
126
127
|
{
|
|
127
|
-
ref: "https://
|
|
128
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_06.ptau",
|
|
128
129
|
size: 0.000153
|
|
129
130
|
},
|
|
130
131
|
{
|
|
131
|
-
ref: "https://
|
|
132
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_07.ptau",
|
|
132
133
|
size: 0.000225
|
|
133
134
|
},
|
|
134
135
|
{
|
|
135
|
-
ref: "https://
|
|
136
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_08.ptau",
|
|
136
137
|
size: 0.0004
|
|
137
138
|
},
|
|
138
139
|
{
|
|
139
|
-
ref: "https://
|
|
140
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_09.ptau",
|
|
140
141
|
size: 0.000658
|
|
141
142
|
},
|
|
142
143
|
{
|
|
143
|
-
ref: "https://
|
|
144
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_10.ptau",
|
|
144
145
|
size: 0.0013
|
|
145
146
|
},
|
|
146
147
|
{
|
|
147
|
-
ref: "https://
|
|
148
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_11.ptau",
|
|
148
149
|
size: 0.0023
|
|
149
150
|
},
|
|
150
151
|
{
|
|
151
|
-
ref: "https://
|
|
152
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_12.ptau",
|
|
152
153
|
size: 0.0046
|
|
153
154
|
},
|
|
154
155
|
{
|
|
155
|
-
ref: "https://
|
|
156
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_13.ptau",
|
|
156
157
|
size: 0.0091
|
|
157
158
|
},
|
|
158
159
|
{
|
|
159
|
-
ref: "https://
|
|
160
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_14.ptau",
|
|
160
161
|
size: 0.0181
|
|
161
162
|
},
|
|
162
163
|
{
|
|
163
|
-
ref: "https://
|
|
164
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_15.ptau",
|
|
164
165
|
size: 0.0361
|
|
165
166
|
},
|
|
166
167
|
{
|
|
167
|
-
ref: "https://
|
|
168
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_16.ptau",
|
|
168
169
|
size: 0.0721
|
|
169
170
|
},
|
|
170
171
|
{
|
|
171
|
-
ref: "https://
|
|
172
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_17.ptau",
|
|
172
173
|
size: 0.144
|
|
173
174
|
},
|
|
174
175
|
{
|
|
175
|
-
ref: "https://
|
|
176
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_18.ptau",
|
|
176
177
|
size: 0.288
|
|
177
178
|
},
|
|
178
179
|
{
|
|
179
|
-
ref: "https://
|
|
180
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_19.ptau",
|
|
180
181
|
size: 0.576
|
|
181
182
|
},
|
|
182
183
|
{
|
|
183
|
-
ref: "https://
|
|
184
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_20.ptau",
|
|
184
185
|
size: 1.1
|
|
185
186
|
},
|
|
186
187
|
{
|
|
187
|
-
ref: "https://
|
|
188
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_21.ptau",
|
|
188
189
|
size: 2.3
|
|
189
190
|
},
|
|
190
191
|
{
|
|
191
|
-
ref: "https://
|
|
192
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_22.ptau",
|
|
192
193
|
size: 4.5
|
|
193
194
|
},
|
|
194
195
|
{
|
|
195
|
-
ref: "https://
|
|
196
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_23.ptau",
|
|
196
197
|
size: 9.0
|
|
197
198
|
},
|
|
198
199
|
{
|
|
199
|
-
ref: "https://
|
|
200
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_24.ptau",
|
|
200
201
|
size: 18.0
|
|
201
202
|
},
|
|
202
203
|
{
|
|
203
|
-
ref: "https://
|
|
204
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_25.ptau",
|
|
204
205
|
size: 36.0
|
|
205
206
|
},
|
|
206
207
|
{
|
|
207
|
-
ref: "https://
|
|
208
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_26.ptau",
|
|
208
209
|
size: 72.0
|
|
209
210
|
},
|
|
210
211
|
{
|
|
211
|
-
ref: "https://
|
|
212
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_27.ptau",
|
|
212
213
|
size: 144.0
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_final.ptau",
|
|
217
|
+
size: 288.0
|
|
213
218
|
}
|
|
214
219
|
];
|
|
215
220
|
/**
|
|
@@ -340,6 +345,8 @@ const commonTerms = {
|
|
|
340
345
|
finalizeCeremony: "finalizeCeremony",
|
|
341
346
|
downloadCircuitArtifacts: "downloadCircuitArtifacts",
|
|
342
347
|
transferObject: "transferObject",
|
|
348
|
+
bandadaValidateProof: "bandadaValidateProof",
|
|
349
|
+
checkNonceOfSIWEAddress: "checkNonceOfSIWEAddress"
|
|
343
350
|
}
|
|
344
351
|
};
|
|
345
352
|
|
|
@@ -690,19 +697,23 @@ const getChunksAndPreSignedUrls = async (cloudFunctions, bucketName, objectKey,
|
|
|
690
697
|
* @param cloudFunctions <Functions> - the Firebase Cloud Functions service instance.
|
|
691
698
|
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
692
699
|
* @param alreadyUploadedChunks Array<ETagWithPartNumber> - the temporary information about the already uploaded chunks.
|
|
700
|
+
* @param logger <GenericBar> - an optional logger to show progress.
|
|
693
701
|
* @returns <Promise<Array<ETagWithPartNumber>>> - the completed (uploaded) chunks information.
|
|
694
702
|
*/
|
|
695
|
-
const uploadParts = async (chunksWithUrls, contentType, cloudFunctions, ceremonyId, alreadyUploadedChunks) => {
|
|
703
|
+
const uploadParts = async (chunksWithUrls, contentType, cloudFunctions, ceremonyId, alreadyUploadedChunks, logger) => {
|
|
696
704
|
// Keep track of uploaded chunks.
|
|
697
705
|
const uploadedChunks = alreadyUploadedChunks || [];
|
|
706
|
+
// if we were passed a logger, start it
|
|
707
|
+
if (logger)
|
|
708
|
+
logger.start(chunksWithUrls.length, 0);
|
|
698
709
|
// Loop through remaining chunks.
|
|
699
710
|
for (let i = alreadyUploadedChunks ? alreadyUploadedChunks.length : 0; i < chunksWithUrls.length; i += 1) {
|
|
700
711
|
// Consume the pre-signed url to upload the chunk.
|
|
701
712
|
// @ts-ignore
|
|
702
713
|
const response = await fetch(chunksWithUrls[i].preSignedUrl, {
|
|
703
714
|
retryOptions: {
|
|
704
|
-
retryInitialDelay: 500,
|
|
705
|
-
socketTimeout: 60000,
|
|
715
|
+
retryInitialDelay: 500, // 500 ms.
|
|
716
|
+
socketTimeout: 60000, // 60 seconds.
|
|
706
717
|
retryMaxDuration: 300000 // 5 minutes.
|
|
707
718
|
},
|
|
708
719
|
method: "PUT",
|
|
@@ -726,6 +737,9 @@ const uploadParts = async (chunksWithUrls, contentType, cloudFunctions, ceremony
|
|
|
726
737
|
// nb. this must be done only when contributing (not finalizing).
|
|
727
738
|
if (!!ceremonyId && !!cloudFunctions)
|
|
728
739
|
await temporaryStoreCurrentContributionUploadedChunkData(cloudFunctions, ceremonyId, chunk);
|
|
740
|
+
// increment the count on the logger
|
|
741
|
+
if (logger)
|
|
742
|
+
logger.increment();
|
|
729
743
|
}
|
|
730
744
|
return uploadedChunks;
|
|
731
745
|
};
|
|
@@ -746,8 +760,9 @@ const uploadParts = async (chunksWithUrls, contentType, cloudFunctions, ceremony
|
|
|
746
760
|
* @param configStreamChunkSize <number> - size of each chunk into which the artifact is going to be splitted (nb. will be converted in MB).
|
|
747
761
|
* @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).
|
|
748
762
|
* @param [temporaryDataToResumeMultiPartUpload] <TemporaryParticipantContributionData> - the temporary information necessary to resume an already started multi-part upload.
|
|
763
|
+
* @param logger <GenericBar> - an optional logger to show progress.
|
|
749
764
|
*/
|
|
750
|
-
const multiPartUpload = async (cloudFunctions, bucketName, objectKey, localFilePath, configStreamChunkSize, ceremonyId, temporaryDataToResumeMultiPartUpload) => {
|
|
765
|
+
const multiPartUpload = async (cloudFunctions, bucketName, objectKey, localFilePath, configStreamChunkSize, ceremonyId, temporaryDataToResumeMultiPartUpload, logger) => {
|
|
751
766
|
// The unique identifier of the multi-part upload.
|
|
752
767
|
let multiPartUploadId = "";
|
|
753
768
|
// The list of already uploaded chunks.
|
|
@@ -771,7 +786,7 @@ const multiPartUpload = async (cloudFunctions, bucketName, objectKey, localFileP
|
|
|
771
786
|
const chunksWithUrlsZkey = await getChunksAndPreSignedUrls(cloudFunctions, bucketName, objectKey, localFilePath, multiPartUploadId, configStreamChunkSize, ceremonyId);
|
|
772
787
|
// Step (2).
|
|
773
788
|
const partNumbersAndETagsZkey = await uploadParts(chunksWithUrlsZkey, mime.lookup(localFilePath), // content-type.
|
|
774
|
-
cloudFunctions, ceremonyId, alreadyUploadedChunks);
|
|
789
|
+
cloudFunctions, ceremonyId, alreadyUploadedChunks, logger);
|
|
775
790
|
// Step (3).
|
|
776
791
|
await completeMultiPartUpload(cloudFunctions, bucketName, objectKey, multiPartUploadId, partNumbersAndETagsZkey, ceremonyId);
|
|
777
792
|
};
|
|
@@ -995,6 +1010,17 @@ const getClosedCeremonies = async (firestoreDatabase) => {
|
|
|
995
1010
|
]);
|
|
996
1011
|
return fromQueryToFirebaseDocumentInfo(closedCeremoniesQuerySnap.docs);
|
|
997
1012
|
};
|
|
1013
|
+
/**
|
|
1014
|
+
* Query all ceremonies
|
|
1015
|
+
* @notice get all ceremonies from the database.
|
|
1016
|
+
* @dev this is a helper for the CLI ceremony methods.
|
|
1017
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
1018
|
+
* @returns <Promise<Array<FirebaseDocumentInfo>>> - the list of all ceremonies.
|
|
1019
|
+
*/
|
|
1020
|
+
const getAllCeremonies = async (firestoreDatabase) => {
|
|
1021
|
+
const ceremoniesQuerySnap = await queryCollection(firestoreDatabase, commonTerms.collections.ceremonies.name, []);
|
|
1022
|
+
return fromQueryToFirebaseDocumentInfo(ceremoniesQuerySnap.docs);
|
|
1023
|
+
};
|
|
998
1024
|
|
|
999
1025
|
/**
|
|
1000
1026
|
* @hidden
|
|
@@ -1016,6 +1042,9 @@ const blake512FromPath = async (path) => {
|
|
|
1016
1042
|
const hash = await new Promise((resolve) => {
|
|
1017
1043
|
fs.createReadStream(path)
|
|
1018
1044
|
.on("data", (chunk) => {
|
|
1045
|
+
if (typeof chunk === "string") {
|
|
1046
|
+
chunk = Buffer.from(chunk);
|
|
1047
|
+
}
|
|
1019
1048
|
blake.blake2bUpdate(context, chunk);
|
|
1020
1049
|
})
|
|
1021
1050
|
.on("end", () => {
|
|
@@ -1043,192 +1072,22 @@ const compareHashes = async (path1, path2) => {
|
|
|
1043
1072
|
};
|
|
1044
1073
|
|
|
1045
1074
|
/**
|
|
1046
|
-
*
|
|
1047
|
-
* @
|
|
1048
|
-
* @
|
|
1049
|
-
* @param cleanup <boolean> - whether to delete the r1cs file after parsing
|
|
1050
|
-
* @returns any - the data to pass to the cloud function for setup and the circuit artifacts
|
|
1075
|
+
* Return a string with double digits if the provided input is one digit only.
|
|
1076
|
+
* @param in <number> - the input number to be converted.
|
|
1077
|
+
* @returns <string> - the two digits stringified number derived from the conversion.
|
|
1051
1078
|
*/
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
throw new Error("You need to provide the data for at least 1 circuit.");
|
|
1065
|
-
// validate that the end date is in the future
|
|
1066
|
-
let endDate;
|
|
1067
|
-
let startDate;
|
|
1068
|
-
try {
|
|
1069
|
-
endDate = new Date(data.endDate);
|
|
1070
|
-
startDate = new Date(data.startDate);
|
|
1071
|
-
}
|
|
1072
|
-
catch (error) {
|
|
1073
|
-
throw new Error("The dates should follow this format: 2023-07-04T00:00:00.");
|
|
1074
|
-
}
|
|
1075
|
-
if (endDate <= startDate)
|
|
1076
|
-
throw new Error("The end date should be greater than the start date.");
|
|
1077
|
-
const currentDate = new Date();
|
|
1078
|
-
if (endDate <= currentDate || startDate <= currentDate)
|
|
1079
|
-
throw new Error("The start and end dates should be in the future.");
|
|
1080
|
-
// validate penalty
|
|
1081
|
-
if (data.penalty <= 0)
|
|
1082
|
-
throw new Error("The penalty should be greater than zero.");
|
|
1083
|
-
const circuits = [];
|
|
1084
|
-
const urlPattern = /(https?:\/\/[^\s]+)/g;
|
|
1085
|
-
const commitHashPattern = /^[a-f0-9]{40}$/i;
|
|
1086
|
-
const circuitArtifacts = [];
|
|
1087
|
-
for (let i = 0; i < data.circuits.length; i++) {
|
|
1088
|
-
const circuitData = data.circuits[i];
|
|
1089
|
-
const artifacts = circuitData.artifacts;
|
|
1090
|
-
circuitArtifacts.push({
|
|
1091
|
-
artifacts: artifacts
|
|
1092
|
-
});
|
|
1093
|
-
// where we storing the r1cs downloaded
|
|
1094
|
-
const localR1csPath = `./${circuitData.name}.r1cs`;
|
|
1095
|
-
// where we storing the wasm downloaded
|
|
1096
|
-
const localWasmPath = `./${circuitData.name}.wasm`;
|
|
1097
|
-
// download the r1cs to extract the metadata
|
|
1098
|
-
const streamPipeline = promisify(pipeline);
|
|
1099
|
-
// Make the call.
|
|
1100
|
-
const responseR1CS = await fetch(artifacts.r1csStoragePath);
|
|
1101
|
-
// Handle errors.
|
|
1102
|
-
if (!responseR1CS.ok && responseR1CS.status !== 200)
|
|
1103
|
-
throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
|
|
1104
|
-
await streamPipeline(responseR1CS.body, createWriteStream(localR1csPath));
|
|
1105
|
-
// Write the file locally
|
|
1106
|
-
// extract the metadata from the r1cs
|
|
1107
|
-
const metadata = getR1CSInfo(localR1csPath);
|
|
1108
|
-
// download wasm too to ensure it's available
|
|
1109
|
-
const responseWASM = await fetch(artifacts.wasmStoragePath);
|
|
1110
|
-
if (!responseWASM.ok && responseWASM.status !== 200)
|
|
1111
|
-
throw new Error(`There was an error while trying to download the WASM file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
|
|
1112
|
-
await streamPipeline(responseWASM.body, createWriteStream(localWasmPath));
|
|
1113
|
-
// validate that the circuit hash and template links are valid
|
|
1114
|
-
const template = circuitData.template;
|
|
1115
|
-
const URLMatch = template.source.match(urlPattern);
|
|
1116
|
-
if (!URLMatch || URLMatch.length === 0 || URLMatch.length > 1)
|
|
1117
|
-
throw new Error("You should provide the URL to the circuits templates on GitHub.");
|
|
1118
|
-
const hashMatch = template.commitHash.match(commitHashPattern);
|
|
1119
|
-
if (!hashMatch || hashMatch.length === 0 || hashMatch.length > 1)
|
|
1120
|
-
throw new Error("You should provide a valid commit hash of the circuit templates.");
|
|
1121
|
-
// calculate the hash of the r1cs file
|
|
1122
|
-
const r1csBlake2bHash = await blake512FromPath(localR1csPath);
|
|
1123
|
-
const circuitPrefix = extractPrefix(circuitData.name);
|
|
1124
|
-
// filenames
|
|
1125
|
-
const doubleDigitsPowers = convertToDoubleDigits(metadata.pot);
|
|
1126
|
-
const r1csCompleteFilename = `${circuitData.name}.r1cs`;
|
|
1127
|
-
const wasmCompleteFilename = `${circuitData.name}.wasm`;
|
|
1128
|
-
const smallestPowersOfTauCompleteFilenameForCircuit = `${potFilenameTemplate}${doubleDigitsPowers}.ptau`;
|
|
1129
|
-
const firstZkeyCompleteFilename = `${circuitPrefix}_${genesisZkeyIndex}.zkey`;
|
|
1130
|
-
// storage paths
|
|
1131
|
-
const r1csStorageFilePath = getR1csStorageFilePath(circuitPrefix, r1csCompleteFilename);
|
|
1132
|
-
const wasmStorageFilePath = getWasmStorageFilePath(circuitPrefix, wasmCompleteFilename);
|
|
1133
|
-
const potStorageFilePath = getPotStorageFilePath(smallestPowersOfTauCompleteFilenameForCircuit);
|
|
1134
|
-
const zkeyStorageFilePath = getZkeyStorageFilePath(circuitPrefix, firstZkeyCompleteFilename);
|
|
1135
|
-
const files = {
|
|
1136
|
-
potFilename: smallestPowersOfTauCompleteFilenameForCircuit,
|
|
1137
|
-
r1csFilename: r1csCompleteFilename,
|
|
1138
|
-
wasmFilename: wasmCompleteFilename,
|
|
1139
|
-
initialZkeyFilename: firstZkeyCompleteFilename,
|
|
1140
|
-
potStoragePath: potStorageFilePath,
|
|
1141
|
-
r1csStoragePath: r1csStorageFilePath,
|
|
1142
|
-
wasmStoragePath: wasmStorageFilePath,
|
|
1143
|
-
initialZkeyStoragePath: zkeyStorageFilePath,
|
|
1144
|
-
r1csBlake2bHash: r1csBlake2bHash
|
|
1145
|
-
};
|
|
1146
|
-
// validate that the compiler hash is a valid hash
|
|
1147
|
-
const compiler = circuitData.compiler;
|
|
1148
|
-
const compilerHashMatch = compiler.commitHash.match(commitHashPattern);
|
|
1149
|
-
if (!compilerHashMatch || compilerHashMatch.length === 0 || compilerHashMatch.length > 1)
|
|
1150
|
-
throw new Error("You should provide a valid commit hash of the circuit compiler.");
|
|
1151
|
-
// validate that the verification options are valid
|
|
1152
|
-
const verification = circuitData.verification;
|
|
1153
|
-
if (verification.cfOrVm !== "CF" && verification.cfOrVm !== "VM")
|
|
1154
|
-
throw new Error("Please enter a valid verification mechanism: either CF or VM");
|
|
1155
|
-
// @todo VM parameters verification
|
|
1156
|
-
// if (verification['cfOrVM'] === "VM") {}
|
|
1157
|
-
// check that the timeout is provided for the correct configuration
|
|
1158
|
-
let dynamicThreshold;
|
|
1159
|
-
let fixedTimeWindow;
|
|
1160
|
-
let circuit = {};
|
|
1161
|
-
if (data.timeoutMechanismType === "DYNAMIC" /* CeremonyTimeoutType.DYNAMIC */) {
|
|
1162
|
-
if (circuitData.dynamicThreshold <= 0)
|
|
1163
|
-
throw new Error("The dynamic threshold should be > 0.");
|
|
1164
|
-
dynamicThreshold = circuitData.dynamicThreshold;
|
|
1165
|
-
// the Circuit data for the ceremony setup
|
|
1166
|
-
circuit = {
|
|
1167
|
-
name: circuitData.name,
|
|
1168
|
-
description: circuitData.description,
|
|
1169
|
-
prefix: circuitPrefix,
|
|
1170
|
-
sequencePosition: i + 1,
|
|
1171
|
-
metadata: metadata,
|
|
1172
|
-
files: files,
|
|
1173
|
-
template: template,
|
|
1174
|
-
compiler: compiler,
|
|
1175
|
-
verification: verification,
|
|
1176
|
-
dynamicThreshold: dynamicThreshold,
|
|
1177
|
-
avgTimings: {
|
|
1178
|
-
contributionComputation: 0,
|
|
1179
|
-
fullContribution: 0,
|
|
1180
|
-
verifyCloudFunction: 0
|
|
1181
|
-
},
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
if (data.timeoutMechanismType === "FIXED" /* CeremonyTimeoutType.FIXED */) {
|
|
1185
|
-
if (circuitData.fixedTimeWindow <= 0)
|
|
1186
|
-
throw new Error("The fixed time window threshold should be > 0.");
|
|
1187
|
-
fixedTimeWindow = circuitData.fixedTimeWindow;
|
|
1188
|
-
// the Circuit data for the ceremony setup
|
|
1189
|
-
circuit = {
|
|
1190
|
-
name: circuitData.name,
|
|
1191
|
-
description: circuitData.description,
|
|
1192
|
-
prefix: circuitPrefix,
|
|
1193
|
-
sequencePosition: i + 1,
|
|
1194
|
-
metadata: metadata,
|
|
1195
|
-
files: files,
|
|
1196
|
-
template: template,
|
|
1197
|
-
compiler: compiler,
|
|
1198
|
-
verification: verification,
|
|
1199
|
-
fixedTimeWindow: fixedTimeWindow,
|
|
1200
|
-
avgTimings: {
|
|
1201
|
-
contributionComputation: 0,
|
|
1202
|
-
fullContribution: 0,
|
|
1203
|
-
verifyCloudFunction: 0
|
|
1204
|
-
},
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
circuits.push(circuit);
|
|
1208
|
-
// remove the local r1cs and wasm downloads (if used for verifying the config only vs setup)
|
|
1209
|
-
if (cleanup)
|
|
1210
|
-
fs.unlinkSync(localR1csPath);
|
|
1211
|
-
fs.unlinkSync(localWasmPath);
|
|
1212
|
-
}
|
|
1213
|
-
const setupData = {
|
|
1214
|
-
ceremonyInputData: {
|
|
1215
|
-
title: data.title,
|
|
1216
|
-
description: data.description,
|
|
1217
|
-
startDate: startDate.valueOf(),
|
|
1218
|
-
endDate: endDate.valueOf(),
|
|
1219
|
-
timeoutMechanismType: data.timeoutMechanismType,
|
|
1220
|
-
penalty: data.penalty
|
|
1221
|
-
},
|
|
1222
|
-
ceremonyPrefix: extractPrefix(data.title),
|
|
1223
|
-
circuits: circuits,
|
|
1224
|
-
circuitArtifacts: circuitArtifacts
|
|
1225
|
-
};
|
|
1226
|
-
return setupData;
|
|
1227
|
-
}
|
|
1228
|
-
catch (error) {
|
|
1229
|
-
throw new Error(`Error while parsing up the ceremony setup file. ${error.message}`);
|
|
1230
|
-
}
|
|
1231
|
-
};
|
|
1079
|
+
const convertToDoubleDigits = (amount) => (amount < 10 ? `0${amount}` : amount.toString());
|
|
1080
|
+
/**
|
|
1081
|
+
* Extract a prefix consisting of alphanumeric and underscore characters from a string with arbitrary characters.
|
|
1082
|
+
* @dev replaces all special symbols and whitespaces with an underscore char ('_'). Convert all uppercase chars to lowercase.
|
|
1083
|
+
* @notice example: str = 'Multiplier-2!2.4.zkey'; output prefix = 'multiplier_2_2_4.zkey'.
|
|
1084
|
+
* NB. Prefix extraction is a key process that conditions the name of the ceremony artifacts, download/upload from/to storage, collections paths.
|
|
1085
|
+
* @param str <string> - the arbitrary string from which to extract the prefix.
|
|
1086
|
+
* @returns <string> - the resulting prefix.
|
|
1087
|
+
*/
|
|
1088
|
+
const extractPrefix = (str) =>
|
|
1089
|
+
// eslint-disable-next-line no-useless-escape
|
|
1090
|
+
str.replace(/[`\s~!@#$%^&*()|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").toLowerCase();
|
|
1232
1091
|
/**
|
|
1233
1092
|
* Extract data from a R1CS metadata file generated with a custom file-based logger.
|
|
1234
1093
|
* @notice useful for extracting metadata circuits contained in the generated file using a logger
|
|
@@ -1285,17 +1144,6 @@ const formatZkeyIndex = (progress) => {
|
|
|
1285
1144
|
* @returns <number> - the amount of powers.
|
|
1286
1145
|
*/
|
|
1287
1146
|
const extractPoTFromFilename = (potCompleteFilename) => Number(potCompleteFilename.split("_").pop()?.split(".").at(0));
|
|
1288
|
-
/**
|
|
1289
|
-
* Extract a prefix consisting of alphanumeric and underscore characters from a string with arbitrary characters.
|
|
1290
|
-
* @dev replaces all special symbols and whitespaces with an underscore char ('_'). Convert all uppercase chars to lowercase.
|
|
1291
|
-
* @notice example: str = 'Multiplier-2!2.4.zkey'; output prefix = 'multiplier_2_2_4.zkey'.
|
|
1292
|
-
* NB. Prefix extraction is a key process that conditions the name of the ceremony artifacts, download/upload from/to storage, collections paths.
|
|
1293
|
-
* @param str <string> - the arbitrary string from which to extract the prefix.
|
|
1294
|
-
* @returns <string> - the resulting prefix.
|
|
1295
|
-
*/
|
|
1296
|
-
const extractPrefix = (str) =>
|
|
1297
|
-
// eslint-disable-next-line no-useless-escape
|
|
1298
|
-
str.replace(/[`\s~!@#$%^&*()|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").toLowerCase();
|
|
1299
1147
|
/**
|
|
1300
1148
|
* Automate the generation of an entropy for a contribution.
|
|
1301
1149
|
* @dev Took inspiration from here https://github.com/glamperd/setup-mpc-ui/blob/master/client/src/state/Compute.tsx#L112.
|
|
@@ -1362,7 +1210,9 @@ const getContributionsValidityForContributor = async (firestoreDatabase, circuit
|
|
|
1362
1210
|
* @param isFinalizing <boolean> - true when the coordinator is finalizing the ceremony, otherwise false.
|
|
1363
1211
|
* @returns <string> - the public attestation preamble.
|
|
1364
1212
|
*/
|
|
1365
|
-
const getPublicAttestationPreambleForContributor = (contributorIdentifier, ceremonyName, isFinalizing) => `Hey, I'm ${contributorIdentifier} and I have ${isFinalizing ? "finalized" : "contributed to"} the ${ceremonyName}
|
|
1213
|
+
const getPublicAttestationPreambleForContributor = (contributorIdentifier, ceremonyName, isFinalizing) => `Hey, I'm ${contributorIdentifier} and I have ${isFinalizing ? "finalized" : "contributed to"} the ${ceremonyName}${ceremonyName.toLowerCase().includes("trusted setup") || ceremonyName.toLowerCase().includes("ceremony")
|
|
1214
|
+
? "."
|
|
1215
|
+
: " MPC Phase2 Trusted Setup ceremony."}\nThe following are my contribution signatures:`;
|
|
1366
1216
|
/**
|
|
1367
1217
|
* Check and prepare public attestation for the contributor made only of its valid contributions.
|
|
1368
1218
|
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
@@ -1433,6 +1283,41 @@ const readBytesFromFile = (localFilePath, offset, length, position) => {
|
|
|
1433
1283
|
// Return the read bytes.
|
|
1434
1284
|
return buffer;
|
|
1435
1285
|
};
|
|
1286
|
+
/**
|
|
1287
|
+
* Given a buffer in little endian format, convert it to bigint
|
|
1288
|
+
* @param buffer
|
|
1289
|
+
* @returns
|
|
1290
|
+
*/
|
|
1291
|
+
function leBufferToBigint(buffer) {
|
|
1292
|
+
return BigInt(`0x${buffer.reverse().toString("hex")}`);
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Given an input containing string values, convert them
|
|
1296
|
+
* to bigint
|
|
1297
|
+
* @param input - The input to convert
|
|
1298
|
+
* @returns the input with string values converted to bigint
|
|
1299
|
+
*/
|
|
1300
|
+
const unstringifyBigInts = (input) => {
|
|
1301
|
+
if (typeof input === "string" && /^[0-9]+$/.test(input)) {
|
|
1302
|
+
return BigInt(input);
|
|
1303
|
+
}
|
|
1304
|
+
if (typeof input === "string" && /^0x[0-9a-fA-F]+$/.test(input)) {
|
|
1305
|
+
return BigInt(input);
|
|
1306
|
+
}
|
|
1307
|
+
if (Array.isArray(input)) {
|
|
1308
|
+
return input.map(unstringifyBigInts);
|
|
1309
|
+
}
|
|
1310
|
+
if (input === null) {
|
|
1311
|
+
return null;
|
|
1312
|
+
}
|
|
1313
|
+
if (typeof input === "object") {
|
|
1314
|
+
return Object.entries(input).reduce((acc, [key, value]) => {
|
|
1315
|
+
acc[key] = unstringifyBigInts(value);
|
|
1316
|
+
return acc;
|
|
1317
|
+
}, {});
|
|
1318
|
+
}
|
|
1319
|
+
return input;
|
|
1320
|
+
};
|
|
1436
1321
|
/**
|
|
1437
1322
|
* Return the info about the R1CS file.ù
|
|
1438
1323
|
* @dev this method was built taking inspiration from
|
|
@@ -1493,17 +1378,17 @@ const getR1CSInfo = (localR1CSFilePath) => {
|
|
|
1493
1378
|
let constraints = 0;
|
|
1494
1379
|
try {
|
|
1495
1380
|
// Get 'number of section' (jump magic r1cs and version1 data).
|
|
1496
|
-
const numberOfSections =
|
|
1381
|
+
const numberOfSections = leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, 8));
|
|
1497
1382
|
// Jump to first section.
|
|
1498
1383
|
pointer = 12;
|
|
1499
1384
|
// For each section
|
|
1500
1385
|
for (let i = 0; i < numberOfSections; i++) {
|
|
1501
1386
|
// Read section type.
|
|
1502
|
-
const sectionType =
|
|
1387
|
+
const sectionType = leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, pointer));
|
|
1503
1388
|
// Jump to section size.
|
|
1504
1389
|
pointer += 4;
|
|
1505
1390
|
// Read section size
|
|
1506
|
-
const sectionSize = Number(
|
|
1391
|
+
const sectionSize = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 8, pointer)));
|
|
1507
1392
|
// If at header section (0x00000001 : Header Section).
|
|
1508
1393
|
if (sectionType === BigInt(1)) {
|
|
1509
1394
|
// Read info from header section.
|
|
@@ -1535,22 +1420,22 @@ const getR1CSInfo = (localR1CSFilePath) => {
|
|
|
1535
1420
|
*/
|
|
1536
1421
|
pointer += sectionSize - 20;
|
|
1537
1422
|
// Read R1CS info.
|
|
1538
|
-
wires = Number(
|
|
1423
|
+
wires = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, pointer)));
|
|
1539
1424
|
pointer += 4;
|
|
1540
|
-
publicOutputs = Number(
|
|
1425
|
+
publicOutputs = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, pointer)));
|
|
1541
1426
|
pointer += 4;
|
|
1542
|
-
publicInputs = Number(
|
|
1427
|
+
publicInputs = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, pointer)));
|
|
1543
1428
|
pointer += 4;
|
|
1544
|
-
privateInputs = Number(
|
|
1429
|
+
privateInputs = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, pointer)));
|
|
1545
1430
|
pointer += 4;
|
|
1546
|
-
labels = Number(
|
|
1431
|
+
labels = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 8, pointer)));
|
|
1547
1432
|
pointer += 8;
|
|
1548
|
-
constraints = Number(
|
|
1433
|
+
constraints = Number(leBufferToBigint(readBytesFromFile(localR1CSFilePath, 0, 4, pointer)));
|
|
1549
1434
|
}
|
|
1550
1435
|
pointer += 8 + Number(sectionSize);
|
|
1551
1436
|
}
|
|
1552
1437
|
return {
|
|
1553
|
-
curve: "bn-128",
|
|
1438
|
+
curve: "bn-128", /// @note currently default to bn-128 as we support only Groth16 proving system.
|
|
1554
1439
|
wires,
|
|
1555
1440
|
constraints,
|
|
1556
1441
|
privateInputs,
|
|
@@ -1565,11 +1450,212 @@ const getR1CSInfo = (localR1CSFilePath) => {
|
|
|
1565
1450
|
}
|
|
1566
1451
|
};
|
|
1567
1452
|
/**
|
|
1568
|
-
*
|
|
1569
|
-
* @
|
|
1570
|
-
* @
|
|
1453
|
+
* Parse and validate that the ceremony configuration is correct
|
|
1454
|
+
* @notice this does not upload any files to storage
|
|
1455
|
+
* @param path <string> - the path to the configuration file
|
|
1456
|
+
* @param cleanup <boolean> - whether to delete the r1cs file after parsing
|
|
1457
|
+
* @returns any - the data to pass to the cloud function for setup and the circuit artifacts
|
|
1571
1458
|
*/
|
|
1572
|
-
const
|
|
1459
|
+
const parseCeremonyFile = async (path, cleanup = false) => {
|
|
1460
|
+
// check that the path exists
|
|
1461
|
+
if (!fs.existsSync(path))
|
|
1462
|
+
throw new Error("The provided path to the configuration file does not exist. Please provide an absolute path and try again.");
|
|
1463
|
+
try {
|
|
1464
|
+
// read the data
|
|
1465
|
+
const data = JSON.parse(fs.readFileSync(path).toString());
|
|
1466
|
+
// verify that the data is correct
|
|
1467
|
+
if (data.timeoutMechanismType !== "DYNAMIC" /* CeremonyTimeoutType.DYNAMIC */ &&
|
|
1468
|
+
data.timeoutMechanismType !== "FIXED" /* CeremonyTimeoutType.FIXED */)
|
|
1469
|
+
throw new Error("Invalid timeout type. Please choose between DYNAMIC and FIXED.");
|
|
1470
|
+
// validate that we have at least 1 circuit input data
|
|
1471
|
+
if (!data.circuits || data.circuits.length === 0)
|
|
1472
|
+
throw new Error("You need to provide the data for at least 1 circuit.");
|
|
1473
|
+
// validate that the end date is in the future
|
|
1474
|
+
let endDate;
|
|
1475
|
+
let startDate;
|
|
1476
|
+
try {
|
|
1477
|
+
endDate = new Date(data.endDate);
|
|
1478
|
+
startDate = new Date(data.startDate);
|
|
1479
|
+
}
|
|
1480
|
+
catch (error) {
|
|
1481
|
+
throw new Error("The dates should follow this format: 2023-07-04T00:00:00.");
|
|
1482
|
+
}
|
|
1483
|
+
if (endDate <= startDate)
|
|
1484
|
+
throw new Error("The end date should be greater than the start date.");
|
|
1485
|
+
const currentDate = new Date();
|
|
1486
|
+
if (endDate <= currentDate || startDate <= currentDate)
|
|
1487
|
+
throw new Error("The start and end dates should be in the future.");
|
|
1488
|
+
// validate penalty
|
|
1489
|
+
if (data.penalty <= 0)
|
|
1490
|
+
throw new Error("The penalty should be greater than zero.");
|
|
1491
|
+
const circuits = [];
|
|
1492
|
+
const urlPattern = /(https?:\/\/[^\s]+)/g;
|
|
1493
|
+
const commitHashPattern = /^[a-f0-9]{40}$/i;
|
|
1494
|
+
const circuitArtifacts = [];
|
|
1495
|
+
for (let i = 0; i < data.circuits.length; i++) {
|
|
1496
|
+
const circuitData = data.circuits[i];
|
|
1497
|
+
const { artifacts } = circuitData;
|
|
1498
|
+
circuitArtifacts.push({
|
|
1499
|
+
artifacts
|
|
1500
|
+
});
|
|
1501
|
+
// where we storing the r1cs downloaded
|
|
1502
|
+
const localR1csPath = `./${circuitData.name}.r1cs`;
|
|
1503
|
+
// where we storing the wasm downloaded
|
|
1504
|
+
const localWasmPath = `./${circuitData.name}.wasm`;
|
|
1505
|
+
// download the r1cs to extract the metadata
|
|
1506
|
+
const streamPipeline = promisify(pipeline);
|
|
1507
|
+
// Check if r1cs file already exists
|
|
1508
|
+
let r1csExists = false;
|
|
1509
|
+
if (fs.existsSync(localR1csPath)) {
|
|
1510
|
+
console.log(`Found existing r1cs file for circuit ${circuitData.name}. Skipping download.`);
|
|
1511
|
+
r1csExists = true;
|
|
1512
|
+
}
|
|
1513
|
+
if (!r1csExists) {
|
|
1514
|
+
// Make the call to download r1cs.
|
|
1515
|
+
const responseR1CS = await fetch(artifacts.r1csStoragePath);
|
|
1516
|
+
// Handle errors.
|
|
1517
|
+
if (!responseR1CS.ok && responseR1CS.status !== 200)
|
|
1518
|
+
throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
|
|
1519
|
+
// Write the file locally
|
|
1520
|
+
await streamPipeline(responseR1CS.body, createWriteStream(localR1csPath));
|
|
1521
|
+
console.log(`Downloaded r1cs file for circuit ${circuitData.name}.`);
|
|
1522
|
+
}
|
|
1523
|
+
// extract the metadata from the r1cs
|
|
1524
|
+
const metadata = getR1CSInfo(localR1csPath);
|
|
1525
|
+
// Check if wasm file already exists
|
|
1526
|
+
let wasmExists = false;
|
|
1527
|
+
if (fs.existsSync(localWasmPath)) {
|
|
1528
|
+
console.log(`Found existing wasm file for circuit ${circuitData.name}. Skipping download.`);
|
|
1529
|
+
wasmExists = true;
|
|
1530
|
+
}
|
|
1531
|
+
if (!wasmExists) {
|
|
1532
|
+
// download wasm if it's not available
|
|
1533
|
+
const responseWASM = await fetch(artifacts.wasmStoragePath);
|
|
1534
|
+
if (!responseWASM.ok && responseWASM.status !== 200)
|
|
1535
|
+
throw new Error(`There was an error while trying to download the WASM file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
|
|
1536
|
+
await streamPipeline(responseWASM.body, createWriteStream(localWasmPath));
|
|
1537
|
+
console.log(`Downloaded wasm file for circuit ${circuitData.name}.`);
|
|
1538
|
+
}
|
|
1539
|
+
// validate that the circuit hash and template links are valid
|
|
1540
|
+
const { template } = circuitData;
|
|
1541
|
+
const URLMatch = template.source.match(urlPattern);
|
|
1542
|
+
if (!URLMatch || URLMatch.length === 0 || URLMatch.length > 1)
|
|
1543
|
+
throw new Error("You should provide the URL to the circuits templates on GitHub.");
|
|
1544
|
+
const hashMatch = template.commitHash.match(commitHashPattern);
|
|
1545
|
+
if (!hashMatch || hashMatch.length === 0 || hashMatch.length > 1)
|
|
1546
|
+
throw new Error("You should provide a valid commit hash of the circuit templates.");
|
|
1547
|
+
// calculate the hash of the r1cs file
|
|
1548
|
+
const r1csBlake2bHash = await blake512FromPath(localR1csPath);
|
|
1549
|
+
const circuitPrefix = extractPrefix(circuitData.name);
|
|
1550
|
+
// filenames
|
|
1551
|
+
const doubleDigitsPowers = convertToDoubleDigits(metadata.pot);
|
|
1552
|
+
const r1csCompleteFilename = `${circuitData.name}.r1cs`;
|
|
1553
|
+
const wasmCompleteFilename = `${circuitData.name}.wasm`;
|
|
1554
|
+
const smallestPowersOfTauCompleteFilenameForCircuit = `${potFilenameTemplate}${doubleDigitsPowers}.ptau`;
|
|
1555
|
+
const firstZkeyCompleteFilename = `${circuitPrefix}_${genesisZkeyIndex}.zkey`;
|
|
1556
|
+
// storage paths
|
|
1557
|
+
const r1csStorageFilePath = getR1csStorageFilePath(circuitPrefix, r1csCompleteFilename);
|
|
1558
|
+
const wasmStorageFilePath = getWasmStorageFilePath(circuitPrefix, wasmCompleteFilename);
|
|
1559
|
+
const potStorageFilePath = getPotStorageFilePath(smallestPowersOfTauCompleteFilenameForCircuit);
|
|
1560
|
+
const zkeyStorageFilePath = getZkeyStorageFilePath(circuitPrefix, firstZkeyCompleteFilename);
|
|
1561
|
+
const files = {
|
|
1562
|
+
potFilename: smallestPowersOfTauCompleteFilenameForCircuit,
|
|
1563
|
+
r1csFilename: r1csCompleteFilename,
|
|
1564
|
+
wasmFilename: wasmCompleteFilename,
|
|
1565
|
+
initialZkeyFilename: firstZkeyCompleteFilename,
|
|
1566
|
+
potStoragePath: potStorageFilePath,
|
|
1567
|
+
r1csStoragePath: r1csStorageFilePath,
|
|
1568
|
+
wasmStoragePath: wasmStorageFilePath,
|
|
1569
|
+
initialZkeyStoragePath: zkeyStorageFilePath,
|
|
1570
|
+
r1csBlake2bHash
|
|
1571
|
+
};
|
|
1572
|
+
// validate that the compiler hash is a valid hash
|
|
1573
|
+
const { compiler } = circuitData;
|
|
1574
|
+
const compilerHashMatch = compiler.commitHash.match(commitHashPattern);
|
|
1575
|
+
if (!compilerHashMatch || compilerHashMatch.length === 0 || compilerHashMatch.length > 1)
|
|
1576
|
+
throw new Error("You should provide a valid commit hash of the circuit compiler.");
|
|
1577
|
+
// validate that the verification options are valid
|
|
1578
|
+
const { verification } = circuitData;
|
|
1579
|
+
if (verification.cfOrVm !== "CF" && verification.cfOrVm !== "VM")
|
|
1580
|
+
throw new Error("Please enter a valid verification mechanism: either CF or VM");
|
|
1581
|
+
// @todo VM parameters verification
|
|
1582
|
+
// if (verification['cfOrVM'] === "VM") {}
|
|
1583
|
+
// check that the timeout is provided for the correct configuration
|
|
1584
|
+
let dynamicThreshold;
|
|
1585
|
+
let fixedTimeWindow;
|
|
1586
|
+
let circuit = {};
|
|
1587
|
+
if (data.timeoutMechanismType === "DYNAMIC" /* CeremonyTimeoutType.DYNAMIC */) {
|
|
1588
|
+
if (circuitData.dynamicThreshold <= 0)
|
|
1589
|
+
throw new Error("The dynamic threshold should be > 0.");
|
|
1590
|
+
dynamicThreshold = circuitData.dynamicThreshold;
|
|
1591
|
+
// the Circuit data for the ceremony setup
|
|
1592
|
+
circuit = {
|
|
1593
|
+
name: circuitData.name,
|
|
1594
|
+
description: circuitData.description,
|
|
1595
|
+
prefix: circuitPrefix,
|
|
1596
|
+
sequencePosition: i + 1,
|
|
1597
|
+
metadata,
|
|
1598
|
+
files,
|
|
1599
|
+
template,
|
|
1600
|
+
compiler,
|
|
1601
|
+
verification,
|
|
1602
|
+
dynamicThreshold,
|
|
1603
|
+
avgTimings: {
|
|
1604
|
+
contributionComputation: 0,
|
|
1605
|
+
fullContribution: 0,
|
|
1606
|
+
verifyCloudFunction: 0
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
if (data.timeoutMechanismType === "FIXED" /* CeremonyTimeoutType.FIXED */) {
|
|
1611
|
+
if (circuitData.fixedTimeWindow <= 0)
|
|
1612
|
+
throw new Error("The fixed time window threshold should be > 0.");
|
|
1613
|
+
fixedTimeWindow = circuitData.fixedTimeWindow;
|
|
1614
|
+
// the Circuit data for the ceremony setup
|
|
1615
|
+
circuit = {
|
|
1616
|
+
name: circuitData.name,
|
|
1617
|
+
description: circuitData.description,
|
|
1618
|
+
prefix: circuitPrefix,
|
|
1619
|
+
sequencePosition: i + 1,
|
|
1620
|
+
metadata,
|
|
1621
|
+
files,
|
|
1622
|
+
template,
|
|
1623
|
+
compiler,
|
|
1624
|
+
verification,
|
|
1625
|
+
fixedTimeWindow,
|
|
1626
|
+
avgTimings: {
|
|
1627
|
+
contributionComputation: 0,
|
|
1628
|
+
fullContribution: 0,
|
|
1629
|
+
verifyCloudFunction: 0
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
circuits.push(circuit);
|
|
1634
|
+
// remove the local r1cs and wasm downloads (if used for verifying the config only vs setup)
|
|
1635
|
+
if (cleanup) {
|
|
1636
|
+
fs.unlinkSync(localR1csPath);
|
|
1637
|
+
fs.unlinkSync(localWasmPath);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
const setupData = {
|
|
1641
|
+
ceremonyInputData: {
|
|
1642
|
+
title: data.title,
|
|
1643
|
+
description: data.description,
|
|
1644
|
+
startDate: startDate.valueOf(),
|
|
1645
|
+
endDate: endDate.valueOf(),
|
|
1646
|
+
timeoutMechanismType: data.timeoutMechanismType,
|
|
1647
|
+
penalty: data.penalty
|
|
1648
|
+
},
|
|
1649
|
+
ceremonyPrefix: extractPrefix(data.title),
|
|
1650
|
+
circuits,
|
|
1651
|
+
circuitArtifacts
|
|
1652
|
+
};
|
|
1653
|
+
return setupData;
|
|
1654
|
+
}
|
|
1655
|
+
catch (error) {
|
|
1656
|
+
throw new Error(`Error while parsing up the ceremony setup file. ${error.message}`);
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1573
1659
|
|
|
1574
1660
|
/**
|
|
1575
1661
|
* Verify that a zKey is valid
|
|
@@ -1818,7 +1904,7 @@ const getFirestoreDatabase = (app) => getFirestore(app);
|
|
|
1818
1904
|
* @param app <FirebaseApp> - the Firebase application.
|
|
1819
1905
|
* @returns <Functions> - the Cloud Functions associated to the application.
|
|
1820
1906
|
*/
|
|
1821
|
-
const getFirebaseFunctions = (app) => getFunctions(app,
|
|
1907
|
+
const getFirebaseFunctions = (app) => getFunctions(app, "europe-west1");
|
|
1822
1908
|
/**
|
|
1823
1909
|
* Retrieve the configuration variables for the AWS services (S3, EC2).
|
|
1824
1910
|
* @returns <AWSVariables> - the values of the AWS services configuration variables.
|
|
@@ -1827,14 +1913,14 @@ const getAWSVariables = () => {
|
|
|
1827
1913
|
if (!process.env.AWS_ACCESS_KEY_ID ||
|
|
1828
1914
|
!process.env.AWS_SECRET_ACCESS_KEY ||
|
|
1829
1915
|
!process.env.AWS_REGION ||
|
|
1830
|
-
!process.env.
|
|
1916
|
+
!process.env.AWS_INSTANCE_PROFILE_ARN ||
|
|
1831
1917
|
!process.env.AWS_AMI_ID)
|
|
1832
1918
|
throw new Error("Could not retrieve the AWS environment variables. Please, verify your environment configuration and retry");
|
|
1833
1919
|
return {
|
|
1834
1920
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
1835
1921
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
1836
1922
|
region: process.env.AWS_REGION || "us-east-1",
|
|
1837
|
-
|
|
1923
|
+
instanceProfileArn: process.env.AWS_INSTANCE_PROFILE_ARN,
|
|
1838
1924
|
amiId: process.env.AWS_AMI_ID
|
|
1839
1925
|
};
|
|
1840
1926
|
};
|
|
@@ -1915,11 +2001,11 @@ const p256 = (proofPart) => {
|
|
|
1915
2001
|
*/
|
|
1916
2002
|
const formatSolidityCalldata = (circuitInput, _proof) => {
|
|
1917
2003
|
try {
|
|
1918
|
-
const proof =
|
|
2004
|
+
const proof = unstringifyBigInts(_proof);
|
|
1919
2005
|
// format the public inputs to the circuit
|
|
1920
2006
|
const formattedCircuitInput = [];
|
|
1921
2007
|
for (const cInput of circuitInput) {
|
|
1922
|
-
formattedCircuitInput.push(p256(
|
|
2008
|
+
formattedCircuitInput.push(p256(unstringifyBigInts(cInput)));
|
|
1923
2009
|
}
|
|
1924
2010
|
// construct calldata
|
|
1925
2011
|
const calldata = {
|
|
@@ -2087,7 +2173,8 @@ const getGitHubStats = async (user) => {
|
|
|
2087
2173
|
following: jsonData.following,
|
|
2088
2174
|
followers: jsonData.followers,
|
|
2089
2175
|
publicRepos: jsonData.public_repos,
|
|
2090
|
-
avatarUrl: jsonData.avatar_url
|
|
2176
|
+
avatarUrl: jsonData.avatar_url,
|
|
2177
|
+
age: jsonData.created_at
|
|
2091
2178
|
};
|
|
2092
2179
|
return data;
|
|
2093
2180
|
};
|
|
@@ -2099,20 +2186,21 @@ const getGitHubStats = async (user) => {
|
|
|
2099
2186
|
* @param minimumAmountOfPublicRepos <number> The minimum amount of public repos the user should have
|
|
2100
2187
|
* @returns <any> Return the avatar URL of the user if the user is reputable, false otherwise
|
|
2101
2188
|
*/
|
|
2102
|
-
const githubReputation = async (userLogin, minimumAmountOfFollowing, minimumAmountOfFollowers, minimumAmountOfPublicRepos) => {
|
|
2189
|
+
const githubReputation = async (userLogin, minimumAmountOfFollowing, minimumAmountOfFollowers, minimumAmountOfPublicRepos, minimumAge) => {
|
|
2103
2190
|
if (!process.env.GITHUB_ACCESS_TOKEN)
|
|
2104
2191
|
throw new Error("The GitHub access token is missing. Please insert a valid token to be used for anti-sybil checks on user registation, and then try again.");
|
|
2105
|
-
const { following, followers, publicRepos, avatarUrl } = await getGitHubStats(userLogin);
|
|
2192
|
+
const { following, followers, publicRepos, avatarUrl, age } = await getGitHubStats(userLogin);
|
|
2106
2193
|
if (following < minimumAmountOfFollowing ||
|
|
2107
2194
|
publicRepos < minimumAmountOfPublicRepos ||
|
|
2108
|
-
followers < minimumAmountOfFollowers
|
|
2195
|
+
followers < minimumAmountOfFollowers ||
|
|
2196
|
+
new Date(age) > new Date(Date.now() - minimumAge))
|
|
2109
2197
|
return {
|
|
2110
2198
|
reputable: false,
|
|
2111
2199
|
avatarUrl: ""
|
|
2112
2200
|
};
|
|
2113
2201
|
return {
|
|
2114
2202
|
reputable: true,
|
|
2115
|
-
avatarUrl
|
|
2203
|
+
avatarUrl
|
|
2116
2204
|
};
|
|
2117
2205
|
};
|
|
2118
2206
|
|
|
@@ -2299,8 +2387,8 @@ const createSSMClient = async () => {
|
|
|
2299
2387
|
* @returns <Array<string>> - the list of startup commands to be executed.
|
|
2300
2388
|
*/
|
|
2301
2389
|
const vmBootstrapCommand = (bucketName) => [
|
|
2302
|
-
"#!/bin/bash",
|
|
2303
|
-
`aws s3 cp s3://${bucketName}/${vmBootstrapScriptFilename} ${vmBootstrapScriptFilename}`,
|
|
2390
|
+
"#!/bin/bash", // shabang.
|
|
2391
|
+
`aws s3 cp s3://${bucketName}/${vmBootstrapScriptFilename} ${vmBootstrapScriptFilename}`, // copy file from S3 bucket to VM.
|
|
2304
2392
|
`chmod +x ${vmBootstrapScriptFilename} && bash ${vmBootstrapScriptFilename}` // grant permission and execute.
|
|
2305
2393
|
];
|
|
2306
2394
|
/**
|
|
@@ -2321,8 +2409,13 @@ const vmDependenciesAndCacheArtifactsCommand = (zKeyPath, potPath, snsTopic, reg
|
|
|
2321
2409
|
// eslint-disable-next-line no-template-curly-in-string
|
|
2322
2410
|
"touch ${MARKER_FILE}",
|
|
2323
2411
|
"sudo yum update -y",
|
|
2324
|
-
"curl -
|
|
2325
|
-
"
|
|
2412
|
+
"curl -O https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.xz",
|
|
2413
|
+
"tar -xf node-v16.13.0-linux-x64.tar.xz",
|
|
2414
|
+
"mv node-v16.13.0-linux-x64 nodejs",
|
|
2415
|
+
"sudo mv nodejs /opt/",
|
|
2416
|
+
"echo 'export NODEJS_HOME=/opt/nodejs' >> /etc/profile",
|
|
2417
|
+
"echo 'export PATH=$NODEJS_HOME/bin:$PATH' >> /etc/profile",
|
|
2418
|
+
"source /etc/profile",
|
|
2326
2419
|
"npm install -g snarkjs",
|
|
2327
2420
|
`aws s3 cp s3://${zKeyPath} /var/tmp/genesisZkey.zkey`,
|
|
2328
2421
|
`aws s3 cp s3://${potPath} /var/tmp/pot.ptau`,
|
|
@@ -2341,6 +2434,7 @@ const vmDependenciesAndCacheArtifactsCommand = (zKeyPath, potPath, snsTopic, reg
|
|
|
2341
2434
|
* @returns Array<string> - the list of commands for contribution verification.
|
|
2342
2435
|
*/
|
|
2343
2436
|
const vmContributionVerificationCommand = (bucketName, lastZkeyStoragePath, verificationTranscriptStoragePathAndFilename) => [
|
|
2437
|
+
`source /etc/profile`,
|
|
2344
2438
|
`aws s3 cp s3://${bucketName}/${lastZkeyStoragePath} /var/tmp/lastZKey.zkey > /var/tmp/log.txt`,
|
|
2345
2439
|
`snarkjs zkvi /var/tmp/genesisZkey.zkey /var/tmp/pot.ptau /var/tmp/lastZKey.zkey > /var/tmp/verification_transcript.log`,
|
|
2346
2440
|
`aws s3 cp /var/tmp/verification_transcript.log s3://${bucketName}/${verificationTranscriptStoragePathAndFilename} &>/dev/null`,
|
|
@@ -2367,8 +2461,9 @@ const computeDiskSizeForVM = (zKeySizeInBytes, pot) => Math.ceil(2 * convertByte
|
|
|
2367
2461
|
*/
|
|
2368
2462
|
const createEC2Instance = async (ec2, commands, instanceType, volumeSize, diskType) => {
|
|
2369
2463
|
// Get the AWS variables.
|
|
2370
|
-
const { amiId,
|
|
2464
|
+
const { amiId, instanceProfileArn } = getAWSVariables();
|
|
2371
2465
|
// Parametrize the VM EC2 instance.
|
|
2466
|
+
console.log("\nLAUNCHING AWS EC2 INSTANCE\n");
|
|
2372
2467
|
const params = {
|
|
2373
2468
|
ImageId: amiId,
|
|
2374
2469
|
InstanceType: instanceType,
|
|
@@ -2376,7 +2471,7 @@ const createEC2Instance = async (ec2, commands, instanceType, volumeSize, diskTy
|
|
|
2376
2471
|
MinCount: 1,
|
|
2377
2472
|
// nb. to find this: iam -> roles -> role_name.
|
|
2378
2473
|
IamInstanceProfile: {
|
|
2379
|
-
Arn:
|
|
2474
|
+
Arn: instanceProfileArn
|
|
2380
2475
|
},
|
|
2381
2476
|
// nb. for running commands at the startup.
|
|
2382
2477
|
UserData: Buffer.from(commands.join("\n")).toString("base64"),
|
|
@@ -2385,7 +2480,7 @@ const createEC2Instance = async (ec2, commands, instanceType, volumeSize, diskTy
|
|
|
2385
2480
|
DeviceName: "/dev/xvda",
|
|
2386
2481
|
Ebs: {
|
|
2387
2482
|
DeleteOnTermination: true,
|
|
2388
|
-
VolumeSize: volumeSize,
|
|
2483
|
+
VolumeSize: volumeSize, // disk size in GB.
|
|
2389
2484
|
VolumeType: diskType
|
|
2390
2485
|
}
|
|
2391
2486
|
}
|
|
@@ -2402,6 +2497,19 @@ const createEC2Instance = async (ec2, commands, instanceType, volumeSize, diskTy
|
|
|
2402
2497
|
{
|
|
2403
2498
|
Key: "Initialized",
|
|
2404
2499
|
Value: "false"
|
|
2500
|
+
},
|
|
2501
|
+
{
|
|
2502
|
+
Key: "Project",
|
|
2503
|
+
Value: "trusted-setup"
|
|
2504
|
+
}
|
|
2505
|
+
]
|
|
2506
|
+
},
|
|
2507
|
+
{
|
|
2508
|
+
ResourceType: "volume",
|
|
2509
|
+
Tags: [
|
|
2510
|
+
{
|
|
2511
|
+
Key: "Project",
|
|
2512
|
+
Value: "trusted-setup"
|
|
2405
2513
|
}
|
|
2406
2514
|
]
|
|
2407
2515
|
}
|
|
@@ -2571,4 +2679,4 @@ const retrieveCommandStatus = async (ssm, instanceId, commandId) => {
|
|
|
2571
2679
|
}
|
|
2572
2680
|
};
|
|
2573
2681
|
|
|
2574
|
-
export { CeremonyState, CeremonyTimeoutType, CeremonyType, CircuitContributionVerificationMechanism, DiskTypeForVM, ParticipantContributionStep, ParticipantStatus, RequestType, TestingEnvironment, TimeoutType, autoGenerateEntropy, blake512FromPath, checkAndPrepareCoordinatorForFinalization, checkIfObjectExist, checkIfRunning, checkParticipantForCeremony, commonTerms, compareCeremonyArtifacts, compareHashes, compileContract, completeMultiPartUpload, computeDiskSizeForVM, computeSHA256ToHex, computeSmallestPowersOfTauForCircuit, convertBytesOrKbToGb, convertToDoubleDigits, createCustomLoggerForFile, createEC2Client, createEC2Instance, createS3Bucket, createSSMClient, downloadAllCeremonyArtifacts, downloadCeremonyArtifact, ec2InstanceTag, exportVerifierAndVKey, exportVerifierContract, exportVkey, extractPoTFromFilename, extractPrefix, extractR1CSInfoValueForGivenKey, finalContributionIndex, finalizeCeremony, finalizeCircuit, formatSolidityCalldata, formatZkeyIndex, fromQueryToFirebaseDocumentInfo, generateGROTH16Proof, generateGetObjectPreSignedUrl, generatePreSignedUrlsParts, generateValidContributionsAttestation, generateZkeyFromScratch, genesisZkeyIndex, getAllCollectionDocs, getBucketName, getCeremonyCircuits, getCircuitBySequencePosition, getCircuitContributionsFromContributor, getCircuitsCollectionPath, getClosedCeremonies, getContributionsCollectionPath, getContributionsValidityForContributor, getCurrentActiveParticipantTimeout, getCurrentFirebaseAuthUser, getDocumentById, getOpenedCeremonies, getParticipantsCollectionPath, getPotStorageFilePath, getPublicAttestationPreambleForContributor, getR1CSInfo, getR1csStorageFilePath, getTimeoutsCollectionPath, getTranscriptStorageFilePath, getVerificationKeyStorageFilePath, getVerifierContractStorageFilePath, getWasmStorageFilePath, getZkeyStorageFilePath, githubReputation, initializeFirebaseCoreServices, isCoordinator, multiPartUpload, numExpIterations, p256, parseCeremonyFile, permanentlyStoreCurrentContributionTimeAndHash, potFileDownloadMainUrl, potFilenameTemplate, powersOfTauFiles, progressToNextCircuitForContribution, progressToNextContributionStep, queryCollection, resumeContributionAfterTimeoutExpiration, retrieveCommandOutput, retrieveCommandStatus, runCommandUsingSSM, setupCeremony, signInToFirebaseWithCredentials, solidityVersion, startEC2Instance, stopEC2Instance, temporaryStoreCurrentContributionMultiPartUploadId, temporaryStoreCurrentContributionUploadedChunkData, terminateEC2Instance, toHex, verificationKeyAcronym, verifierSmartContractAcronym, verifyCeremony, verifyContribution, verifyGROTH16Proof, verifyGROTH16ProofOnChain, verifyZKey, vmBootstrapCommand, vmBootstrapScriptFilename, vmConfigurationTypes, vmContributionVerificationCommand, vmDependenciesAndCacheArtifactsCommand };
|
|
2682
|
+
export { CeremonyState, CeremonyTimeoutType, CeremonyType, CircuitContributionVerificationMechanism, DiskTypeForVM, ParticipantContributionStep, ParticipantStatus, RequestType, TestingEnvironment, TimeoutType, autoGenerateEntropy, blake512FromPath, checkAndPrepareCoordinatorForFinalization, checkIfObjectExist, checkIfRunning, checkParticipantForCeremony, commonTerms, compareCeremonyArtifacts, compareHashes, compileContract, completeMultiPartUpload, computeDiskSizeForVM, computeSHA256ToHex, computeSmallestPowersOfTauForCircuit, contribHashRegex, convertBytesOrKbToGb, convertToDoubleDigits, createCustomLoggerForFile, createEC2Client, createEC2Instance, createS3Bucket, createSSMClient, downloadAllCeremonyArtifacts, downloadCeremonyArtifact, ec2InstanceTag, exportVerifierAndVKey, exportVerifierContract, exportVkey, extractPoTFromFilename, extractPrefix, extractR1CSInfoValueForGivenKey, finalContributionIndex, finalizeCeremony, finalizeCircuit, formatSolidityCalldata, formatZkeyIndex, fromQueryToFirebaseDocumentInfo, generateGROTH16Proof, generateGetObjectPreSignedUrl, generatePreSignedUrlsParts, generateValidContributionsAttestation, generateZkeyFromScratch, genesisZkeyIndex, getAllCeremonies, getAllCollectionDocs, getBucketName, getCeremonyCircuits, getCircuitBySequencePosition, getCircuitContributionsFromContributor, getCircuitsCollectionPath, getClosedCeremonies, getContributionsCollectionPath, getContributionsValidityForContributor, getCurrentActiveParticipantTimeout, getCurrentFirebaseAuthUser, getDocumentById, getOpenedCeremonies, getParticipantsCollectionPath, getPotStorageFilePath, getPublicAttestationPreambleForContributor, getR1CSInfo, getR1csStorageFilePath, getTimeoutsCollectionPath, getTranscriptStorageFilePath, getVerificationKeyStorageFilePath, getVerifierContractStorageFilePath, getWasmStorageFilePath, getZkeyStorageFilePath, githubReputation, initializeFirebaseCoreServices, isCoordinator, multiPartUpload, numExpIterations, p256, parseCeremonyFile, permanentlyStoreCurrentContributionTimeAndHash, potFileDownloadMainUrl, potFilenameTemplate, powersOfTauFiles, progressToNextCircuitForContribution, progressToNextContributionStep, queryCollection, resumeContributionAfterTimeoutExpiration, retrieveCommandOutput, retrieveCommandStatus, runCommandUsingSSM, setupCeremony, signInToFirebaseWithCredentials, solidityVersion, startEC2Instance, stopEC2Instance, temporaryStoreCurrentContributionMultiPartUploadId, temporaryStoreCurrentContributionUploadedChunkData, terminateEC2Instance, toHex, verificationKeyAcronym, verifierSmartContractAcronym, verifyCeremony, verifyContribution, verifyGROTH16Proof, verifyGROTH16ProofOnChain, verifyZKey, vmBootstrapCommand, vmBootstrapScriptFilename, vmConfigurationTypes, vmContributionVerificationCommand, vmDependenciesAndCacheArtifactsCommand };
|