@devtion/actions 0.0.0-bfc9ee4 → 0.0.0-c1f4cbe
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 +1 -1
- package/dist/index.mjs +331 -298
- package/dist/index.node.js +331 -297
- package/dist/types/src/helpers/constants.d.ts +8 -0
- package/dist/types/src/helpers/constants.d.ts.map +1 -1
- package/dist/types/src/helpers/contracts.d.ts.map +1 -1
- package/dist/types/src/helpers/crypto.d.ts +1 -0
- package/dist/types/src/helpers/crypto.d.ts.map +1 -1
- package/dist/types/src/helpers/database.d.ts +8 -0
- package/dist/types/src/helpers/database.d.ts.map +1 -1
- package/dist/types/src/helpers/security.d.ts +2 -2
- package/dist/types/src/helpers/security.d.ts.map +1 -1
- package/dist/types/src/helpers/storage.d.ts +5 -2
- package/dist/types/src/helpers/storage.d.ts.map +1 -1
- package/dist/types/src/helpers/utils.d.ts +34 -20
- package/dist/types/src/helpers/utils.d.ts.map +1 -1
- package/dist/types/src/helpers/verification.d.ts +3 -2
- package/dist/types/src/helpers/verification.d.ts.map +1 -1
- package/dist/types/src/helpers/vm.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +9 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/package.json +3 -8
- package/src/helpers/constants.ts +8 -0
- package/src/helpers/contracts.ts +3 -3
- package/src/helpers/database.ts +13 -0
- package/src/helpers/functions.ts +1 -1
- package/src/helpers/security.ts +33 -52
- package/src/helpers/services.ts +3 -3
- package/src/helpers/storage.ts +15 -3
- package/src/helpers/utils.ts +316 -277
- package/src/helpers/verification.ts +6 -6
- package/src/helpers/vm.ts +14 -7
- package/src/index.ts +3 -2
- package/src/types/index.ts +32 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { groth16, zKey } from "snarkjs"
|
|
1
|
+
import { CircuitSignals, Groth16Proof, PublicSignals, groth16, zKey } from "snarkjs"
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
import { Firestore, where } from "firebase/firestore"
|
|
4
4
|
import { Functions } from "firebase/functions"
|
|
@@ -61,7 +61,7 @@ export const verifyZKey = async (
|
|
|
61
61
|
* @returns <Promise<object>> The proof
|
|
62
62
|
*/
|
|
63
63
|
export const generateGROTH16Proof = async (
|
|
64
|
-
circuitInput:
|
|
64
|
+
circuitInput: CircuitSignals,
|
|
65
65
|
zkeyFilePath: string,
|
|
66
66
|
wasmFilePath: string,
|
|
67
67
|
logger?: any
|
|
@@ -88,8 +88,8 @@ export const generateGROTH16Proof = async (
|
|
|
88
88
|
*/
|
|
89
89
|
export const verifyGROTH16Proof = async (
|
|
90
90
|
verificationKeyPath: string,
|
|
91
|
-
publicSignals:
|
|
92
|
-
proof:
|
|
91
|
+
publicSignals: PublicSignals,
|
|
92
|
+
proof: Groth16Proof
|
|
93
93
|
): Promise<boolean> => {
|
|
94
94
|
const verificationKey = JSON.parse(fs.readFileSync(verificationKeyPath).toString())
|
|
95
95
|
const success = await groth16.verify(verificationKey, publicSignals, proof)
|
|
@@ -182,8 +182,8 @@ export const generateZkeyFromScratch = async (
|
|
|
182
182
|
await zKey.beacon(
|
|
183
183
|
finalContributionZKeyLocalPath,
|
|
184
184
|
zkeyLocalPath,
|
|
185
|
-
coordinatorIdentifier
|
|
186
|
-
beacon
|
|
185
|
+
coordinatorIdentifier!,
|
|
186
|
+
beacon!,
|
|
187
187
|
numExpIterations,
|
|
188
188
|
logger
|
|
189
189
|
)
|
package/src/helpers/vm.ts
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
StopInstancesCommand,
|
|
6
6
|
TerminateInstancesCommand,
|
|
7
7
|
EC2Client,
|
|
8
|
-
RunInstancesCommandInput
|
|
8
|
+
RunInstancesCommandInput,
|
|
9
|
+
_InstanceType
|
|
9
10
|
} from "@aws-sdk/client-ec2"
|
|
10
11
|
import {
|
|
11
12
|
GetCommandInvocationCommand,
|
|
@@ -82,7 +83,7 @@ export const vmDependenciesAndCacheArtifactsCommand = (
|
|
|
82
83
|
zKeyPath: string,
|
|
83
84
|
potPath: string,
|
|
84
85
|
snsTopic: string,
|
|
85
|
-
region: string
|
|
86
|
+
region: string
|
|
86
87
|
): Array<string> => [
|
|
87
88
|
"#!/bin/bash",
|
|
88
89
|
'MARKER_FILE="/var/run/my_script_ran"',
|
|
@@ -93,8 +94,13 @@ export const vmDependenciesAndCacheArtifactsCommand = (
|
|
|
93
94
|
// eslint-disable-next-line no-template-curly-in-string
|
|
94
95
|
"touch ${MARKER_FILE}",
|
|
95
96
|
"sudo yum update -y",
|
|
96
|
-
"curl -
|
|
97
|
-
"
|
|
97
|
+
"curl -O https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.xz",
|
|
98
|
+
"tar -xf node-v16.13.0-linux-x64.tar.xz",
|
|
99
|
+
"mv node-v16.13.0-linux-x64 nodejs",
|
|
100
|
+
"sudo mv nodejs /opt/",
|
|
101
|
+
"echo 'export NODEJS_HOME=/opt/nodejs' >> /etc/profile",
|
|
102
|
+
"echo 'export PATH=$NODEJS_HOME/bin:$PATH' >> /etc/profile",
|
|
103
|
+
"source /etc/profile",
|
|
98
104
|
"npm install -g snarkjs",
|
|
99
105
|
`aws s3 cp s3://${zKeyPath} /var/tmp/genesisZkey.zkey`,
|
|
100
106
|
`aws s3 cp s3://${potPath} /var/tmp/pot.ptau`,
|
|
@@ -118,6 +124,7 @@ export const vmContributionVerificationCommand = (
|
|
|
118
124
|
lastZkeyStoragePath: string,
|
|
119
125
|
verificationTranscriptStoragePathAndFilename: string
|
|
120
126
|
): Array<string> => [
|
|
127
|
+
`source /etc/profile`,
|
|
121
128
|
`aws s3 cp s3://${bucketName}/${lastZkeyStoragePath} /var/tmp/lastZKey.zkey > /var/tmp/log.txt`,
|
|
122
129
|
`snarkjs zkvi /var/tmp/genesisZkey.zkey /var/tmp/pot.ptau /var/tmp/lastZKey.zkey > /var/tmp/verification_transcript.log`,
|
|
123
130
|
`aws s3 cp /var/tmp/verification_transcript.log s3://${bucketName}/${verificationTranscriptStoragePathAndFilename} &>/dev/null`,
|
|
@@ -153,17 +160,17 @@ export const createEC2Instance = async (
|
|
|
153
160
|
diskType: DiskTypeForVM
|
|
154
161
|
): Promise<EC2Instance> => {
|
|
155
162
|
// Get the AWS variables.
|
|
156
|
-
const { amiId,
|
|
163
|
+
const { amiId, instanceProfileArn } = getAWSVariables()
|
|
157
164
|
|
|
158
165
|
// Parametrize the VM EC2 instance.
|
|
159
166
|
const params: RunInstancesCommandInput = {
|
|
160
167
|
ImageId: amiId,
|
|
161
|
-
InstanceType: instanceType,
|
|
168
|
+
InstanceType: instanceType as _InstanceType,
|
|
162
169
|
MaxCount: 1,
|
|
163
170
|
MinCount: 1,
|
|
164
171
|
// nb. to find this: iam -> roles -> role_name.
|
|
165
172
|
IamInstanceProfile: {
|
|
166
|
-
Arn:
|
|
173
|
+
Arn: instanceProfileArn
|
|
167
174
|
},
|
|
168
175
|
// nb. for running commands at the startup.
|
|
169
176
|
UserData: Buffer.from(commands.join("\n")).toString("base64"),
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export {
|
|
|
23
23
|
getContributionsCollectionPath,
|
|
24
24
|
getTimeoutsCollectionPath,
|
|
25
25
|
getOpenedCeremonies,
|
|
26
|
+
getAllCeremonies,
|
|
26
27
|
getCeremonyCircuits
|
|
27
28
|
} from "./helpers/database"
|
|
28
29
|
export {
|
|
@@ -87,7 +88,7 @@ export {
|
|
|
87
88
|
verifyContribution,
|
|
88
89
|
checkAndPrepareCoordinatorForFinalization,
|
|
89
90
|
finalizeCircuit,
|
|
90
|
-
finalizeCeremony
|
|
91
|
+
finalizeCeremony
|
|
91
92
|
} from "./helpers/functions"
|
|
92
93
|
export { toHex, blake512FromPath, computeSHA256ToHex, compareHashes } from "./helpers/crypto"
|
|
93
94
|
export {
|
|
@@ -159,4 +160,4 @@ export {
|
|
|
159
160
|
createEC2Client,
|
|
160
161
|
vmContributionVerificationCommand,
|
|
161
162
|
retrieveCommandStatus
|
|
162
|
-
} from "./helpers/vm"
|
|
163
|
+
} from "./helpers/vm"
|
package/src/types/index.ts
CHANGED
|
@@ -17,14 +17,14 @@ import {
|
|
|
17
17
|
* @property {string} accessKeyId - the key identifier related to S3 APIs.
|
|
18
18
|
* @property {string} secretAccessKey - the secret access key related to S3 APIs.
|
|
19
19
|
* @property {string} region - the region where your buckets are located.
|
|
20
|
-
* @property {string}
|
|
20
|
+
* @property {string} instanceProfileArn - the EC2 instance profile the VM should use to access S3.
|
|
21
21
|
* @property {string} amiId - the AWS AMI ID (default to Amazon Linux 2).
|
|
22
22
|
*/
|
|
23
23
|
export type AWSVariables = {
|
|
24
24
|
accessKeyId: string
|
|
25
25
|
secretAccessKey: string
|
|
26
26
|
region: string
|
|
27
|
-
|
|
27
|
+
instanceProfileArn: string
|
|
28
28
|
amiId: string
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -190,7 +190,7 @@ export type VMConfiguration = {
|
|
|
190
190
|
/**
|
|
191
191
|
* Group information about the circuit contribution verification mechanism.
|
|
192
192
|
* @typedef {Object} CircuitContributionVerification
|
|
193
|
-
* @property {CircuitContributionVerificationMechanism} cfOrVm - the mechanism
|
|
193
|
+
* @property {CircuitContributionVerificationMechanism} cfOrVm - the mechanism chosen by the coordinator.
|
|
194
194
|
* @property {VMConfiguration} [vm] - the VM configuration specs.
|
|
195
195
|
*/
|
|
196
196
|
export type CircuitContributionVerification = {
|
|
@@ -620,7 +620,6 @@ export type SetupCeremonyData = {
|
|
|
620
620
|
circuitArtifacts: Array<CeremonySetupTemplateCircuitArtifacts>
|
|
621
621
|
}
|
|
622
622
|
|
|
623
|
-
|
|
624
623
|
export type CeremonySetupTemplateCircuitArtifacts = {
|
|
625
624
|
artifacts: {
|
|
626
625
|
bucket: string
|
|
@@ -640,11 +639,36 @@ export type CeremonySetupTemplateCircuitName = {
|
|
|
640
639
|
}
|
|
641
640
|
|
|
642
641
|
export type CeremonySetupTemplate = {
|
|
643
|
-
title: string
|
|
642
|
+
title: string
|
|
644
643
|
description: string
|
|
645
644
|
startDate: string
|
|
646
645
|
endDate: string
|
|
647
646
|
timeoutMechanismType: CeremonyTimeoutType
|
|
648
|
-
penalty: number
|
|
649
|
-
circuits: Array<
|
|
650
|
-
|
|
647
|
+
penalty: number
|
|
648
|
+
circuits: Array<
|
|
649
|
+
CircuitDocument &
|
|
650
|
+
CeremonySetupTemplateCircuitArtifacts &
|
|
651
|
+
CeremonySetupTemplateCircuitTimeout &
|
|
652
|
+
CeremonySetupTemplateCircuitName
|
|
653
|
+
>
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
export type StringifiedBigInts =
|
|
657
|
+
| StringifiedBigInts[]
|
|
658
|
+
| string
|
|
659
|
+
| string[]
|
|
660
|
+
| string[][]
|
|
661
|
+
| string[][][]
|
|
662
|
+
| { [key: string]: StringifiedBigInts }
|
|
663
|
+
| null
|
|
664
|
+
|
|
665
|
+
export type BigIntVariants =
|
|
666
|
+
| BigIntVariants[]
|
|
667
|
+
| StringifiedBigInts
|
|
668
|
+
| bigint
|
|
669
|
+
| bigint[]
|
|
670
|
+
| bigint[][]
|
|
671
|
+
| bigint[][][]
|
|
672
|
+
| { [key: string]: BigIntVariants }
|
|
673
|
+
| Uint8Array
|
|
674
|
+
| null
|