HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelibsodium-bindings-0.0.1.1Haskell2010

LibSodium.Bindings.KeyExchange

  • 9 values

Introduction

0 declarations

The key exchange API allows two parties to securely compute a set of shared keys using their peer's public key, and their own secret key.

Key Exchange

0 declarations

Key generation

valuecryptoKXSeedKeypair
  1. :: Ptr CUChar

    The buffer that will hold the public key, of size cryptoKXPublicKeyBytes.

  2. -> Ptr CUChar

    The buffer that will hold the secret key, of size cryptoKXSecretKeyBytes.

  3. -> Ptr CUChar

    The pointer to the seed from which the keys are derived. It is of size cryptoKXSeedBytes bytes.

  4. -> IO CInt

    Returns 0 on success, -1 on error.

#

Create a new key pair from a seed.

This function takes pointers to two empty buffers that will hold (respectively) the public and secret keys, as well as the seed from which these keys will be derived.

See: crypto_kx_seed_keypair()

Client

valuecryptoKXClientSessionKeys
  1. :: Ptr CUChar

    A pointer to the buffer that will hold the shared secret key, of size cryptoKXSessionKeyBytes bytes.

  2. -> Ptr CUChar

    A pointer to the buffer that will hold the shared public key, of size cryptoKXSessionKeyBytes bytes.

  3. -> Ptr CUChar

    A pointer to the client's public key, of size cryptoKXPublicKeyBytes bytes.

  4. -> Ptr CUChar

    A pointer to the client's secret key, of size cryptoKXSecretKeyBytes bytes.

  5. -> Ptr CUChar

    A pointer to the server's public key, of size cryptoKXPublicKeyBytes bytes.

  6. -> IO CInt

    Returns 0 on success, -1 on error, such as when the server's public key is not acceptable.

#

Compute a pair of shared session keys (secret and public).

These session keys are computed using:

  • The client's public key

  • The client's secret key

  • The server's public key

The shared secret key should be used by the client to receive data from the server, whereas the shared public key should be used for data flowing to the server.

If only one session key is required, either the pointer to the shared secret key or the pointer to the shared public key can be set to Foreign.nullPtr.

See: crypto_kx_client_session_keys()

Server

valuecryptoKXServerSessionKeys
  1. :: Ptr CUChar

    A pointer to the buffer that will hold the shared secret key, of size cryptoKXSessionKeyBytes bytes.

  2. -> Ptr CUChar

    A pointer to the buffer that will hold the shared public key, of size cryptoKXSessionKeyBytes bytes.

  3. -> Ptr CUChar

    A pointer to the server's public key, of size cryptoKXPublicKeyBytes bytes.

  4. -> Ptr CUChar

    A pointer to the server's secret key, of size cryptoKXSecretKeyBytes bytes.

  5. -> Ptr CUChar

    A pointer to the client's public key, of size cryptoKXPublicKeyBytes bytes.

  6. -> IO CInt

    Returns 0 on success, -1 on error, such as when the server's public key is not acceptable.

#

Compute a pair of shared session keys (secret and public).

These session keys are computed using:

  • The server's public key

  • The server's secret key

  • The client's public key

The shared secret key should be used by the server to receive data from the client, whereas the shared public key should be used for data flowing to the client.

If only one session key is required, either the pointer to the shared secret key or the pointer to the shared public key can be set to Foreign.nullPtr.

See: crypto_kx_server_session_keys()

Constants