# 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](#creating-key-pairs)

* [Deriving Shared Secrets](#deriving-shared-secrets)

### Creating Key Pairs

```ts twoslash
import { X25519 } from 'ox'

const { privateKey, publicKey } = X25519.createKeyPair()
```

### Deriving Shared Secrets

```ts twoslash
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`](/api/X25519/createKeyPair) | Creates a new X25519 key pair consisting of a private key and its corresponding public key. |
| [`X25519.getPublicKey`](/api/X25519/getPublicKey) | Computes the X25519 public key from a provided private key. |
| [`X25519.getSharedSecret`](/api/X25519/getSharedSecret) | Computes a shared secret using X25519 elliptic curve Diffie-Hellman between a private key and a public key. |
| [`X25519.randomPrivateKey`](/api/X25519/randomPrivateKey) | Generates a random X25519 private key. |
