UNPKG

keygentoolshed

Version:

Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3

58 lines (49 loc) 1.85 kB
import { Falcon1024 } from '@dashlane/pqc-sign-falcon-1024-browser'; import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; async function generateFalconKeys(size, rawOutput, secure) { try { const falcon = new Falcon1024(); const { pubKey, privKey } = falcon.generateKeys(); console.log(`Falcon-${size} Key Pair Generated`); if (rawOutput) { console.log(`Public Key (RAW):`, pubKey); console.log(`Private Key (RAW):`, privKey); } else { console.log(`Public Key (HEX): ${Buffer.from(pubKey).toString('hex')}`); console.log(`Private Key (HEX): ${Buffer.from(privKey).toString('hex')}`); } if (secure) { console.log("Secure Mode Enabled: Keys will be stored in a protected file."); fs.writeFileSync(`falcon_${length}_pubkey.raw`, publicKey); fs.writeFileSync(`falcon_${length}_privkey.raw`, privateKey); } return { pubKey, privKey }; } catch (error) { console.error(`Key Generation Failed: ${error.message}`); } } async function main() { const argv = yargs(hideBin(process.argv)) .option('size', { alias: 's', type: 'number', default: 1024, describe: 'Falcon key size (default is 1024)' }) .option('rawOutput', { alias: 'r', type: 'boolean', default: false, describe: 'Output keys in raw format' }) .option('secure', { alias: 'p', type: 'boolean', default: false, describe: 'Enable secure key storage' }) .argv; await generateFalconKeys(argv.size, argv.rawOutput, argv.secure); } main();