# X25519.getSharedSecret

Computes a shared secret using X25519 elliptic curve Diffie-Hellman between a private key and a public key.

## Imports

:::code-group
```ts [Named]
import { X25519 } from 'ox'
```

```ts [Entrypoint]
import * as X25519 from 'ox/X25519'
```
:::

## Examples

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

const { privateKey: privateKeyA } = X25519.createKeyPair()
const { publicKey: publicKeyB } = X25519.createKeyPair()

const sharedSecret = X25519.getSharedSecret({
  privateKey: privateKeyA,
  publicKey: publicKeyB
})
```

## Definition

```ts
function getSharedSecret<as>(
  options: getSharedSecret.Options<as>,
): getSharedSecret.ReturnType<as>
```

**Source:** [src/core/X25519.ts](https://github.com/wevm/ox/blob/main/src/core/X25519.ts#L205)

## Parameters

### options

* **Type:** `getSharedSecret.Options<as>`

The options to compute the shared secret.

#### options.as

* **Type:** `"Bytes" | "Hex" | as`
* **Optional**

Format of the returned shared secret.

#### options.privateKey

* **Type:** `0x${string} | Uint8Array`

Private key to use for the shared secret computation.

#### options.publicKey

* **Type:** `0x${string} | Uint8Array`

Public key to use for the shared secret computation.

## Return Type

The computed shared secret.

`getSharedSecret.ReturnType<as>`
