@maci-protocol/coordinator 0.0.0-ci.533e19d
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/CHANGELOG.md +51 -0
- package/LICENSE +22 -0
- package/README.md +42 -0
- package/build/hardhat.config.cjs +31 -0
- package/build/hardhat.config.cjs.map +1 -0
- package/build/hardhat.config.d.cts +24 -0
- package/build/hardhat.config.d.cts.map +1 -0
- package/build/scripts/generateKeypair.d.ts +2 -0
- package/build/scripts/generateKeypair.d.ts.map +1 -0
- package/build/scripts/generateKeypair.js +25 -0
- package/build/scripts/generateKeypair.js.map +1 -0
- package/build/scripts/generateMaciKeyPair.d.ts +2 -0
- package/build/scripts/generateMaciKeyPair.d.ts.map +1 -0
- package/build/scripts/generateMaciKeyPair.js +3 -0
- package/build/scripts/generateMaciKeyPair.js.map +1 -0
- package/build/scripts/getAuthHeader.d.ts +2 -0
- package/build/scripts/getAuthHeader.d.ts.map +1 -0
- package/build/scripts/getAuthHeader.js +31 -0
- package/build/scripts/getAuthHeader.js.map +1 -0
- package/build/tests/constants.d.ts +8 -0
- package/build/tests/constants.d.ts.map +1 -0
- package/build/tests/constants.js +10 -0
- package/build/tests/constants.js.map +1 -0
- package/build/tests/e2e.aa.test.d.ts +2 -0
- package/build/tests/e2e.aa.test.d.ts.map +1 -0
- package/build/tests/e2e.aa.test.js +103 -0
- package/build/tests/e2e.aa.test.js.map +1 -0
- package/build/tests/e2e.deploy.test.d.ts +2 -0
- package/build/tests/e2e.deploy.test.d.ts.map +1 -0
- package/build/tests/e2e.deploy.test.js +234 -0
- package/build/tests/e2e.deploy.test.js.map +1 -0
- package/build/tests/utils.d.ts +14 -0
- package/build/tests/utils.d.ts.map +1 -0
- package/build/tests/utils.js +44 -0
- package/build/tests/utils.js.map +1 -0
- package/build/ts/app.module.d.ts +3 -0
- package/build/ts/app.module.d.ts.map +1 -0
- package/build/ts/app.module.js +36 -0
- package/build/ts/app.module.js.map +1 -0
- package/build/ts/auth/AccountSignatureGuard.service.d.ts +44 -0
- package/build/ts/auth/AccountSignatureGuard.service.d.ts.map +1 -0
- package/build/ts/auth/AccountSignatureGuard.service.js +96 -0
- package/build/ts/auth/AccountSignatureGuard.service.js.map +1 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.d.ts +2 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.d.ts.map +1 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.js +113 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.js.map +1 -0
- package/build/ts/common/__tests__/common.test.d.ts +2 -0
- package/build/ts/common/__tests__/common.test.d.ts.map +1 -0
- package/build/ts/common/__tests__/common.test.js +79 -0
- package/build/ts/common/__tests__/common.test.js.map +1 -0
- package/build/ts/common/accountAbstraction.d.ts +55 -0
- package/build/ts/common/accountAbstraction.d.ts.map +1 -0
- package/build/ts/common/accountAbstraction.js +110 -0
- package/build/ts/common/accountAbstraction.js.map +1 -0
- package/build/ts/common/errors.d.ts +33 -0
- package/build/ts/common/errors.d.ts.map +1 -0
- package/build/ts/common/errors.js +34 -0
- package/build/ts/common/errors.js.map +1 -0
- package/build/ts/common/index.d.ts +4 -0
- package/build/ts/common/index.d.ts.map +1 -0
- package/build/ts/common/index.js +4 -0
- package/build/ts/common/index.js.map +1 -0
- package/build/ts/common/networks.d.ts +29 -0
- package/build/ts/common/networks.d.ts.map +1 -0
- package/build/ts/common/networks.js +70 -0
- package/build/ts/common/networks.js.map +1 -0
- package/build/ts/common/types.d.ts +9 -0
- package/build/ts/common/types.d.ts.map +1 -0
- package/build/ts/common/types.js +2 -0
- package/build/ts/common/types.js.map +1 -0
- package/build/ts/crypto/__tests__/crypto.service.test.d.ts +2 -0
- package/build/ts/crypto/__tests__/crypto.service.test.d.ts.map +1 -0
- package/build/ts/crypto/__tests__/crypto.service.test.js +26 -0
- package/build/ts/crypto/__tests__/crypto.service.test.js.map +1 -0
- package/build/ts/crypto/crypto.module.d.ts +3 -0
- package/build/ts/crypto/crypto.module.d.ts.map +1 -0
- package/build/ts/crypto/crypto.module.js +18 -0
- package/build/ts/crypto/crypto.module.js.map +1 -0
- package/build/ts/crypto/crypto.service.d.ts +31 -0
- package/build/ts/crypto/crypto.service.d.ts.map +1 -0
- package/build/ts/crypto/crypto.service.js +68 -0
- package/build/ts/crypto/crypto.service.js.map +1 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.d.ts +2 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.js +84 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -0
- package/build/ts/deployer/__tests__/deployer.service.test.d.ts +2 -0
- package/build/ts/deployer/__tests__/deployer.service.test.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/deployer.service.test.js +425 -0
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -0
- package/build/ts/deployer/__tests__/utils.d.ts +36 -0
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/utils.js +96 -0
- package/build/ts/deployer/__tests__/utils.js.map +1 -0
- package/build/ts/deployer/constants.d.ts +13 -0
- package/build/ts/deployer/constants.d.ts.map +1 -0
- package/build/ts/deployer/constants.js +13 -0
- package/build/ts/deployer/constants.js.map +1 -0
- package/build/ts/deployer/deployer.controller.d.ts +34 -0
- package/build/ts/deployer/deployer.controller.d.ts.map +1 -0
- package/build/ts/deployer/deployer.controller.js +89 -0
- package/build/ts/deployer/deployer.controller.js.map +1 -0
- package/build/ts/deployer/deployer.module.d.ts +3 -0
- package/build/ts/deployer/deployer.module.d.ts.map +1 -0
- package/build/ts/deployer/deployer.module.js +23 -0
- package/build/ts/deployer/deployer.module.js.map +1 -0
- package/build/ts/deployer/deployer.service.d.ts +112 -0
- package/build/ts/deployer/deployer.service.d.ts.map +1 -0
- package/build/ts/deployer/deployer.service.js +614 -0
- package/build/ts/deployer/deployer.service.js.map +1 -0
- package/build/ts/deployer/dto.d.ts +46 -0
- package/build/ts/deployer/dto.d.ts.map +1 -0
- package/build/ts/deployer/dto.js +117 -0
- package/build/ts/deployer/dto.js.map +1 -0
- package/build/ts/deployer/types.d.ts +293 -0
- package/build/ts/deployer/types.d.ts.map +1 -0
- package/build/ts/deployer/types.js +2 -0
- package/build/ts/deployer/types.js.map +1 -0
- package/build/ts/deployer/utils.d.ts +8 -0
- package/build/ts/deployer/utils.d.ts.map +1 -0
- package/build/ts/deployer/utils.js +9 -0
- package/build/ts/deployer/utils.js.map +1 -0
- package/build/ts/file/__tests__/file.service.test.d.ts +2 -0
- package/build/ts/file/__tests__/file.service.test.d.ts.map +1 -0
- package/build/ts/file/__tests__/file.service.test.js +76 -0
- package/build/ts/file/__tests__/file.service.test.js.map +1 -0
- package/build/ts/file/file.module.d.ts +3 -0
- package/build/ts/file/file.module.d.ts.map +1 -0
- package/build/ts/file/file.module.js +18 -0
- package/build/ts/file/file.module.js.map +1 -0
- package/build/ts/file/file.service.d.ts +62 -0
- package/build/ts/file/file.service.d.ts.map +1 -0
- package/build/ts/file/file.service.js +115 -0
- package/build/ts/file/file.service.js.map +1 -0
- package/build/ts/file/types.d.ts +36 -0
- package/build/ts/file/types.d.ts.map +1 -0
- package/build/ts/file/types.js +2 -0
- package/build/ts/file/types.js.map +1 -0
- package/build/ts/jest/setup.d.ts +8 -0
- package/build/ts/jest/setup.d.ts.map +1 -0
- package/build/ts/jest/setup.js +2 -0
- package/build/ts/jest/setup.js.map +1 -0
- package/build/ts/jest/transform.d.ts +8 -0
- package/build/ts/jest/transform.d.ts.map +1 -0
- package/build/ts/jest/transform.js +10 -0
- package/build/ts/jest/transform.js.map +1 -0
- package/build/ts/main.d.ts +2 -0
- package/build/ts/main.d.ts.map +1 -0
- package/build/ts/main.js +46 -0
- package/build/ts/main.js.map +1 -0
- package/build/ts/proof/__tests__/proof.controller.test.d.ts +2 -0
- package/build/ts/proof/__tests__/proof.controller.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/proof.controller.test.js +89 -0
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -0
- package/build/ts/proof/__tests__/proof.gateway.test.d.ts +2 -0
- package/build/ts/proof/__tests__/proof.gateway.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/proof.gateway.test.js +61 -0
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -0
- package/build/ts/proof/__tests__/proof.service.test.d.ts +2 -0
- package/build/ts/proof/__tests__/proof.service.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/proof.service.test.js +128 -0
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -0
- package/build/ts/proof/dto.d.ts +73 -0
- package/build/ts/proof/dto.d.ts.map +1 -0
- package/build/ts/proof/dto.js +255 -0
- package/build/ts/proof/dto.js.map +1 -0
- package/build/ts/proof/proof.controller.d.ts +46 -0
- package/build/ts/proof/proof.controller.d.ts.map +1 -0
- package/build/ts/proof/proof.controller.js +135 -0
- package/build/ts/proof/proof.controller.js.map +1 -0
- package/build/ts/proof/proof.gateway.d.ts +35 -0
- package/build/ts/proof/proof.gateway.d.ts.map +1 -0
- package/build/ts/proof/proof.gateway.js +93 -0
- package/build/ts/proof/proof.gateway.js.map +1 -0
- package/build/ts/proof/proof.module.d.ts +3 -0
- package/build/ts/proof/proof.module.d.ts.map +1 -0
- package/build/ts/proof/proof.module.js +24 -0
- package/build/ts/proof/proof.module.js.map +1 -0
- package/build/ts/proof/proof.service.d.ts +54 -0
- package/build/ts/proof/proof.service.d.ts.map +1 -0
- package/build/ts/proof/proof.service.js +246 -0
- package/build/ts/proof/proof.service.js.map +1 -0
- package/build/ts/proof/types.d.ts +140 -0
- package/build/ts/proof/types.d.ts.map +1 -0
- package/build/ts/proof/types.js +11 -0
- package/build/ts/proof/types.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.d.ts +2 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.d.ts.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js +44 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.d.ts +2 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.d.ts.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js +61 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/utils.d.ts +25 -0
- package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -0
- package/build/ts/sessionKeys/__tests__/utils.js +64 -0
- package/build/ts/sessionKeys/__tests__/utils.js.map +1 -0
- package/build/ts/sessionKeys/dto.d.ts +11 -0
- package/build/ts/sessionKeys/dto.d.ts.map +1 -0
- package/build/ts/sessionKeys/dto.js +29 -0
- package/build/ts/sessionKeys/dto.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.controller.d.ts +26 -0
- package/build/ts/sessionKeys/sessionKeys.controller.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.controller.js +74 -0
- package/build/ts/sessionKeys/sessionKeys.controller.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.module.d.ts +3 -0
- package/build/ts/sessionKeys/sessionKeys.module.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.module.js +23 -0
- package/build/ts/sessionKeys/sessionKeys.module.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +50 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.js +104 -0
- package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -0
- package/build/ts/sessionKeys/types.d.ts +11 -0
- package/build/ts/sessionKeys/types.d.ts.map +1 -0
- package/build/ts/sessionKeys/types.js +2 -0
- package/build/ts/sessionKeys/types.js.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.d.ts +2 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.d.ts.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js +50 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.d.ts +2 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.d.ts.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js +83 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.d.ts +2 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.d.ts.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.js +58 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.js.map +1 -0
- package/build/ts/subgraph/dto.d.ts +27 -0
- package/build/ts/subgraph/dto.d.ts.map +1 -0
- package/build/ts/subgraph/dto.js +83 -0
- package/build/ts/subgraph/dto.js.map +1 -0
- package/build/ts/subgraph/subgraph.controller.d.ts +24 -0
- package/build/ts/subgraph/subgraph.controller.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.controller.js +66 -0
- package/build/ts/subgraph/subgraph.controller.js.map +1 -0
- package/build/ts/subgraph/subgraph.gateway.d.ts +35 -0
- package/build/ts/subgraph/subgraph.gateway.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.gateway.js +93 -0
- package/build/ts/subgraph/subgraph.gateway.js.map +1 -0
- package/build/ts/subgraph/subgraph.module.d.ts +3 -0
- package/build/ts/subgraph/subgraph.module.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.module.js +23 -0
- package/build/ts/subgraph/subgraph.module.js.map +1 -0
- package/build/ts/subgraph/subgraph.service.d.ts +20 -0
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.service.js +106 -0
- package/build/ts/subgraph/subgraph.service.js.map +1 -0
- package/build/ts/subgraph/types.d.ts +93 -0
- package/build/ts/subgraph/types.d.ts.map +1 -0
- package/build/ts/subgraph/types.js +24 -0
- package/build/ts/subgraph/types.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Server } from "socket.io";
|
|
2
|
+
import { GenerateProofDto } from "./dto";
|
|
3
|
+
import { ProofGeneratorService } from "./proof.service";
|
|
4
|
+
/**
|
|
5
|
+
* ProofGateway is responsible for websockets integration between client and ProofGeneratorService.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ProofGateway {
|
|
8
|
+
private readonly proofGeneratorService;
|
|
9
|
+
/**
|
|
10
|
+
* Logger
|
|
11
|
+
*/
|
|
12
|
+
private readonly logger;
|
|
13
|
+
/**
|
|
14
|
+
* Websocket server
|
|
15
|
+
*/
|
|
16
|
+
server: Server;
|
|
17
|
+
/**
|
|
18
|
+
* Initialize ProofGateway
|
|
19
|
+
*
|
|
20
|
+
* @param proofGeneratorService - proof generator service
|
|
21
|
+
*/
|
|
22
|
+
constructor(proofGeneratorService: ProofGeneratorService);
|
|
23
|
+
/**
|
|
24
|
+
* Generate proofs api method.
|
|
25
|
+
* Events:
|
|
26
|
+
* 1. EProofGenerationEvents.START - trigger method call
|
|
27
|
+
* 2. EProofGenerationEvents.PROGRESS - returns generated proofs with batch info
|
|
28
|
+
* 3. EProofGenerationEvents.FINISH - returns generated proofs and tally data when available
|
|
29
|
+
* 4. EProofGenerationEvents.ERROR - triggered when exception is thrown
|
|
30
|
+
*
|
|
31
|
+
* @param args - generate proof dto
|
|
32
|
+
*/
|
|
33
|
+
generate(data: GenerateProofDto): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=proof.gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.gateway.d.ts","sourceRoot":"","sources":["../../../ts/proof/proof.gateway.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD;;GAEG;AACH,qBAMa,YAAY;IAiBX,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAhBlD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD;;OAEG;IAEH,MAAM,EAAG,MAAM,CAAC;IAEhB;;;;OAIG;gBAC0B,qBAAqB,EAAE,qBAAqB;IAEzE;;;;;;;;;OASG;IAUG,QAAQ,CAEZ,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,IAAI,CAAC;CAcjB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var ProofGateway_1;
|
|
14
|
+
import { Logger, UseGuards, UsePipes, ValidationPipe } from "@nestjs/common";
|
|
15
|
+
import { MessageBody, SubscribeMessage, WebSocketGateway, WebSocketServer, WsException } from "@nestjs/websockets";
|
|
16
|
+
import { AccountSignatureGuard } from "../auth/AccountSignatureGuard.service";
|
|
17
|
+
import { GenerateProofDto } from "./dto";
|
|
18
|
+
import { ProofGeneratorService } from "./proof.service";
|
|
19
|
+
import { EProofGenerationEvents } from "./types";
|
|
20
|
+
/**
|
|
21
|
+
* ProofGateway is responsible for websockets integration between client and ProofGeneratorService.
|
|
22
|
+
*/
|
|
23
|
+
let ProofGateway = ProofGateway_1 = class ProofGateway {
|
|
24
|
+
proofGeneratorService;
|
|
25
|
+
/**
|
|
26
|
+
* Logger
|
|
27
|
+
*/
|
|
28
|
+
logger = new Logger(ProofGateway_1.name);
|
|
29
|
+
/**
|
|
30
|
+
* Websocket server
|
|
31
|
+
*/
|
|
32
|
+
server;
|
|
33
|
+
/**
|
|
34
|
+
* Initialize ProofGateway
|
|
35
|
+
*
|
|
36
|
+
* @param proofGeneratorService - proof generator service
|
|
37
|
+
*/
|
|
38
|
+
constructor(proofGeneratorService) {
|
|
39
|
+
this.proofGeneratorService = proofGeneratorService;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generate proofs api method.
|
|
43
|
+
* Events:
|
|
44
|
+
* 1. EProofGenerationEvents.START - trigger method call
|
|
45
|
+
* 2. EProofGenerationEvents.PROGRESS - returns generated proofs with batch info
|
|
46
|
+
* 3. EProofGenerationEvents.FINISH - returns generated proofs and tally data when available
|
|
47
|
+
* 4. EProofGenerationEvents.ERROR - triggered when exception is thrown
|
|
48
|
+
*
|
|
49
|
+
* @param args - generate proof dto
|
|
50
|
+
*/
|
|
51
|
+
async generate(data) {
|
|
52
|
+
await this.proofGeneratorService.generate(data, {
|
|
53
|
+
onBatchComplete: (result) => {
|
|
54
|
+
this.server.emit(EProofGenerationEvents.PROGRESS, result);
|
|
55
|
+
},
|
|
56
|
+
onComplete: (proofs, tallyData) => {
|
|
57
|
+
this.server.emit(EProofGenerationEvents.FINISH, { proofs, tallyData });
|
|
58
|
+
},
|
|
59
|
+
onFail: (error) => {
|
|
60
|
+
this.logger.error(`Error:`, error);
|
|
61
|
+
this.server.emit(EProofGenerationEvents.ERROR, { message: error.message });
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__decorate([
|
|
67
|
+
WebSocketServer(),
|
|
68
|
+
__metadata("design:type", Function)
|
|
69
|
+
], ProofGateway.prototype, "server", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
SubscribeMessage(EProofGenerationEvents.START),
|
|
72
|
+
UsePipes(new ValidationPipe({
|
|
73
|
+
transform: true,
|
|
74
|
+
exceptionFactory(validationErrors) {
|
|
75
|
+
return new WsException(validationErrors);
|
|
76
|
+
},
|
|
77
|
+
})),
|
|
78
|
+
__param(0, MessageBody()),
|
|
79
|
+
__metadata("design:type", Function),
|
|
80
|
+
__metadata("design:paramtypes", [GenerateProofDto]),
|
|
81
|
+
__metadata("design:returntype", Promise)
|
|
82
|
+
], ProofGateway.prototype, "generate", null);
|
|
83
|
+
ProofGateway = ProofGateway_1 = __decorate([
|
|
84
|
+
WebSocketGateway({
|
|
85
|
+
cors: {
|
|
86
|
+
origin: process.env.COORDINATOR_ALLOWED_ORIGINS?.split(","),
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
UseGuards(AccountSignatureGuard),
|
|
90
|
+
__metadata("design:paramtypes", [ProofGeneratorService])
|
|
91
|
+
], ProofGateway);
|
|
92
|
+
export { ProofGateway };
|
|
93
|
+
//# sourceMappingURL=proof.gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.gateway.js","sourceRoot":"","sources":["../../../ts/proof/proof.gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE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,CAAA;AA7CC;IADC,eAAe,EAAE;;4CACF;AA4BV;IATL,gBAAgB,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAC9C,QAAQ,CACP,IAAI,cAAc,CAAC;QACjB,SAAS,EAAE,IAAI;QACf,gBAAgB,CAAC,gBAAgB;YAC/B,OAAO,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC,CACH;IAEE,WAAA,WAAW,EAAE,CAAA;;qCACR,gBAAgB;;4CAcvB;AAtDU,YAAY;IANxB,gBAAgB,CAAC;QAChB,IAAI,EAAE;YACJ,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,KAAK,CAAC,GAAG,CAAC;SAC5D;KACF,CAAC;IACD,SAAS,CAAC,qBAAqB,CAAC;qCAkBqB,qBAAqB;GAjB9D,YAAY,CAuDxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.module.d.ts","sourceRoot":"","sources":["../../../ts/proof/proof.module.ts"],"names":[],"mappings":"AAUA,qBAKa,WAAW;CAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { CryptoModule } from "../crypto/crypto.module";
|
|
9
|
+
import { FileModule } from "../file/file.module";
|
|
10
|
+
import { SessionKeysModule } from "../sessionKeys/sessionKeys.module";
|
|
11
|
+
import { ProofController } from "./proof.controller";
|
|
12
|
+
import { ProofGateway } from "./proof.gateway";
|
|
13
|
+
import { ProofGeneratorService } from "./proof.service";
|
|
14
|
+
let ProofModule = class ProofModule {
|
|
15
|
+
};
|
|
16
|
+
ProofModule = __decorate([
|
|
17
|
+
Module({
|
|
18
|
+
imports: [FileModule, CryptoModule, SessionKeysModule],
|
|
19
|
+
controllers: [ProofController],
|
|
20
|
+
providers: [ProofGeneratorService, ProofGateway],
|
|
21
|
+
})
|
|
22
|
+
], ProofModule);
|
|
23
|
+
export { ProofModule };
|
|
24
|
+
//# sourceMappingURL=proof.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.module.js","sourceRoot":"","sources":["../../../ts/proof/proof.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAOjD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IALvB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC;QACtD,WAAW,EAAE,CAAC,eAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,qBAAqB,EAAE,YAAY,CAAC;KACjD,CAAC;GACW,WAAW,CAAG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type IGenerateProofsOptions } from "@maci-protocol/sdk";
|
|
2
|
+
import { IProof } from "@maci-protocol/sdk";
|
|
3
|
+
import type { IGenerateArgs, IGenerateData, IMergeArgs, ISubmitProofsArgs } from "./types";
|
|
4
|
+
import { CryptoService } from "../crypto/crypto.service";
|
|
5
|
+
import { FileService } from "../file/file.service";
|
|
6
|
+
import { SessionKeysService } from "../sessionKeys/sessionKeys.service";
|
|
7
|
+
/**
|
|
8
|
+
* ProofGeneratorService is responsible for generating message processing and tally proofs.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ProofGeneratorService {
|
|
11
|
+
private readonly cryptoService;
|
|
12
|
+
private readonly fileService;
|
|
13
|
+
private readonly sessionKeysService;
|
|
14
|
+
/**
|
|
15
|
+
* Deployment helper
|
|
16
|
+
*/
|
|
17
|
+
private readonly deployment;
|
|
18
|
+
/**
|
|
19
|
+
* Logger
|
|
20
|
+
*/
|
|
21
|
+
private readonly logger;
|
|
22
|
+
/**
|
|
23
|
+
* Proof generator initialization
|
|
24
|
+
*/
|
|
25
|
+
constructor(cryptoService: CryptoService, fileService: FileService, sessionKeysService: SessionKeysService);
|
|
26
|
+
/**
|
|
27
|
+
* Read and parse proofs
|
|
28
|
+
* @param folder - folder path to read proofs from
|
|
29
|
+
* @param type - type of proofs to read (tally or process)
|
|
30
|
+
* @returns proofs
|
|
31
|
+
*/
|
|
32
|
+
readProofs(folder: string, type: "tally" | "process"): Promise<IProof[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Generate proofs for message processing and tally
|
|
35
|
+
*
|
|
36
|
+
* @param args - generate proofs arguments
|
|
37
|
+
* @returns - generated proofs for message processing and tally
|
|
38
|
+
*/
|
|
39
|
+
generate({ poll, maciContractAddress, tallyContractAddress, useQuadraticVoting, encryptedCoordinatorPrivateKey, startBlock, endBlock, blocksPerBatch, }: IGenerateArgs, options?: IGenerateProofsOptions): Promise<IGenerateData>;
|
|
40
|
+
/**
|
|
41
|
+
* Merge state and message trees
|
|
42
|
+
*
|
|
43
|
+
* @param args - merge arguments
|
|
44
|
+
* @returns whether the proofs were successfully merged
|
|
45
|
+
*/
|
|
46
|
+
merge({ maciContractAddress, pollId, approval, sessionKeyAddress, chain }: IMergeArgs): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Submit proofs on-chain
|
|
49
|
+
*
|
|
50
|
+
* @param args - submit proofs on-chain arguments
|
|
51
|
+
*/
|
|
52
|
+
submit({ maciContractAddress, pollId, chain }: ISubmitProofsArgs): Promise<boolean>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=proof.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.service.d.ts","sourceRoot":"","sources":["../../../ts/proof/proof.service.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,sBAAsB,EAU5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAc,MAAM,oBAAoB,CAAC;AASxD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAI3F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE;;GAEG;AACH,qBACa,qBAAqB;IAe9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAhBrC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;OAEG;gBAEgB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,kBAAkB;IAOzD;;;;;OAKG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAY9E;;;;;OAKG;IACG,QAAQ,CACZ,EACE,IAAI,EACJ,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,8BAA8B,EAC9B,UAAU,EACV,QAAQ,EACR,cAAc,GACf,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,aAAa,CAAC;IAgGzB;;;;;OAKG;IACG,KAAK,CAAC,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAc9G;;;;OAIG;IACG,MAAM,CAAC,EAAE,mBAAmB,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CA4E1F"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var ProofGeneratorService_1;
|
|
11
|
+
import { Keypair, PrivKey, PubKey } from "@maci-protocol/domainobjs";
|
|
12
|
+
import { Deployment, EContracts, ProofGenerator, Poll__factory as PollFactory, MACI__factory as MACIFactory, Prover, getPoll, mergeSignups, } from "@maci-protocol/sdk";
|
|
13
|
+
import { Logger, Injectable } from "@nestjs/common";
|
|
14
|
+
import { ZeroAddress } from "ethers";
|
|
15
|
+
import hre from "hardhat";
|
|
16
|
+
import fs from "fs";
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { ErrorCodes } from "../common";
|
|
19
|
+
import { getPublicClient } from "../common/accountAbstraction";
|
|
20
|
+
import { CryptoService } from "../crypto/crypto.service";
|
|
21
|
+
import { FileService } from "../file/file.service";
|
|
22
|
+
import { SessionKeysService } from "../sessionKeys/sessionKeys.service";
|
|
23
|
+
/**
|
|
24
|
+
* ProofGeneratorService is responsible for generating message processing and tally proofs.
|
|
25
|
+
*/
|
|
26
|
+
let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorService {
|
|
27
|
+
cryptoService;
|
|
28
|
+
fileService;
|
|
29
|
+
sessionKeysService;
|
|
30
|
+
/**
|
|
31
|
+
* Deployment helper
|
|
32
|
+
*/
|
|
33
|
+
deployment;
|
|
34
|
+
/**
|
|
35
|
+
* Logger
|
|
36
|
+
*/
|
|
37
|
+
logger;
|
|
38
|
+
/**
|
|
39
|
+
* Proof generator initialization
|
|
40
|
+
*/
|
|
41
|
+
constructor(cryptoService, fileService, sessionKeysService) {
|
|
42
|
+
this.cryptoService = cryptoService;
|
|
43
|
+
this.fileService = fileService;
|
|
44
|
+
this.sessionKeysService = sessionKeysService;
|
|
45
|
+
this.deployment = Deployment.getInstance({ hre });
|
|
46
|
+
this.deployment.setHre(hre);
|
|
47
|
+
this.logger = new Logger(ProofGeneratorService_1.name);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Read and parse proofs
|
|
51
|
+
* @param folder - folder path to read proofs from
|
|
52
|
+
* @param type - type of proofs to read (tally or process)
|
|
53
|
+
* @returns proofs
|
|
54
|
+
*/
|
|
55
|
+
async readProofs(folder, type) {
|
|
56
|
+
const files = await fs.promises.readdir(folder);
|
|
57
|
+
return Promise.all(files
|
|
58
|
+
.filter((f) => f.startsWith(`${type}_`) && f.endsWith(".json"))
|
|
59
|
+
.sort()
|
|
60
|
+
.map(async (file) => fs.promises.readFile(`${folder}/${file}`, "utf8").then((result) => JSON.parse(result))));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate proofs for message processing and tally
|
|
64
|
+
*
|
|
65
|
+
* @param args - generate proofs arguments
|
|
66
|
+
* @returns - generated proofs for message processing and tally
|
|
67
|
+
*/
|
|
68
|
+
async generate({ poll, maciContractAddress, tallyContractAddress, useQuadraticVoting, encryptedCoordinatorPrivateKey, startBlock, endBlock, blocksPerBatch, }, options) {
|
|
69
|
+
try {
|
|
70
|
+
const maciContract = await this.deployment.getContract({
|
|
71
|
+
name: EContracts.MACI,
|
|
72
|
+
address: maciContractAddress,
|
|
73
|
+
});
|
|
74
|
+
const signer = await this.deployment.getDeployer();
|
|
75
|
+
const pollData = await getPoll({
|
|
76
|
+
maciAddress: maciContractAddress,
|
|
77
|
+
pollId: poll,
|
|
78
|
+
signer,
|
|
79
|
+
});
|
|
80
|
+
const pollContract = await this.deployment.getContract({
|
|
81
|
+
name: EContracts.Poll,
|
|
82
|
+
address: pollData.address,
|
|
83
|
+
});
|
|
84
|
+
const [coordinatorPublicKey, isStateAqMerged] = await Promise.all([
|
|
85
|
+
pollContract.coordinatorPubKey(),
|
|
86
|
+
pollContract.stateMerged(),
|
|
87
|
+
]);
|
|
88
|
+
if (!isStateAqMerged) {
|
|
89
|
+
this.logger.error(`Error: ${ErrorCodes.NOT_MERGED_STATE_TREE}, state tree is not merged`);
|
|
90
|
+
throw new Error(ErrorCodes.NOT_MERGED_STATE_TREE.toString());
|
|
91
|
+
}
|
|
92
|
+
const { privateKey } = await this.fileService.getPrivateKey();
|
|
93
|
+
const maciPrivateKey = PrivKey.deserialize(this.cryptoService.decrypt(privateKey, encryptedCoordinatorPrivateKey));
|
|
94
|
+
const coordinatorKeypair = new Keypair(maciPrivateKey);
|
|
95
|
+
const publicKey = new PubKey([
|
|
96
|
+
BigInt(coordinatorPublicKey.x.toString()),
|
|
97
|
+
BigInt(coordinatorPublicKey.y.toString()),
|
|
98
|
+
]);
|
|
99
|
+
if (!coordinatorKeypair.pubKey.equals(publicKey)) {
|
|
100
|
+
this.logger.error(`Error: ${ErrorCodes.PRIVATE_KEY_MISMATCH}, wrong private key`);
|
|
101
|
+
throw new Error(ErrorCodes.PRIVATE_KEY_MISMATCH.toString());
|
|
102
|
+
}
|
|
103
|
+
const outputDir = path.resolve("./proofs");
|
|
104
|
+
const maciState = await ProofGenerator.prepareState({
|
|
105
|
+
maciContract,
|
|
106
|
+
pollContract,
|
|
107
|
+
maciPrivateKey,
|
|
108
|
+
coordinatorKeypair,
|
|
109
|
+
pollId: poll,
|
|
110
|
+
signer,
|
|
111
|
+
outputDir,
|
|
112
|
+
options: {
|
|
113
|
+
startBlock,
|
|
114
|
+
endBlock,
|
|
115
|
+
blocksPerBatch,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
const foundPoll = maciState.polls.get(BigInt(poll));
|
|
119
|
+
if (!foundPoll) {
|
|
120
|
+
this.logger.error(`Error: ${ErrorCodes.POLL_NOT_FOUND}, Poll ${poll} not found in maci state`);
|
|
121
|
+
throw new Error(ErrorCodes.POLL_NOT_FOUND.toString());
|
|
122
|
+
}
|
|
123
|
+
const proofGenerator = new ProofGenerator({
|
|
124
|
+
poll: foundPoll,
|
|
125
|
+
maciContractAddress,
|
|
126
|
+
tallyContractAddress,
|
|
127
|
+
tally: this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, useQuadraticVoting),
|
|
128
|
+
mp: this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, useQuadraticVoting),
|
|
129
|
+
rapidsnark: process.env.COORDINATOR_RAPIDSNARK_EXE,
|
|
130
|
+
outputDir,
|
|
131
|
+
tallyOutputFile: path.resolve("./tally.json"),
|
|
132
|
+
useQuadraticVoting,
|
|
133
|
+
});
|
|
134
|
+
const processProofs = await proofGenerator.generateMpProofs(options);
|
|
135
|
+
const { proofs: tallyProofs, tallyData } = await proofGenerator.generateTallyProofs(hre.network.name, String(hre.network.config.chainId || 1), options);
|
|
136
|
+
return {
|
|
137
|
+
processProofs,
|
|
138
|
+
tallyProofs,
|
|
139
|
+
tallyData,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
options?.onFail?.(error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Merge state and message trees
|
|
149
|
+
*
|
|
150
|
+
* @param args - merge arguments
|
|
151
|
+
* @returns whether the proofs were successfully merged
|
|
152
|
+
*/
|
|
153
|
+
async merge({ maciContractAddress, pollId, approval, sessionKeyAddress, chain }) {
|
|
154
|
+
// get a kernel client
|
|
155
|
+
const kernelClient = await this.sessionKeysService.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
|
|
156
|
+
const signer = await this.sessionKeysService.getKernelClientSigner(kernelClient);
|
|
157
|
+
await mergeSignups({
|
|
158
|
+
maciAddress: maciContractAddress,
|
|
159
|
+
pollId: BigInt(pollId),
|
|
160
|
+
signer,
|
|
161
|
+
});
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Submit proofs on-chain
|
|
166
|
+
*
|
|
167
|
+
* @param args - submit proofs on-chain arguments
|
|
168
|
+
*/
|
|
169
|
+
async submit({ maciContractAddress, pollId, chain }) {
|
|
170
|
+
const publicClient = getPublicClient(chain);
|
|
171
|
+
// get the poll address
|
|
172
|
+
const pollContracts = await publicClient.readContract({
|
|
173
|
+
address: maciContractAddress,
|
|
174
|
+
abi: MACIFactory.abi,
|
|
175
|
+
functionName: "getPoll",
|
|
176
|
+
args: [BigInt(pollId)],
|
|
177
|
+
});
|
|
178
|
+
const pollAddress = pollContracts.poll;
|
|
179
|
+
if (pollAddress.toLowerCase() === ZeroAddress.toLowerCase()) {
|
|
180
|
+
this.logger.error(`Error: ${ErrorCodes.POLL_NOT_FOUND}, Poll ${pollId} not found`);
|
|
181
|
+
throw new Error(ErrorCodes.POLL_NOT_FOUND.toString());
|
|
182
|
+
}
|
|
183
|
+
// check if state tree has been merged
|
|
184
|
+
const isStateMerged = await publicClient.readContract({
|
|
185
|
+
address: pollAddress,
|
|
186
|
+
abi: PollFactory.abi,
|
|
187
|
+
functionName: "stateMerged",
|
|
188
|
+
});
|
|
189
|
+
if (!isStateMerged) {
|
|
190
|
+
this.logger.error(`Error: ${ErrorCodes.NOT_MERGED_STATE_TREE}, state tree is not merged`);
|
|
191
|
+
throw new Error(ErrorCodes.NOT_MERGED_STATE_TREE.toString());
|
|
192
|
+
}
|
|
193
|
+
const [maciContract, mpContract, pollContract, tallyContract, vkRegistryContract, verifierContract] = await Promise.all([
|
|
194
|
+
this.deployment.getContract({
|
|
195
|
+
name: EContracts.MACI,
|
|
196
|
+
address: maciContractAddress,
|
|
197
|
+
}),
|
|
198
|
+
this.deployment.getContract({
|
|
199
|
+
name: EContracts.MessageProcessor,
|
|
200
|
+
address: pollContracts.messageProcessor,
|
|
201
|
+
}),
|
|
202
|
+
this.deployment.getContract({
|
|
203
|
+
name: EContracts.Poll,
|
|
204
|
+
address: pollContracts.poll,
|
|
205
|
+
}),
|
|
206
|
+
this.deployment.getContract({
|
|
207
|
+
name: EContracts.Tally,
|
|
208
|
+
address: pollContracts.tally,
|
|
209
|
+
}),
|
|
210
|
+
this.deployment.getContract({ name: EContracts.VkRegistry }),
|
|
211
|
+
this.deployment.getContract({ name: EContracts.Verifier }),
|
|
212
|
+
]);
|
|
213
|
+
const prover = new Prover({
|
|
214
|
+
maciContract,
|
|
215
|
+
mpContract,
|
|
216
|
+
pollContract,
|
|
217
|
+
tallyContract,
|
|
218
|
+
vkRegistryContract,
|
|
219
|
+
verifierContract,
|
|
220
|
+
});
|
|
221
|
+
const data = {
|
|
222
|
+
processProofs: await this.readProofs(path.resolve("./proofs"), "process"),
|
|
223
|
+
tallyProofs: await this.readProofs(path.resolve("./proofs"), "tally"),
|
|
224
|
+
};
|
|
225
|
+
// prove message processing
|
|
226
|
+
await prover.proveMessageProcessing(data.processProofs);
|
|
227
|
+
// read tally data
|
|
228
|
+
const tallyData = await fs.promises
|
|
229
|
+
.readFile("./tally.json", "utf8")
|
|
230
|
+
.then((result) => JSON.parse(result));
|
|
231
|
+
// prove tally
|
|
232
|
+
await prover.proveTally(data.tallyProofs);
|
|
233
|
+
// submit results
|
|
234
|
+
const voteOptions = Number(await pollContract.voteOptions());
|
|
235
|
+
await prover.submitResults(tallyData, voteOptions);
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
ProofGeneratorService = ProofGeneratorService_1 = __decorate([
|
|
240
|
+
Injectable(),
|
|
241
|
+
__metadata("design:paramtypes", [CryptoService,
|
|
242
|
+
FileService,
|
|
243
|
+
SessionKeysService])
|
|
244
|
+
], ProofGeneratorService);
|
|
245
|
+
export { ProofGeneratorService };
|
|
246
|
+
//# sourceMappingURL=proof.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.service.js","sourceRoot":"","sources":["../../../ts/proof/proof.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EAId,aAAa,IAAI,WAAW,EAC5B,aAAa,IAAI,WAAW,EAC5B,MAAM,EAKN,OAAO,EACP,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,GAAG,MAAM,SAAS,CAAC;AAG1B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;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G;YACX,aAAa,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC;YACzE,WAAW,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;SACtE,CAAC;QACF,2BAA2B;QAC3B,MAAM,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACxD,kBAAkB;QAClB,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,QAAQ;aAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAA0B,CAAC,CAAC;QACjE,cAAc;QACd,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,iBAAiB;QACjB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7D,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAjQY,qBAAqB;IADjC,UAAU,EAAE;qCAgBuB,aAAa;QACf,WAAW;QACJ,kBAAkB;GAjB9C,qBAAqB,CAiQjC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { ITallyData, IProof } from "@maci-protocol/sdk";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import { ESupportedNetworks } from "../common";
|
|
4
|
+
/**
|
|
5
|
+
* WS events for proof generation
|
|
6
|
+
*/
|
|
7
|
+
export declare enum EProofGenerationEvents {
|
|
8
|
+
START = "start-generation",
|
|
9
|
+
PROGRESS = "progress-generation",
|
|
10
|
+
FINISH = "finish-generation",
|
|
11
|
+
ERROR = "exception"
|
|
12
|
+
}
|
|
13
|
+
export interface IReadProofsResults {
|
|
14
|
+
/**
|
|
15
|
+
* Process proofs list
|
|
16
|
+
*/
|
|
17
|
+
process: IProof[];
|
|
18
|
+
/**
|
|
19
|
+
* Tally proofs list
|
|
20
|
+
*/
|
|
21
|
+
tally: IProof[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface that represents generate proofs arguments
|
|
25
|
+
*/
|
|
26
|
+
export interface IGenerateArgs {
|
|
27
|
+
/**
|
|
28
|
+
* Poll id
|
|
29
|
+
*/
|
|
30
|
+
poll: number;
|
|
31
|
+
/**
|
|
32
|
+
* Maci contract address
|
|
33
|
+
*/
|
|
34
|
+
maciContractAddress: string;
|
|
35
|
+
/**
|
|
36
|
+
* Tally contract address
|
|
37
|
+
*/
|
|
38
|
+
tallyContractAddress: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to use Qv or NonQv
|
|
41
|
+
*/
|
|
42
|
+
useQuadraticVoting: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Encrypted coordinator private key with RSA public key (see .env.example)
|
|
45
|
+
*/
|
|
46
|
+
encryptedCoordinatorPrivateKey: string;
|
|
47
|
+
/**
|
|
48
|
+
* Start block for event processing
|
|
49
|
+
*/
|
|
50
|
+
startBlock?: number;
|
|
51
|
+
/**
|
|
52
|
+
* End block for event processing
|
|
53
|
+
*/
|
|
54
|
+
endBlock?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Blocks per batch for event processing
|
|
57
|
+
*/
|
|
58
|
+
blocksPerBatch?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Interface that represents generated proofs data
|
|
62
|
+
*/
|
|
63
|
+
export interface IGenerateData {
|
|
64
|
+
/**
|
|
65
|
+
* Message processing proofs
|
|
66
|
+
*/
|
|
67
|
+
processProofs: IProof[];
|
|
68
|
+
/**
|
|
69
|
+
* Tally proofs
|
|
70
|
+
*/
|
|
71
|
+
tallyProofs: IProof[];
|
|
72
|
+
/**
|
|
73
|
+
* TallyData
|
|
74
|
+
*/
|
|
75
|
+
tallyData: ITallyData;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Interface that represents zkey filepaths
|
|
79
|
+
*/
|
|
80
|
+
export interface IGetZkeyFilesData {
|
|
81
|
+
/**
|
|
82
|
+
* Zkey filepath
|
|
83
|
+
*/
|
|
84
|
+
zkey: string;
|
|
85
|
+
/**
|
|
86
|
+
* Wasm filepath
|
|
87
|
+
*/
|
|
88
|
+
wasm: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Merge arguments
|
|
92
|
+
*/
|
|
93
|
+
export interface IMergeArgs {
|
|
94
|
+
/**
|
|
95
|
+
* MACI contract address
|
|
96
|
+
*/
|
|
97
|
+
maciContractAddress: string;
|
|
98
|
+
/**
|
|
99
|
+
* Poll ID
|
|
100
|
+
*/
|
|
101
|
+
pollId: number;
|
|
102
|
+
/**
|
|
103
|
+
* Approval for the session key
|
|
104
|
+
*/
|
|
105
|
+
approval: string;
|
|
106
|
+
/**
|
|
107
|
+
* Session key address
|
|
108
|
+
*/
|
|
109
|
+
sessionKeyAddress: Hex;
|
|
110
|
+
/**
|
|
111
|
+
* Chain
|
|
112
|
+
*/
|
|
113
|
+
chain: ESupportedNetworks;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Submit proofs on-chain arguments
|
|
117
|
+
*/
|
|
118
|
+
export interface ISubmitProofsArgs {
|
|
119
|
+
/**
|
|
120
|
+
* MACI contract address
|
|
121
|
+
*/
|
|
122
|
+
maciContractAddress: string;
|
|
123
|
+
/**
|
|
124
|
+
* Poll ID
|
|
125
|
+
*/
|
|
126
|
+
pollId: number;
|
|
127
|
+
/**
|
|
128
|
+
* Approval for the session key
|
|
129
|
+
*/
|
|
130
|
+
approval: string;
|
|
131
|
+
/**
|
|
132
|
+
* Session key address
|
|
133
|
+
*/
|
|
134
|
+
sessionKeyAddress: Hex;
|
|
135
|
+
/**
|
|
136
|
+
* Chain
|
|
137
|
+
*/
|
|
138
|
+
chain: ESupportedNetworks;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/proof/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;GAEG;AACH,oBAAY,sBAAsB;IAChC,KAAK,qBAAqB;IAC1B,QAAQ,wBAAwB;IAChC,MAAM,sBAAsB;IAC5B,KAAK,cAAc;CACpB;AAKD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,8BAA8B,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WS events for proof generation
|
|
3
|
+
*/
|
|
4
|
+
export var EProofGenerationEvents;
|
|
5
|
+
(function (EProofGenerationEvents) {
|
|
6
|
+
EProofGenerationEvents["START"] = "start-generation";
|
|
7
|
+
EProofGenerationEvents["PROGRESS"] = "progress-generation";
|
|
8
|
+
EProofGenerationEvents["FINISH"] = "finish-generation";
|
|
9
|
+
EProofGenerationEvents["ERROR"] = "exception";
|
|
10
|
+
})(EProofGenerationEvents || (EProofGenerationEvents = {}));
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/proof/types.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,CAAN,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,oDAA0B,CAAA;IAC1B,0DAAgC,CAAA;IAChC,sDAA4B,CAAA;IAC5B,6CAAmB,CAAA;AACrB,CAAC,EALW,sBAAsB,KAAtB,sBAAsB,QAKjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.controller.test.d.ts","sourceRoot":"","sources":["../../../../ts/sessionKeys/__tests__/sessionKeys.controller.test.ts"],"names":[],"mappings":""}
|