@devtion/devcli 0.0.0-7e983e3 → 0.0.0-8b5a17f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,6 +61,8 @@ or run specific commands with `npx`:
61
61
  npx @p0tion/phase2cli contribute
62
62
  ```
63
63
 
64
+ > Please note that phase2cli only runs on Linux or Mac systems. If a Windows user, please install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) first.
65
+
64
66
  ## 📜 Usage
65
67
 
66
68
  ### Local Development
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';
@@ -809,7 +807,7 @@ const handleStartOrResumeContribution = async (cloudFunctions, firestoreDatabase
809
807
  console.log(`${theme.symbols.success} Contribution ${theme.text.bold(`#${nextZkeyIndex}`)} already computed`);
810
808
  // Contribution step = UPLOADING.
811
809
  if (isFinalizing || participantData.contributionStep === "UPLOADING" /* ParticipantContributionStep.UPLOADING */) {
812
- spinner.text = `Uploading ${isFinalizing ? "final" : "your"} contribution ${!isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : ""} to storage.\n${theme.symbols.warning} This step may take a while based on circuit size and your contribution speed. Everything's fine, just be patient.`;
810
+ spinner.text = `Uploading ${isFinalizing ? "final" : "your"} contribution ${!isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : ""} to storage.\n${theme.symbols.warning} This step may take a while based on circuit size and your internet speed. Everything's fine, just be patient.`;
813
811
  spinner.start();
814
812
  if (!isFinalizing)
815
813
  await multiPartUpload(cloudFunctions, bucketName, nextZkeyStorageFilePath, nextZkeyLocalFilePath, Number(process.env.CONFIG_STREAM_CHUNK_SIZE_IN_MB), ceremony.id, participantData.tempContributionData);
@@ -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));
@@ -2113,8 +2100,9 @@ const onVerification = async (verification) => {
2113
2100
  clipboard.writeSync(verification.user_code);
2114
2101
  clipboard.readSync();
2115
2102
  // Display data.
2116
- console.log(`${theme.symbols.warning} Visit ${theme.text.bold(theme.text.underlined(verification.verification_uri))} on this device to generate a new token and authenticate`);
2117
- console.log(`${theme.symbols.info} Your auth code: ${theme.text.bold(verification.user_code)} (${theme.emojis.clipboard} ${theme.symbols.success})\n`);
2103
+ console.log(`${theme.symbols.warning} Visit ${theme.text.bold(theme.text.underlined(verification.verification_uri))} on this device to generate a new token and authenticate\n`);
2104
+ console.log(theme.colors.magenta(figlet.textSync("Code is Below", { font: "ANSI Shadow" })), '\n');
2105
+ console.log(`${theme.symbols.info} Your auth code: ${theme.text.bold(verification.user_code)} has been copied to your clipboard (${theme.emojis.clipboard} ${theme.symbols.success})\n`);
2118
2106
  const spinner = customSpinner(`Redirecting to Github...`, `clock`);
2119
2107
  spinner.start();
2120
2108
  await sleep(10000); // ~10s to make users able to read the CLI.
@@ -2407,7 +2395,6 @@ const listenToCeremonyCircuitDocumentChanges = (firestoreDatabase, ceremonyId, p
2407
2395
  const { avgTimings, waitingQueue } = changedCircuit.data();
2408
2396
  const { fullContribution, verifyCloudFunction } = avgTimings;
2409
2397
  const { currentContributor } = waitingQueue;
2410
- // Get circuit current contributor participant document.
2411
2398
  const circuitCurrentContributor = await getDocumentById(firestoreDatabase, getParticipantsCollectionPath(ceremonyId), currentContributor);
2412
2399
  // Check data.
2413
2400
  if (!circuitCurrentContributor.data())
@@ -2616,7 +2603,7 @@ const listenToParticipantDocumentChanges = async (firestoreDatabase, cloudFuncti
2616
2603
  // Get latest contribution verification result.
2617
2604
  await getLatestVerificationResult(firestoreDatabase, ceremony.id, circuit.id, participant.id);
2618
2605
  // Get next circuit for contribution.
2619
- const nextCircuit = getCircuitBySequencePosition(circuits, changedContributionProgress + 1);
2606
+ const nextCircuit = timeoutExpired ? getCircuitBySequencePosition(circuits, changedContributionProgress) : getCircuitBySequencePosition(circuits, changedContributionProgress + 1);
2620
2607
  // Check disk space requirements for participant.
2621
2608
  const wannaGenerateAttestation = await handleDiskSpaceRequirementForNextContribution(cloudFunctions, ceremony.id, nextCircuit.data.sequencePosition, nextCircuit.data.zKeySizeInBytes, timeoutExpired, providerUserId);
2622
2609
  // Check if the participant would like to generate a new attestation.
@@ -2654,11 +2641,12 @@ const listenToParticipantDocumentChanges = async (firestoreDatabase, cloudFuncti
2654
2641
  */
2655
2642
  const contribute = async (opt) => {
2656
2643
  const { firebaseApp, firebaseFunctions, firestoreDatabase } = await bootstrapCommandExecutionAndServices();
2657
- // Check for authentication.
2658
- const { user, providerUserId, token } = await checkAuth(firebaseApp);
2659
2644
  // Get options.
2660
2645
  const ceremonyOpt = opt.ceremony;
2661
2646
  const entropyOpt = opt.entropy;
2647
+ const auth = opt.auth;
2648
+ // Check for authentication.
2649
+ const { user, providerUserId, token } = auth ? await authWithToken(firebaseApp, auth) : await checkAuth(firebaseApp);
2662
2650
  // Prepare data.
2663
2651
  let selectedCeremony;
2664
2652
  // Retrieve the opened ceremonies.
@@ -3168,6 +3156,7 @@ program
3168
3156
  .description("compute contributions for a Phase2 Trusted Setup ceremony circuits")
3169
3157
  .option("-c, --ceremony <string>", "the prefix of the ceremony you want to contribute for", "")
3170
3158
  .option("-e, --entropy <string>", "the entropy (aka toxic waste) of your contribution", "")
3159
+ .option("-a, --auth <string>", "the Github OAuth 2.0 token", "")
3171
3160
  .action(contribute);
3172
3161
  program
3173
3162
  .command("clean")
@@ -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-7e983e3",
4
+ "version": "0.0.0-8b5a17f",
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",
@@ -64,10 +64,11 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@adobe/node-fetch-retry": "^2.2.0",
67
+ "@aws-sdk/client-s3": "^3.329.0",
68
+ "@devtion/actions": "latest",
67
69
  "@octokit/auth-oauth-app": "^5.0.5",
68
70
  "@octokit/auth-oauth-device": "^4.0.4",
69
71
  "@octokit/request": "^6.2.3",
70
- "@p0tion/actions": "^1.0.5",
71
72
  "blakejs": "^1.2.1",
72
73
  "boxen": "^7.1.0",
73
74
  "chalk": "^5.2.0",
@@ -96,5 +97,5 @@
96
97
  "publishConfig": {
97
98
  "access": "public"
98
99
  },
99
- "gitHead": "afae72061a3b366b05508de53fe91e9b254cc3d5"
100
+ "gitHead": "df754397c15a7086a163688fb4d3f4e7c98ad379"
100
101
  }
@@ -4,6 +4,7 @@ import { Verification } from "@octokit/auth-oauth-device/dist-types/types.js"
4
4
  import clipboard from "clipboardy"
5
5
  import dotenv from "dotenv"
6
6
  import open from "open"
7
+ import figlet from "figlet"
7
8
  import { fileURLToPath } from "url"
8
9
  import { dirname } from "path"
9
10
  import { GENERIC_ERRORS, showError } from "../lib/errors.js"
@@ -69,10 +70,13 @@ export const onVerification = async (verification: Verification): Promise<void>
69
70
  console.log(
70
71
  `${theme.symbols.warning} Visit ${theme.text.bold(
71
72
  theme.text.underlined(verification.verification_uri)
72
- )} on this device to generate a new token and authenticate`
73
+ )} on this device to generate a new token and authenticate\n`
73
74
  )
75
+
76
+ console.log(theme.colors.magenta(figlet.textSync("Code is Below", { font: "ANSI Shadow" })), '\n')
77
+
74
78
  console.log(
75
- `${theme.symbols.info} Your auth code: ${theme.text.bold(verification.user_code)} (${theme.emojis.clipboard} ${
79
+ `${theme.symbols.info} Your auth code: ${theme.text.bold(verification.user_code)} has been copied to your clipboard (${theme.emojis.clipboard} ${
76
80
  theme.symbols.success
77
81
  })\n`
78
82
  )
@@ -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"
@@ -40,7 +40,7 @@ import {
40
40
  estimateParticipantFreeGlobalDiskSpace
41
41
  } from "../lib/utils.js"
42
42
  import { COMMAND_ERRORS, showError } from "../lib/errors.js"
43
- import { bootstrapCommandExecutionAndServices, checkAuth } from "../lib/services.js"
43
+ import { authWithToken, bootstrapCommandExecutionAndServices, checkAuth } from "../lib/services.js"
44
44
  import { getAttestationLocalFilePath, localPaths } from "../lib/localConfigs.js"
45
45
  import theme from "../lib/theme.js"
46
46
  import { checkAndMakeNewDirectoryIfNonexistent, writeFile } from "../lib/files.js"
@@ -464,7 +464,6 @@ export const listenToCeremonyCircuitDocumentChanges = (
464
464
  const { fullContribution, verifyCloudFunction } = avgTimings
465
465
  const { currentContributor } = waitingQueue
466
466
 
467
- // Get circuit current contributor participant document.
468
467
  const circuitCurrentContributor = await getDocumentById(
469
468
  firestoreDatabase,
470
469
  getParticipantsCollectionPath(ceremonyId),
@@ -811,7 +810,7 @@ export const listenToParticipantDocumentChanges = async (
811
810
  await getLatestVerificationResult(firestoreDatabase, ceremony.id, circuit.id, participant.id)
812
811
 
813
812
  // Get next circuit for contribution.
814
- const nextCircuit = getCircuitBySequencePosition(circuits, changedContributionProgress + 1)
813
+ const nextCircuit = timeoutExpired ? getCircuitBySequencePosition(circuits, changedContributionProgress) : getCircuitBySequencePosition(circuits, changedContributionProgress + 1)
815
814
 
816
815
  // Check disk space requirements for participant.
817
816
  const wannaGenerateAttestation = await handleDiskSpaceRequirementForNextContribution(
@@ -892,12 +891,13 @@ export const listenToParticipantDocumentChanges = async (
892
891
  const contribute = async (opt: any) => {
893
892
  const { firebaseApp, firebaseFunctions, firestoreDatabase } = await bootstrapCommandExecutionAndServices()
894
893
 
895
- // Check for authentication.
896
- const { user, providerUserId, token } = await checkAuth(firebaseApp)
897
-
898
894
  // Get options.
899
895
  const ceremonyOpt = opt.ceremony
900
896
  const entropyOpt = opt.entropy
897
+ const auth = opt.auth
898
+
899
+ // Check for authentication.
900
+ const { user, providerUserId, token } = auth ? await authWithToken(firebaseApp, auth) : await checkAuth(firebaseApp)
901
901
 
902
902
  // Prepare data.
903
903
  let selectedCeremony: FirebaseDocumentInfo
@@ -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"
@@ -7,7 +7,6 @@ import { pipeline } from "node:stream"
7
7
  import { promisify } from "node:util"
8
8
  import fetch from "node-fetch"
9
9
  import { Functions } from "firebase/functions"
10
- import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"
11
10
  import {
12
11
  CeremonyTimeoutType,
13
12
  CircomCompilerData,
@@ -37,7 +36,7 @@ import {
37
36
  setupCeremony,
38
37
  parseCeremonyFile,
39
38
  CircuitContributionVerificationMechanism
40
- } from "@p0tion/actions"
39
+ } from "@devtion/actions"
41
40
  import { customSpinner, simpleLoader, sleep, terminate } from "../lib/utils.js"
42
41
  import {
43
42
  promptCeremonyInputData,
@@ -63,7 +62,6 @@ import {
63
62
  getFileStats,
64
63
  checkAndMakeNewDirectoryIfNonexistent
65
64
  } from "../lib/files.js"
66
- import { Readable } from "stream"
67
65
 
68
66
  /**
69
67
  * Handle whatever is needed to obtain the input data for a circuit that the coordinator would like to add to the ceremony.
@@ -516,9 +514,6 @@ const setup = async (cmd: { template?: string, auth?: string}) => {
516
514
  const bucketName = await handleCeremonyBucketCreation(firebaseFunctions, ceremonySetupData.ceremonyPrefix)
517
515
  console.log(`\n${theme.symbols.success} Ceremony bucket name: ${theme.text.bold(bucketName)}`)
518
516
 
519
- // create S3 clienbt
520
- const s3 = new S3Client({region: 'us-east-1'})
521
-
522
517
  // loop through each circuit
523
518
  for await (const circuit of setupCeremonyData.circuits) {
524
519
  // Local paths.
@@ -529,32 +524,14 @@ const setup = async (cmd: { template?: string, auth?: string}) => {
529
524
  const zkeyLocalPathAndFileName = getZkeyLocalFilePath(circuit.files.initialZkeyFilename)
530
525
 
531
526
  // 2. download the pot and wasm files
532
- const streamPipeline = promisify(pipeline)
533
527
  await checkAndDownloadSmallestPowersOfTau(convertToDoubleDigits(circuit.metadata?.pot!), circuit.files.potFilename)
534
528
 
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
529
  // 3. generate the zKey
530
+ const spinner = customSpinner(`Generating genesis zKey for circuit ${theme.text.bold(circuit.name)}...`, `clock`)
531
+ spinner.start()
556
532
  await zKey.newZKey(r1csLocalPathAndFileName, getPotLocalFilePath(circuit.files.potFilename), zkeyLocalPathAndFileName, undefined)
557
-
533
+ spinner.succeed(`Generation of the genesis zKey for citcui ${theme.text.bold(circuit.name)} completed successfully`)
534
+
558
535
  // 4. calculate the hashes
559
536
  const wasmBlake2bHash = await blake512FromPath(wasmLocalPathAndFileName)
560
537
  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
  /**
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ program
21
21
  .description("compute contributions for a Phase2 Trusted Setup ceremony circuits")
22
22
  .option("-c, --ceremony <string>", "the prefix of the ceremony you want to contribute for", "")
23
23
  .option("-e, --entropy <string>", "the entropy (aka toxic waste) of your contribution", "")
24
+ .option("-a, --auth <string>", "the Github OAuth 2.0 token", "")
24
25
  .action(contribute)
25
26
  program
26
27
  .command("clean")
@@ -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"
@@ -696,7 +696,7 @@ export const handleStartOrResumeContribution = async (
696
696
  !isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : ""
697
697
  } to storage.\n${
698
698
  theme.symbols.warning
699
- } This step may take a while based on circuit size and your contribution speed. Everything's fine, just be patient.`
699
+ } This step may take a while based on circuit size and your internet speed. Everything's fine, just be patient.`
700
700
  spinner.start()
701
701
 
702
702
  if (!isFinalizing)