$$x_{montgomery} = \frac{1 + y_{edwards}}{1 - y_{edwards}}$$
Using the libsodium ed25519 implementation, I have tried to write the following:
void keypair_2(unsigned char *pk, unsigned char *sk)
{
ge_p3 A;
int i;
sk[0] &= 248;
sk[31] &= 63;
sk[31] |= 64;
ge_scalarmult_base(&A,sk); // generate ed25519 public from sk.
fe one;
fe u, v, vinv;
fe montx;
fe_1(one);
fe_sub(v, one, A.Y); //v = 1-y
fe_add(u, A.Y, one); //u = y+1
fe_invert(vinv, v); //vinv = v^(-1) = (1-y)^(-1)
fe_mul(montx, u, vinv); //montx = u/v = (y+1)/(1-y)
fe_tobytes(pk, montx);
}
And I have compared this against the curve25519 implementation, but I am getting differing results.
I am unsure as to my error.
test/default/ed25519_convert.c
for some example code. $\endgroup$