Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scripts): add MACI key generation script #1869

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,6 @@ packages/cli/contractAddresses.old.json
packages/circuits/circom/test

**/ts/__benchmarks__/results/**

# MACI keys
maci-keys/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"test": "lerna run test --ignore maci-integrationtests --ignore maci-cli",
"types": "lerna run types",
"docs": "lerna run docs",
"prepare": "is-ci || husky"
"prepare": "is-ci || husky",
"generate-maci-keys": "ts-node scripts/generateMaciKeys.ts"
},
"author": "PSE",
"devDependencies": {
Expand Down
25 changes: 25 additions & 0 deletions scripts/generateMaciKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { genKeypair } from "maci-crypto";

import fs from "fs";
import path from "path";

async function generateMaciKeys(): Promise<void> {
const { privKey, pubKey } = genKeypair();

const keys = {
privateKey: privKey.toString(),
publicKey: pubKey.toString(),
};

const outputDir = path.resolve(__dirname, "..", "maci-keys");
try {
await fs.promises.access(outputDir);
} catch (error) {
await fs.promises.mkdir(outputDir, { recursive: true });
}

const outputFile = path.resolve(outputDir, "maci-keys.json");
await fs.promises.writeFile(outputFile, JSON.stringify(keys, null, 2));
}

generateMaciKeys();
Loading