Skip to content

Instantly share code, notes, and snippets.

@emwadde
Last active August 2, 2025 09:04
Show Gist options
  • Save emwadde/3df69f73e33641e1c2929a706094fa3a to your computer and use it in GitHub Desktop.
Save emwadde/3df69f73e33641e1c2929a706094fa3a to your computer and use it in GitHub Desktop.
import { generateKeyPair, exportJWK } from "jose";
(async () => {
const { publicKey, privateKey } = await generateKeyPair("EdDSA", {
extractable: true, // 👈 this is the key fix
});
const pubKey = await exportJWK(publicKey);
const priKey = await exportJWK(privateKey);
console.log("ed25519-pub.json", JSON.stringify(pubKey));
console.log("ed25519-priv.json", JSON.stringify(priKey));
})();
{
"name": "create-ed25519-jwk-with-npx",
"version": "1.0.0",
"bin": "./index.js",
"type": "module",
"dependencies": {
"jose": "^6.0.12"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment