UNPKG

keygentoolshed

Version:

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

58 lines (49 loc) 1.82 kB
import { SIDH } from 'sidh'; import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; async function generateSIDHKeys(size, rawOutput, secure) { try { const sidh = new SIDH(size); const { publicKey, privateKey } = sidh.keyPair(); console.log(`SIDH-${size} Key Pair Generated`); if (rawOutput) { console.log(`Public Key (RAW):`, publicKey); console.log(`Private Key (RAW):`, privateKey); } else { console.log(`Public Key (HEX): ${Buffer.from(publicKey).toString('hex')}`); console.log(`Private Key (HEX): ${Buffer.from(privateKey).toString('hex')}`); } if (secure) { console.log("Secure Mode Enabled: Keys will be stored in a protected file."); fs.writeFileSync(`sidh_${length}_pubkey.raw`, publicKey); fs.writeFileSync(`sidh_${length}_privkey.raw`, privateKey); } return { publicKey, privateKey }; } 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: 512, describe: 'SIDH key size (default is 512 bits)' }) .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 generateSIDHKeys(argv.size, argv.rawOutput, argv.secure); } main();