AntonKueltz / fastecdsa

Python library for fast elliptic curve crypto
https://pypi.python.org/pypi/fastecdsa
The Unlicense
263 stars 76 forks source link

Compressed verifying keys? #47

Closed thejohnfreeman closed 4 years ago

thejohnfreeman commented 4 years ago

There seems to be a popular compression scheme for ECDSA verifying (public) keys. Does this library support them? Something like this in ecdsa?

AntonKueltz commented 4 years ago

I'm not sure what you mean by verifying? The compression scheme you indicate just compresses the point down from x/y coordinates to just x coordinate and a byte indicating the value of y mod 2. That scheme is easy enough to implement and can be added to the backlog of work.

thejohnfreeman commented 4 years ago

Oh sorry, I meant "verifying key", as in "a key for verifying a signature", or "public key". I got mixed up, and forgot this library doesn't use the "verifying key" terminology that some others do. I'll rephrase:

There seems to be a popular compression scheme for ECDSA public keys.

I'm just asking for functions to compress and expand the public key according to this scheme. Happy to see it added to the backlog.

AntonKueltz commented 4 years ago

Ah gotcha, shouldn't be too hard to do but hasn't been any requests for it till now. Will add it to the TODO list.

AntonKueltz commented 4 years ago

@thejohnfreeman sorry for the delay here, I missed that the SEC1 encoder already does this when I first looked at this request. You can use SEC1Encoder.decode_public_key(bytes, curve) to do this, the docs for the method have some additional details as well (docs need to be fixed in that leading 0x04 is uncompressed and leading 0x02 / 0x03 is compressed).

AntonKueltz commented 4 years ago

Closing this out, feel free to re-open if the above does not address your needs. 👍