[semidet]curve25519_scalar_mult(+Scalar,
+Point, -Result)^256-1, or 32 bytes. Fails if Point
has small order, i.e., if the result would be the point at infinity.
Alice and Bob can use this to establish a shared secret, where Generator is obtained with curve25519_generator/1:
- Alice creates a random integer a and sends As = a*Generator to Bob.
- Bob creates a random integer b and sends Bs = b*Generator to Alice.
- Alice computes Rs = a*Bs.
- Bob computes Rs = b*As.
- Alice and Bob use crypto_data_hkdf/4 on Rs with suitable (same) parameters to obtain keys and initialization vectors for symmetric encryption.
If a and b are kept secret, this method is considered very secure.