ECDH-ES implementation for X25519 keys extension for the jose module

Usage no npm install needed!

<script type="module">
  import joseX25519Ecdh from '';



This is a plugin for the jose package that implements Key Agreement with Elliptic Curve Diffie-Hellman Ephemeral Static for X25519 OKP keys.

Why a plugin?

  1. It's backed by libsodium instead of node crypto, unfortunately Node.js does not support this ECDH yet
  2. It'll get deprecated once Node.js fills the missing feature gap and the functionality will be implemented in the jose module instead



npm install jose // jose ^1.16.0 declared as a peer dependency
npm install jose-x25519-ecdh
const jose = require('jose')
const x25519 = require('jose-x25519-ecdh')

(async () => {
  await x25519 // wait for libsodium to be ready!

    const key = jose.JWK.generateSync('OKP', 'X25519')
    console.log(jose.JWE.encrypt('foobar', key))

Note: X25519 OKP keys are only supported in Node.js runtime >= 12.0.0 and are not supported in electron due to BoringSSL not having the curve implemented.

Have a question about using jose? - ask.
Found a bug? - report it.
Missing a feature? - If it wasn't already discussed before, ask for it.
Found a vulnerability? - Reach out to us via email first, see security vulnerability disclosure.


If you or your business use jose, please consider becoming a sponsor so I can continue maintaining it and adding new features carefree.