Skip to content

Instantly share code, notes, and snippets.

@maxogden

maxogden/index.js

Created May 24, 2019
Embed
What would you like to do?
ed25519 private and public keys to pem
import { composePrivateKey, composePublicKey } from 'crypto-key-composer'
function privateToPem(privateKey) {
var decomposed = {
format: 'pkcs8-pem',
keyAlgorithm: { id: 'ed25519' },
keyData: {
seed: privateKey,
},
}
return composePrivateKey(decomposed)
}
function publicToPem(publicKey) {
var decomposed = {
format: 'spki-pem',
keyAlgorithm: { id: 'ed25519' },
keyData: {
bytes: publicKey,
},
}
return composePublicKey(decomposed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.