The RFC 8032 describes the point encoding like this :
A curve point (x,y), with coordinates in the range 0 <= x,y < p, is coded as follows. First, encode the y-coordinate as a little-endian string of 32 octets. The most significant bit of the final octet is always zero. To form the encoding of the point, copy the least significant bit of the x-coordinate to the most significant bit of the final octet.
And implements it like this :
def point_compress(P): zinv = modp_inv(P) x = P * zinv % p y = P * zinv % p return int.to_bytes(y | ((x & 1) << 255), 32, "little")
Could you explain the meaning of the word "copy" in this sentence "copy the least significant bit of the x-coordinate to the most significant bit of the final octet" ? Why isn't the bit copied in the code ? Why is it just a bitwise OR ?