whyoleg / cryptography-kotlin

Kotlin Multiplatform cryptography / crypto library
https://whyoleg.github.io/cryptography-kotlin/
Apache License 2.0
273 stars 15 forks source link

Add support for compressing X962 ECDSA encoded public key #35

Open huskcasaca opened 1 month ago

huskcasaca commented 1 month ago

Hi, I'm planning to use this lib in my crypto lib. It's really nice to have the ECDSA support but some core functions are missing.

The compressed X962 ec point is used to generate Bitcoin address, but in the latest release I we cannot get the parameter inside a curve, and as you mentioned in #32 there's no plan for curve access.

It will be really useful if we can generate a compressed public key and for my cryptocurrency lib.

Here's an API doc from cryptography in python https://cryptography.io/en/3.4.2/hazmat/primitives/asymmetric/serialization.html#serialization-formats

Thanks.

whyoleg commented 1 month ago

Hey! Thanks for the report, I will check what is possible. Encoding of public key to compressed format is rather easy, but decoding it could be not so easy in most of the providers. AFAIU only in openssl it's available out of the box, nor JDK, nor WebCrypto support compressed keys. So it might require a lot of hand-written logic if it's possible at all.