İçeriğe geç

Haşimoğlu Tarım Makineleri

Ethereum: Why do compressed and uncompressed public keys have to produce different addresses?

Why Compressed and Uncompressed Public Keys Have Different Addresses

As we delve deeper into the world of Ethereum, two types of public keys become relevant: compressed and uncompressed. In this article, we will explore why these different forms of public keys produce different addresses.

The Elliptic Curve-Based Public Key

In the early days of Ethereum, users’ public keys were represented by a pair of coordinates on an elliptic curve (EC). Each coordinate consisted of two numbers: x and y. These coordinates could be thought of as the position of a point on the elliptic curve in 2D space.

To generate an Ethereum public key, you would first choose a random number between -2^256 and 2^256 (inclusive) to represent x, and another random number between -2^256 and 2^256 to represent y. The resulting pair of numbers was then encrypted using SHA-256 to produce the compressed public key.

Compressed Public Key

A compressed public key is a 32-byte (384-bit) value that represents the coordinates on the elliptic curve. This value is created by hashing the x and y values ​​with SHA-256, along with additional data. The resulting hash value is then truncated to a fixed length of 32 bytes.

Here is an example of how the compressed public key for a specific user might be represented:

0x...a9b6d88c4f5e3cc1...b41...

Uncompressed Public Key

In contrast, an uncompressed public key is simply the original coordinate pair (x and y) without any hashing or compression. Uncompressed public keys are used for cryptographic purposes and can be more powerful than compressed keys.

To generate an uncompressed Ethereum public key, you need to choose two random numbers between -2^256 and 2^256 to represent x and y respectively. These values ​​are then hashed using SHA-256 to produce the uncompressed public key.

Uncompressed and Compressed Addresses

Ethereum: Why do compressed and uncompressed public keys have to produce different addresses?

Now that we have explained why compressed and uncompressed public keys have different addresses, let’s see how they are generated:

  • Uncompressed Addresses: Each Ethereum address is represented by a 40-byte (512-bit) value containing two random numbers (x and y), followed by additional data such as the network hash and block number. The resulting hash value is used to generate the uncompressed public key.
  • Compressed Addresses: Similarly, compressed addresses are generated by hashing the uncompressed public key with SHA-256 and truncating it to a fixed length of 32 bytes.

Why different addresses?

The reason for this difference lies in the way Ethereum public keys are designed:

  • Uncompressed addresses are more efficient because they do not require additional data such as network hash or block number. Therefore, they are better suited for use cases where fast and lightweight transactions are required.
  • Compressed addresses, on the other hand, provide a balance between efficiency and security. They are still protected against most attacks, but compressed addresses can be generated and verified more quickly.

In conclusion, the choice of compressed or uncompressed public keys depends on the specific use case. Uncompressed addresses are more efficient for cryptographic purposes, while compressed addresses provide better performance in transactions where fast and lightweight responses are required.

Ethereum About That Duplicate

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir