@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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -0
  3. package/dist/index.mjs +2608 -0
  4. package/dist/index.node.js +2714 -0
  5. package/dist/types/hardhat.config.d.ts +6 -0
  6. package/dist/types/hardhat.config.d.ts.map +1 -0
  7. package/dist/types/src/helpers/authentication.d.ts +21 -0
  8. package/dist/types/src/helpers/authentication.d.ts.map +1 -0
  9. package/dist/types/src/helpers/constants.d.ts +194 -0
  10. package/dist/types/src/helpers/constants.d.ts.map +1 -0
  11. package/dist/types/src/helpers/contracts.d.ts +57 -0
  12. package/dist/types/src/helpers/contracts.d.ts.map +1 -0
  13. package/dist/types/src/helpers/crypto.d.ts +27 -0
  14. package/dist/types/src/helpers/crypto.d.ts.map +1 -0
  15. package/dist/types/src/helpers/database.d.ts +105 -0
  16. package/dist/types/src/helpers/database.d.ts.map +1 -0
  17. package/dist/types/src/helpers/functions.d.ts +145 -0
  18. package/dist/types/src/helpers/functions.d.ts.map +1 -0
  19. package/dist/types/src/helpers/security.d.ts +10 -0
  20. package/dist/types/src/helpers/security.d.ts.map +1 -0
  21. package/dist/types/src/helpers/services.d.ts +38 -0
  22. package/dist/types/src/helpers/services.d.ts.map +1 -0
  23. package/dist/types/src/helpers/storage.d.ts +121 -0
  24. package/dist/types/src/helpers/storage.d.ts.map +1 -0
  25. package/dist/types/src/helpers/tasks.d.ts +2 -0
  26. package/dist/types/src/helpers/tasks.d.ts.map +1 -0
  27. package/dist/types/src/helpers/utils.d.ts +139 -0
  28. package/dist/types/src/helpers/utils.d.ts.map +1 -0
  29. package/dist/types/src/helpers/verification.d.ts +95 -0
  30. package/dist/types/src/helpers/verification.d.ts.map +1 -0
  31. package/dist/types/src/helpers/vm.d.ts +112 -0
  32. package/dist/types/src/helpers/vm.d.ts.map +1 -0
  33. package/dist/types/src/index.d.ts +15 -0
  34. package/dist/types/src/index.d.ts.map +1 -0
  35. package/dist/types/src/types/enums.d.ts +133 -0
  36. package/dist/types/src/types/enums.d.ts.map +1 -0
  37. package/dist/types/src/types/index.d.ts +603 -0
  38. package/dist/types/src/types/index.d.ts.map +1 -0
  39. package/package.json +87 -0
  40. package/src/helpers/authentication.ts +37 -0
  41. package/src/helpers/constants.ts +312 -0
  42. package/src/helpers/contracts.ts +268 -0
  43. package/src/helpers/crypto.ts +55 -0
  44. package/src/helpers/database.ts +221 -0
  45. package/src/helpers/functions.ts +438 -0
  46. package/src/helpers/security.ts +86 -0
  47. package/src/helpers/services.ts +83 -0
  48. package/src/helpers/storage.ts +329 -0
  49. package/src/helpers/tasks.ts +56 -0
  50. package/src/helpers/utils.ts +743 -0
  51. package/src/helpers/verification.ts +354 -0
  52. package/src/helpers/vm.ts +392 -0
  53. package/src/index.ts +162 -0
  54. package/src/types/enums.ts +141 -0
  55. package/src/types/index.ts +650 -0
@@ -0,0 +1,650 @@
1
+ import { FirebaseApp } from "firebase/app"
2
+ import { DocumentReference, DocumentData, Firestore } from "firebase/firestore"
3
+ import { Functions } from "firebase/functions"
4
+ import {
5
+ CeremonyState,
6
+ CeremonyTimeoutType,
7
+ CeremonyType,
8
+ CircuitContributionVerificationMechanism,
9
+ DiskTypeForVM,
10
+ ParticipantContributionStep,
11
+ ParticipantStatus
12
+ } from "./enums.js"
13
+
14
+ /**
15
+ * A shared type that groups all the AWS services variables.
16
+ * @typedef {Object} AWSVariables
17
+ * @property {string} accessKeyId - the key identifier related to S3 APIs.
18
+ * @property {string} secretAccessKey - the secret access key related to S3 APIs.
19
+ * @property {string} region - the region where your buckets are located.
20
+ * @property {string} roleArn - the EC2 instance role to access S3.
21
+ * @property {string} amiId - the AWS AMI ID (default to Amazon Linux 2).
22
+ */
23
+ export type AWSVariables = {
24
+ accessKeyId: string
25
+ secretAccessKey: string
26
+ region: string
27
+ roleArn: string
28
+ amiId: string
29
+ }
30
+
31
+ /**
32
+ * A shared type that groups all the Firebase services used in the application context.
33
+ * @typedef {Object} FirebaseServices
34
+ * @property {FirebaseApp} firebaseApp - the instance of the Firebase application.
35
+ * @property {Firestore} firestoreDatabase - the instance of the Firestore database in use for the application.
36
+ * @property {Functions} firebaseFunctions - the instance of the Cloud Functions in use for the application.
37
+ */
38
+ export type FirebaseServices = {
39
+ firebaseApp: FirebaseApp
40
+ firestoreDatabase: Firestore
41
+ firebaseFunctions: Functions
42
+ }
43
+
44
+ /**
45
+ * Useful for interacting with reference and data from a Firestore document at the same time.
46
+ * @typedef {Object} FirebaseDocumentInfo
47
+ * @property {string} id - the unique identifier of the Firestore document.
48
+ * @property {DocumentReference<DocumentData>} ref - the Firestore reference for the document (useful for queries).
49
+ * @property {DocumentData} data - the Firestore document whole data.
50
+ */
51
+ export type FirebaseDocumentInfo = {
52
+ id: string
53
+ ref: DocumentReference<DocumentData>
54
+ data: DocumentData
55
+ }
56
+
57
+ /**
58
+ * Define a custom file data chunk associated with a pre-signed url.
59
+ * @dev Useful when interacting with AWS S3 buckets using pre-signed urls for multi-part upload or download storing temporary information on the database.
60
+ * @typedef {Object} ChunkWithUrl
61
+ * @property {number} partNumber - indicate where the chunk is positioned in order to reconhstruct the file with multiPartUpload/Download.
62
+ * @property {Buffer} chunk - the piece of information in bytes.
63
+ * @property {string} preSignedUrl - the unique reference to the pre-signed url to which this chunk is linked too.
64
+ */
65
+ export type ChunkWithUrl = {
66
+ partNumber: number
67
+ chunk: Buffer
68
+ preSignedUrl: string
69
+ }
70
+
71
+ /**
72
+ * Group a pre-signed url chunk core information.
73
+ * @typedef {Object} ETagWithPartNumber
74
+ * @property {string | null} ETag - a unique reference to this chunk associated to a pre-signed url.
75
+ * @property {number} PartNumber - indicate where the chunk is positioned in order to reconhstruct the file with multiPartUpload/Download.
76
+ */
77
+ export type ETagWithPartNumber = {
78
+ ETag: string | undefined
79
+ PartNumber: number
80
+ }
81
+
82
+ /**
83
+ * Group the information when retrieving the validity of a contribution for a contributor.
84
+ * @typedef {Object} ContributionValidity
85
+ * @property {string} contributionId - the unique identifier of the contribution.
86
+ * @property {string} circuitId - the unique identifier of the circuit for which the contribution was computed.
87
+ * @property {boolean} valid - true if and only if the contribution is valid; otherwise false.
88
+ */
89
+ export type ContributionValidity = {
90
+ contributionId: string
91
+ circuitId: string
92
+ valid: boolean
93
+ }
94
+
95
+ /**
96
+ * Necessary data to define a user database document.
97
+ * @typedef {Object} UserDocument
98
+ * @property {string} name - the name of the user.
99
+ * @property {string | undefined} displayName - the public (visible) name of the user.
100
+ * @property {number} creationTime - the timestamp when the document has been created.
101
+ * @property {number} lastSignInTime - the timestamp when the user has been authenticated for the last time.
102
+ * @property {number} lastUpdated - the timestamp where the last update of the Firestore document has happened.
103
+ * @property {string} email - the email of the user.
104
+ * @property {boolean} emailVerified - true when the email of the user has been verified; otherwise false.
105
+ * @property {string | undefined} photoURL - the external url of the profile photo of the user.
106
+ */
107
+ export type UserDocument = {
108
+ name: string
109
+ displayName: string | undefined
110
+ creationTime: number
111
+ lastSignInTime: number
112
+ lastUpdated: number
113
+ email: string
114
+ emailVerified: boolean
115
+ photoURL: string | undefined
116
+ }
117
+
118
+ /**
119
+ * Groups all the information received as input from the coordinator when creating a ceremony.
120
+ * @typedef {Object} CeremonyInputData
121
+ * @property {string} title - the title/name of the ceremony.
122
+ * @property {string} description - a brief description of the ceremony.
123
+ * @property {number} startDate - the start (opening to contributions) date for the ceremony (in ms).
124
+ * @property {number} endDate - the end (closing to contributions) date for the ceremony (in ms).
125
+ * @property {CeremonyTimeoutType} timeoutMechanismType - the timeout mechanism type used for avoiding blocking contribution behaviours.
126
+ * @property {number} penalty - the amount of time expressed in minutes that the blocking contributor has to wait before joining the waiting queue again.
127
+ */
128
+ export type CeremonyInputData = {
129
+ title: string
130
+ description: string
131
+ startDate: number
132
+ endDate: number
133
+ timeoutMechanismType: CeremonyTimeoutType
134
+ penalty: number
135
+ }
136
+
137
+ /**
138
+ * Group information about the version of the Circom compiler used for the ceremony circuits.
139
+ * @typedef {Object} CircomCompilerData
140
+ * @property {string} version - the version of the Circom compiler.
141
+ * @property {string} commitHash - the commit hash of the version of the Circom compiler.
142
+ */
143
+ export type CircomCompilerData = {
144
+ version: string
145
+ commitHash: string
146
+ }
147
+
148
+ /**
149
+ * Group information about the Circom circuit template used for the ceremony circuits.
150
+ * @dev we are assuming that the circuit template have been published to a public repository (as Github).
151
+ * @typedef {Object} SourceTemplateData
152
+ * @property {string} source - the external link where the circuit template has been published.
153
+ * @property {string} commitHash - the commit hash of the version of the circuit template.
154
+ * @property {Array<string>} paramsConfiguration - the list of parameter values used to configure the circuit template (if any).
155
+ */
156
+ export type SourceTemplateData = {
157
+ source: string
158
+ commitHash: string
159
+ paramsConfiguration: Array<string>
160
+ }
161
+
162
+ /**
163
+ * The references about the artifacts produced during the compilation of the ceremony circuit.
164
+ * @typedef {Object} CompilationArtifacts
165
+ * @property {string} r1csFilename - the name of the R1CS file.
166
+ * @property {string} wasmFilename - the name of the WASM file.
167
+ */
168
+ export type CompilationArtifacts = {
169
+ r1csFilename: string
170
+ wasmFilename: string
171
+ }
172
+
173
+ /**
174
+ * Group information about the VM configuration for circuit contribution verification.
175
+ * @dev the coordinator could choose among CF and VM.
176
+ * @notice the VM configurations could be retrieved at https://aws.amazon.com/ec2/instance-types/.
177
+ * @typedef {Object} VMConfiguration
178
+ * @property {string} [vmConfigurationType] - the VM configuration type.
179
+ * @property {string} [vmDiskType] - the VM volume type (e.g., gp2)
180
+ * @property {number} [vmDiskSize] - the VM disk size in GB.
181
+ * @property {string} [vmInstanceId] - the VM instance identifier (after VM instantiation).
182
+ */
183
+ export type VMConfiguration = {
184
+ vmConfigurationType?: string
185
+ vmDiskType?: DiskTypeForVM
186
+ vmDiskSize?: number
187
+ vmInstanceId?: string
188
+ }
189
+
190
+ /**
191
+ * Group information about the circuit contribution verification mechanism.
192
+ * @typedef {Object} CircuitContributionVerification
193
+ * @property {CircuitContributionVerificationMechanism} cfOrVm - the mechanism choosen by the coordinator.
194
+ * @property {VMConfiguration} [vm] - the VM configuration specs.
195
+ */
196
+ export type CircuitContributionVerification = {
197
+ cfOrVm: CircuitContributionVerificationMechanism
198
+ vm?: VMConfiguration
199
+ }
200
+
201
+ /**
202
+ * Group input data for defining a ceremony circuit.
203
+ * @dev The data is both entered by the coordinator and derived.
204
+ * @typedef {Object} CircuitInputData
205
+ * @property {string} description - a short description for the circuit.
206
+ * @property {CircomCompilerData} compiler - the info about the Circom compiler used to compile the circuit template.
207
+ * @property {SourceTemplateData} template - the info about the circuit template.
208
+ * @property {CircuitContributionVerification} verification - the info about the circuit contribution verification mechanism.
209
+ * @property {CompilationArtifacts} compilationArtifacts - the references about the circuit compilation artifacts.
210
+ * @property {CircuitMetadata} [metadata] - the info about the R1CS file.
211
+ * @property {string} [name] - the name of the circuit.
212
+ * @property {number} [dynamicThreshold] - the dynamic timeout threshold expressed in percentage.
213
+ * @property {number} [fixedTimeWindow] - the amount of fixed max contribution time which can be spent while contributing before the timeout can be triggered.
214
+ * @property {number} [sequencePosition] - the position which define the order of contributions in the ceremony.
215
+ * @property {string} [prefix] - the prefix of the circuit derived from the name.
216
+ * @property {number} [zKeySizeInBytes] - the size of the related zKey expressed in bytes.
217
+ */
218
+ export type CircuitInputData = {
219
+ description: string
220
+ compiler: CircomCompilerData
221
+ template: SourceTemplateData
222
+ verification: CircuitContributionVerification
223
+ compilationArtifacts?: CompilationArtifacts
224
+ metadata?: CircuitMetadata
225
+ name?: string
226
+ dynamicThreshold?: number
227
+ fixedTimeWindow?: number
228
+ sequencePosition?: number
229
+ prefix?: string
230
+ zKeySizeInBytes?: number
231
+ }
232
+
233
+ /**
234
+ * Necessary data to define a ceremony database document.
235
+ * @dev The data is both entered by the coordinator and derived.
236
+ * @typedef {Object} CeremonyDocument
237
+ * @property {string} prefix - the prefix of the ceremony derived from the name.
238
+ * @property {CeremonyState} state - the current state of the ceremony.
239
+ * @property {CeremonyType} type - the type of the ceremony.
240
+ * @property {string} coordinatorId - the unique identifier of the coordinator.
241
+ * @property {number} lastUpdated - the timestamp where the last update of the Firestore document has happened.
242
+ */
243
+ export type CeremonyDocument = CeremonyInputData & {
244
+ prefix: string
245
+ state: CeremonyState
246
+ type: CeremonyType
247
+ coordinatorId: string
248
+ lastUpdated: number
249
+ }
250
+
251
+ /**
252
+ * Data defining a contribution made by a participant.
253
+ * @typedef {Object} Contribution
254
+ * @property {string} doc - the unique identifier of the document related to the contribution.
255
+ * @property {number} computationTime - the overall time spent while computing the contribution.
256
+ * @property {string} hash - the contribution hash (generated as output from the snarkjs command).
257
+ */
258
+ export type Contribution = {
259
+ doc: string
260
+ computationTime: number
261
+ hash: string
262
+ }
263
+
264
+ /**
265
+ * Auxiliary data needed for resumption in an intermediate step of contribution.
266
+ * @dev The data is used when the current contributorinterrupts during the download, contribute, upload steps
267
+ * to prevent it from having to start over but can pick up where it left off.
268
+ * This restart operation does NOT interact with the timeout mechanism (which remains unchanged).
269
+ * @typedef {Object} TemporaryParticipantContributionData
270
+ * @property {number} contributionComputationTime - the time spent since the contribution start.
271
+ * @property {string} uploadId - the unique identifier of the pre-signed url PUT request to upload the newest contribution.
272
+ * @property {Array<ETagWithPartNumber>} chunks - the list of ETags and PartNumbers that make up the chunks.
273
+ */
274
+ export type TemporaryParticipantContributionData = {
275
+ contributionComputationTime: number
276
+ uploadId: string
277
+ chunks: Array<ETagWithPartNumber>
278
+ }
279
+
280
+ /**
281
+ * Necessary data to define a participant database document.
282
+ * @typedef {Object} ParticipantDocument
283
+ * @property {string} userId - the unique identifier of the user associated with the participant.
284
+ * @property {number} contributionProgress - indicates the number of the circuit for which the user has to wait in the queue.
285
+ * @property {ParticipantStatus} status - the current status of the participant.
286
+ * @property {Array<Contribution>} contributions - the list of references to the contributions computed by the participant.
287
+ * @property {number} lastUpdated - the timestamp where the last update of the Firestore document has happened.
288
+ * @property {number} [contributionStartedAt] - the timestamp of when the latest contribution has started.
289
+ * @property {number} [verificationStartedAt] - the timestamp of when the latest verification process has started.
290
+ * @property {TemporaryParticipantContributionData} [tempContributionData] - the auxiliary data needed for resumption in an intermediate step of contribution.
291
+ */
292
+ export type ParticipantDocument = {
293
+ userId: string
294
+ contributionProgress: number
295
+ status: ParticipantStatus
296
+ contributions: Array<Contribution>
297
+ lastUpdated: number
298
+ contributionStartedAt: number
299
+ contributionStep?: ParticipantContributionStep
300
+ verificationStartedAt?: number
301
+ tempContributionData?: TemporaryParticipantContributionData
302
+ }
303
+
304
+ /**
305
+ * The metadata of a Groth16 circuit.
306
+ * @dev The data is derived by reading the R1CS file.
307
+ * @typedef {Object} CircuitMetadata
308
+ * @property {string} curve - the curve used by the proving system for circuit construction.
309
+ * @property {number} wires - the circuit amount of wires among field/gates.
310
+ * @property {number} constraints - the amount of constraints (= the size of the circuit).
311
+ * @property {number} privateInputs - the amount of private inputs (derived from constraints).
312
+ * @property {number} publicInputs - the amount of public inputs (derived from constraints).
313
+ * @property {number} labels - the amount of labels.
314
+ * @property {number} outputs - the amount of outputs.
315
+ * @property {number} pot - the smallest amount of powers needed to work with the circuit (Powers of Tau from Phase 1 setup).
316
+ */
317
+ export type CircuitMetadata = {
318
+ curve: string
319
+ wires: number
320
+ constraints: number
321
+ privateInputs: number
322
+ publicInputs: number
323
+ labels: number
324
+ outputs: number
325
+ pot: number
326
+ }
327
+
328
+ /**
329
+ * The references about the artifacts produced during the ceremony for a circuit.
330
+ * @dev The references are related to the storage solution used where the files are stored (currently AWS S3).
331
+ * @typedef {Object} CircuitArtifacts
332
+ * @property {string} potFilename - the name of the Powers of Tau file.
333
+ * @property {string} r1csFilename - the name of the R1CS file.
334
+ * @property {string} wasmFilename - the name of the WASM file.
335
+ * @property {string} initialZkeyFilename - the name of the initial (= genesis) zKey file.
336
+ * @property {string} potStoragePath - the storage path of the Powers of Tau file.
337
+ * @property {string} r1csStoragePath - the storage path of the R1CS file.
338
+ * @property {string} wasmStoragePath - the storage path of the WASM file.
339
+ * @property {string} initialZkeyStoragePath - the storage path of the initial (= genesis) zKey file.
340
+ * @property {string} potBlake2bHash - the blake2b hash of the Powers of Tau file.
341
+ * @property {string} r1csBlake2bHash - the blake2b hash of the R1CS file.
342
+ * @property {string} wasmBlake2bHash - the blake2b hash of the WASM file.
343
+ * @property {string} initialZkeyBlake2bHash - the blake2b hash of the initial (= genesis) zKey file.
344
+ */
345
+ export type CircuitArtifacts = {
346
+ potFilename: string
347
+ r1csFilename: string
348
+ wasmFilename: string
349
+ initialZkeyFilename: string
350
+ potStoragePath: string
351
+ r1csStoragePath: string
352
+ wasmStoragePath: string
353
+ initialZkeyStoragePath: string
354
+ potBlake2bHash: string
355
+ r1csBlake2bHash: string
356
+ wasmBlake2bHash: string
357
+ initialZkeyBlake2bHash: string
358
+ }
359
+
360
+ /**
361
+ * The references about the average time spent by contributors on the circuit.
362
+ * @typedef {Object} CircuitTimings
363
+ * @property {number} contributionComputation - the average amount of time spent for contribution computation only.
364
+ * @property {number} fullContribution - the average amount of time spent for the whole contribution.
365
+ * @property {number} verifyCloudFunction - the average amount of time spent for verification of contribution only.
366
+ */
367
+ export type CircuitTimings = {
368
+ contributionComputation: number
369
+ fullContribution: number
370
+ verifyCloudFunction: number
371
+ }
372
+
373
+ /**
374
+ * The information to handle the queue for circuit contributions.
375
+ * @typedef {Object} CircuitWaitingQueue
376
+ * @property {number} completedContributions - the total amount of completed contributions.
377
+ * @property {Array<string>} contributors - the list of unique identifiers of the participants waiting for contributing.
378
+ * @property {string} currentContributor - the unique identifier of the participant who is currently contributing.
379
+ * @property {number} failedContributions - the total amount of failed contributions.
380
+ */
381
+ export type CircuitWaitingQueue = {
382
+ completedContributions: number
383
+ contributors: Array<string>
384
+ currentContributor: string
385
+ failedContributions: number
386
+ }
387
+
388
+ /**
389
+ * Necessary data to define a circuit database document.
390
+ * @typedef {Object} CircuitDocument
391
+ * @property {CircuitMetadata} metadata - the info about the circuit metadata.
392
+ * @property {CircuitArtifacts} [files] - the references about the circuit artifacts.
393
+ * @property {CircuitTimings} [avgTimings] - the info about the average timings for the circuit.
394
+ * @property {SourceTemplateData} [template] - the info about the circuit template.
395
+ * @property {CircomCompilerData} [compiler] - the info about the circom compiler.
396
+ * @property {CircuitWaitingQueue} [waitingQueue] - the info about the circuit waiting queue.
397
+ * @property {number} [lastUpdated] - the timestamp where the last update of the Firestore document has happened.
398
+ */
399
+ export type CircuitDocument = CircuitInputData & {
400
+ metadata?: CircuitMetadata
401
+ files?: CircuitArtifacts
402
+ avgTimings?: CircuitTimings
403
+ template?: SourceTemplateData
404
+ compiler?: CircomCompilerData
405
+ waitingQueue?: CircuitWaitingQueue
406
+ lastUpdated?: number
407
+ }
408
+
409
+ /**
410
+ * The references about the artifacts produced during the contribution (either final or not) to a ceremony circuit.
411
+ * @dev The references are related to the storage solution used where the files are stored (currently AWS S3).
412
+ * @typedef {Object} ContributionFiles
413
+ * @property {string} transcriptFilename - the name of the transcript file.
414
+ * @property {string} lastZkeyFilename - the name of the contribution (zKey) file.
415
+ * @property {string} transcriptStoragePath - the storage path of the transcript file.
416
+ * @property {string} lastZkeyStoragePath - the storage path of the contribution (zKey) file.
417
+ * @property {string} transcriptBlake2bHash - the blake2b hash of the transcript file.
418
+ * @property {string} lastZkeyBlake2bHash - the blake2b hash of the contribution (zKey) file.
419
+ * @property {string} [verificationKeyBlake2bHash] - the blake2b hash of the verification key file (final contribution only).
420
+ * @property {string} [verificationKeyFilename] - the name of the verification key file (final contribution only).
421
+ * @property {string} [verificationKeyStoragePath] - the storage path of the verification key file (final contribution only).
422
+ * @property {string} [verifierContractBlake2bHash] - the blake2b hash of the verifier smart contract file (final contribution only).
423
+ * @property {string} [verifierContractFilename] - the name of the verifier smart contract file (final contribution only).
424
+ * @property {string} [verifierContractStoragePath] - the storage path of the verifier smart contract file (final contribution only).
425
+ */
426
+ export type ContributionFiles = {
427
+ transcriptFilename: string
428
+ lastZkeyFilename: string
429
+ transcriptStoragePath: string
430
+ lastZkeyStoragePath: string
431
+ transcriptBlake2bHash: string
432
+ lastZkeyBlake2bHash: string
433
+ verificationKeyBlake2bHash?: string
434
+ verificationKeyFilename?: string
435
+ verificationKeyStoragePath?: string
436
+ verifierContractBlake2bHash?: string
437
+ verifierContractFilename?: string
438
+ verifierContractStoragePath?: string
439
+ }
440
+
441
+ /**
442
+ * Group information about the version of the verification software used for contribution verification.
443
+ * @typedef {Object} ContributionVerificationSoftware
444
+ * @property {string} name - the name of the verification software.
445
+ * @property {string} version - the version of the verification software.
446
+ * @property {string} commitHash - the commit hash of the version of the verification software.
447
+ */
448
+ export type ContributionVerificationSoftware = {
449
+ name: string
450
+ version: string
451
+ commitHash: string
452
+ }
453
+
454
+ /**
455
+ * Group information about the value (beacon) used to compute the final contribution while finalizing the ceremony.
456
+ * @typedef {Object} BeaconInfo
457
+ * @property {string} value - the value of the beacon.
458
+ * @property {string} hash - the SHA 256 hash of the beacon.
459
+ */
460
+ export type BeaconInfo = {
461
+ value: string
462
+ hash: string
463
+ }
464
+
465
+ /**
466
+ * Necessary data to define a contribution document.
467
+ * @typedef {Object} ContributionDocument
468
+ * @property {string} participantId - the unique identifier of the contributor.
469
+ * @property {number} contributionComputationTime - the amount of time spent for the contribution (download, compute, upload).
470
+ * @property {number} verificationComputationTime - the amount of time spent for the verification of the contribution.
471
+ * @property {string} zkeyIndex - the index of the contribution.
472
+ * @property {ContributionFiles} files - the references and hashes of the artifacts produced during the contribution (and verification).
473
+ * @property {ContributionVerificationSoftware} verificationSoftware - the info about the verification software used to verify the contributions.
474
+ * @property {boolean} valid - true if the contribution has been evaluated as valid; otherwise false.
475
+ * @property {number} lastUpdated - the timestamp where the last update of the Firestore document has happened.
476
+ * @property {BeaconInfo} beacon - the data about the value used to compute the final contribution while finalizing the ceremony (final contribution only).
477
+ */
478
+ export type ContributionDocument = {
479
+ participantId: string
480
+ contributionComputationTime: number
481
+ verificationComputationTime: number
482
+ zkeyIndex: string
483
+ files: ContributionFiles
484
+ verificationSoftware: ContributionVerificationSoftware
485
+ valid: boolean
486
+ lastUpdated: number
487
+ beacon?: BeaconInfo
488
+ }
489
+
490
+ /**
491
+ * Define a circuit document reference and data.
492
+ * @dev must be used for generating fake/mock documents when testing.
493
+ * @typedef {Object} CircuitDocumentReferenceAndData
494
+ * @property {string} uid - the unique identifier of the document.
495
+ * @property {CircuitDocument} doc - the info about the circuit document.
496
+ */
497
+ export type CircuitDocumentReferenceAndData = {
498
+ uid: string
499
+ data: CircuitDocument
500
+ }
501
+
502
+ /**
503
+ * Define a user document reference and data.
504
+ * @dev must be used for generating fake/mock documents when testing.
505
+ * @typedef {Object} UserDocumentReferenceAndData
506
+ * @property {string} uid - the unique identifier of the document.
507
+ * @property {UserDocument} doc - the info about the user document.
508
+ */
509
+ export type UserDocumentReferenceAndData = {
510
+ uid: string
511
+ data: UserDocument
512
+ }
513
+
514
+ /**
515
+ * Define a ceremony document reference and data.
516
+ * @dev must be used for generating fake/mock documents when testing.
517
+ * @typedef {Object} CeremonyDocumentReferenceAndData
518
+ * @property {string} uid - the unique identifier of the document.
519
+ * @property {CeremonyDocument} doc - the info about the user document.
520
+ */
521
+ export type CeremonyDocumentReferenceAndData = {
522
+ uid: string
523
+ data: CeremonyDocument
524
+ }
525
+
526
+ /**
527
+ * Define a participant document reference and data.
528
+ * @dev must be used for generating fake/mock documents when testing.
529
+ * @typedef {Object} ParticipantDocumentReferenceAndData
530
+ * @property {string} uid - the unique identifier of the document.
531
+ * @property {ParticipantDocument} doc - the info about the user document.
532
+ */
533
+ export type ParticipantDocumentReferenceAndData = {
534
+ uid: string
535
+ data: ParticipantDocument
536
+ }
537
+
538
+ /**
539
+ * Define a ceremony artifacts with their local paths.
540
+ * @typedef {Object} CeremonyArtifacts
541
+ * @property {string} circuitPrefix - the prefix of the circuit.
542
+ * @property {string} circuitId - the unique identifier of the circuit.
543
+ * @property {string} directoryRoot - the root directory of the ceremony.
544
+ * @property {string} potLocalFilePath - the local path of the pot file.
545
+ * @property {string} r1csLocalFilePath - the local path of the r1cs file.
546
+ * @property {string} finalZkeyLocalFilePath - the local path of the final zKey file.
547
+ * @property {string} lastZkeyLocalFilePath - the local path of the last zKey file.
548
+ * @property {string} verifierLocalFilePath - the local path of the verifier file.
549
+ * @property {string} verificationKeyLocalFilePath - the local path of the verification key file.
550
+ * @property {string} wasmLocalFilePath - the local path of the wasm file.
551
+ * @dev must be used for generating fake/mock documents when testing.
552
+ */
553
+ export type CeremonyArtifacts = {
554
+ circuitPrefix: string
555
+ circuitId: string
556
+ directoryRoot: string
557
+ potLocalFilePath: string
558
+ r1csLocalFilePath: string
559
+ finalZkeyLocalFilePath: string
560
+ lastZkeyLocalFilePath: string
561
+ verifierLocalFilePath: string
562
+ verificationKeyLocalFilePath: string
563
+ wasmLocalFilePath: string
564
+ }
565
+
566
+ /**
567
+ * Define a contribution document reference and data.
568
+ * @dev must be used for generating fake/mock documents when testing.
569
+ * @typedef {Object} ContributionDocumentReferenceAndData
570
+ * @property {string} uid - the unique identifier of the document.
571
+ * @property {ContributionDocument} doc - the info about the contribution document.
572
+ */
573
+ export type ContributionDocumentReferenceAndData = {
574
+ uid: string
575
+ data: ContributionDocument
576
+ }
577
+
578
+ /**
579
+ * Group the details for a VM EC2 instance.
580
+ * @typedef {Object} EC2Instance
581
+ * @property {string} instanceId - the unique identifier of the VM.
582
+ * @property {string} imageId - the unique identifier of the image.
583
+ * @property {string} instanceType - the VM type.
584
+ * @property {string} keyName - the name of the key.
585
+ * @property {string} launchTime - the timestamp of the launch of the VM.
586
+ */
587
+ export type EC2Instance = {
588
+ instanceId: string
589
+ imageId: string
590
+ instanceType: string
591
+ keyName: string
592
+ launchTime: string
593
+ }
594
+
595
+ /**
596
+ * Group the information of a Virtual Machine configuration type.
597
+ * @typedef {Object} VMConfigurationType
598
+ * @property {string} type - the name of the instance type (e.g., t3.small).
599
+ * @property {string} ram - the amount of RAM.
600
+ * @property {string} vcpu - the number of VCPUs.
601
+ */
602
+ export type VMConfigurationType = {
603
+ type: string
604
+ ram: number
605
+ vcpu: number
606
+ }
607
+
608
+ /**
609
+ * Group the information required to setup a new ceremony
610
+ * @typedef {Object} SetupCeremonyData
611
+ * @property {CeremonyInputData} - the details of the ceremony
612
+ * @property {string} - the ceremony prefix
613
+ * @property {Array<CircuitDocument>} - the details of the circuits
614
+ * @property {Array<CeremonyArtifacts>} - the details of the ceremony artifacts
615
+ */
616
+ export type SetupCeremonyData = {
617
+ ceremonyInputData: CeremonyInputData
618
+ ceremonyPrefix: string
619
+ circuits: Array<CircuitDocument>
620
+ circuitArtifacts: Array<CeremonySetupTemplateCircuitArtifacts>
621
+ }
622
+
623
+
624
+ export type CeremonySetupTemplateCircuitArtifacts = {
625
+ artifacts: {
626
+ bucket: string
627
+ region: string
628
+ r1csStoragePath: string
629
+ wasmStoragePath: string
630
+ }
631
+ }
632
+
633
+ export type CeremonySetupTemplateCircuitTimeout = {
634
+ dynamicThreshold: number
635
+ fixedTimeWindow: number
636
+ }
637
+
638
+ export type CeremonySetupTemplateCircuitName = {
639
+ name: string
640
+ }
641
+
642
+ export type CeremonySetupTemplate = {
643
+ title: string
644
+ description: string
645
+ startDate: string
646
+ endDate: string
647
+ timeoutMechanismType: CeremonyTimeoutType
648
+ penalty: number
649
+ circuits: Array<CircuitDocument & CeremonySetupTemplateCircuitArtifacts & CeremonySetupTemplateCircuitTimeout & CeremonySetupTemplateCircuitName>
650
+ }