X25519.getSharedSecret
Computes a shared secret using X25519 elliptic curve Diffie-Hellman between a private key and a public key.
Imports
Named
import { X25519 } from 'ox'
Examples
import { X25519 } from 'ox'
const { privateKey: privateKeyA } = X25519.createKeyPair()
const { publicKey: publicKeyB } = X25519.createKeyPair()
const sharedSecret = X25519.getSharedSecret({
privateKey: privateKeyA,
publicKey: publicKeyB
})
Definition
function getSharedSecret<as>(
options: getSharedSecret.Options<as>,
): getSharedSecret.ReturnType<as>
Source: src/core/X25519.ts
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>