libsodium_crypto_scalarmult_curve25519 (libsodium v3.0.1)
View SourceX25519 (RFC 7748) point multiplication on Curve25519.
base/1 computes a bytes/0 byte public key from a scalarbytes/0 byte
secret key, and crypto_scalarmult_curve25519/2 computes a shared secret
from a secret key and another party's public key. Scalars are clamped.
Do not use the shared secret directly as a key: hash it together with both
public keys, or use libsodium_crypto_kx instead.
AliceSK = libsodium_randombytes:buf(libsodium_crypto_scalarmult_curve25519:scalarbytes()),
BobSK = libsodium_randombytes:buf(libsodium_crypto_scalarmult_curve25519:scalarbytes()),
AlicePK = libsodium_crypto_scalarmult_curve25519:base(AliceSK),
BobPK = libsodium_crypto_scalarmult_curve25519:base(BobSK),
Shared = libsodium_crypto_scalarmult_curve25519:crypto_scalarmult_curve25519(AliceSK, BobPK),
Shared = libsodium_crypto_scalarmult_curve25519:crypto_scalarmult_curve25519(BobSK, AlicePK).
Summary
Types
A crypto_scalarmult_curve25519_SCALARBYTES (32-byte) binary.
A crypto_scalarmult_curve25519_BYTES (32-byte) binary.
A crypto_scalarmult_curve25519_BYTES (32-byte) binary.
Functions
Compute the public key for the clamped secret scalar N by multiplying
the base point. Returns -1 on failure.
Return crypto_scalarmult_curve25519_bytes(), in bytes.
Multiply the point P by the clamped secret scalar N, producing a
shared secret. Returns -1 when P is a low-order point.
Return crypto_scalarmult_curve25519_scalarbytes(), in bytes.
Types
Functions
Compute the public key for the clamped secret scalar N by multiplying
the base point. Returns -1 on failure.
-spec bytes() -> Result when Result :: 32.
Return crypto_scalarmult_curve25519_bytes(), in bytes.
Multiply the point P by the clamped secret scalar N, producing a
shared secret. Returns -1 when P is a low-order point.
-spec scalarbytes() -> Result when Result :: 32.
Return crypto_scalarmult_curve25519_scalarbytes(), in bytes.