crypto_from_eddsa_private,
crypto_from_eddsa_public —
conversion of key pairs for EdDSA with BLAKE2b to
X25519 key pairs
#include
<monocypher.h>
void
crypto_from_eddsa_private(
uint8_t
x25519[32],
const uint8_t eddsa[32]);
void
crypto_from_eddsa_public(
uint8_t
x25519[32],
const uint8_t eddsa[32]);
These functions convert keys for use with
crypto_sign(3monocypher)
(EdDSA with the BLAKE2b hash function) to keys for use with
crypto_key_exchange(3monocypher)
and
crypto_x25519(3monocypher).
This may be useful in some resource-constrained contexts or when no other key
is available (for example, when retrieving SSH public keys from GitHub and
reusing the SSH public keys as X25519 public keys).
The
crypto_from_eddsa_private() function converts
an EdDSA (with BLAKE2b) private key to an X25519 private key. The
crypto_from_eddsa_public() function converts an
EdDSA public key to an X25519 public key.
X25519 key pairs cannot be converted back to EdDSA key pairs. The conversion of
private keys is specific to EdDSA with BLAKE2b because of the way EdDSA works.
In particular, this means that the output of
crypto_from_eddsa_private() differs from
crypto_from_ed25519_private(3monocypher)
in the optional code. However, the output of
crypto_from_eddsa_public() is identical to
crypto_from_ed25519_public(3monocypher).
The arguments are:
-
-
- eddsa
- The signing public key or private key to convert to a
X25519 public key or private key, respectively.
-
-
- x25519
- The converted private key or public key.
The arguments may overlap or point at the same buffer.
These functions return nothing. They cannot fail.
crypto_key_exchange_public_key(3monocypher),
crypto_sign_public_key(3monocypher),
intro(3monocypher)
The
crypto_from_eddsa_private() and
crypto_from_eddsa_public() functions first
appeared in Monocypher 3.1.0.
It is generally considered poor form to reuse the same key for different
purposes. While this conversion is technically safe, avoid these functions
nonetheless unless you are particularly resource-constrained or have some
other kind of hard requirement. It is otherwise an unnecessary risk
factor.