As of Feb 18th 2020, the release of jose@^1.23.0
supports ECDH-ES for both X25519 and X448 on
Node.js runtime with improved diffie-hellman support. This module is no longer needed, is deprecated
and repository archived.
This is a plugin for the jose
package that implements Key Agreement with Elliptic Curve
Diffie-Hellman Ephemeral Static for X25519
OKP keys.
- It's backed by libsodium instead of node crypto, unfortunately Node.js does not support this ECDH yet
- It'll get deprecated once Node.js fills the missing feature gap and the functionality will be implemented in the jose module instead
Installing
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(key.algorithms())
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.