@devtion/backend 0.0.0-9c50f66 → 0.0.0-9d46256
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 +7 -7
- package/dist/src/functions/index.js +674 -356
- package/dist/src/functions/index.mjs +676 -360
- package/dist/types/functions/bandada.d.ts +4 -0
- package/dist/types/functions/bandada.d.ts.map +1 -0
- package/dist/types/functions/ceremony.d.ts.map +1 -1
- package/dist/types/functions/circuit.d.ts.map +1 -1
- package/dist/types/functions/index.d.ts +2 -0
- package/dist/types/functions/index.d.ts.map +1 -1
- package/dist/types/functions/siwe.d.ts +4 -0
- package/dist/types/functions/siwe.d.ts.map +1 -0
- package/dist/types/functions/storage.d.ts.map +1 -1
- package/dist/types/functions/timeout.d.ts.map +1 -1
- package/dist/types/functions/user.d.ts.map +1 -1
- package/dist/types/lib/errors.d.ts +3 -1
- package/dist/types/lib/errors.d.ts.map +1 -1
- package/dist/types/lib/services.d.ts +7 -0
- package/dist/types/lib/services.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts +1 -1
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +57 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/functions/bandada.ts +154 -0
- package/src/functions/ceremony.ts +19 -10
- package/src/functions/circuit.ts +444 -391
- package/src/functions/index.ts +2 -0
- package/src/functions/participant.ts +16 -16
- package/src/functions/siwe.ts +77 -0
- package/src/functions/storage.ts +13 -9
- package/src/functions/timeout.ts +17 -15
- package/src/functions/user.ts +23 -13
- package/src/lib/errors.ts +11 -1
- package/src/lib/services.ts +36 -0
- package/src/lib/utils.ts +11 -9
- package/src/types/declarations.d.ts +1 -0
- package/src/types/index.ts +61 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bandada.d.ts","sourceRoot":"","sources":["../../../src/functions/bandada.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAa/C,eAAO,MAAM,oBAAoB,mDAyI3B,CAAA;AAEN,eAAe,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ceremony.d.ts","sourceRoot":"","sources":["../../../src/functions/ceremony.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuC/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kCAiBpB,CAAA;AAEN;;;;;GAKG;AACH,eAAO,MAAM,YAAY,kCAkBnB,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"ceremony.d.ts","sourceRoot":"","sources":["../../../src/functions/ceremony.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuC/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kCAiBpB,CAAA;AAEN;;;;;GAKG;AACH,eAAO,MAAM,YAAY,kCAkBnB,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,aAAa,mDAkIpB,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,+BAA+B,oEAsCtC,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mDAiEvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circuit.d.ts","sourceRoot":"","sources":["../../../src/functions/circuit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"circuit.d.ts","sourceRoot":"","sources":["../../../src/functions/circuit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AA2CpD,OAAO,EAAuB,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAwP5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,4FAoGpC,CAAA;AAwBN;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,0EA6b9B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,+CAA+C,wEA4EtD,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,eAAe,uDA8EtB,CAAA"}
|
|
@@ -3,5 +3,7 @@ export { startCeremony, stopCeremony, setupCeremony, initEmptyWaitingQueueForCir
|
|
|
3
3
|
export { checkParticipantForCeremony, progressToNextContributionStep, permanentlyStoreCurrentContributionTimeAndHash, temporaryStoreCurrentContributionMultiPartUploadId, temporaryStoreCurrentContributionUploadedChunkData, progressToNextCircuitForContribution, checkAndPrepareCoordinatorForFinalization } from "./participant";
|
|
4
4
|
export { coordinateCeremonyParticipant, verifycontribution, refreshParticipantAfterContributionVerification, finalizeCircuit } from "./circuit";
|
|
5
5
|
export { createBucket, checkIfObjectExist, generateGetObjectPreSignedUrl, startMultiPartUpload, generatePreSignedUrlsParts, completeMultiPartUpload } from "./storage";
|
|
6
|
+
export { bandadaValidateProof } from "./bandada";
|
|
7
|
+
export { checkNonceOfSIWEAddress } from "./siwe";
|
|
6
8
|
export { checkAndRemoveBlockingContributor, resumeContributionAfterTimeoutExpiration } from "./timeout";
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EACH,aAAa,EACb,YAAY,EACZ,aAAa,EACb,+BAA+B,EAC/B,gBAAgB,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,2BAA2B,EAC3B,8BAA8B,EAC9B,8CAA8C,EAC9C,kDAAkD,EAClD,kDAAkD,EAClD,oCAAoC,EACpC,yCAAyC,EAC5C,MAAM,eAAe,CAAA;AACtB,OAAO,EACH,6BAA6B,EAC7B,kBAAkB,EAClB,+CAA+C,EAC/C,eAAe,EAClB,MAAM,WAAW,CAAA;AAClB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,6BAA6B,EAC7B,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EAC1B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,iCAAiC,EAAE,wCAAwC,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EACH,aAAa,EACb,YAAY,EACZ,aAAa,EACb,+BAA+B,EAC/B,gBAAgB,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,2BAA2B,EAC3B,8BAA8B,EAC9B,8CAA8C,EAC9C,kDAAkD,EAClD,kDAAkD,EAClD,oCAAoC,EACpC,yCAAyC,EAC5C,MAAM,eAAe,CAAA;AACtB,OAAO,EACH,6BAA6B,EAC7B,kBAAkB,EAClB,+CAA+C,EAC/C,eAAe,EAClB,MAAM,WAAW,CAAA;AAClB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,6BAA6B,EAC7B,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EAC1B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,iCAAiC,EAAE,wCAAwC,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siwe.d.ts","sourceRoot":"","sources":["../../../src/functions/siwe.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAQ/C,eAAO,MAAM,uBAAuB,mDAgE9B,CAAA;AAEN,eAAe,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/functions/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAiI/C;;;GAGG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/functions/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAiI/C;;;GAGG;AACH,eAAO,MAAM,YAAY,mDAmGnB,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,kBAAkB,mDAgDzB,CAAA;AAEN;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,mDAyCpC,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,oBAAoB,mDA2D3B,CAAA;AAEN;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,mDAwElC,CAAA;AAEL;;;GAGG;AACH,eAAO,MAAM,uBAAuB,mDAgE9B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../../src/functions/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,
|
|
1
|
+
{"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../../src/functions/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,kCA8MxC,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,wCAAwC,mDA0C/C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/functions/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAW/C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/functions/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAW/C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,mEAgHvB,CAAA;AACN;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,mEA+BpC,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { LogLevel } from "../types/enums";
|
|
|
6
6
|
* @notice the set of Firebase Functions status codes. The codes are the same at the
|
|
7
7
|
* ones exposed by {@link https://github.com/grpc/grpc/blob/master/doc/statuscodes.md | gRPC}.
|
|
8
8
|
* @param errorCode <FunctionsErrorCode> - the set of possible error codes.
|
|
9
|
-
* @param message <string> - the error
|
|
9
|
+
* @param message <string> - the error message.
|
|
10
10
|
* @param [details] <string> - the details of the error (optional).
|
|
11
11
|
* @returns <HttpsError>
|
|
12
12
|
*/
|
|
@@ -55,6 +55,8 @@ export declare const SPECIFIC_ERRORS: {
|
|
|
55
55
|
SE_VM_TIMEDOUT_COMMAND_EXECUTION: functions.auth.HttpsError;
|
|
56
56
|
SE_VM_CANCELLED_COMMAND_EXECUTION: functions.auth.HttpsError;
|
|
57
57
|
SE_VM_DELAYED_COMMAND_EXECUTION: functions.auth.HttpsError;
|
|
58
|
+
SE_VM_UNKNOWN_COMMAND_STATUS: functions.auth.HttpsError;
|
|
59
|
+
WRONG_BUCKET_NAME: functions.auth.HttpsError;
|
|
58
60
|
};
|
|
59
61
|
/**
|
|
60
62
|
* A set of common errors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,cAAe,kBAAkB,WAAW,MAAM,YAAY,MAAM,KAAG,UAC9B,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,YAAa,MAAM,YAAY,QAAQ,SAqB3D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,UAAU,UAGjD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,cAAe,kBAAkB,WAAW,MAAM,YAAY,MAAM,KAAG,UAC9B,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,YAAa,MAAM,YAAY,QAAQ,SAqB3D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,UAAU,UAGjD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4I3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;CA2CzB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ethers from "ethers";
|
|
1
2
|
import { S3Client } from "@aws-sdk/client-s3";
|
|
2
3
|
/**
|
|
3
4
|
* Return a configured and connected instance of the AWS S3 client.
|
|
@@ -6,4 +7,10 @@ import { S3Client } from "@aws-sdk/client-s3";
|
|
|
6
7
|
* @returns <Promise<S3Client>> - the instance of the connected S3 Client instance.
|
|
7
8
|
*/
|
|
8
9
|
export declare const getS3Client: () => Promise<S3Client>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a Prvider, connected via a configured JSON URL or else
|
|
12
|
+
* the ethers.js default provider, using configured API keys.
|
|
13
|
+
* @returns <ethers.providers.Provider> An Eth node provider
|
|
14
|
+
*/
|
|
15
|
+
export declare const setEthProvider: () => ethers.providers.Provider;
|
|
9
16
|
//# sourceMappingURL=services.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../src/lib/services.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../src/lib/services.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAM7C;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAa,QAAQ,QAAQ,CAkBpD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,OAAO,SAAS,CAAC,QAwBlD,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentData, QuerySnapshot, DocumentSnapshot, QueryDocumentSnapshot, WhereFilterOp } from "firebase-admin/firestore";
|
|
2
2
|
import admin from "firebase-admin";
|
|
3
|
-
import { CircuitDocument } from "@
|
|
3
|
+
import { CircuitDocument } from "@devtion/actions";
|
|
4
4
|
import { SSMClient } from "@aws-sdk/client-ssm";
|
|
5
5
|
import { EC2Client } from "@aws-sdk/client-ec2";
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mapp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S,aAAa,CAAC,CAYxD,CAAA;AAEd;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,eACjB,MAAM,aACP,MAAM,KAClB,QAAQ,sBAAsB,YAAY,CAAC,CAgB7C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,oBAAqB,eAAe,KAAG,eAKvE,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,GAerC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,GAkBlC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAa,QAAQ,SAAS,CAYzD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAa,QAAQ,SAAS,CAYzD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,cAAqB,MAAM,KAAG,QAAQ,MAAM,CAQxE,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@
|
|
1
|
+
import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@devtion/actions";
|
|
2
|
+
import type { Groth16Proof, PublicSignals } from "snarkjs";
|
|
2
3
|
/**
|
|
3
4
|
* Group all the necessary data needed for running the `setupCeremony` cloud function.
|
|
4
5
|
* @typedef {Object} SetupCeremonyData
|
|
@@ -127,4 +128,59 @@ export type FinalizeCircuitData = {
|
|
|
127
128
|
bucketName: string;
|
|
128
129
|
beacon: string;
|
|
129
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Group all the necessary data needed for running the `bandadaValidateProof` cloud function.
|
|
133
|
+
* @typedef {Object} BandadaValidateProof
|
|
134
|
+
* @property {string} merkleTreeRoot - the merkle tree root of the group.
|
|
135
|
+
* @property {string} nullifierHash - the nullifier hash of the member.
|
|
136
|
+
* @property {string} externalNullifier - the external nullifier of the member.
|
|
137
|
+
* @property {PackedProof} proof - the packed proof generated on the client.
|
|
138
|
+
*/
|
|
139
|
+
export type BandadaValidateProof = {
|
|
140
|
+
proof: Groth16Proof;
|
|
141
|
+
publicSignals: PublicSignals;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Define the return object of the function that verifies the Bandada membership and proof.
|
|
145
|
+
* @typedef {Object} VerifiedBandadaResponse
|
|
146
|
+
* @property {boolean} valid - true if the proof is valid and the user is a member of the group; otherwise false.
|
|
147
|
+
* @property {string} message - a message describing the result of the verification.
|
|
148
|
+
* @property {string} token - the custom access token.
|
|
149
|
+
*/
|
|
150
|
+
export type VerifiedBandadaResponse = {
|
|
151
|
+
valid: boolean;
|
|
152
|
+
message: string;
|
|
153
|
+
token: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Define the check nonce object for the cloud function
|
|
157
|
+
* @typedef {Object} CheckNonceOfSIWEAddressRequest
|
|
158
|
+
* @property {string} auth0Token - token from the device flow authentication
|
|
159
|
+
*/
|
|
160
|
+
export type CheckNonceOfSIWEAddressRequest = {
|
|
161
|
+
auth0Token: string;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Define the check nonce response object of the cloud function
|
|
165
|
+
* @typedef {Object} CheckNonceOfSIWEAddressResponse
|
|
166
|
+
* @property {boolean} valid - if the checking result was valid or not
|
|
167
|
+
* @property {string} message - informative message
|
|
168
|
+
* @property {string} token - token to sign in
|
|
169
|
+
*/
|
|
170
|
+
export type CheckNonceOfSIWEAddressResponse = {
|
|
171
|
+
valid: boolean;
|
|
172
|
+
message?: string;
|
|
173
|
+
token?: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Define the response from auth0 /userinfo endpoint
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
export type Auth0UserInfo = {
|
|
180
|
+
sub: string;
|
|
181
|
+
nickname: string;
|
|
182
|
+
name: string;
|
|
183
|
+
picture: string;
|
|
184
|
+
updated_at: string;
|
|
185
|
+
};
|
|
130
186
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;CACnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,GAAG;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,8BAA8B,GAAG,sBAAsB,GAAG;IAClE,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,GAAG;IAC/D,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAChC,UAAU,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,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AACD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtion/backend",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-9d46256",
|
|
4
4
|
"description": "MPC Phase 2 backend for Firebase services management",
|
|
5
5
|
"repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
|
|
6
6
|
"homepage": "https://github.com/privacy-scaling-explorations/p0tion",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@aws-sdk/client-ssm": "^3.357.0",
|
|
68
68
|
"@aws-sdk/middleware-endpoint": "^3.329.0",
|
|
69
69
|
"@aws-sdk/s3-request-presigner": "^3.329.0",
|
|
70
|
+
"@bandada/api-sdk": "^1.0.0-beta.1",
|
|
70
71
|
"@devtion/actions": "latest",
|
|
71
72
|
"blakejs": "^1.2.1",
|
|
72
73
|
"dotenv": "^16.0.3",
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
"html-entities": "^2.3.3",
|
|
77
78
|
"rimraf": "^5.0.0",
|
|
78
79
|
"rollup": "^3.21.6",
|
|
79
|
-
"snarkjs": "
|
|
80
|
+
"snarkjs": "0.7.3",
|
|
80
81
|
"solc": "^0.8.19",
|
|
81
82
|
"timer-node": "^5.0.7",
|
|
82
83
|
"uuid": "^9.0.0",
|
|
@@ -85,5 +86,5 @@
|
|
|
85
86
|
"publishConfig": {
|
|
86
87
|
"access": "public"
|
|
87
88
|
},
|
|
88
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "db993436c57f04fae0ee535d013474a6f87f8271"
|
|
89
90
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import dotenv from "dotenv"
|
|
2
|
+
import * as functions from "firebase-functions"
|
|
3
|
+
import { ApiSdk } from "@bandada/api-sdk"
|
|
4
|
+
import { groth16 } from "snarkjs"
|
|
5
|
+
import { getAuth } from "firebase-admin/auth"
|
|
6
|
+
import admin from "firebase-admin"
|
|
7
|
+
import { BandadaValidateProof, VerifiedBandadaResponse } from "../types/index"
|
|
8
|
+
|
|
9
|
+
dotenv.config()
|
|
10
|
+
|
|
11
|
+
const { BANDADA_API_URL, BANDADA_GROUP_ID } = process.env
|
|
12
|
+
|
|
13
|
+
const bandadaApi = new ApiSdk(BANDADA_API_URL)
|
|
14
|
+
|
|
15
|
+
export const bandadaValidateProof = functions
|
|
16
|
+
.region("europe-west1")
|
|
17
|
+
.runWith({
|
|
18
|
+
memory: "1GB"
|
|
19
|
+
})
|
|
20
|
+
.https.onCall(async (data: BandadaValidateProof): Promise<VerifiedBandadaResponse> => {
|
|
21
|
+
const VKEY_DATA = {
|
|
22
|
+
protocol: "groth16",
|
|
23
|
+
curve: "bn128",
|
|
24
|
+
nPublic: 3,
|
|
25
|
+
vk_alpha_1: [
|
|
26
|
+
"20491192805390485299153009773594534940189261866228447918068658471970481763042",
|
|
27
|
+
"9383485363053290200918347156157836566562967994039712273449902621266178545958",
|
|
28
|
+
"1"
|
|
29
|
+
],
|
|
30
|
+
vk_beta_2: [
|
|
31
|
+
[
|
|
32
|
+
"6375614351688725206403948262868962793625744043794305715222011528459656738731",
|
|
33
|
+
"4252822878758300859123897981450591353533073413197771768651442665752259397132"
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"10505242626370262277552901082094356697409835680220590971873171140371331206856",
|
|
37
|
+
"21847035105528745403288232691147584728191162732299865338377159692350059136679"
|
|
38
|
+
],
|
|
39
|
+
["1", "0"]
|
|
40
|
+
],
|
|
41
|
+
vk_gamma_2: [
|
|
42
|
+
[
|
|
43
|
+
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
|
44
|
+
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
|
48
|
+
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
|
|
49
|
+
],
|
|
50
|
+
["1", "0"]
|
|
51
|
+
],
|
|
52
|
+
vk_delta_2: [
|
|
53
|
+
[
|
|
54
|
+
"3697618915467790705869942236922063775466274665053173890632463796679068973252",
|
|
55
|
+
"14948341351907992175709156460547989243732741534604949238422596319735704165658"
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
"3028459181652799888716942141752307629938889957960373621898607910203491239368",
|
|
59
|
+
"11380736494786911280692284374675752681598754560757720296073023058533044108340"
|
|
60
|
+
],
|
|
61
|
+
["1", "0"]
|
|
62
|
+
],
|
|
63
|
+
vk_alphabeta_12: [
|
|
64
|
+
[
|
|
65
|
+
[
|
|
66
|
+
"2029413683389138792403550203267699914886160938906632433982220835551125967885",
|
|
67
|
+
"21072700047562757817161031222997517981543347628379360635925549008442030252106"
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
"5940354580057074848093997050200682056184807770593307860589430076672439820312",
|
|
71
|
+
"12156638873931618554171829126792193045421052652279363021382169897324752428276"
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
"7898200236362823042373859371574133993780991612861777490112507062703164551277",
|
|
75
|
+
"7074218545237549455313236346927434013100842096812539264420499035217050630853"
|
|
76
|
+
]
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
[
|
|
80
|
+
"7077479683546002997211712695946002074877511277312570035766170199895071832130",
|
|
81
|
+
"10093483419865920389913245021038182291233451549023025229112148274109565435465"
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"4595479056700221319381530156280926371456704509942304414423590385166031118820",
|
|
85
|
+
"19831328484489333784475432780421641293929726139240675179672856274388269393268"
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
"11934129596455521040620786944827826205713621633706285934057045369193958244500",
|
|
89
|
+
"8037395052364110730298837004334506829870972346962140206007064471173334027475"
|
|
90
|
+
]
|
|
91
|
+
]
|
|
92
|
+
],
|
|
93
|
+
IC: [
|
|
94
|
+
[
|
|
95
|
+
"12951059800758687233303204819298121944551181861362200875212570257618182506154",
|
|
96
|
+
"5751958719396509176593242305268064754837298673622815112953832050159760501392",
|
|
97
|
+
"1"
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
"9561588427935871983444704959674198910445823619407211599507208879011862515257",
|
|
101
|
+
"14576201570478094842467636169770180675293504492823217349086195663150934064643",
|
|
102
|
+
"1"
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"4811967233483727873912563574622036989372099129165459921963463310078093941559",
|
|
106
|
+
"1874883809855039536107616044787862082553628089593740724610117059083415551067",
|
|
107
|
+
"1"
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
"12252730267779308452229639835051322390696643456253768618882001876621526827161",
|
|
111
|
+
"7899194018737016222260328309937800777948677569409898603827268776967707173231",
|
|
112
|
+
"1"
|
|
113
|
+
]
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
if (!BANDADA_GROUP_ID) throw new Error("BANDADA_GROUP_ID is not defined in .env")
|
|
117
|
+
|
|
118
|
+
const { proof, publicSignals } = data
|
|
119
|
+
const isCorrect = groth16.verify(VKEY_DATA, publicSignals, proof)
|
|
120
|
+
if (!isCorrect)
|
|
121
|
+
return {
|
|
122
|
+
valid: false,
|
|
123
|
+
message: "Invalid proof",
|
|
124
|
+
token: ""
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const commitment = data.publicSignals[1]
|
|
128
|
+
const isMember = await bandadaApi.isGroupMember(BANDADA_GROUP_ID, commitment)
|
|
129
|
+
if (!isMember)
|
|
130
|
+
return {
|
|
131
|
+
valid: false,
|
|
132
|
+
message: "Not a member of the group",
|
|
133
|
+
token: ""
|
|
134
|
+
}
|
|
135
|
+
const auth = getAuth()
|
|
136
|
+
try {
|
|
137
|
+
await admin.auth().createUser({
|
|
138
|
+
uid: commitment
|
|
139
|
+
})
|
|
140
|
+
} catch (error: any) {
|
|
141
|
+
// if user already exist then just pass
|
|
142
|
+
if (error.code !== "auth/uid-already-exists") {
|
|
143
|
+
throw new Error(error)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const token = await auth.createCustomToken(commitment)
|
|
147
|
+
return {
|
|
148
|
+
valid: true,
|
|
149
|
+
message: "Valid proof and group member",
|
|
150
|
+
token
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
export default bandadaValidateProof
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
vmBootstrapCommand,
|
|
19
19
|
vmDependenciesAndCacheArtifactsCommand,
|
|
20
20
|
vmBootstrapScriptFilename
|
|
21
|
-
} from "@
|
|
21
|
+
} from "@devtion/actions"
|
|
22
22
|
import { encode } from "html-entities"
|
|
23
23
|
import { SetupCeremonyData } from "../types/index"
|
|
24
24
|
import { COMMON_ERRORS, logAndThrowError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
|
|
@@ -46,7 +46,7 @@ dotenv.config()
|
|
|
46
46
|
export const startCeremony = functions
|
|
47
47
|
.region("europe-west1")
|
|
48
48
|
.runWith({
|
|
49
|
-
memory: "
|
|
49
|
+
memory: "1GB"
|
|
50
50
|
})
|
|
51
51
|
.pubsub.schedule(`every 30 minutes`)
|
|
52
52
|
.onRun(async () => {
|
|
@@ -71,7 +71,7 @@ export const startCeremony = functions
|
|
|
71
71
|
export const stopCeremony = functions
|
|
72
72
|
.region("europe-west1")
|
|
73
73
|
.runWith({
|
|
74
|
-
memory: "
|
|
74
|
+
memory: "1GB"
|
|
75
75
|
})
|
|
76
76
|
.pubsub.schedule(`every 30 minutes`)
|
|
77
77
|
.onRun(async () => {
|
|
@@ -96,7 +96,7 @@ export const stopCeremony = functions
|
|
|
96
96
|
export const setupCeremony = functions
|
|
97
97
|
.region("europe-west1")
|
|
98
98
|
.runWith({
|
|
99
|
-
memory: "
|
|
99
|
+
memory: "1GB"
|
|
100
100
|
})
|
|
101
101
|
.https.onCall(async (data: SetupCeremonyData, context: functions.https.CallableContext): Promise<any> => {
|
|
102
102
|
// Check if the user has the coordinator claim.
|
|
@@ -141,12 +141,14 @@ export const setupCeremony = functions
|
|
|
141
141
|
let vmInstanceId: string = ""
|
|
142
142
|
|
|
143
143
|
// Get a new circuit document.
|
|
144
|
-
const
|
|
144
|
+
const ccp = getCircuitsCollectionPath(ceremonyDoc.ref.id)
|
|
145
|
+
printLog(`CircuitsCollectionPath = ${ccp}`, LogLevel.DEBUG)
|
|
146
|
+
const circuitDoc = await firestore.collection(ccp).doc().get()
|
|
145
147
|
|
|
146
148
|
// Check if using the VM approach for contribution verification.
|
|
147
149
|
if (circuit.verification.cfOrVm === CircuitContributionVerificationMechanism.VM) {
|
|
148
150
|
// VM command to be run at the startup.
|
|
149
|
-
const startupCommand = vmBootstrapCommand(bucketName)
|
|
151
|
+
const startupCommand = vmBootstrapCommand(`${bucketName}/circuits/${circuit.name!}`)
|
|
150
152
|
|
|
151
153
|
// Get EC2 client.
|
|
152
154
|
const ec2Client = await createEC2Client()
|
|
@@ -165,7 +167,12 @@ export const setupCeremony = functions
|
|
|
165
167
|
printLog(`Check VM dependencies and cache artifacts commands ${vmCommands.join("\n")}`, LogLevel.DEBUG)
|
|
166
168
|
|
|
167
169
|
// Upload the post-startup commands script file.
|
|
168
|
-
|
|
170
|
+
printLog(`Uploading VM post-startup commands script file ${vmBootstrapScriptFilename}`, LogLevel.DEBUG)
|
|
171
|
+
await uploadFileToBucketNoFile(
|
|
172
|
+
bucketName,
|
|
173
|
+
`circuits/${circuit.name!}/${vmBootstrapScriptFilename}`,
|
|
174
|
+
vmCommands.join("\n")
|
|
175
|
+
)
|
|
169
176
|
|
|
170
177
|
// Compute the VM disk space requirement (in GB).
|
|
171
178
|
const vmDiskSize = computeDiskSizeForVM(circuit.zKeySizeInBytes!, circuit.metadata?.pot!)
|
|
@@ -201,6 +208,7 @@ export const setupCeremony = functions
|
|
|
201
208
|
// Encode circuit data.
|
|
202
209
|
const encodedCircuit = htmlEncodeCircuitData(circuit)
|
|
203
210
|
|
|
211
|
+
printLog(`writing circuit data...`, LogLevel.DEBUG)
|
|
204
212
|
// Prepare tx to write circuit data.
|
|
205
213
|
batch.create(circuitDoc.ref, {
|
|
206
214
|
...encodedCircuit,
|
|
@@ -208,6 +216,7 @@ export const setupCeremony = functions
|
|
|
208
216
|
})
|
|
209
217
|
}
|
|
210
218
|
|
|
219
|
+
printLog(`Done handling circuits...`, LogLevel.DEBUG)
|
|
211
220
|
// Send txs in a batch (to avoid race conditions).
|
|
212
221
|
await batch.commit()
|
|
213
222
|
|
|
@@ -223,7 +232,7 @@ export const setupCeremony = functions
|
|
|
223
232
|
export const initEmptyWaitingQueueForCircuit = functions
|
|
224
233
|
.region("europe-west1")
|
|
225
234
|
.runWith({
|
|
226
|
-
memory: "
|
|
235
|
+
memory: "1GB"
|
|
227
236
|
})
|
|
228
237
|
.firestore.document(
|
|
229
238
|
`/${commonTerms.collections.ceremonies.name}/{ceremony}/${commonTerms.collections.circuits.name}/{circuit}`
|
|
@@ -268,7 +277,7 @@ export const initEmptyWaitingQueueForCircuit = functions
|
|
|
268
277
|
export const finalizeCeremony = functions
|
|
269
278
|
.region("europe-west1")
|
|
270
279
|
.runWith({
|
|
271
|
-
memory: "
|
|
280
|
+
memory: "1GB"
|
|
272
281
|
})
|
|
273
282
|
.https.onCall(async (data: { ceremonyId: string }, context: functions.https.CallableContext): Promise<any> => {
|
|
274
283
|
if (!context.auth || !context.auth.token.coordinator) logAndThrowError(COMMON_ERRORS.CM_NOT_COORDINATOR_ROLE)
|
|
@@ -293,7 +302,7 @@ export const finalizeCeremony = functions
|
|
|
293
302
|
const circuits = await getCeremonyCircuits(ceremonyId)
|
|
294
303
|
|
|
295
304
|
// Get final contribution for each circuit.
|
|
296
|
-
// nb. the `getFinalContributionDocument` checks the
|
|
305
|
+
// nb. the `getFinalContributionDocument` checks the existence of the final contribution document (if not present, throws).
|
|
297
306
|
// Therefore, we just need to call the method without taking any data to verify the pre-condition of having already computed
|
|
298
307
|
// the final contributions for each ceremony circuit.
|
|
299
308
|
for await (const circuit of circuits) await getFinalContribution(ceremonyId, circuit.id)
|