X25519
Utilities for working with X25519 elliptic curve Diffie-Hellman key agreement.
X25519 is a high-performance elliptic curve that can be used to perform Diffie-Hellman key agreement to derive shared secrets between parties. It is designed for use with the elliptic curve Diffie-Hellman (ECDH) key agreement scheme.
Examples
Below are some examples demonstrating common usages of the X25519
module:
Creating Key Pairs
import { X25519 } from 'ox'
const { privateKey, publicKey } = X25519.createKeyPair()
Deriving Shared Secrets
import { X25519 } from 'ox'
const { privateKey: privateKeyA } = X25519.createKeyPair()
const { publicKey: publicKeyB } = X25519.createKeyPair()
const sharedSecret = X25519.getSharedSecret({
privateKey: privateKeyA,
publicKey: publicKeyB
})
Functions
Name | Description |
---|---|
X25519.createKeyPair | Creates a new X25519 key pair consisting of a private key and its corresponding public key. |
X25519.getPublicKey | Computes the X25519 public key from a provided private key. |
X25519.getSharedSecret | Computes a shared secret using X25519 elliptic curve Diffie-Hellman between a private key and a public key. |
X25519.randomPrivateKey | Generates a random X25519 private key. |