How to create x25519 public key from XZ coordinates?

1.1k views Asked by At

As far as I understand, x25519 DH function used on Curve25519 uses only Xcoordinates as I can read in the wikipedia definition:

The protocol uses compressed elliptic point (only X coordinates), so it allows efficient use of the Montgomery ladder for ECDH, using only XZ coordinates.[5]

XZ coordinates [database entry] represent x y as X Z satisfying the following equations:

x=X/Z

according to this documentation.

I found these equations in this stack exchange answer:

enter image description here

enter image description here

enter image description here

I've looked at the X25519_public_from_private function and found:

    /*
     * We only need the u-coordinate of the curve25519 point.
     * The map is u=(y+1)/(1-y). Since y=Y/Z, this gives
     * u=(Z+Y)/(Z-Y).
     */

What I'd like to know is how to create a public key from u,v or x,y (or X,Y) coordinates. And especially if it is even possible?

For example, with classic ecdsa, one can create public numbers thanks to the x,y coordinates and the curve hence create a public key from them.
Example using cryptography python library:

public_numbers = ec.EllipticCurvePublicNumbers(x, y, curve)
public_key = public_numbers.public_key(backend)

I'd like to achieve the same thing with Curve25519.

References:
https://medium.com/@chain_66731/a-deep-dive-into-x25519-7a926e8a91c7
https://hackernoon.com/what-is-the-math-behind-elliptic-curve-cryptography-f61b25253da3
https://crypto.stackexchange.com/questions/74598/key-specifications-for-x25519-need-two-clarifications-please

0

There are 0 answers