Skip to content

Commit

Permalink
feat(sdk): return processProofs, tallyProofs and tallyData in generat…
Browse files Browse the repository at this point in the history
…eProofs (#2193)
  • Loading branch information
NicoSerranoP authored Feb 28, 2025
1 parent 48baee8 commit dfbc410
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/cli/ts/commands/genProofs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const genProofsCommand = async ({
logError("Invalid MACI private key");
}

const tallyData = await generateProofs({
const { tallyData } = await generateProofs({
networkName: network?.name || "",
chainId: network?.chainId.toString() || "0",
maciContractAddress,
Expand Down
12 changes: 5 additions & 7 deletions packages/sdk/ts/proof/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Keypair, PrivKey } from "maci-domainobjs";

import fs from "fs";

import type { ITallyData } from "../tally";

import { IGenerateProofsArgs } from "./types";
import { IGenerateProofsArgs, IGenerateProofsData } from "./types";

/**
* Generate proofs for the message processing and tally calculations
Expand Down Expand Up @@ -35,7 +33,7 @@ export const generateProofs = async ({
processWitgen,
processWasm,
tallyFile,
}: IGenerateProofsArgs): Promise<ITallyData> => {
}: IGenerateProofsArgs): Promise<IGenerateProofsData> => {
// if we do not have the output directory just create it
const isOutputDirExists = fs.existsSync(outputDir);

Expand Down Expand Up @@ -103,8 +101,8 @@ export const generateProofs = async ({
useQuadraticVoting,
});

await proofGenerator.generateMpProofs();
const { tallyData } = await proofGenerator.generateTallyProofs(networkName, chainId);
const processProofs = await proofGenerator.generateMpProofs();
const { proofs: tallyProofs, tallyData } = await proofGenerator.generateTallyProofs(networkName, chainId);

return tallyData;
return { processProofs, tallyProofs, tallyData };
};
2 changes: 1 addition & 1 deletion packages/sdk/ts/proof/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type { IGenerateProofsArgs, IProof, IProveOnChainArgs } from "./types";
export type { IGenerateProofsArgs, IGenerateProofsData, IProof, IProveOnChainArgs } from "./types";
export { generateProofs } from "./generate";
export { proveOnChain } from "./prove";
11 changes: 11 additions & 0 deletions packages/sdk/ts/proof/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { Groth16Proof, SnarkProof } from "maci-contracts";
import type { CircuitInputs } from "maci-core";
import type { PublicSignals } from "snarkjs";

import { ITallyData } from "../tally";

/**
* Interface for the arguments to the proveOnChain command
*/
Expand Down Expand Up @@ -167,3 +169,12 @@ export interface IGenerateProofsArgs {
*/
tallyFile: string;
}

/**
* Interface for the data returned by the generateProofs function
*/
export interface IGenerateProofsData {
processProofs: IProof[];
tallyProofs: IProof[];
tallyData: ITallyData;
}

0 comments on commit dfbc410

Please sign in to comment.