smartcrypto/dist_ts/smartcrypto.classes.keypair.js
2023-08-21 08:29:27 +02:00

26 lines
2.2 KiB
JavaScript

import * as plugins from './smartcrypto.plugins.js';
import { PublicKey } from './smartcrypto.classes.publickey.js';
import { PrivateKey } from './smartcrypto.classes.privatekey.js';
export class KeyPair {
// STATIC
static async createNewKeyPair() {
const done = plugins.smartpromise.defer();
const rsa = plugins.nodeForge.pki.rsa;
rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => {
if (err) {
console.log(err);
throw err;
}
done.resolve(new KeyPair({
privateKey: new PrivateKey(keypair.privateKey),
publicKey: new PublicKey(keypair.publicKey),
}));
});
return done.promise;
}
constructor(optionsArg) {
this.privateKey = optionsArg.privateKey;
this.publicKey = optionsArg.publicKey;
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMEJBQTBCLENBQUM7QUFDcEQsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBQy9ELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUVqRSxNQUFNLE9BQU8sT0FBTztJQUNsQixTQUFTO0lBQ0YsTUFBTSxDQUFDLEtBQUssQ0FBQyxnQkFBZ0I7UUFDbEMsTUFBTSxJQUFJLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxLQUFLLEVBQVcsQ0FBQztRQUNuRCxNQUFNLEdBQUcsR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUM7UUFDdEMsR0FBRyxD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