Curve25519#

Elliptic-curve Diffie-Hellman key agreement on Curve25519.

Implementations#

There are multiple implementations, i.e., …

  • a portable implementation (Hacl_Curve25519_51.h),

  • a fast 64-bit implementation that requires BMI2 & ADX CPU support (Hacl_Curve25519_64.h), and

  • a slower 64-bit implementation without the requirements stated above (Hacl_Curve25519_64_Slow.h).

API Reference#

#include "Hacl_Curve25519_51.h"
void Hacl_Curve25519_51_scalarmult(uint8_t *out, uint8_t *priv, uint8_t *pub)#

Compute the scalar multiple of a point.

Parameters:
  • out – Pointer to 32 bytes of memory, allocated by the caller, where the resulting point is written to.

  • priv – Pointer to 32 bytes of memory where the secret/private key is read from.

  • pub – Pointer to 32 bytes of memory where the public point is read from.

void Hacl_Curve25519_51_secret_to_public(uint8_t *pub, uint8_t *priv)#

Calculate a public point from a secret/private key.

This computes a scalar multiplication of the secret/private key with the curve’s basepoint.

Parameters:
  • pub – Pointer to 32 bytes of memory, allocated by the caller, where the resulting point is written to.

  • priv – Pointer to 32 bytes of memory where the secret/private key is read from.

bool Hacl_Curve25519_51_ecdh(uint8_t *out, uint8_t *priv, uint8_t *pub)#

Execute the diffie-hellmann key exchange.

Parameters:
  • out – Pointer to 32 bytes of memory, allocated by the caller, where the resulting point is written to.

  • priv – Pointer to 32 bytes of memory where our secret/private key is read from.

  • pub – Pointer to 32 bytes of memory where their public point is read from.