@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
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@devtion/actions",
3
+ "version": "0.0.0-7e983e3",
4
+ "description": "A set of actions and helpers for CLI commands",
5
+ "repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
6
+ "homepage": "https://github.com/privacy-scaling-explorations/p0tion",
7
+ "bugs": "https://github.com/privacy-scaling-explorations/p0tion/issues",
8
+ "license": "MIT",
9
+ "exports": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.node.js",
12
+ "types": "./dist/types/src/index.d.ts"
13
+ },
14
+ "main": "dist/index.node.js",
15
+ "types": "dist/types/src/index.d.ts",
16
+ "engines": {
17
+ "node": ">=16.14.0"
18
+ },
19
+ "files": [
20
+ "dist/",
21
+ "src/"
22
+ ],
23
+ "keywords": [
24
+ "typescript",
25
+ "zero-knowledge",
26
+ "zk-snarks",
27
+ "phase-2",
28
+ "trusted-setup",
29
+ "ceremony",
30
+ "snarkjs",
31
+ "circom"
32
+ ],
33
+ "scripts": {
34
+ "build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
35
+ "build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
36
+ "pre:publish": "yarn build",
37
+ "compile:contracts": "hardhat compile",
38
+ "test:contracts": "GOOGLE_APPLICATION_CREDENTIALS=\"../backend/serviceAccountKey.json\" && NODE_ENV=prod && TS_NODE_FILES=true hardhat test test/unit/contract.test.ts",
39
+ "verify:ceremony": "GOOGLE_APPLICATION_CREDENTIALS=\"../backend/serviceAccountKey.json\" && NODE_ENV=prod hardhat verifyCeremony",
40
+ "docs": "typedoc src/**/*.ts --out ../../docs/actions"
41
+ },
42
+ "dependencies": {
43
+ "@adobe/node-fetch-retry": "^2.2.0",
44
+ "@aws-sdk/client-ec2": "^3.358.0",
45
+ "@aws-sdk/client-s3": "^3.329.0",
46
+ "@aws-sdk/client-ssm": "^3.358.0",
47
+ "@octokit/auth-oauth-device": "^4.0.4",
48
+ "@types/winston": "^2.4.4",
49
+ "blakejs": "^1.2.1",
50
+ "chai": "^4.3.7",
51
+ "chai-as-promised": "^7.1.1",
52
+ "dotenv": "^16.0.3",
53
+ "ethers": "^5.7.2",
54
+ "ffjavascript": "^0.2.57",
55
+ "firebase": "^9.21.0",
56
+ "firebase-admin": "^11.8.0",
57
+ "googleapis": "^118.0.0",
58
+ "puppeteer": "^20.1.2",
59
+ "puppeteer-extra": "^3.3.6",
60
+ "puppeteer-extra-plugin-anonymize-ua": "^2.4.6",
61
+ "puppeteer-extra-plugin-stealth": "^2.11.2",
62
+ "rimraf": "^5.0.0",
63
+ "rollup": "^3.21.6",
64
+ "snarkjs": "^0.6.11",
65
+ "solc": "^0.8.19"
66
+ },
67
+ "devDependencies": {
68
+ "@ethersproject/providers": "^5.7.2",
69
+ "@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
70
+ "@nomiclabs/hardhat-ethers": "^2.2.3",
71
+ "@typechain/ethers-v5": "^10.2.1",
72
+ "@typechain/hardhat": "^6.1.6",
73
+ "@types/mocha": "^10.0.1",
74
+ "@types/rollup-plugin-auto-external": "^2.0.2",
75
+ "hardhat": "^2.14.0",
76
+ "rollup-plugin-auto-external": "^2.0.0",
77
+ "rollup-plugin-cleanup": "^3.2.1",
78
+ "rollup-plugin-typescript2": "^0.34.1",
79
+ "ts-node": "^10.9.1",
80
+ "typescript": "^5.0.4",
81
+ "winston": "^3.8.2"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "gitHead": "afae72061a3b366b05508de53fe91e9b254cc3d5"
87
+ }
@@ -0,0 +1,37 @@
1
+ import { User, getAuth, signInWithCredential, initializeAuth, OAuthCredential } from "firebase/auth"
2
+ import { FirebaseApp } from "firebase/app" // ref https://firebase.google.com/docs/web/setup#access-firebase.
3
+
4
+ /**
5
+ * Sign in w/ OAuth 2.0 token.
6
+ * @param firebaseApp <FirebaseApp> - the configured instance of the Firebase App in use.
7
+ * @param credentials <OAuthCredential> - the OAuth credential generated from token exchange.
8
+ */
9
+ export const signInToFirebaseWithCredentials = async (firebaseApp: FirebaseApp, credentials: OAuthCredential) =>
10
+ signInWithCredential(initializeAuth(firebaseApp), credentials)
11
+
12
+ /**
13
+ * Return the current authenticated user in the given Firebase Application.
14
+ * @param firebaseApp <FirebaseApp> - the configured instance of the Firebase App in use.
15
+ * @returns <User> - the object containing the data about the current authenticated user in the given Firebase application.
16
+ */
17
+ export const getCurrentFirebaseAuthUser = (firebaseApp: FirebaseApp): User => {
18
+ const user = getAuth(firebaseApp).currentUser
19
+
20
+ if (!user)
21
+ throw new Error(
22
+ `Unable to find the user currently authenticated with Firebase. Verify that the Firebase application is properly configured and repeat user authentication before trying again.`
23
+ )
24
+
25
+ return user
26
+ }
27
+
28
+ /**
29
+ * Check if the user can claim to be a coordinator.
30
+ * @param user <User> - the user to be checked.
31
+ * @returns Promise<boolean> - true if the user is a coordinator, false otherwise.
32
+ */
33
+ export const isCoordinator = async (user: User) => {
34
+ const userTokenAndClaims = await user.getIdTokenResult()
35
+
36
+ return !!userTokenAndClaims.claims.coordinator
37
+ }
@@ -0,0 +1,312 @@
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_`
5
+ // The genesis zKey index.
6
+ export const genesisZkeyIndex = `00000`
7
+ // The number of exponential iterations to be executed by SnarkJS when finalizing the ceremony.
8
+ export const numExpIterations = 10
9
+ // The Solidity version of the Verifier Smart Contract generated with SnarkJS when finalizing the ceremony.
10
+ export const solidityVersion = "0.8.0"
11
+ // The index of the final zKey.
12
+ export const finalContributionIndex = "final"
13
+ // The acronym for verification key.
14
+ export const verificationKeyAcronym = "vkey"
15
+ // The acronym for Verifier smart contract.
16
+ export const verifierSmartContractAcronym = "verifier"
17
+ // The tag for ec2 instances.
18
+ export const ec2InstanceTag = "p0tionec2instance"
19
+ // The name of the VM startup script file.
20
+ export const vmBootstrapScriptFilename = "bootstrap.sh"
21
+
22
+ /**
23
+ * Define the supported VM configuration types.
24
+ * @dev the VM configurations can be retrieved at https://aws.amazon.com/ec2/instance-types/
25
+ * The on-demand prices for the configurations can be retrieved at https://aws.amazon.com/ec2/pricing/on-demand/.
26
+ * @notice the price has to be intended as on-demand hourly billing usage for Linux OS
27
+ * VMs located in the us-east-1 region expressed in USD.
28
+ */
29
+ export const vmConfigurationTypes = {
30
+ t3_large: {
31
+ type: "t3.large",
32
+ ram: 8,
33
+ vcpu: 2,
34
+ pricePerHour: 0.08352
35
+ },
36
+ t3_2xlarge: {
37
+ type: "t3.2xlarge",
38
+ ram: 32,
39
+ vcpu: 8,
40
+ pricePerHour: 0.3328
41
+ },
42
+ c5_9xlarge: {
43
+ type: "c5.9xlarge",
44
+ ram: 72,
45
+ vcpu: 36,
46
+ pricePerHour: 1.53
47
+ },
48
+ c5_18xlarge: {
49
+ type: "c5.18xlarge",
50
+ ram: 144,
51
+ vcpu: 72,
52
+ pricePerHour: 3.06
53
+ },
54
+ c5a_8xlarge: {
55
+ type: "c5a.8xlarge",
56
+ ram: 64,
57
+ vcpu: 32,
58
+ pricePerHour: 1.232
59
+ },
60
+ c6id_32xlarge: {
61
+ type: "c6id.32xlarge",
62
+ ram: 256,
63
+ vcpu: 128,
64
+ pricePerHour: 6.4512
65
+ },
66
+ m6a_32xlarge: {
67
+ type: "m6a.32xlarge",
68
+ ram: 512,
69
+ vcpu: 128,
70
+ pricePerHour: 5.5296
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Define the PPoT Trusted Setup ceremony output powers of tau files size (in GB).
76
+ * @dev the powers of tau files can be retrieved at https://github.com/weijiekoh/perpetualpowersoftau
77
+ */
78
+ export const powersOfTauFiles = [
79
+ {
80
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_01.ptau",
81
+ size: 0.000084
82
+ },
83
+ {
84
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_02.ptau",
85
+ size: 0.000086
86
+ },
87
+ {
88
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_03.ptau",
89
+ size: 0.000091
90
+ },
91
+ {
92
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_04.ptau",
93
+ size: 0.0001
94
+ },
95
+ {
96
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_05.ptau",
97
+ size: 0.000117
98
+ },
99
+ {
100
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_06.ptau",
101
+ size: 0.000153
102
+ },
103
+ {
104
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_07.ptau",
105
+ size: 0.000225
106
+ },
107
+ {
108
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_08.ptau",
109
+ size: 0.0004
110
+ },
111
+ {
112
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_09.ptau",
113
+ size: 0.000658
114
+ },
115
+ {
116
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_10.ptau",
117
+ size: 0.0013
118
+ },
119
+ {
120
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_11.ptau",
121
+ size: 0.0023
122
+ },
123
+ {
124
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_12.ptau",
125
+ size: 0.0046
126
+ },
127
+ {
128
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_13.ptau",
129
+ size: 0.0091
130
+ },
131
+ {
132
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_14.ptau",
133
+ size: 0.0181
134
+ },
135
+ {
136
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_15.ptau",
137
+ size: 0.0361
138
+ },
139
+ {
140
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_16.ptau",
141
+ size: 0.0721
142
+ },
143
+ {
144
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_17.ptau",
145
+ size: 0.144
146
+ },
147
+ {
148
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_18.ptau",
149
+ size: 0.288
150
+ },
151
+ {
152
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_19.ptau",
153
+ size: 0.576
154
+ },
155
+ {
156
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_20.ptau",
157
+ size: 1.1
158
+ },
159
+ {
160
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_21.ptau",
161
+ size: 2.3
162
+ },
163
+ {
164
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_22.ptau",
165
+ size: 4.5
166
+ },
167
+ {
168
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_23.ptau",
169
+ size: 9.0
170
+ },
171
+ {
172
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_24.ptau",
173
+ size: 18.0
174
+ },
175
+ {
176
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_25.ptau",
177
+ size: 36.0
178
+ },
179
+ {
180
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_26.ptau",
181
+ size: 72.0
182
+ },
183
+ {
184
+ ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_27.ptau",
185
+ size: 144.0
186
+ }
187
+ ]
188
+
189
+ /**
190
+ * Commonly used terms.
191
+ * @dev useful for creating paths, references to collections and queries, object properties, folder names, and so on.
192
+ */
193
+ export const commonTerms = {
194
+ collections: {
195
+ users: {
196
+ name: "users",
197
+ fields: {
198
+ creationTime: "creationTime",
199
+ displayName: "displayName",
200
+ email: "email",
201
+ emailVerified: "emailVerified",
202
+ lastSignInTime: "lastSignInTime",
203
+ lastUpdated: "lastUpdated",
204
+ name: "name",
205
+ photoURL: "photoURL"
206
+ }
207
+ },
208
+ participants: {
209
+ name: "participants",
210
+ fields: {
211
+ contributionProgress: "contributionProgress",
212
+ contributionStartedAt: "contributionStartedAt",
213
+ contributionStep: "contributionStep",
214
+ contributions: "contributions",
215
+ lastUpdated: "lastUpdated",
216
+ status: "status",
217
+ verificationStartedAt: "verificationStartedAt"
218
+ }
219
+ },
220
+ ceremonies: {
221
+ name: "ceremonies",
222
+ fields: {
223
+ coordinatorId: "coordinatorId",
224
+ description: "description",
225
+ endDate: "endDate",
226
+ lastUpdated: "lastUpdated",
227
+ penalty: "penalty",
228
+ prefix: "prefix",
229
+ startDate: "startDate",
230
+ state: "state",
231
+ timeoutType: "timeoutType",
232
+ title: "title",
233
+ type: "type"
234
+ }
235
+ },
236
+ circuits: {
237
+ name: "circuits",
238
+ fields: {
239
+ avgTimings: "avgTimings",
240
+ compiler: "compiler",
241
+ description: "description",
242
+ files: "files",
243
+ lastUpdated: "lastUpdated",
244
+ metadata: "metadata",
245
+ name: "name",
246
+ prefix: "prefix",
247
+ sequencePosition: "sequencePosition",
248
+ template: "template",
249
+ timeoutMaxContributionWaitingTime: "timeoutMaxContributionWaitingTime",
250
+ waitingQueue: "waitingQueue",
251
+ zKeySizeInBytes: "zKeySizeInBytes",
252
+ verification: "verification"
253
+ }
254
+ },
255
+ contributions: {
256
+ name: "contributions",
257
+ fields: {
258
+ contributionComputationTime: "contributionComputationTime",
259
+ files: "files",
260
+ lastUpdated: "lastUpdated",
261
+ participantId: "participantId",
262
+ valid: "valid",
263
+ verificationComputationTime: "verificationComputationTime",
264
+ zkeyIndex: "zKeyIndex"
265
+ }
266
+ },
267
+ timeouts: {
268
+ name: "timeouts",
269
+ fields: {
270
+ type: "type",
271
+ startDate: "startDate",
272
+ endDate: "endDate"
273
+ }
274
+ }
275
+ },
276
+ foldersAndPathsTerms: {
277
+ output: `output`,
278
+ setup: `setup`,
279
+ contribute: `contribute`,
280
+ finalize: `finalize`,
281
+ pot: `pot`,
282
+ zkeys: `zkeys`,
283
+ wasm: `wasm`,
284
+ vkeys: `vkeys`,
285
+ metadata: `metadata`,
286
+ transcripts: `transcripts`,
287
+ attestation: `attestation`,
288
+ verifiers: `verifiers`
289
+ },
290
+ cloudFunctionsNames: {
291
+ setupCeremony: "setupCeremony",
292
+ checkParticipantForCeremony: "checkParticipantForCeremony",
293
+ progressToNextCircuitForContribution: "progressToNextCircuitForContribution",
294
+ resumeContributionAfterTimeoutExpiration: "resumeContributionAfterTimeoutExpiration",
295
+ createBucket: "createBucket",
296
+ generateGetObjectPreSignedUrl: "generateGetObjectPreSignedUrl",
297
+ progressToNextContributionStep: "progressToNextContributionStep",
298
+ permanentlyStoreCurrentContributionTimeAndHash: "permanentlyStoreCurrentContributionTimeAndHash",
299
+ startMultiPartUpload: "startMultiPartUpload",
300
+ temporaryStoreCurrentContributionMultiPartUploadId: "temporaryStoreCurrentContributionMultiPartUploadId",
301
+ temporaryStoreCurrentContributionUploadedChunkData: "temporaryStoreCurrentContributionUploadedChunkData",
302
+ generatePreSignedUrlsParts: "generatePreSignedUrlsParts",
303
+ completeMultiPartUpload: "completeMultiPartUpload",
304
+ checkIfObjectExist: "checkIfObjectExist",
305
+ verifyContribution: "verifycontribution",
306
+ checkAndPrepareCoordinatorForFinalization: "checkAndPrepareCoordinatorForFinalization",
307
+ finalizeCircuit: "finalizeCircuit",
308
+ finalizeCeremony: "finalizeCeremony",
309
+ downloadCircuitArtifacts: "downloadCircuitArtifacts",
310
+ transferObject: "transferObject",
311
+ }
312
+ }