@devtion/actions 0.0.0-3df1645 → 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.
Files changed (51) hide show
  1. package/README.md +2 -2
  2. package/dist/index.mjs +353 -262
  3. package/dist/index.node.js +354 -261
  4. package/dist/types/src/helpers/authentication.d.ts.map +1 -1
  5. package/dist/types/src/helpers/constants.d.ts +5 -2
  6. package/dist/types/src/helpers/constants.d.ts.map +1 -1
  7. package/dist/types/src/helpers/contracts.d.ts.map +1 -1
  8. package/dist/types/src/helpers/crypto.d.ts.map +1 -1
  9. package/dist/types/src/helpers/database.d.ts +8 -0
  10. package/dist/types/src/helpers/database.d.ts.map +1 -1
  11. package/dist/types/src/helpers/functions.d.ts +2 -1
  12. package/dist/types/src/helpers/functions.d.ts.map +1 -1
  13. package/dist/types/src/helpers/security.d.ts +1 -1
  14. package/dist/types/src/helpers/security.d.ts.map +1 -1
  15. package/dist/types/src/helpers/services.d.ts.map +1 -1
  16. package/dist/types/src/helpers/storage.d.ts +1 -1
  17. package/dist/types/src/helpers/storage.d.ts.map +1 -1
  18. package/dist/types/src/helpers/utils.d.ts +33 -21
  19. package/dist/types/src/helpers/utils.d.ts.map +1 -1
  20. package/dist/types/src/helpers/verification.d.ts +3 -2
  21. package/dist/types/src/helpers/verification.d.ts.map +1 -1
  22. package/dist/types/src/helpers/vm.d.ts.map +1 -1
  23. package/dist/types/src/index.d.ts +2 -2
  24. package/dist/types/src/index.d.ts.map +1 -1
  25. package/dist/types/src/types/index.d.ts +9 -4
  26. package/dist/types/src/types/index.d.ts.map +1 -1
  27. package/dist/types/test/data/generators.d.ts +32 -0
  28. package/dist/types/test/data/generators.d.ts.map +1 -0
  29. package/dist/types/test/data/samples.d.ts +40 -0
  30. package/dist/types/test/data/samples.d.ts.map +1 -0
  31. package/dist/types/test/utils/authentication.d.ts +72 -0
  32. package/dist/types/test/utils/authentication.d.ts.map +1 -0
  33. package/dist/types/test/utils/configs.d.ts +52 -0
  34. package/dist/types/test/utils/configs.d.ts.map +1 -0
  35. package/dist/types/test/utils/index.d.ts +4 -0
  36. package/dist/types/test/utils/index.d.ts.map +1 -0
  37. package/dist/types/test/utils/storage.d.ts +126 -0
  38. package/dist/types/test/utils/storage.d.ts.map +1 -0
  39. package/package.json +7 -8
  40. package/src/helpers/constants.ts +40 -32
  41. package/src/helpers/contracts.ts +3 -3
  42. package/src/helpers/crypto.ts +5 -1
  43. package/src/helpers/database.ts +13 -0
  44. package/src/helpers/security.ts +8 -5
  45. package/src/helpers/services.ts +2 -2
  46. package/src/helpers/storage.ts +3 -3
  47. package/src/helpers/utils.ts +320 -255
  48. package/src/helpers/verification.ts +6 -6
  49. package/src/helpers/vm.ts +19 -4
  50. package/src/index.ts +3 -1
  51. package/src/types/index.ts +23 -3
@@ -0,0 +1,52 @@
1
+ import admin from "firebase-admin";
2
+ import { FirebaseApp } from "firebase/app";
3
+ import { Firestore } from "firebase/firestore";
4
+ import { Functions } from "firebase/functions";
5
+ import { TestingEnvironment } from "../../src/types/enums";
6
+ export declare const envType: TestingEnvironment;
7
+ /**
8
+ * Initialize and return the Admin SDK app and services.
9
+ * @returns <App, Firestore, Auth, SecurityRules> - the instance of the initialized admin app and services.
10
+ */
11
+ export declare const initializeAdminServices: () => {
12
+ adminApp: admin.app.App;
13
+ adminFirestore: admin.firestore.Firestore;
14
+ adminAuth: admin.auth.Auth;
15
+ adminSecurityRules: admin.securityRules.SecurityRules;
16
+ };
17
+ /**
18
+ * Initialize and return the Firebase app and services.
19
+ * @returns <App, Firestore, Functions> - the instance of the initialized Firebase app and services.
20
+ */
21
+ export declare const initializeUserServices: () => {
22
+ userApp: FirebaseApp;
23
+ userFirestore: Firestore;
24
+ userFunctions: Functions;
25
+ };
26
+ /**
27
+ * Get necessary information for correctly config the storage module.
28
+ * @returns <number, string, number> - the necessary information for configuring storage module (AWS S3).
29
+ */
30
+ export declare const getStorageConfiguration: () => {
31
+ streamChunkSizeInMb: number;
32
+ ceremonyBucketPostfix: string;
33
+ presignedUrlExpirationInSeconds: number;
34
+ };
35
+ /**
36
+ * Get necessary information for correctly config the authentication module.
37
+ * @returns <string> - the necessary information for dealing with the authentication.
38
+ */
39
+ export declare const getAuthenticationConfiguration: () => {
40
+ githubClientId: string;
41
+ userEmail: string;
42
+ githubUserPw: string;
43
+ gmailClientId: string;
44
+ gmailClientSecret: string;
45
+ gmailRedirectUrl: string;
46
+ gmailRefreshToken: string;
47
+ };
48
+ /**
49
+ * Delete all initialized apps using the Admin SDK.
50
+ */
51
+ export declare const deleteAdminApp: () => Promise<void>;
52
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../test/utils/configs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAElC,OAAO,EAAE,WAAW,EAAyB,MAAM,cAAc,CAAA;AACjE,OAAO,EAA4B,SAAS,EAAgB,MAAM,oBAAoB,CAAA;AACtF,OAAO,EAA4B,SAAS,EAAgB,MAAM,oBAAoB,CAAA;AAEtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAW1D,eAAO,MAAM,OAAO,oBAAmG,CAAA;AAEvH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAO;IACvC,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAA;IACvB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAA;IACzC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAA;IAC1B,kBAAkB,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,CAAA;CAkBxD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAO;IACtC,OAAO,EAAE,WAAW,CAAA;IACpB,aAAa,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;CA6B3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAO;IACvC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,+BAA+B,EAAE,MAAM,CAAA;CAKzC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,QAAO;IAC9C,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;CAS3B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,qBAE1B,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { envType, initializeAdminServices, initializeUserServices, getStorageConfiguration, getAuthenticationConfiguration, deleteAdminApp } from "./configs";
2
+ export { createMockCeremony, cleanUpRecursively, cleanUpMockCeremony, createMockContribution, createMockTimedOutContribution, cleanUpMockParticipant, cleanUpMockTimeout, createMockParticipant, cleanUpMockContribution, deleteBucket, deleteObjectFromS3, getContributionLocalFilePath, getPotLocalFilePath, getZkeyLocalFilePath, mockCeremoniesCleanup, uploadFileToS3, getTranscriptLocalFilePath, storeMockDoneParticipant } from "./storage";
3
+ export { createMockUser, cleanUpMockUsers, createNewFirebaseUserWithEmailAndPw, generateUserPasswords, setCustomClaims, sleep, generatePseudoRandomStringOfNumbers } from "./authentication";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../test/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,cAAc,EACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,mCAAmC,EACnC,qBAAqB,EACrB,eAAe,EACf,KAAK,EACL,mCAAmC,EACtC,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,126 @@
1
+ import { CeremonyDocumentReferenceAndData, CircuitDocumentReferenceAndData, ParticipantDocumentReferenceAndData } from "../../src/types/index";
2
+ /**
3
+ * Create a new S3 Client object
4
+ * @returns <S3Client | boolean> an S3 client if the credentials are set, false otherwise
5
+ */
6
+ export declare const getS3Client: () => any;
7
+ /**
8
+ * Deletes an object from S3 (test function only)
9
+ * @param bucketName <string> the name of the bucket to delete the object from
10
+ * @param objectKey <string> the key of the object to delete
11
+ * @returns <boolean> true if the object was deleted, false otherwise
12
+ */
13
+ export declare const deleteObjectFromS3: (bucketName: string, objectKey: string) => Promise<boolean>;
14
+ /**
15
+ * Deletes a bucket from s3 (test function only)
16
+ * @param bucketName <string> the name of the bucket to delete
17
+ * @returns boolean true if the bucket was deleted, false otherwise
18
+ */
19
+ export declare const deleteBucket: (bucketName: string) => Promise<boolean>;
20
+ /**
21
+ * Uploads a file to S3 (test function only)
22
+ * @param bucketName <string> the name of the bucket to upload the file to
23
+ * @param objectKey <string> the key of the object to upload
24
+ * @param path <string> the path of the file to upload
25
+ */
26
+ export declare const uploadFileToS3: (bucketName: string, objectKey: string, path: string) => Promise<void>;
27
+ /**
28
+ * Creates mock data on Firestore (test function only)
29
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
30
+ * @param ceremonyData <CeremonyDocumentReferenceAndData> the ceremony data
31
+ * @param circuitData <CircuitDocumentReferenceAndData> the circuit data
32
+ */
33
+ export declare const createMockCeremony: (adminFirestore: FirebaseFirestore.Firestore, ceremonyData: CeremonyDocumentReferenceAndData, circuitData: CircuitDocumentReferenceAndData) => Promise<void>;
34
+ /**
35
+ * Cleans up mock data on Firestore (test function only)
36
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
37
+ * @param ceremonyId <string> the ceremony id
38
+ * @param circuitId <string> the circuit id
39
+ */
40
+ export declare const cleanUpMockCeremony: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, circuitId: string) => Promise<void>;
41
+ /**
42
+ * Recursively clean up all documents of a ceremony given its id
43
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
44
+ * @param ceremonyId <string> the ceremony id
45
+ */
46
+ export declare const cleanUpRecursively: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string) => Promise<void>;
47
+ /**
48
+ * Clean up all mock ceremonies on Firestore (test function only)
49
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
50
+ */
51
+ export declare const mockCeremoniesCleanup: (adminFirestore: FirebaseFirestore.Firestore) => Promise<void>;
52
+ /**
53
+ * Creates a mock contribution on Firestore (test function only)
54
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
55
+ * @param contributorId <string> the contributor id
56
+ * @param ceremonyId <string> the ceremony id
57
+ * @param circuitId <string> the circuit id
58
+ */
59
+ export declare const createMockContribution: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, circuitId: string, contribution: any, contributionId: string) => Promise<void>;
60
+ /**
61
+ * Delete a mock contribution (test function only)
62
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
63
+ * @param contributorId <string> the contributor id
64
+ * @param ceremonyId <string> the ceremony id
65
+ * @param circuitId <string> the circuit id
66
+ */
67
+ export declare const cleanUpMockContribution: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, circuitId: string, contributionId: string) => Promise<void>;
68
+ /**
69
+ * Store a participant on Firestore (test function only)
70
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
71
+ * @param ceremonyId <string> the ceremony id
72
+ */
73
+ export declare const createMockParticipant: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, participantId: string, participantData: ParticipantDocumentReferenceAndData) => Promise<void>;
74
+ /**
75
+ * Store a participant on Firestore with contribution Done (test function only)
76
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
77
+ * @param ceremonyId <string> the ceremony id
78
+ * @param participantUID <string> the participant uid
79
+ */
80
+ export declare const storeMockDoneParticipant: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, participantUID: string) => Promise<void>;
81
+ /**
82
+ * Clean up the mock participant at step 1 from Firestore (test function only)
83
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
84
+ * @param ceremonyId <string> the ceremony id
85
+ */
86
+ export declare const cleanUpMockParticipant: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, participantId: string) => Promise<void>;
87
+ /**
88
+ * Creates a mock timed out contribution on Firestore (test function only)
89
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
90
+ * @param contributorId <string> the contributor id
91
+ * @param ceremonyId <string> the ceremony id
92
+ * @param circuitId <string> the circuit id
93
+ */
94
+ export declare const createMockTimedOutContribution: (adminFirestore: FirebaseFirestore.Firestore, contributorId: string, ceremonyId: string) => Promise<void>;
95
+ /**
96
+ * Clean up a mock timeout (test function only)
97
+ * @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
98
+ * @param contributorId <string> the contributor id
99
+ * @param ceremonyId <string> the ceremony id
100
+ */
101
+ export declare const cleanUpMockTimeout: (adminFirestore: FirebaseFirestore.Firestore, contributorId: string, ceremonyId: string) => Promise<void>;
102
+ /**
103
+ * Get the complete PoT file path.
104
+ * @param completeFilename <string> - the complete filename of the file (name.ext).
105
+ * @returns <string> - the complete PoT path to the file.
106
+ */
107
+ export declare const getPotLocalFilePath: (completeFilename: string) => string;
108
+ /**
109
+ * Get the complete zKey file path.
110
+ * @param completeFilename <string> - the complete filename of the file (name.ext).
111
+ * @returns <string> - the complete zKey path to the file.
112
+ */
113
+ export declare const getZkeyLocalFilePath: (completeFilename: string) => string;
114
+ /**
115
+ * Get the complete contribution file path.
116
+ * @param completeFilename <string> - the complete filename of the file (name.ext).
117
+ * @returns <string> - the complete contribution path to the file.
118
+ */
119
+ export declare const getContributionLocalFilePath: (completeFilename: string) => string;
120
+ /**
121
+ * Get the transcript file path.
122
+ * @param completeFilename <string> - the complete filename of the file (name.ext).
123
+ * @returns <string> - the the transcript path to the file.
124
+ */
125
+ export declare const getTranscriptLocalFilePath: (completeFilename: string) => string;
126
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../test/utils/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,gCAAgC,EAChC,+BAA+B,EAC/B,mCAAmC,EACtC,MAAM,uBAAuB,CAAA;AAY9B;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAO,GAmB9B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAU,YAAY,MAAM,EAAE,WAAW,MAAM,qBAmB7E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,OAAO,CAiBtE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,EAAE,WAAW,MAAM,EAAE,MAAM,MAAM,kBAevF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC3B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,cAAc,gCAAgC,EAC9C,aAAa,+BAA+B,kBAgB/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC5B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,WAAW,MAAM,kBAIpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,gBAAgB,iBAAiB,CAAC,SAAS,EAAE,YAAY,MAAM,kBAIvG,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAU,gBAAgB,iBAAiB,CAAC,SAAS,kBAYtF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAC/B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,cAAc,GAAG,EACjB,gBAAgB,MAAM,kBAQzB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAChC,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,gBAAgB,MAAM,kBAGzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAC9B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,eAAe,MAAM,EACrB,iBAAiB,mCAAmC,kBAQvD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACjC,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,gBAAgB,MAAM,kBA2BzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAC/B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,eAAe,MAAM,kBAGxB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GACvC,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,eAAe,MAAM,EACrB,YAAY,MAAM,kBAoBrB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC3B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,eAAe,MAAM,EACrB,YAAY,MAAM,kBAIrB,CAAA;AAWD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,kBAAkB,MAAM,KAAG,MAAqD,CAAA;AAEpH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,kBAAkB,MAAM,KAAG,MAAuD,CAAA;AAEvH;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,kBAAkB,MAAM,KAAG,MACf,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,kBAAkB,MAAM,KAAG,MACH,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtion/actions",
3
- "version": "0.0.0-3df1645",
3
+ "version": "0.0.0-477457c",
4
4
  "description": "A set of actions and helpers for CLI commands",
5
5
  "repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
6
6
  "homepage": "https://github.com/privacy-scaling-explorations/p0tion",
@@ -14,7 +14,7 @@
14
14
  "main": "dist/index.node.js",
15
15
  "types": "dist/types/src/index.d.ts",
16
16
  "engines": {
17
- "node": ">=16.14.0"
17
+ "node": ">=20.0.0"
18
18
  },
19
19
  "files": [
20
20
  "dist/",
@@ -31,8 +31,8 @@
31
31
  "circom"
32
32
  ],
33
33
  "scripts": {
34
- "build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
35
- "build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
34
+ "build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript --bundleConfigAsCjs",
35
+ "build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript --bundleConfigAsCjs",
36
36
  "pre:publish": "yarn build",
37
37
  "compile:contracts": "hardhat compile",
38
38
  "test:contracts": "GOOGLE_APPLICATION_CREDENTIALS=\"../backend/serviceAccountKey.json\" && NODE_ENV=prod && TS_NODE_FILES=true hardhat test test/unit/contract.test.ts",
@@ -51,19 +51,19 @@
51
51
  "chai-as-promised": "^7.1.1",
52
52
  "dotenv": "^16.0.3",
53
53
  "ethers": "^5.7.2",
54
- "ffjavascript": "^0.2.57",
55
54
  "firebase": "^9.21.0",
56
55
  "firebase-admin": "^11.8.0",
57
56
  "googleapis": "^118.0.0",
58
57
  "rimraf": "^5.0.0",
59
58
  "rollup": "^3.21.6",
60
- "snarkjs": "^0.6.11",
59
+ "snarkjs": "0.7.3",
61
60
  "solc": "^0.8.19"
62
61
  },
63
62
  "devDependencies": {
64
63
  "@ethersproject/providers": "^5.7.2",
65
64
  "@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
66
65
  "@nomiclabs/hardhat-ethers": "^2.2.3",
66
+ "@rollup/plugin-typescript": "^11.1.6",
67
67
  "@typechain/ethers-v5": "^10.2.1",
68
68
  "@typechain/hardhat": "^6.1.6",
69
69
  "@types/mocha": "^10.0.1",
@@ -71,7 +71,6 @@
71
71
  "hardhat": "^2.14.0",
72
72
  "rollup-plugin-auto-external": "^2.0.0",
73
73
  "rollup-plugin-cleanup": "^3.2.1",
74
- "rollup-plugin-typescript2": "^0.34.1",
75
74
  "ts-node": "^10.9.1",
76
75
  "typescript": "^5.0.4",
77
76
  "winston": "^3.8.2"
@@ -79,5 +78,5 @@
79
78
  "publishConfig": {
80
79
  "access": "public"
81
80
  },
82
- "gitHead": "6f9aa8c0097076db64ca825e5714f4e149012f03"
81
+ "gitHead": "a160aad10b1d03b9d4307a44aa00d13405767d90"
83
82
  }
@@ -1,7 +1,7 @@
1
- // Main part for the Hermez Phase 1 Trusted Setup URLs to download PoT files.
2
- export const potFileDownloadMainUrl = `https://hermez.s3-eu-west-1.amazonaws.com/`
3
- // Main part for the Hermez Phase 1 Trusted Setup PoT files to be downloaded.
4
- export const potFilenameTemplate = `powersOfTau28_hez_final_`
1
+ // Main part for the PPoT Phase 1 Trusted Setup URLs to download PoT files.
2
+ export const potFileDownloadMainUrl = `https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/`
3
+ // Main part for the PPoT Phase 1 Trusted Setup PoT files to be downloaded.
4
+ export const potFilenameTemplate = `ppot_0080_`
5
5
  // The genesis zKey index.
6
6
  export const genesisZkeyIndex = `00000`
7
7
  // The number of exponential iterations to be executed by SnarkJS when finalizing the ceremony.
@@ -18,6 +18,8 @@ export const verifierSmartContractAcronym = "verifier"
18
18
  export const ec2InstanceTag = "p0tionec2instance"
19
19
  // The name of the VM startup script file.
20
20
  export const vmBootstrapScriptFilename = "bootstrap.sh"
21
+ // Match hash output by snarkjs in transcript log
22
+ export const contribHashRegex = /Contribution.+Hash.+\s+.+\s+.+\s+.+\s+.+\s*/
21
23
 
22
24
  /**
23
25
  * Define the supported VM configuration types.
@@ -77,112 +79,116 @@ export const vmConfigurationTypes = {
77
79
  */
78
80
  export const powersOfTauFiles = [
79
81
  {
80
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_01.ptau",
82
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_01.ptau",
81
83
  size: 0.000084
82
84
  },
83
85
  {
84
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_02.ptau",
86
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_02.ptau",
85
87
  size: 0.000086
86
88
  },
87
89
  {
88
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_03.ptau",
90
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_03.ptau",
89
91
  size: 0.000091
90
92
  },
91
93
  {
92
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_04.ptau",
94
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_04.ptau",
93
95
  size: 0.0001
94
96
  },
95
97
  {
96
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_05.ptau",
98
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_05.ptau",
97
99
  size: 0.000117
98
100
  },
99
101
  {
100
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_06.ptau",
102
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_06.ptau",
101
103
  size: 0.000153
102
104
  },
103
105
  {
104
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_07.ptau",
106
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_07.ptau",
105
107
  size: 0.000225
106
108
  },
107
109
  {
108
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_08.ptau",
110
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_08.ptau",
109
111
  size: 0.0004
110
112
  },
111
113
  {
112
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_09.ptau",
114
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_09.ptau",
113
115
  size: 0.000658
114
116
  },
115
117
  {
116
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_10.ptau",
118
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_10.ptau",
117
119
  size: 0.0013
118
120
  },
119
121
  {
120
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_11.ptau",
122
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_11.ptau",
121
123
  size: 0.0023
122
124
  },
123
125
  {
124
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_12.ptau",
126
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_12.ptau",
125
127
  size: 0.0046
126
128
  },
127
129
  {
128
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_13.ptau",
130
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_13.ptau",
129
131
  size: 0.0091
130
132
  },
131
133
  {
132
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_14.ptau",
134
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_14.ptau",
133
135
  size: 0.0181
134
136
  },
135
137
  {
136
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_15.ptau",
138
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_15.ptau",
137
139
  size: 0.0361
138
140
  },
139
141
  {
140
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_16.ptau",
142
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_16.ptau",
141
143
  size: 0.0721
142
144
  },
143
145
  {
144
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_17.ptau",
146
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_17.ptau",
145
147
  size: 0.144
146
148
  },
147
149
  {
148
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_18.ptau",
150
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_18.ptau",
149
151
  size: 0.288
150
152
  },
151
153
  {
152
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_19.ptau",
154
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_19.ptau",
153
155
  size: 0.576
154
156
  },
155
157
  {
156
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_20.ptau",
158
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_20.ptau",
157
159
  size: 1.1
158
160
  },
159
161
  {
160
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_21.ptau",
162
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_21.ptau",
161
163
  size: 2.3
162
164
  },
163
165
  {
164
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_22.ptau",
166
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_22.ptau",
165
167
  size: 4.5
166
168
  },
167
169
  {
168
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_23.ptau",
170
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_23.ptau",
169
171
  size: 9.0
170
172
  },
171
173
  {
172
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_24.ptau",
174
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_24.ptau",
173
175
  size: 18.0
174
176
  },
175
177
  {
176
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_25.ptau",
178
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_25.ptau",
177
179
  size: 36.0
178
180
  },
179
181
  {
180
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_26.ptau",
182
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_26.ptau",
181
183
  size: 72.0
182
184
  },
183
185
  {
184
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_27.ptau",
186
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_27.ptau",
185
187
  size: 144.0
188
+ },
189
+ {
190
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_final.ptau",
191
+ size: 288.0
186
192
  }
187
193
  ]
188
194
 
@@ -313,6 +319,8 @@ export const commonTerms = {
313
319
  finalizeCircuit: "finalizeCircuit",
314
320
  finalizeCeremony: "finalizeCeremony",
315
321
  downloadCircuitArtifacts: "downloadCircuitArtifacts",
316
- transferObject: "transferObject"
322
+ transferObject: "transferObject",
323
+ bandadaValidateProof: "bandadaValidateProof",
324
+ checkNonceOfSIWEAddress: "checkNonceOfSIWEAddress"
317
325
  }
318
326
  }
@@ -1,5 +1,4 @@
1
1
  import { Contract, ContractFactory, Signer } from "ethers"
2
- import { utils as ffUtils } from "ffjavascript"
3
2
  import { Firestore, where } from "firebase/firestore"
4
3
  import { Functions } from "firebase/functions"
5
4
  import fs from "fs"
@@ -16,6 +15,7 @@ import {
16
15
  import { compareHashes } from "./crypto"
17
16
  import { commonTerms, finalContributionIndex, verificationKeyAcronym, verifierSmartContractAcronym } from "./constants"
18
17
  import { fromQueryToFirebaseDocumentInfo, queryCollection } from "./database"
18
+ import { unstringifyBigInts } from "./utils"
19
19
 
20
20
  /**
21
21
  * Formats part of a GROTH16 SNARK proof
@@ -41,11 +41,11 @@ export const p256 = (proofPart: any) => {
41
41
  */
42
42
  export const formatSolidityCalldata = (circuitInput: string[], _proof: any): any => {
43
43
  try {
44
- const proof = ffUtils.unstringifyBigInts(_proof)
44
+ const proof = unstringifyBigInts(_proof) as any
45
45
  // format the public inputs to the circuit
46
46
  const formattedCircuitInput = []
47
47
  for (const cInput of circuitInput) {
48
- formattedCircuitInput.push(p256(ffUtils.unstringifyBigInts(cInput)))
48
+ formattedCircuitInput.push(p256(unstringifyBigInts(cInput)))
49
49
  }
50
50
  // construct calldata
51
51
  const calldata = {
@@ -24,7 +24,11 @@ export const blake512FromPath = async (path: fs.PathLike): Promise<string> => {
24
24
 
25
25
  const hash: string = await new Promise((resolve) => {
26
26
  fs.createReadStream(path)
27
- .on("data", (chunk: Buffer) => {
27
+ .on("data", (chunk: string | Buffer) => {
28
+ if (typeof chunk === "string") {
29
+ chunk = Buffer.from(chunk)
30
+ }
31
+
28
32
  blake.blake2bUpdate(context, chunk)
29
33
  })
30
34
  .on("end", () => {
@@ -219,3 +219,16 @@ export const getClosedCeremonies = async (firestoreDatabase: Firestore): Promise
219
219
 
220
220
  return fromQueryToFirebaseDocumentInfo(closedCeremoniesQuerySnap.docs)
221
221
  }
222
+
223
+ /**
224
+ * Query all ceremonies
225
+ * @notice get all ceremonies from the database.
226
+ * @dev this is a helper for the CLI ceremony methods.
227
+ * @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
228
+ * @returns <Promise<Array<FirebaseDocumentInfo>>> - the list of all ceremonies.
229
+ */
230
+ export const getAllCeremonies = async (firestoreDatabase: Firestore): Promise<Array<FirebaseDocumentInfo>> => {
231
+ const ceremoniesQuerySnap = await queryCollection(firestoreDatabase, commonTerms.collections.ceremonies.name, [])
232
+
233
+ return fromQueryToFirebaseDocumentInfo(ceremoniesQuerySnap.docs)
234
+ }
@@ -20,7 +20,8 @@ const getGitHubStats = async (user: string): Promise<any> => {
20
20
  following: jsonData.following,
21
21
  followers: jsonData.followers,
22
22
  publicRepos: jsonData.public_repos,
23
- avatarUrl: jsonData.avatar_url
23
+ avatarUrl: jsonData.avatar_url,
24
+ age: jsonData.created_at
24
25
  }
25
26
 
26
27
  return data
@@ -38,19 +39,21 @@ export const githubReputation = async (
38
39
  userLogin: string,
39
40
  minimumAmountOfFollowing: number,
40
41
  minimumAmountOfFollowers: number,
41
- minimumAmountOfPublicRepos: number
42
+ minimumAmountOfPublicRepos: number,
43
+ minimumAge: number
42
44
  ): Promise<any> => {
43
45
  if (!process.env.GITHUB_ACCESS_TOKEN)
44
46
  throw new Error(
45
47
  "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."
46
48
  )
47
49
 
48
- const { following, followers, publicRepos, avatarUrl } = await getGitHubStats(userLogin)
50
+ const { following, followers, publicRepos, avatarUrl, age } = await getGitHubStats(userLogin)
49
51
 
50
52
  if (
51
53
  following < minimumAmountOfFollowing ||
52
54
  publicRepos < minimumAmountOfPublicRepos ||
53
- followers < minimumAmountOfFollowers
55
+ followers < minimumAmountOfFollowers ||
56
+ new Date(age) > new Date(Date.now() - minimumAge)
54
57
  )
55
58
  return {
56
59
  reputable: false,
@@ -59,6 +62,6 @@ export const githubReputation = async (
59
62
 
60
63
  return {
61
64
  reputable: true,
62
- avatarUrl: avatarUrl
65
+ avatarUrl
63
66
  }
64
67
  }
@@ -33,7 +33,7 @@ export const getAWSVariables = (): AWSVariables => {
33
33
  !process.env.AWS_ACCESS_KEY_ID ||
34
34
  !process.env.AWS_SECRET_ACCESS_KEY ||
35
35
  !process.env.AWS_REGION ||
36
- !process.env.AWS_ROLE_ARN ||
36
+ !process.env.AWS_INSTANCE_PROFILE_ARN ||
37
37
  !process.env.AWS_AMI_ID
38
38
  )
39
39
  throw new Error(
@@ -44,7 +44,7 @@ export const getAWSVariables = (): AWSVariables => {
44
44
  accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
45
45
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
46
46
  region: process.env.AWS_REGION || "us-east-1",
47
- roleArn: process.env.AWS_ROLE_ARN!,
47
+ instanceProfileArn: process.env.AWS_INSTANCE_PROFILE_ARN!,
48
48
  amiId: process.env.AWS_AMI_ID!
49
49
  }
50
50
  }
@@ -3,6 +3,7 @@ import mime from "mime-types"
3
3
  import fs, { createWriteStream } from "fs"
4
4
  import fetch from "@adobe/node-fetch-retry"
5
5
  import https from "https"
6
+ import { GenericBar } from "cli-progress"
6
7
  import { ETagWithPartNumber, ChunkWithUrl, TemporaryParticipantContributionData } from "../types/index"
7
8
  import { commonTerms } from "./constants"
8
9
  import {
@@ -13,7 +14,6 @@ import {
13
14
  temporaryStoreCurrentContributionMultiPartUploadId,
14
15
  temporaryStoreCurrentContributionUploadedChunkData
15
16
  } from "./functions"
16
- import { GenericBar } from "cli-progress"
17
17
 
18
18
  /**
19
19
  * Return the bucket name based on ceremony prefix.
@@ -169,7 +169,7 @@ export const multiPartUpload = async (
169
169
  configStreamChunkSize: number,
170
170
  ceremonyId?: string,
171
171
  temporaryDataToResumeMultiPartUpload?: TemporaryParticipantContributionData,
172
- logger?: GenericBar
172
+ logger?: GenericBar
173
173
  ) => {
174
174
  // The unique identifier of the multi-part upload.
175
175
  let multiPartUploadId: string = ""
@@ -210,7 +210,7 @@ export const multiPartUpload = async (
210
210
  cloudFunctions,
211
211
  ceremonyId,
212
212
  alreadyUploadedChunks,
213
- logger
213
+ logger
214
214
  )
215
215
 
216
216
  // Step (3).