The Art of Compression: Understanding Public Key Coordinates
In cryptography, public key compression is a clever technique used to reduce the size of large public keys while preserving their essential properties. One aspect of this compression process is related to the coordinate system used in public key systems, particularly Ethereum. In this article, we will dive into the world of compressed public keys and explore why an even or odd y-coordinate corresponds to the positive or negative sign, respectively.
According to Andreas Møller’s book on compressed/uncompressed public keys, “Chapter 4 - Section - Key Formats”, uncompressed public keys have a prefix of “04”, followed by a sequence of bytes representing the cryptographic hash of the public key. When this public key is compressed, it usually takes the form of an elliptic curve digital signature (ECDSA) or similar algorithm. As part of the compression process, the y-coordinate of the compressed public key is often assigned.
The reason behind this seemingly arbitrary choice lies in the underlying mathematics of elliptic curves and cryptography. In an elliptic curve-based system like Ethereum, each point on the curve corresponds to a unique pair of (x, y) coordinates. These points are represented by "(x, y)" pairs, where "y" is typically computed as "-log(x)".
When considering compressed public keys, the compression algorithm often reduces the size of the x coordinate while preserving the integrity and security of the key. However, the y coordinate, which represents the point on the curve corresponding to a particular public key, may change during the compression process.
The reason for this change in behavior is based on how the compression algorithm works. When compressing an elliptic curve-based public key, the algorithm typically uses a simple transformation that maps the original "(x, y)" coordinates to a new set of "(x', y')" coordinates. In many cases, this transformation involves reducing the y coordinate by a constant factor or applying a non-linear function.
The specific implementation of compression algorithms can vary depending on the chosen encryption scheme and cryptographic library. However, in general, an even or odd y coordinate corresponds to a positive or negative sign, respectively, due to the inherent mathematical properties of elliptic curves. This is because when "y" is calculated as "-log(x)", it is common for "-log(x)" to be symmetric about zero.
To illustrate this concept, consider an example where we have an elliptic curve with coordinates (x, y) = (1, 2). Applying the transformation defined by the compression algorithm, we obtain (x', y') = (1, -2). In this case, the original even "y" coordinate corresponds to a positive sign, while the transformed odd "y" coordinate corresponds to a negative sign.
In conclusion, the choice of whether a y-coordinate is even or odd in compressed public keys is not arbitrary; it is deeply rooted in the mathematical structure of elliptic curves and cryptography. The compression algorithm typically reduces the size of the x-coordinate while preserving the integrity of the key, resulting in an even or odd “y” coordinate corresponding to a positive or negative sign, respectively.
As we continue to explore the complexities of public key systems, it is essential to understand how these mathematical choices affect the security and usability of these cryptographic protocols. By understanding the underlying principles of compression algorithms, we can better appreciate the importance of careful design and implementation in creating secure and reliable cryptographic systems like Ethereum.