Skip to content

Commit

Permalink
feat(scripts): add MACI key generation script
Browse files Browse the repository at this point in the history
    - Add generateMaciKeys.js script
    - Update package.json with new script command
    - Update .gitignore to exclude maci-keys directory
  • Loading branch information
programmerraja committed Oct 23, 2024
1 parent 05e621b commit 1ae8ad1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
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": "node scripts/generateMaciKeys.js"
},
"author": "PSE",
"devDependencies": {
Expand Down
24 changes: 24 additions & 0 deletions scripts/generateMaciKeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { genKeypair } = require('maci-crypto');
const fs = require('fs');
const path = require('path');

function generateMaciKeys() {
const { privKey, pubKey } = genKeypair();

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

const outputDir = path.join(__dirname, '..', 'maci-keys');
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}

const outputFile = path.join(outputDir, 'maci-keys.json');
fs.writeFileSync(outputFile, JSON.stringify(keys, null, 2));

console.log('MACI keys generated and saved to:', outputFile);
}

generateMaciKeys();

0 comments on commit 1ae8ad1

Please sign in to comment.