Skip to content

Instantly share code, notes, and snippets.

@adrianhopebailie
Last active September 26, 2022 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianhopebailie/b7d65c52c6e5f21edc1297b55757b8f6 to your computer and use it in GitHub Desktop.
Save adrianhopebailie/b7d65c52c6e5f21edc1297b55757b8f6 to your computer and use it in GitHub Desktop.
Generate an ED25519 key pair with node and export as JWK

Generate a key using the node REPL

Needs JOSE npm lib. Easiest thing to do is just install it in a temp working dir.

cd /tmp
npm i jose
node

Inside the REPL:

const jose = await import('jose')
const crypto = await import('crypto')
const key = crypto.generateKeyPairSync('ed25519')
await jose.exportJWK(key.publicKey)
await jose.exportJWK(key.privateKey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment