Home > Net >  Generating public private keys from openpgp
Generating public private keys from openpgp

Time:12-08

I have the following code and I'm trying to generate public-private key:

const openpgp = require("openpgp")
const generateKeyPair = async () => {
const { publicKeyArmored } = await openpgp.generateKey({
    userIds: [
        {
            name: 'Jon Smith', email: '[email protected]',
            comment: 'This key is for public sharing'
        }
    ],
    curve: 'ed25519',
    passphrase: 'super long and hard to guess secret',
});

console.log(publicKeyArmored);
}

But I'm getting this error. Any idea how to solve it:

(node:17380) UnhandledPromiseRejectionWarning: Error: Unknown option: userIds

CodePudding user response:

publicKeyArmored is not the method of openpgp.generateKey try publicKey.

const openpgp = require("openpgp")
const generateKeyPair = async () => {
    const { publicKey } = await openpgp.generateKey({
        curve: 'ed25519',
        userIDs: [
            {
                name: 'Jon Smith', email: '[email protected]',
                comment: 'This key is for public sharing'
            }
        ],
        passphrase: 'super long and hard to guess secret',
    });

    console.log(publicKey);
}

generateKeyPair()

output ----> enter image description here

  • Related