There are many different ED25519/Curve25519/X25519 implementations around. I focus on two of them:
The libsodium library provides the function
crypto_scalarmult_curve25519_ref10(unsigned char *q, const unsigned char *n, const unsigned char *p) in the file x25519_ref10.c which is e.q. used during the SSH handshake to exchange a secret using ECDH.
The ed25519-donna provides a very fast implementation of ed25519 and also provides the function
/* Fast Curve25519 basepoint scalar multiplication */ void ED25519_FN(curved25519_scalarmult_basepoint) (curved25519_key pk, const curved25519_key e) { ...
Unfortunately this doesn't yield the same result as the x25519 scalar multiplication from libsodium.
Now the question:
Is there a way to implement the scalar multiplication of X25519 by using the ed25519 functions? And how would an implementation look like?