ethereum / eth-keys

A common API for Ethereum key operations.
MIT License
159 stars 64 forks source link

Compressed public keys #55

Closed jannikluhn closed 3 weeks ago

jannikluhn commented 5 years ago

What was wrong?

The ENR v4 identity scheme uses compressed secp256k1 public keys (i.e. 33 instead of 64 bytes). eth_keys supports only uncompressed public keys.

How can it be fixed?

Add support for compressed public keys, e.g., with the following interface:

PublicKey.from_compressed_bytes(cls, compressed_bytes: bytes) -> PublicKey:

PublicKey.to_compressed_bytes(self) -> bytes:

Instead of from_compressed_bytes, the __init__ method could also be changed to allow both compressed and uncompressed public keys as input.

kclowes commented 3 weeks ago

Looks like this was closed via #56