@devtion/devcli 0.0.0-7140596 → 0.0.0-92056fa

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/dist/.env CHANGED
@@ -1,40 +1,41 @@
1
- ### FIREBASE ###
2
- ### These configs are related to the configuration of the Firebase services.
1
+ ### FIREBASE ###
2
+ ### These configs are related to the configuration of the Firebase services.
3
+
4
+
5
+ # The Firebase Application API key for making request against the services.
6
+ # nb. this is going to be auto-generated when creating a new application.
7
+ FIREBASE_API_KEY=AIzaSyDVAu8U4zBpM3FFLPyktSjZnCmg1IR73Cg
8
+ # The URL to Firebase Authentication service (should point to default).
9
+ # nb. this is going to be auto-generated when creating a new application.
10
+ FIREBASE_AUTH_DOMAIN=p0tion-ci-environment.firebaseapp.com
11
+ # The Firebase Application project id (should match with application name).
12
+ FIREBASE_PROJECT_ID=p0tion-ci-environment
13
+ # The Firebase unique message sender identifier (to recognize the application user).
14
+ # nb. this is going to be auto-generated when creating a new application.
15
+ FIREBASE_MESSAGING_SENDER_ID=22680510841
16
+ # The Firebase unique identifier for your application.
17
+ # nb. this is going to be auto-generated when creating a new application.
18
+ FIREBASE_APP_ID=1:22680510841:web:529a664e73dbabd1c7cfa8
19
+ FIREBASE_CF_URL_VERIFY_CONTRIBUTION=https://verifycontribution-mq4aqokliq-ew.a.run.app
20
+
21
+ ### AUTHENTICATION ###
22
+ ### These configs are related to the authentication of users.
23
+
24
+ # The unique identifier for the Github client associated to the OAuth Application.
25
+ AUTH_GITHUB_CLIENT_ID=e9f8a5fabdfe0d95618c
26
+
27
+ ### AWS S3 STORAGE ###
28
+ ### These configs are related to the configuration of the interaction with the
29
+ ### AWS S3 bucket used as storage for ceremony artifacts.
30
+
31
+ # The chunk size to be used when executing multi-part upload or downloads.
32
+ # default 50 MBs.
33
+ # (e.g. a 200 MB file setting a stream chunk size of 50 MB is going to be splitted and uploaded/downloaded in 4 chunks).
34
+ CONFIG_STREAM_CHUNK_SIZE_IN_MB=50
35
+ # The postfix string for each ceremony bucket.
36
+ # default -ph2-ceremony
37
+ CONFIG_CEREMONY_BUCKET_POSTFIX=-p0tion-development-environment
38
+ # The amount of time in seconds which indicates the duration about the validity of a pre-signed URL.
39
+ # default: 7200 seconds = 2 hours.
40
+ CONFIG_PRESIGNED_URL_EXPIRATION_IN_SECONDS=7200
3
41
 
4
-
5
- # The Firebase Application API key for making request against the services.
6
- # nb. this is going to be auto-generated when creating a new application.
7
- FIREBASE_API_KEY="AIzaSyDVAu8U4zBpM3FFLPyktSjZnCmg1IR73Cg"
8
- # The URL to Firebase Authentication service (should point to default).
9
- # nb. this is going to be auto-generated when creating a new application.
10
- FIREBASE_AUTH_DOMAIN="p0tion-ci-environment.firebaseapp.com"
11
- # The Firebase Application project id (should match with application name).
12
- FIREBASE_PROJECT_ID="p0tion-ci-environment"
13
- # The Firebase unique message sender identifier (to recognize the application user).
14
- # nb. this is going to be auto-generated when creating a new application.
15
- FIREBASE_MESSAGING_SENDER_ID="22680510841"
16
- # The Firebase unique identifier for your application.
17
- # nb. this is going to be auto-generated when creating a new application.
18
- FIREBASE_APP_ID="1:22680510841:web:529a664e73dbabd1c7cfa8"
19
- FIREBASE_CF_URL_VERIFY_CONTRIBUTION="https://verifycontribution-mq4aqokliq-ew.a.run.app"
20
-
21
- ### AUTHENTICATION ###
22
- ### These configs are related to the authentication of users.
23
-
24
- # The unique identifier for the Github client associated to the OAuth Application.
25
- AUTH_GITHUB_CLIENT_ID="e9f8a5fabdfe0d95618c"
26
-
27
- ### AWS S3 STORAGE ###
28
- ### These configs are related to the configuration of the interaction with the
29
- ### AWS S3 bucket used as storage for ceremony artifacts.
30
-
31
- # The chunk size to be used when executing multi-part upload or downloads.
32
- # default 50 MBs.
33
- # (e.g. a 200 MB file setting a stream chunk size of 50 MB is going to be splitted and uploaded/downloaded in 4 chunks).
34
- CONFIG_STREAM_CHUNK_SIZE_IN_MB=50
35
- # The postfix string for each ceremony bucket.
36
- # default "-ph2-ceremony"
37
- CONFIG_CEREMONY_BUCKET_POSTFIX="-p0tion-development-environment"
38
- # The amount of time in seconds which indicates the duration about the validity of a pre-signed URL.
39
- # default: 7200 seconds = 2 hours.
40
- CONFIG_PRESIGNED_URL_EXPIRATION_IN_SECONDS=7200
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * @module @p0tion/phase2cli
5
- * @version 1.0.5
4
+ * @module @devtion/devcli
5
+ * @version 1.0.6
6
6
  * @file All-in-one interactive command-line for interfacing with zkSNARK Phase 2 Trusted Setup ceremonies
7
7
  * @copyright Ethereum Foundation 2022
8
8
  * @license MIT
@@ -17,8 +17,7 @@ import boxen from 'boxen';
17
17
  import { pipeline } from 'node:stream';
18
18
  import { promisify } from 'node:util';
19
19
  import fetch$1 from 'node-fetch';
20
- import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
21
- import { commonTerms, formatZkeyIndex, getZkeyStorageFilePath, finalContributionIndex, createCustomLoggerForFile, getBucketName, progressToNextContributionStep, permanentlyStoreCurrentContributionTimeAndHash, convertToDoubleDigits, multiPartUpload, verifyContribution, generateGetObjectPreSignedUrl, convertBytesOrKbToGb, numExpIterations, getDocumentById, getParticipantsCollectionPath, fromQueryToFirebaseDocumentInfo, getAllCollectionDocs, extractPrefix, autoGenerateEntropy, vmConfigurationTypes, initializeFirebaseCoreServices, signInToFirebaseWithCredentials, getCurrentFirebaseAuthUser, isCoordinator, parseCeremonyFile, blake512FromPath, checkIfObjectExist, setupCeremony, genesisZkeyIndex, getR1csStorageFilePath, getWasmStorageFilePath, getPotStorageFilePath, extractPoTFromFilename, potFileDownloadMainUrl, createS3Bucket, potFilenameTemplate, getR1CSInfo, getOpenedCeremonies, getCeremonyCircuits, checkParticipantForCeremony, getCurrentActiveParticipantTimeout, getCircuitBySequencePosition, getCircuitContributionsFromContributor, progressToNextCircuitForContribution, resumeContributionAfterTimeoutExpiration, generateValidContributionsAttestation, getContributionsValidityForContributor, getClosedCeremonies, checkAndPrepareCoordinatorForFinalization, computeSHA256ToHex, finalizeCeremony, getVerificationKeyStorageFilePath, verificationKeyAcronym, getVerifierContractStorageFilePath, verifierSmartContractAcronym, finalizeCircuit, exportVkey, exportVerifierContract } from '@p0tion/actions';
20
+ import { commonTerms, formatZkeyIndex, getZkeyStorageFilePath, finalContributionIndex, createCustomLoggerForFile, getBucketName, progressToNextContributionStep, permanentlyStoreCurrentContributionTimeAndHash, convertToDoubleDigits, multiPartUpload, verifyContribution, generateGetObjectPreSignedUrl, convertBytesOrKbToGb, numExpIterations, getDocumentById, getParticipantsCollectionPath, fromQueryToFirebaseDocumentInfo, getAllCollectionDocs, extractPrefix, autoGenerateEntropy, vmConfigurationTypes, initializeFirebaseCoreServices, signInToFirebaseWithCredentials, getCurrentFirebaseAuthUser, isCoordinator, parseCeremonyFile, blake512FromPath, checkIfObjectExist, setupCeremony, genesisZkeyIndex, getR1csStorageFilePath, getWasmStorageFilePath, getPotStorageFilePath, extractPoTFromFilename, potFileDownloadMainUrl, createS3Bucket, potFilenameTemplate, getR1CSInfo, getOpenedCeremonies, getCeremonyCircuits, checkParticipantForCeremony, getCurrentActiveParticipantTimeout, getCircuitBySequencePosition, getCircuitContributionsFromContributor, progressToNextCircuitForContribution, resumeContributionAfterTimeoutExpiration, generateValidContributionsAttestation, getContributionsValidityForContributor, getClosedCeremonies, checkAndPrepareCoordinatorForFinalization, computeSHA256ToHex, finalizeCeremony, getVerificationKeyStorageFilePath, verificationKeyAcronym, getVerifierContractStorageFilePath, verifierSmartContractAcronym, finalizeCircuit, exportVkey, exportVerifierContract } from '@devtion/actions';
22
21
  import fetch from '@adobe/node-fetch-retry';
23
22
  import { request } from '@octokit/request';
24
23
  import { SingleBar, Presets } from 'cli-progress';
@@ -34,7 +33,6 @@ import Conf from 'conf';
34
33
  import prompts from 'prompts';
35
34
  import clear from 'clear';
36
35
  import figlet from 'figlet';
37
- import { Readable } from 'stream';
38
36
  import { createOAuthDeviceAuth } from '@octokit/auth-oauth-device';
39
37
  import clipboard from 'clipboardy';
40
38
  import open from 'open';
@@ -1853,8 +1851,6 @@ const setup = async (cmd) => {
1853
1851
  // create a new bucket
1854
1852
  const bucketName = await handleCeremonyBucketCreation(firebaseFunctions, ceremonySetupData.ceremonyPrefix);
1855
1853
  console.log(`\n${theme.symbols.success} Ceremony bucket name: ${theme.text.bold(bucketName)}`);
1856
- // create S3 clienbt
1857
- const s3 = new S3Client({ region: 'us-east-1' });
1858
1854
  // loop through each circuit
1859
1855
  for await (const circuit of setupCeremonyData.circuits) {
1860
1856
  // Local paths.
@@ -1864,21 +1860,12 @@ const setup = async (cmd) => {
1864
1860
  const potLocalPathAndFileName = getPotLocalFilePath(circuit.files.potFilename);
1865
1861
  const zkeyLocalPathAndFileName = getZkeyLocalFilePath(circuit.files.initialZkeyFilename);
1866
1862
  // 2. download the pot and wasm files
1867
- const streamPipeline = promisify(pipeline);
1868
1863
  await checkAndDownloadSmallestPowersOfTau(convertToDoubleDigits(circuit.metadata?.pot), circuit.files.potFilename);
1869
- // download the wasm to calculate the hash
1870
- const spinner = customSpinner(`Downloading the ${theme.text.bold(`#${circuit.name}`)} WASM file from the project's bucket...`, `clock`);
1871
- spinner.start();
1872
- const command = new GetObjectCommand({ Bucket: ceremonySetupData.circuitArtifacts[index].artifacts.bucket, Key: ceremonySetupData.circuitArtifacts[index].artifacts.wasmStoragePath });
1873
- const response = await s3.send(command);
1874
- if (response.$metadata.httpStatusCode !== 200) {
1875
- throw new Error("There was an error while trying to download the wasm file. Please check that the file has the correct permissions (public) set.");
1876
- }
1877
- if (response.Body instanceof Readable)
1878
- await streamPipeline(response.Body, createWriteStream(wasmLocalPathAndFileName));
1879
- spinner.stop();
1880
1864
  // 3. generate the zKey
1865
+ const spinner = customSpinner(`Generating genesis zKey for circuit ${theme.text.bold(circuit.name)}...`, `clock`);
1866
+ spinner.start();
1881
1867
  await zKey.newZKey(r1csLocalPathAndFileName, getPotLocalFilePath(circuit.files.potFilename), zkeyLocalPathAndFileName, undefined);
1868
+ spinner.succeed(`Generation of the genesis zKey for citcui ${theme.text.bold(circuit.name)} completed successfully`);
1882
1869
  // 4. calculate the hashes
1883
1870
  const wasmBlake2bHash = await blake512FromPath(wasmLocalPathAndFileName);
1884
1871
  const potBlake2bHash = await blake512FromPath(getPotLocalFilePath(circuit.files.potFilename));
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Contribution, ContributionValidity, FirebaseDocumentInfo } from "@p0tion/actions";
2
+ import { Contribution, ContributionValidity, FirebaseDocumentInfo } from "@devtion/actions";
3
3
  import { DocumentSnapshot, DocumentData, Firestore } from "firebase/firestore";
4
4
  import { Functions } from "firebase/functions";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { FirebaseDocumentInfo } from "@p0tion/actions";
2
+ import { FirebaseDocumentInfo } from "@devtion/actions";
3
3
  import { Functions } from "firebase/functions";
4
4
  import { Firestore } from "firebase/firestore";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { FirebaseDocumentInfo } from "@p0tion/actions";
2
+ import { FirebaseDocumentInfo } from "@devtion/actions";
3
3
  import { Firestore } from "firebase/firestore";
4
4
  /**
5
5
  * Clean cursor lines from current position back to root (default: zero).
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Functions } from "firebase/functions";
3
- import { CeremonyTimeoutType, CircomCompilerData, CircuitInputData, CeremonyInputData, CircuitDocument } from "@p0tion/actions";
3
+ import { CeremonyTimeoutType, CircomCompilerData, CircuitInputData, CeremonyInputData, CircuitDocument } from "@devtion/actions";
4
4
  /**
5
5
  * Handle whatever is needed to obtain the input data for a circuit that the coordinator would like to add to the ceremony.
6
6
  * @param choosenCircuitFilename <string> - the name of the circuit to add.
@@ -1,6 +1,6 @@
1
1
  import { Answers } from "prompts";
2
2
  import { Firestore } from "firebase/firestore";
3
- import { CeremonyInputData, FirebaseDocumentInfo, CircomCompilerData, CircuitInputData, CeremonyTimeoutType, DiskTypeForVM } from "@p0tion/actions";
3
+ import { CeremonyInputData, FirebaseDocumentInfo, CircomCompilerData, CircuitInputData, CeremonyTimeoutType, DiskTypeForVM } from "@devtion/actions";
4
4
  /**
5
5
  * Ask a binary (yes/no or true/false) customizable question.
6
6
  * @param question <string> - the question to be answered.
@@ -1,4 +1,4 @@
1
- import { FirebaseDocumentInfo } from "@p0tion/actions";
1
+ import { FirebaseDocumentInfo } from "@devtion/actions";
2
2
  import { OAuthCredential } from "firebase/auth";
3
3
  import { DocumentData, Firestore } from "firebase/firestore";
4
4
  import { Functions } from "firebase/functions";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devtion/devcli",
3
3
  "type": "module",
4
- "version": "0.0.0-7140596",
4
+ "version": "0.0.0-92056fa",
5
5
  "description": "All-in-one interactive command-line for interfacing with zkSNARK Phase 2 Trusted Setup ceremonies",
6
6
  "repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
7
7
  "homepage": "https://github.com/privacy-scaling-explorations/p0tion",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "5f4dde47fdee59378296f3581ce9c7ce01676083"
100
+ "gitHead": "9ecb8d55d49edf248244fdd83e06deb20036c340"
101
101
  }
@@ -22,7 +22,7 @@ import {
22
22
  generateValidContributionsAttestation,
23
23
  commonTerms,
24
24
  convertToDoubleDigits
25
- } from "@p0tion/actions"
25
+ } from "@devtion/actions"
26
26
  import { DocumentSnapshot, DocumentData, Firestore, onSnapshot, Timestamp } from "firebase/firestore"
27
27
  import { Functions } from "firebase/functions"
28
28
  import open from "open"
@@ -22,7 +22,7 @@ import {
22
22
  exportVerifierContract,
23
23
  FirebaseDocumentInfo,
24
24
  exportVkey
25
- } from "@p0tion/actions"
25
+ } from "@devtion/actions"
26
26
  import { Functions } from "firebase/functions"
27
27
  import { Firestore } from "firebase/firestore"
28
28
  import { dirname } from "path"
@@ -1,4 +1,4 @@
1
- import { commonTerms, getAllCollectionDocs } from "@p0tion/actions"
1
+ import { commonTerms, getAllCollectionDocs } from "@devtion/actions"
2
2
  import { showError } from "../lib/errors.js"
3
3
  import { bootstrapCommandExecutionAndServices } from "../lib/services.js"
4
4
 
@@ -7,7 +7,7 @@ import {
7
7
  getOpenedCeremonies,
8
8
  isCoordinator,
9
9
  convertToDoubleDigits
10
- } from "@p0tion/actions"
10
+ } from "@devtion/actions"
11
11
  import { Firestore } from "firebase/firestore"
12
12
  import logSymbols from "log-symbols"
13
13
  import readline from "readline"
@@ -37,7 +37,7 @@ import {
37
37
  setupCeremony,
38
38
  parseCeremonyFile,
39
39
  CircuitContributionVerificationMechanism
40
- } from "@p0tion/actions"
40
+ } from "@devtion/actions"
41
41
  import { customSpinner, simpleLoader, sleep, terminate } from "../lib/utils.js"
42
42
  import {
43
43
  promptCeremonyInputData,
@@ -516,9 +516,6 @@ const setup = async (cmd: { template?: string, auth?: string}) => {
516
516
  const bucketName = await handleCeremonyBucketCreation(firebaseFunctions, ceremonySetupData.ceremonyPrefix)
517
517
  console.log(`\n${theme.symbols.success} Ceremony bucket name: ${theme.text.bold(bucketName)}`)
518
518
 
519
- // create S3 clienbt
520
- const s3 = new S3Client({region: 'us-east-1'})
521
-
522
519
  // loop through each circuit
523
520
  for await (const circuit of setupCeremonyData.circuits) {
524
521
  // Local paths.
@@ -529,32 +526,14 @@ const setup = async (cmd: { template?: string, auth?: string}) => {
529
526
  const zkeyLocalPathAndFileName = getZkeyLocalFilePath(circuit.files.initialZkeyFilename)
530
527
 
531
528
  // 2. download the pot and wasm files
532
- const streamPipeline = promisify(pipeline)
533
529
  await checkAndDownloadSmallestPowersOfTau(convertToDoubleDigits(circuit.metadata?.pot!), circuit.files.potFilename)
534
530
 
535
- // download the wasm to calculate the hash
536
- const spinner = customSpinner(
537
- `Downloading the ${theme.text.bold(
538
- `#${circuit.name}`
539
- )} WASM file from the project's bucket...`,
540
- `clock`
541
- )
542
- spinner.start()
543
- const command = new GetObjectCommand({ Bucket: ceremonySetupData.circuitArtifacts[index].artifacts.bucket, Key: ceremonySetupData.circuitArtifacts[index].artifacts.wasmStoragePath })
544
-
545
- const response = await s3.send(command)
546
-
547
- if (response.$metadata.httpStatusCode !== 200) {
548
- throw new Error("There was an error while trying to download the wasm file. Please check that the file has the correct permissions (public) set.")
549
- }
550
-
551
- if (response.Body instanceof Readable)
552
- await streamPipeline(response.Body, createWriteStream(wasmLocalPathAndFileName))
553
-
554
- spinner.stop()
555
531
  // 3. generate the zKey
532
+ const spinner = customSpinner(`Generating genesis zKey for circuit ${theme.text.bold(circuit.name)}...`, `clock`)
533
+ spinner.start()
556
534
  await zKey.newZKey(r1csLocalPathAndFileName, getPotLocalFilePath(circuit.files.potFilename), zkeyLocalPathAndFileName, undefined)
557
-
535
+ spinner.succeed(`Generation of the genesis zKey for citcui ${theme.text.bold(circuit.name)} completed successfully`)
536
+
558
537
  // 4. calculate the hashes
559
538
  const wasmBlake2bHash = await blake512FromPath(wasmLocalPathAndFileName)
560
539
  const potBlake2bHash = await blake512FromPath(getPotLocalFilePath(circuit.files.potFilename))
@@ -1,4 +1,4 @@
1
- import { parseCeremonyFile } from "@p0tion/actions"
1
+ import { parseCeremonyFile } from "@devtion/actions"
2
2
  import { showError } from "../lib/errors.js"
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { commonTerms } from "@p0tion/actions"
1
+ import { commonTerms } from "@devtion/actions"
2
2
  import Conf from "conf"
3
3
  import { dirname } from "path"
4
4
  import { readFileSync } from "fs"
@@ -14,7 +14,7 @@ import {
14
14
  CircuitContributionVerificationMechanism,
15
15
  vmConfigurationTypes,
16
16
  DiskTypeForVM
17
- } from "@p0tion/actions"
17
+ } from "@devtion/actions"
18
18
  import theme from "./theme.js"
19
19
  import { COMMAND_ERRORS, showError } from "./errors.js"
20
20
 
@@ -2,7 +2,7 @@ import {
2
2
  getCurrentFirebaseAuthUser,
3
3
  initializeFirebaseCoreServices,
4
4
  signInToFirebaseWithCredentials
5
- } from "@p0tion/actions"
5
+ } from "@devtion/actions"
6
6
  import clear from "clear"
7
7
  import figlet from "figlet"
8
8
  import { FirebaseApp } from "firebase/app"
package/src/lib/utils.ts CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  permanentlyStoreCurrentContributionTimeAndHash,
20
20
  progressToNextContributionStep,
21
21
  verifyContribution
22
- } from "@p0tion/actions"
22
+ } from "@devtion/actions"
23
23
  import { Presets, SingleBar } from "cli-progress"
24
24
  import dotenv from "dotenv"
25
25
  import { GithubAuthProvider, OAuthCredential } from "firebase/auth"