UNPKG

crypto-keygen-suite

Version:

Key generation utilities for cryptographic operations. YES I RENAMED IT OMG BASES AND PROTOCOLS!!! See its folder for all <3

60 lines (46 loc) 2.05 kB
import pkg from 'sidh'; import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; import fs from 'fs'; const SIDH = pkg.sidh || pkg.default?.sidh || pkg; // Ensure correct reference async function generateSIDHKeys(secure) { try { if (!SIDH || typeof SIDH.keyPair !== 'function') { throw new Error("❌ SIDH module does not expose `keyPair()`. Check the package structure."); } console.log("🚀 Debug: SIDH module structure:"); console.log(SIDH); // Call `keyPair()` directly instead of instantiating SIDH const { publicKey, privateKey } = await SIDH.keyPair(); console.log(`✅ SIDH Key Pair Generated`); // Convert keys to HEX for easier readability const formattedPubKey = Buffer.from(publicKey).toString('hex'); const formattedPrivKey = Buffer.from(privateKey).toString('hex'); console.log(`Public Key (HEX): ${formattedPubKey}`); console.log(`Private Key (HEX): ${formattedPrivKey}`); if (secure) { console.log("🔒 Secure Mode Enabled: Saving keys to files."); fs.writeFileSync(`sidh_pubkey.hex`, formattedPubKey); fs.writeFileSync(`sidh_privkey.hex`, formattedPrivKey); } return { publicKey: formattedPubKey, privateKey: formattedPrivKey }; } catch (error) { console.error(`❌ Key Generation Failed: ${error.message}`); } } async function main() { const argv = yargs(hideBin(process.argv)) .option('secure', { alias: 's', type: 'boolean', default: false, describe: 'Save keys as files' }) .argv; await generateSIDHKeys(argv.secure); } console.log("🚀 Debug: Package Structure:"); console.log(pkg); // Logs entire package content console.log("Available keys:", Object.keys(pkg)); // Logs all available exported functions console.log("🚀 Debug: Running main function..."); main();